0
私はRails 3.2.2で作業しています。私はユーザーと呼ばれるモデルを持っています。私のユーザモデルで保護された属性のユニットテストRails
私が設定:
attr_protected :is_admin
テストのために
私が作ったこのプロパティ(is_adminは論理属性です):
test "should not be able to change to admin" do
user = User.create(:name => "Joaquim", :email => "[email protected]", :password => "123456", :is_admin => true)
assert user.errors.get(:is_admin), "Cant change admin configuration"
end
私は、このテスト・昇給・エラーを実行すると、 :
1) Error:
test_should_not_be_able_to_change_to_admin(UserTest):
ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: is_admin
test/unit/user_test.rb:44:in `test_should_not_be_able_to_change_to_admin'
このテストにはどのようなアサーションを使用する必要がありますか?
ありがとうございます!