1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Ensure ActiveRecord is defined, which is not true when running Mongoid tests.

This commit is contained in:
Christopher Meiklejohn 2012-04-07 15:54:00 -03:00
parent dacdc72581
commit eb4e23274d

View file

@ -14,20 +14,22 @@ class SessionsControllerTest < ActionController::TestCase
assert_template "devise/sessions/new"
end
if ActiveRecord::Base.respond_to?(:mass_assignment_sanitizer)
test "#new doesn't raise mass-assignment exception even if sign-in key is attr_protected" do
request.env["devise.mapping"] = Devise.mappings[:user]
if defined?(ActiveRecord)
if ActiveRecord::Base.respond_to?(:mass_assignment_sanitizer)
test "#new doesn't raise mass-assignment exception even if sign-in key is attr_protected" do
request.env["devise.mapping"] = Devise.mappings[:user]
ActiveRecord::Base.mass_assignment_sanitizer = :strict
User.class_eval { attr_protected :email }
ActiveRecord::Base.mass_assignment_sanitizer = :strict
User.class_eval { attr_protected :email }
begin
assert_nothing_raised ActiveModel::MassAssignmentSecurity::Error do
get :new, :user => { :email => "allez viens!" }
begin
assert_nothing_raised ActiveModel::MassAssignmentSecurity::Error do
get :new, :user => { :email => "allez viens!" }
end
ensure
ActiveRecord::Base.mass_assignment_sanitizer = :logger
User.class_eval { attr_accessible :email }
end
ensure
ActiveRecord::Base.mass_assignment_sanitizer = :logger
User.class_eval { attr_accessible :email }
end
end
end