I have a test that's failing even though the operation actually works when I test it in the browser. Something wrong with my test, looks like.
I'm using Shoulda and fixtures.
require 'test_helper'
class AddressesControllerTest < ActionController::TestCase
context 'on PUT to :update' do
setup do
put(:update, {
:id => addresses(:mary_publics_address).id,
:street1 => '123 Now St.'
}, { :user_id => users(:stan).id})
end
should 'update the Address' do
a = Address.find(addresses(:mary_publics_address).id)
assert(a.street1 == '123 Now St.', 'Attribute did not get updated.')
end
end
end
Fails with "Attribute did not get updated."
Here is the controller code under test:
class AddressesController < ApplicationController
def update
@address = Address.find(params[:id])
@address.update_attributes!(params[:address])
render(:text => "Address with ID #{params[:id]} updated")
end
end