我对轨道比较陌生,所以请在回答时记住这一点。 :)'注册'过程失败
我已将clearance
gem添加到我的导轨应用程序。我执行rails g clearance:views
,没有麻烦。接下来我执行了rails g clearance:specs
。所有间隙规格传递除了一:
/spec/features/clearance/visitor_signs_up_spec.rb:13 # Visitor signs up with valid email and password
这里的RSpec的错误消息:
Visitor signs up with valid email and password Failure/Error: expect_user_to_be_signed_in expected to find button "Sign out" but there were no matches # ./spec/support/features/clearance_helpers.rb:35:in `expect_user_to_be_signed_in' # ./spec/features/clearance/visitor_signs_up_spec.rb:16:in `block (2 levels) in <top (required)>' # -e:1:in `<main>'
有趣的是,当我尝试手动遵循规范,注册过程,但完成它不创建新的会话。换句话说,我必须在注册后登录。这似乎与/spec/features/clearance/visitor_signs_up_spec.rb:13
中发生的行为相符,但根据该规范,这不是预期的行为。
没有其他使用相同方法的规格expect_user_to_be_signed_in
有这个问题。
另外,我的Rails服务器日志没有显示任何错误。
我不知道在哪里寻找缩小问题范围。你怎么看?
更新:发现错误!
Started POST "/users" for ::1 at 2015-10-18 15:15:44 -0600
Processing by UsersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"first_name"=>"Michael", "last_name"=>"Hargiss", "username"=>"mycargus", "email"=>"[email protected]", "password"=>"[FILTERED]"}, "commit"=>"Sign up"}
Redirected to http://localhost:3000/sign_in
Filter chain halted as :require_login rendered or redirected
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
更新:我通过在成功保存新用户后更改重定向url来修复了以前的错误。我还必须添加以下内容到我的UsersController
:
before_action :require_login, only: [:index, :show, :edit, :update, :destroy]
任何想法?