0
我希望有人能帮助我。我正在构建标准博客应用程序,作为学习Rails的一部分,并已选择将Authlogic包含在认证/授权中。Authlogic:功能测试失败验证
出于某种原因 - 我不能为我的生命数字出来 - 以下功能测试现在失败的我认为是验证原因:
user.rb
class User < ActiveRecord::Base
acts_as_authentic do |c|
c.validates_length_of_password_field_options minimum: 6
end
has_many :articles, dependent: :destroy
has_many :comments, through: :articles
enum role: [:commenter, :contributer, :admin]
end
users_controller_test.rb
class UsersControllerTest < ActionController::TestCase
def setup
@user = users(:ben)
activate_authlogic
end
test "should create user with default commenter role" do
assert_difference 'User.count', 1 do
post :create, user: { username: "Elenor Smalls", email: "[email protected]", password: "foobar", password_confirmation: "foobar", dob: "2000-01-01", gender: "Female" }
end
assert User.find_by(email: "[email protected]").commenter?, "User is not a Commenter."
assert_redirected_to root_url
end
输出
Run options: --seed 48600
# Running:
......F...................
Finished in 1.172103s, 22.1824 runs/s, 33.2735 assertions/s.
1) Failure:
UsersControllerTest#test_should_create_user_with_default_commenter_role
[/Users/Donovan/developer/webdevelopment/workspace/articles/test/controllers/users_controller_test.rb:11]:
"User.count" didn't change by 1.
Expected: 4
Actual: 3
26 runs, 39 assertions, 1 failures, 0 errors, 0 skips
从我可以告诉,创建该帖子是在通过Authlogic所有的验证,删除或覆盖时,它把失败线。任何援助将不胜感激。
谢谢。
显示您的'users_controller'代码 – rick