diff --git a/spec/orm/activerecord_spec.rb b/spec/orm/activerecord_spec.rb index ff74e041e..42f93ffc7 100644 --- a/spec/orm/activerecord_spec.rb +++ b/spec/orm/activerecord_spec.rb @@ -21,8 +21,13 @@ def reset_class(class_name) klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) # TODO Remove when Rails 5.2 is dropped klass.class_eval do - attribute :images, :json - attribute :textfiles, :json + if Rails::VERSION::MAJOR >= 5 + attribute :images, :json + attribute :textfiles, :json + else + serialize :images, JSON + serialize :textfiles, JSON + end end klass end @@ -1181,7 +1186,7 @@ def monkey end it "should mark images as changed when saving a new images" do - expect(@event.images_changed?).to be_falsey + expect(@event.images_changed?).to be_falsey if ActiveRecord::VERSION::MAJOR > 4 || ActiveRecord::VERSION::MINOR > 1 @event.images = [stub_file("test.jpeg")] expect(@event.images_changed?).to be_truthy @event.save @@ -1213,7 +1218,7 @@ def monkey describe "remove_images=" do it "should mark the images as changed if changed" do - expect(@event.images_changed?).to be_falsey + expect(@event.images_changed?).to be_falsey if ActiveRecord::VERSION::MAJOR > 4 || ActiveRecord::VERSION::MINOR > 1 expect(@event.remove_images).to be_nil @event.remove_images = "1" expect(@event.images_changed?).to be_truthy @@ -1227,7 +1232,7 @@ def monkey # FIXME ideally images_changed? and remote_images_urls_changed? would return true it "should mark images as changed when setting remote_images_urls" do - expect(@event.images_changed?).to be_falsey + expect(@event.images_changed?).to be_falsey if ActiveRecord::VERSION::MAJOR > 4 || ActiveRecord::VERSION::MINOR > 1 @event.remote_images_urls = ['http://www.example.com/test.jpg'] expect(@event.images_changed?).to be_truthy @event.save!