brookr (owner)

Revisions

gist: 76542 Download_button fork
public
Public Clone URL: git://gist.github.com/76542.git
Text only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Rails 2.2.2, Shoulda 2.9.1, Factory Girl 1.2.0
 
The default test:
 
  context 'PUT to update for existing survey' do
    setup do
      @survey = Factory(:survey)
      put :update, :id => @survey.to_param,
        :survey => Factory.attributes_for(:survey)
    end
 
    should_set_the_flash_to /updated/i
    should_redirect_to 'surveys_path'
  end
 
 
Fails with:
 
 
  3) Failure:
test: PUT to update for existing survey should redirect to surveys_path. (SurveysControllerTest)
    [/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/macros.rb:239:in `__bind_1236625179_419089'
     /Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `call'
     /Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `test: PUT to update for existing survey should redirect to surveys_path. '
     /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `__send__'
     /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run']:
Expected response to be a redirect to <http://test.host/surveys> but was a redirect to <http://test.host/surveys/3000>.
 
It seems like the expected redirection url doesn't have the ID in it, where the returned URL does. But i may be missing something obvious!
 
An older version of Coulda generated this test for my staff controller a few days ago:
 
 
  context 'PUT to update' do
    setup do
      @staff = Factory(:staff)
      put :update, :id => @staff.staff_id, :staff => Factory.attributes_for(:staff)
    end
    
    should_redirect_to 'staff_path(@staff)'
  end
 
This test runs fine (passes) in my environment.
 
And there the (@staff) is included leading me to believe it would also be needed in the tests of my survey controller.