<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe TeamConsultationsController do
  it_should_behave_like "an authenticated controller"
  it_should_behave_like "an authorized controller"
      

  def mock_team_consultation(stubs={})
    @mock_team_consultation ||= mock_model(TeamConsultation, stubs)
  end
  
  describe "GET index" do
    it "assigns all team_consultations as @team_consultations" do
      TeamConsultation.should_receive(:find).with(:all).and_return([mock_team_consultation])
      get :index
      assigns[:team_consultations].should == [mock_team_consultation]
    end
  end

  describe "GET show" do
    it "assigns the requested team_consultation as @team_consultation" do
      TeamConsultation.should_receive(:find).with("37").and_return(mock_team_consultation)
      get :show, :id => "37"
      assigns[:team_consultation].should equal(mock_team_consultation)
    end
  end

  describe "GET new" do
    it "assigns a new team_consultation as @team_consultation" do
      TeamConsultation.should_receive(:new).and_return(mock_team_consultation)
      get :new
      assigns[:team_consultation].should equal(mock_team_consultation)
    end
  end

  describe "GET edit" do
    it "assigns the requested team_consultation as @team_consultation" do
      TeamConsultation.should_receive(:find).with("37").and_return(mock_team_consultation)
      get :edit, :id => "37"
      assigns[:team_consultation].should equal(mock_team_consultation)
    end
  end

  describe "POST create" do
    before do
      @mock_student = mock_student
      controller.stub!(:current_student_id => '2', :current_user_id => '3', :current_student => @mock_student)
    end
    
    describe "with valid params" do
      it "assigns a newly created team_consultation as @team_consultation" do
        TeamConsultation.should_receive(:new).with({'these' => 'params', 'student_id' => '2', 'requestor_id' => '3'}).and_return(mock_team_consultation(:save => true))
        post :create, :team_consultation => {:these => 'params'}
        assigns[:team_consultation].should equal(mock_team_consultation)
      end

      it "redirects back to the student profile" do
        TeamConsultation.stub!(:new).and_return(mock_team_consultation(:save => true))
        post :create, :team_consultation => {}
        response.should redirect_to(student_url(@mock_student))
      end
    end
    
    describe "with invalid params" do
      it "assigns a newly created but unsaved team_consultation as @team_consultation" do
        TeamConsultation.stub!(:new).with({'these' => 'params', 'student_id' => '2', 'requestor_id' => '3'}).and_return(mock_team_consultation(:save => false))
        post :create, :team_consultation => {:these => 'params'}
        assigns[:team_consultation].should equal(mock_team_consultation)
      end

      it "re-renders the 'new' template" do
        TeamConsultation.stub!(:new).and_return(mock_team_consultation(:save => false))
        post :create, :team_consultation => {}
        response.should render_template('new')
      end
    end
    
  end
<commit_msg>fix spec to use html format<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe TeamConsultationsController do
  it_should_behave_like "an authenticated controller"
  it_should_behave_like "an authorized controller"
      

  def mock_team_consultation(stubs={})
    @mock_team_consultation ||= mock_model(TeamConsultation, stubs)
  end
  
  describe "GET index" do
    it "assigns all team_consultations as @team_consultations" do
      TeamConsultation.should_receive(:find).with(:all).and_return([mock_team_consultation])
      get :index
      assigns[:team_consultations].should == [mock_team_consultation]
    end
  end

  describe "GET show" do
    it "assigns the requested team_consultation as @team_consultation" do
      TeamConsultation.should_receive(:find).with("37").and_return(mock_team_consultation)
      get :show, :id => "37"
      assigns[:team_consultation].should equal(mock_team_consultation)
    end
  end

  describe "GET new" do
    it "assigns a new team_consultation as @team_consultation" do
      TeamConsultation.should_receive(:new).and_return(mock_team_consultation)
      get :new
      assigns[:team_consultation].should equal(mock_team_consultation)
    end
  end

  describe "GET edit" do
    it "assigns the requested team_consultation as @team_consultation" do
      TeamConsultation.should_receive(:find).with("37").and_return(mock_team_consultation)
      get :edit, :id => "37"
      assigns[:team_consultation].should equal(mock_team_consultation)
    end
  end

  describe "POST create" do
    before do
      @mock_student = mock_student
      controller.stub!(:current_student_id => '2', :current_user_id => '3', :current_student => @mock_student)
    end
    
    describe "with valid params" do
      it "assigns a newly created team_consultation as @team_consultation" do
        TeamConsultation.should_receive(:new).with({'these' => 'params', 'student_id' => '2', 'requestor_id' => '3'}).and_return(mock_team_consultation(:save => true))
        post :create, :team_consultation => {:these => 'params'}
        assigns[:team_consultation].should equal(mock_team_consultation)
      end

      it "redirects back to the student profile" do
        TeamConsultation.stub!(:new).and_return(mock_team_consultation(:save => true))
        post :create, :team_consultation => {}, :format => 'html'
        response.should redirect_to(student_url(@mock_student))
      end
    end
    
    describe "with invalid params" do
      it "assigns a newly created but unsaved team_consultation as @team_consultation" do
        TeamConsultation.stub!(:new).with({'these' => 'params', 'student_id' => '2', 'requestor_id' => '3'}).and_return(mock_team_consultation(:save => false))
        post :create, :team_consultation => {:these => 'params'}
        assigns[:team_consultation].should equal(mock_team_consultation)
      end

      it "re-renders the 'new' template" do
        TeamConsultation.stub!(:new).and_return(mock_team_consultation(:save => false))
        post :create, :team_consultation => {}
        response.should render_template('new')
      end
    end
    
  end

{'fraction_non_alphanumeric': 0.10932782456697919, 'fraction_numerical': 0.004449388209121246, 'mean_word_length': 4.039231385108087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 46, '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': '5559401', 'n_tokens_mistral': 2028, 'n_tokens_neox': 1987, 'n_words': 421}