this is the code for the test in the account_controller_test.rb functional test file:
Code:
def test_should_redirect_after_login_with_return_url
post :login, { :login => 'skyblaze', :password => 'prova' }, :return_to => '/story/new'
assert_redirected_to '/story/new'
end
...and this is the before-filter code in application.rb that relates to that test:
Code:
def login_required
return true if logged_in?
session[:return_to] = request.request_uri
redirect_to :controller => "/account", :action => "login" and return false
end
rake test:functionals output is:
skyblaze@skyblaze:~/shovell$ rake test:functionals
(in /home/skyblaze/shovell)
/usr/bin/ruby1.8 -Ilib:test "/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb" "test/functional/story_controller_test.rb" "test/functional/account_controller_test.rb"
Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
Started
...F.F
Finished in 0.146309 seconds.
1) Failure:
test_should_redirect_after_login_with_return_url(AccountControllerTest)
[/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/assertions/response_assertions.rb:86:in `assert_redirected_to'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/assertions/response_assertions.rb:35:in `assert_redirected_to'
./test/functional/account_controller_test.rb:38:in `test_should_redirect_after_login_with_return_url']:
response is not a redirection to all of the options supplied (redirection is <{"controller"=>"story"}>), difference: <{"action"=>"new"}>
2) Failure:
default_test(StoryControllerTest) [/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb:5]:
No tests were specified.
6 tests, 18 assertions, 2 failures, 0 errors
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -Ilib:test "/usr/lib/ruby...]
(See full trace by running task with --trace)
skyblaze@skyblaze:~/shovell$
Bookmarks