Skip to content
Browse files

Fixed missing failure message for should_not allow_mass_assignment_of…

… with no protected attributes
  • Loading branch information...
1 parent 324bbe9 commit 272aad1c4d5897ff232ec9a75a73c85b0f64554a @jferris jferris committed Apr 21, 2010
View
2 lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb
@@ -24,7 +24,7 @@ def matches?(subject)
@failure_message = "#{@attribute} was made accessible"
else
if protected_attributes.empty?
- @failure_message = "no attributes were protected"
+ @negative_failure_message = "no attributes were protected"
else
@failure_message = "#{class_name} is protecting " <<
"#{protected_attributes.to_a.to_sentence}, " <<
View
6 test/matchers/active_record/allow_mass_assignment_of_matcher_test.rb
@@ -63,6 +63,12 @@ class AllowMassAssignmentOfMatcherTest < ActiveSupport::TestCase # :nodoc:
should "accept being mass-assignable" do
assert_accepts allow_mass_assignment_of(:attr), @model
end
+
+ should "assign a negative failure message" do
+ matcher = allow_mass_assignment_of(:attr)
+ matcher.matches?(@model)
+ assert_not_nil matcher.negative_failure_message
+ end
end
end

0 comments on commit 272aad1

Please sign in to comment.
Something went wrong with that request. Please try again.