Skip to content

Commit

Permalink
Fix ActiveRecord 4.x builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Dec 28, 2022
1 parent 8f38657 commit a8dfad2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spec/orm/activerecord_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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!
Expand Down

0 comments on commit a8dfad2

Please sign in to comment.