Functional controller test for #update not calling #update

I'm losing my mind on this one. When I run rspec this test keeps failing. The debugger line in the test is hit, when I continue on from it the test just fails and the debugger call in update is never hit.

Gist: https://gist.github.com/spencercb/1dd3db0ee419abbd3490

I put some of the relevant files below for the lazy but the gist may be easier to look at.

The test
> > before(:each) {
> > @user = FactoryGirl.create(:user)
> > sign_in_helper(FactoryGirl.create(:admin))
> > }
>
> describe "PUT #update" do
> let!(:user) { FactoryGirl.create(:user) }
>
> before(:each) {
> @validParams = { name: "Foo Bar", email: "[email protected]", password: "foobibble", password_confirmation: "foobibble", organization: "New Org" }
> }
>
> context "with valid params" do
> it "should not change user count" do
> debugger
> # TODO why doesn't this call users#update
> put :update, id: user, user: @validParams
>
> User.last.organization.should eq('New Org')
> end
> end
>
> end

The controller
> def update
> debugger
> @user = User.find_by_id(params[:id])
>
> if @user.update_attributes(user_params)
> flash[:success] = "Profile updated."
> sign_in_helper @user
> redirect_to @user
> else
> render 'edit'
> end
> end

The routes
> [email protected] [ rally ] $ rake routes | grep users
> users GET /users(.:format) users#index
> POST /users(.:format) users#create
> new_user GET /users/new(.:format) users#new
> edit_user GET /users/:id/edit(.:format) users#edit
> user GET /users/:id(.:format) users#show
> PUT /users/:id(.:format) users#update
> DELETE /users/:id(.:format) users#destroy
> signup /signup(.:format) users#new

1 thought on “Functional controller test for #update not calling #update”

Leave a Comment