<commit_before>require 'spec_helper'

describe DevelopersController do
  before do
    @user = FactoryGirl.create :user, :roles => [:dev]
  end

  describe "GET index" do
    it "assigns all developers as @developers" do
      developer = FactoryGirl.create(:developer)
      get_with @user, :index, {}
      assigns(:developers).should eq([developer])
    end
  end

  describe "GET show" do
    it "assigns the requested developer as @developer" do
      developer = FactoryGirl.create(:developer)
      get_with @user, :show, {:id => developer.to_param}
      assigns(:developer).should eq(developer)
    end
  end

  describe "GET new" do
    it "assigns a new developer as @developer" do
      get_with @user, :new, {}
      assigns(:developer).should be_a_new(Developer)
    end
  end

  describe "GET edit" do
    it "assigns the requested developer as @developer" do
      developer = FactoryGirl.create(:developer)
      get_with @user, :edit, {:id => developer.to_param}
      assigns(:developer).should eq(developer)
    end
  end

  describe "POST create" do
    describe "with valid params" do
      it "creates a new Developer" do
        expect {
          post_with @user, :create, {:developer => FactoryGirl.attributes_for(:developer)}
        }.to change(Developer, :count).by(1)
      end

      it "assigns a newly created developer as @developer" do
        post_with @user, :create, {:developer => FactoryGirl.attributes_for(:developer)}
        assigns(:developer).should be_a(Developer)
        assigns(:developer).should be_persisted
      end

      it "redirects to the created developer" do
        post_with @user, :create, {:developer => FactoryGirl.attributes_for(:developer)}
        response.should redirect_to(Developer.last)
      end
    end

    describe "with invalid params" do
      it "assigns a newly created but unsaved developer as @developer" do
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        post_with @user, :create, {:developer => {}}
        assigns(:developer).should be_a_new(Developer)
      end

      it "re-renders the 'new' template" do
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        post_with @user, :create, {:developer => {}}
        response.should render_template("new")
      end
    end
  end

  describe "PUT update" do
    describe "with valid params" do
      it "updates the requested developer" do
        developer = FactoryGirl.create(:developer)
        # Assuming there are no other developers in the database, this
        # specifies that the Developer created on the previous line
        # receives the :update_attributes message with whatever params are
        # submitted in the request.
        Developer.any_instance.should_receive(:update_attributes).with({'these' => 'params'}, {:as => :manager})
        put_with @user, :update, {:id => developer.to_param, :developer => {'these' => 'params'}}
      end

      it "assigns the requested developer as @developer" do
        developer = FactoryGirl.create(:developer)
        put_with @user, :update, {:id => developer.to_param, :developer => FactoryGirl.attributes_for(:developer)}
        assigns(:developer).should eq(developer)
      end

      it "redirects to the developer" do
        developer = FactoryGirl.create(:developer)
        put_with @user, :update, {:id => developer.to_param, :developer => FactoryGirl.attributes_for(:developer)}
        response.should redirect_to(developer)
      end
    end

    describe "with invalid params" do
      it "assigns the developer as @developer" do
        developer = FactoryGirl.create(:developer)
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        put_with @user, :update, {:id => developer.to_param, :developer => {}}
        assigns(:developer).should eq(developer)
      end

      it "re-renders the 'edit' template" do
        developer = FactoryGirl.create(:developer)
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        put_with @user, :update, {:id => developer.to_param, :developer => {}}
        response.should render_template("edit")
      end
    end
  end
<commit_msg>adjust test to pass with to_param overrides.<commit_after>require 'spec_helper'

describe DevelopersController do
  before do
    @user = FactoryGirl.create :user, :roles => [:dev]
  end

  describe "GET index" do
    it "assigns all developers as @developers" do
      developer = FactoryGirl.create(:developer)
      get_with @user, :index, {}
      assigns(:developers).should eq([developer])
    end
  end

  describe "GET show" do
    it "assigns the requested developer as @developer" do
      developer = FactoryGirl.create(:developer)
      get_with @user, :show, {:id => developer.to_param}
      assigns(:developer).should eq(developer)
    end
  end

  describe "GET new" do
    it "assigns a new developer as @developer" do
      get_with @user, :new, {}
      assigns(:developer).should be_a_new(Developer)
    end
  end

  describe "GET edit" do
    it "assigns the requested developer as @developer" do
      developer = FactoryGirl.create(:developer)
      get_with @user, :edit, {:id => developer.to_param}
      assigns(:developer).should eq(developer)
    end
  end

  describe "POST create" do
    describe "with valid params" do
      it "creates a new Developer" do
        expect {
          post_with @user, :create, {:developer => FactoryGirl.attributes_for(:developer)}
        }.to change(Developer, :count).by(1)
      end

      it "assigns a newly created developer as @developer" do
        post_with @user, :create, {:developer => FactoryGirl.attributes_for(:developer)}
        assigns(:developer).should be_a(Developer)
        assigns(:developer).should be_persisted
      end

      it "redirects to the created developer" do
        post_with @user, :create, {:developer => FactoryGirl.attributes_for(:developer)}
        response.should redirect_to(Developer.last)
      end
    end

    describe "with invalid params" do
      it "assigns a newly created but unsaved developer as @developer" do
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        post_with @user, :create, {:developer => {}}
        assigns(:developer).should be_a_new(Developer)
      end

      it "re-renders the 'new' template" do
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        post_with @user, :create, {:developer => {}}
        response.should render_template("new")
      end
    end
  end

  describe "PUT update" do
    describe "with valid params" do
      it "updates the requested developer" do
        developer = FactoryGirl.create(:developer)
        # Assuming there are no other developers in the database, this
        # specifies that the Developer created on the previous line
        # receives the :update_attributes message with whatever params are
        # submitted in the request.
        Developer.any_instance.should_receive(:update_attributes).with({'these' => 'params'}, {:as => :manager})
        put_with @user, :update, {:id => developer.to_param, :developer => {'these' => 'params'}}
      end

      it "assigns the requested developer as @developer" do
        developer = FactoryGirl.create(:developer)
        put_with @user, :update, {:id => developer.to_param, :developer => FactoryGirl.attributes_for(:developer)}
        assigns(:developer).should eq(developer)
      end

      it "redirects to the developer" do
        developer = FactoryGirl.create(:developer)
        attrs = FactoryGirl.attributes_for(:developer)
        attrs[:name] = developer.name
        put_with @user, :update, {:id => developer.to_param, :developer => attrs }
        response.should redirect_to(developer)
      end
    end

    describe "with invalid params" do
      it "assigns the developer as @developer" do
        developer = FactoryGirl.create(:developer)
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        put_with @user, :update, {:id => developer.to_param, :developer => {}}
        assigns(:developer).should eq(developer)
      end

      it "re-renders the 'edit' template" do
        developer = FactoryGirl.create(:developer)
        # Trigger the behavior that occurs when invalid params are submitted
        Developer.any_instance.stub(:save).and_return(false)
        put_with @user, :update, {:id => developer.to_param, :developer => {}}
        response.should render_template("edit")
      end
    end
  end

{'fraction_non_alphanumeric': 0.1002219755826859, 'fraction_numerical': 0.00022197558268590456, 'mean_word_length': 3.062669071235347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3098789', 'n_tokens_mistral': 2614, 'n_tokens_neox': 2404, 'n_words': 774}