Skip to content

Commit

Permalink
Fix shrine version for ruby 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
akhsunna committed Oct 7, 2020
1 parent 121583a commit e4d970e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ appraise "rails-5.0" do
gem 'mongoid-paperclip', '>= 0.0.8', require: 'mongoid_paperclip'
gem 'carrierwave-mongoid', '>= 0.6.3', require: 'carrierwave/mongoid'
gem 'cancancan-mongoid'
gem 'shrine-mongoid', '~> 1.0'
gem 'shrine-mongoid', '~> 0.2'
end
end

Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_5.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ group :test do
gem "rubocop", "~> 0.68.1"
gem "rubocop-performance"
gem "simplecov", ">= 0.9", require: false
gem "shrine", "~> 3.0"
gem "shrine", "~> 2.13.0"
gem "shrine-memory"
gem "timecop", ">= 0.5"
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Expand All @@ -61,7 +62,7 @@ group :mongoid do
gem "mongoid-paperclip", ">= 0.0.8", require: "mongoid_paperclip"
gem "carrierwave-mongoid", ">= 0.6.3", require: "carrierwave/mongoid"
gem "cancancan-mongoid"
gem "shrine-mongoid", '~> 1.0'
gem "shrine-mongoid", "~> 0.2.4"
end

gemspec path: "../"
13 changes: 8 additions & 5 deletions spec/dummy_app/app/active_record/shrine_versioning_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ class ShrineVersioningUploader < Shrine
plugin :determine_mime_type
plugin :pretty_location
plugin :remove_attachment
plugin :derivatives

Attacher.derivatives_processor do |original|
{
thumb: FakeIO.new('', filename: File.basename(original.path), content_type: File.extname(original.path)),
}
if Gem.loaded_specs['shrine'].version >= Gem::Version.create('3')
plugin :derivatives

Attacher.derivatives_processor do |original|
{
thumb: FakeIO.new('', filename: File.basename(original.path), content_type: File.extname(original.path)),
}
end
end
end
13 changes: 8 additions & 5 deletions spec/dummy_app/app/mongoid/shrine_versioning_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ class ShrineVersioningUploader < Shrine
plugin :determine_mime_type
plugin :pretty_location
plugin :remove_attachment
plugin :derivatives

Attacher.derivatives_processor do |original|
{
thumb: FakeIO.new('', filename: File.basename(original.path), content_type: File.extname(original.path)),
}
if Gem.loaded_specs['shrine'].version >= Gem::Version.create('3')
plugin :derivatives

Attacher.derivatives_processor do |original|
{
thumb: FakeIO.new('', filename: File.basename(original.path), content_type: File.extname(original.path)),
}
end
end
end
10 changes: 7 additions & 3 deletions spec/rails_admin/config/fields/types/shrine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
end

before do
if record.shrine_versioning_asset
record.shrine_versioning_asset_derivatives!
record.save
if Gem.loaded_specs['shrine'].version >= Gem::Version.create('3')
if record.shrine_versioning_asset
record.shrine_versioning_asset_derivatives!
record.save
end
else
skip
end
end

Expand Down

0 comments on commit e4d970e

Please sign in to comment.