Fix allow_mass_assignment specs in Rails 4

This spec has a lot of active_model version checking in it. The version
checking helpers had to be updated to account for Rails 4.

I was able to remove the check for active_model 3.0 because 3.0 is now
the lowest supported rails version.
This commit is contained in:
Derek Prior 2013-05-17 09:05:10 -04:00 committed by Elliot Winkler
parent aea401fff2
commit 6e1ff3a8c3
3 changed files with 12 additions and 14 deletions

View File

@ -59,7 +59,7 @@ describe Shoulda::Matchers::ActiveModel::AllowMassAssignmentOfMatcher do
end
end
unless active_model_3_2?
unless active_model_3_2? || active_model_4_0?
context 'an attribute on a class with no protected attributes' do
it 'accepts being mass-assignable' do
no_protected_attributes.should allow_mass_assignment_of(:attr)

View File

@ -78,13 +78,11 @@ describe Shoulda::Matchers::ActiveModel::Helpers do
end
end
if active_model_3_0?
context 'if ActiveModel::Errors#generate_message behavior has changed' do
it 'provides the right error message for validate_presence_of' do
stub_active_model_message_generation(:type => :blank,
:message => 'Behavior has diverged.')
assert_presence_validation_has_correct_message
end
context 'if ActiveModel::Errors#generate_message behavior has changed' do
it 'provides the right error message for validate_presence_of' do
stub_active_model_message_generation(:type => :blank,
:message => 'Behavior has diverged.')
assert_presence_validation_has_correct_message
end
end
end

View File

@ -1,13 +1,13 @@
RSpec.configure do |c|
def active_model_3_0?
::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 0
end
def active_model_3_1?
::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 1
(::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 1) || active_model_4_0?
end
def active_model_3_2?
::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 2
(::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 2) || active_model_4_0?
end
def active_model_4_0?
::ActiveModel::VERSION::MAJOR == 4
end
end