Fix absence matcher tests so that they run
Apparently they were supposed to be enabled for ActiveModel >= 4 but ended up being enabled for ActiveModel 4 itself.
This commit is contained in:
parent
34f7732ba8
commit
43f4252561
|
@ -21,6 +21,10 @@ module UnitTests
|
|||
::ActiveModel::VERSION::MAJOR == 4
|
||||
end
|
||||
|
||||
def active_model_supports_absence_validation?
|
||||
active_model_version >= 4
|
||||
end
|
||||
|
||||
def active_model_supports_strict?
|
||||
active_model_version >= 3.2
|
||||
end
|
||||
|
|
|
@ -79,7 +79,12 @@ module UnitTests
|
|||
overrides[:changing_values_with]
|
||||
)
|
||||
|
||||
if respond_to?(:write_attribute)
|
||||
if (
|
||||
respond_to?(:write_attribute) && (
|
||||
!self.class.respond_to?(:reflect_on_association) ||
|
||||
!self.class.reflect_on_association(attribute_name)
|
||||
)
|
||||
)
|
||||
write_attribute(attribute_name, new_value)
|
||||
else
|
||||
super(new_value)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'unit_spec_helper'
|
||||
|
||||
describe Shoulda::Matchers::ActiveModel::ValidateAbsenceOfMatcher, type: :model do
|
||||
if active_model_4_0?
|
||||
if active_model_supports_absence_validation?
|
||||
def self.available_column_types
|
||||
[
|
||||
:string,
|
||||
|
|
Loading…
Reference in New Issue