开发者

Ruby on Rails 2.3.8: Functional Testing: assert_redirect_to not finding action?

开发者 https://www.devze.com 2023-03-19 11:37 出处:网络
Here is zhe error: NoMethodError: undefined method `dashboard_url\' for #<AccountsController:0x105212680 @real_format=nil>

Here is zhe error:

NoMethodError: undefined method `dashboard_url' for #<AccountsController:0x105212680 @real_format=nil>

and here is the function which generates the error (on the assert_redirected_to :dashboard line

def login_as_owner(login = SharedTest.user.login, password = SharedTest.user.password)
  old_controller开发者_StackOverflow社区 = @controller
  @controller = SessionsController.new
  post(:create, :login => login, :password => password)
  @controller = AccountsController.new 
  assert_redirected_to :dashboard
  @controller = old_controller

end

I do controller switiching, because I need to be able to call this method from any of the functional tests, as the entire app requires being logged in first... though I'm not sure if I'm doing it right.

I ran rake routes, and here are the related routes

               root        /                              {:controller=>"accounts", :action=>"dashboard"}
  dashboard_account GET    /account/dashboard(.:format)   {:controller=>"accounts", :action=>"dashboard"}


try

assert_redirected_to :dashboard_account

or explicitly specifying url

assert_redirected_to '/account/dashboard'
0

精彩评论

暂无评论...
验证码 换一张
取 消