<commit_before>#spec/controllers/staff_controller_spec.rb
require 'spec_helper'

describe StaffController do

	context "as a professor" do

    before do
      @course = create(:course)
      @professor = create(:user)
      @professor.courses << @course
      @membership = CourseMembership.where(user: @professor, course: @course).first.update(role: "professor")
      @challenge = create(:challenge, course: @course)
      @course.challenges << @challenge
      @challenges = @course.challenges
      @student = create(:user)
      @student.courses << @course
      @team = create(:team, course: @course)
      @team.students << @student
      @teams = @course.teams

      login_user(@professor)
      session[:course_id] = @course.id
      allow(Resque).to receive(:enqueue).and_return(true)
    end

		describe "GET index" do
      it "returns all staff for the current course" do
        get :index
        expect(assigns(:title)).to eq("Staff Index")
        expect(assigns(:staff)).to eq([@professor])
        expect(response).to render_template(:index)
      end
    end

		describe "GET show" do
      it "displays a single staff member's page" do
        get :show, :id => @professor.id
        expect(assigns(:staff)).to eq(@professor)
        expect(response).to render_template(:show)
      end
    end

	end

	context "as a student" do
		describe "protected routes" do
      [
        :index
      ].each do |route|
          it "#{route} redirects to root" do
            expect(get route).to redirect_to(:root)
          end
        end
    end

    describe "protected routes requiring id in params" do
      [
        :show
      ].each do |route|
        it "#{route} redirects to root" do
          expect(get route, {:id => "1"}).to redirect_to(:root)
        end
      end
    end

	end
end<commit_msg>Sped up staff controller<commit_after>require 'spec_helper'

describe StaffController do
  before(:all) { @course = create(:course) }
  before(:each) do
    session[:course_id] = @course.id
    allow(Resque).to receive(:enqueue).and_return(true)
  end

  context "as a professor" do
    before(:all) do
      @professor = create(:user)
      CourseMembership.create user: @professor, course: @course, role: "professor"
    end
    before { login_user(@professor) }

    describe "GET index" do
      it "returns all staff for the current course" do
        get :index
        expect(assigns(:title)).to eq("Staff Index")
        expect(assigns(:staff)).to eq([@professor])
        expect(response).to render_template(:index)
      end
    end

    describe "GET show" do
      it "displays a single staff member's page" do
        get :show, :id => @professor.id
        expect(assigns(:staff)).to eq(@professor)
        expect(response).to render_template(:show)
      end
    end
  end

  context "as a student" do
    before(:all) do
      @student = create(:user)
      @student.courses << @course
    end
    before(:each) { login_user(@student) }

    describe "protected routes" do
      [
        :index
      ].each do |route|
          it "#{route} redirects to root" do
            expect(get route).to redirect_to(:root)
          end
        end
    end

    describe "protected routes requiring id in params" do
      [
        :show
      ].each do |route|
        it "#{route} redirects to root" do
          expect(get route, {:id => "1"}).to redirect_to(:root)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11556329849012775, 'fraction_numerical': 0.0005807200929152149, 'mean_word_length': 2.4484484484484486, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3941852', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1014, 'n_words': 296}