Skip to content

Commit

Permalink
Merge pull request heartcombo#1780 from cmeiklejohn/master
Browse files Browse the repository at this point in the history
Verify AR constant is defined in test suite.
  • Loading branch information
josevalim committed Apr 8, 2012
2 parents dacdc72 + eb4e232 commit cef5c93
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ class SessionsControllerTest < ActionController::TestCase
assert_equal 200, @response.status
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 }

begin
assert_nothing_raised ActiveModel::MassAssignmentSecurity::Error do
get :new, :user => { :email => "allez viens!" }
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!" }
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
end
end

0 comments on commit cef5c93

Please sign in to comment.