From 25ae06a9a6eb534afa4a5f17e64ca346086bb3b8 Mon Sep 17 00:00:00 2001 From: "M.Shibuya" Date: Sun, 14 Jul 2019 13:58:31 +0900 Subject: [PATCH] Drop Refile support due to inactivity --- lib/rails_admin/config/fields.rb | 1 - .../config/fields/factories/refile.rb | 25 ----------------- lib/rails_admin/config/fields/types/all.rb | 1 - lib/rails_admin/config/fields/types/refile.rb | 27 ------------------- .../rails_admin/main_controller_spec.rb | 7 ++--- spec/dummy_app/Gemfile | 6 ----- .../dummy_app/app/active_record/field_test.rb | 2 -- spec/dummy_app/app/mongoid/field_test.rb | 9 ------- spec/rails_admin/config/fields/base_spec.rb | 21 --------------- .../config/fields/types/file_upload_spec.rb | 2 -- 10 files changed, 2 insertions(+), 99 deletions(-) delete mode 100644 lib/rails_admin/config/fields/factories/refile.rb delete mode 100644 lib/rails_admin/config/fields/types/refile.rb diff --git a/lib/rails_admin/config/fields.rb b/lib/rails_admin/config/fields.rb index fdc9c65dad..5c5b0d8978 100644 --- a/lib/rails_admin/config/fields.rb +++ b/lib/rails_admin/config/fields.rb @@ -82,7 +82,6 @@ def self.register_factory(&block) require 'rails_admin/config/fields/factories/paperclip' require 'rails_admin/config/fields/factories/dragonfly' require 'rails_admin/config/fields/factories/carrierwave' -require 'rails_admin/config/fields/factories/refile' require 'rails_admin/config/fields/factories/active_storage' require 'rails_admin/config/fields/factories/shrine' require 'rails_admin/config/fields/factories/action_text' diff --git a/lib/rails_admin/config/fields/factories/refile.rb b/lib/rails_admin/config/fields/factories/refile.rb deleted file mode 100644 index c669250bb5..0000000000 --- a/lib/rails_admin/config/fields/factories/refile.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'rails_admin/config/fields' -require 'rails_admin/config/fields/types' -require 'rails_admin/config/fields/types/file_upload' - -RailsAdmin::Config::Fields.register_factory do |parent, properties, fields| - extensions = [:id, :filename, :size, :content_type] - model = parent.abstract_model.model - if (properties.name.to_s =~ /^(.+)_id$/) && defined?(::Refile) && model.ancestors.map(&:to_s).include?("Refile::Attachment(#{attachment_name = Regexp.last_match[1].to_sym})") - field = RailsAdmin::Config::Fields::Types.load(:refile).new(parent, attachment_name, properties) - children_fields = [] - extensions.each do |ext| - children_column_name = "#{attachment_name}_#{ext}".to_sym - next unless child_properties = parent.abstract_model.properties.detect { |p| p.name.to_s == children_column_name.to_s } - children_field = fields.detect { |f| f.name == children_column_name } || RailsAdmin::Config::Fields.default_factory.call(parent, child_properties, fields) - children_field.hide - children_field.filterable(false) - children_fields << children_field.name - end - field.children_fields(children_fields) - fields << field - true - else - false - end -end diff --git a/lib/rails_admin/config/fields/types/all.rb b/lib/rails_admin/config/fields/types/all.rb index 009fd0e33e..9ba58c66e8 100644 --- a/lib/rails_admin/config/fields/types/all.rb +++ b/lib/rails_admin/config/fields/types/all.rb @@ -12,7 +12,6 @@ require 'rails_admin/config/fields/types/file_upload' require 'rails_admin/config/fields/types/paperclip' require 'rails_admin/config/fields/types/carrierwave' -require 'rails_admin/config/fields/types/refile' require 'rails_admin/config/fields/types/multiple_file_upload' require 'rails_admin/config/fields/types/multiple_active_storage' require 'rails_admin/config/fields/types/multiple_carrierwave' diff --git a/lib/rails_admin/config/fields/types/refile.rb b/lib/rails_admin/config/fields/types/refile.rb deleted file mode 100644 index 82548eab52..0000000000 --- a/lib/rails_admin/config/fields/types/refile.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_admin/config/fields/base' -require 'rails_admin/config/fields/types/file_upload' - -module RailsAdmin - module Config - module Fields - module Types - class Refile < RailsAdmin::Config::Fields::Types::FileUpload - RailsAdmin::Config::Fields::Types.register(self) - - register_instance_option :thumb_method do - [:limit, 100, 100] - end - - register_instance_option :delete_method do - "remove_#{name}" - end - - def resource_url(thumb = []) - return nil unless value - Object.const_get(:Refile).attachment_url(bindings[:object], name, *thumb) - end - end - end - end - end -end diff --git a/spec/controllers/rails_admin/main_controller_spec.rb b/spec/controllers/rails_admin/main_controller_spec.rb index e331341f52..75fac5a3a3 100644 --- a/spec/controllers/rails_admin/main_controller_spec.rb +++ b/spec/controllers/rails_admin/main_controller_spec.rb @@ -329,7 +329,6 @@ def get(action, params) field :paperclip_asset do delete_method :delete_paperclip_asset end - field :refile_asset if defined?(Refile) field :active_storage_asset do delete_method :remove_active_storage_asset end if defined?(ActiveStorage) @@ -352,8 +351,7 @@ def get(action, params) 'paperclip_asset' => 'test', 'delete_paperclip_asset' => 'test', 'should_not_be_here' => 'test', - }.merge(defined?(Refile) ? {'refile_asset' => 'test', 'remove_refile_asset' => 'test'} : {}). - merge(defined?(ActiveStorage) ? {'active_storage_asset' => 'test', 'remove_active_storage_asset' => 'test', 'active_storage_assets' => 'test', 'remove_active_storage_assets' => 'test'} : {}). + }.merge(defined?(ActiveStorage) ? {'active_storage_asset' => 'test', 'remove_active_storage_asset' => 'test', 'active_storage_assets' => 'test', 'remove_active_storage_assets' => 'test'} : {}). merge(defined?(Shrine) ? {'shrine_asset' => 'test', 'remove_shrine_asset' => 'test'} : {}), ) @@ -368,8 +366,7 @@ def get(action, params) 'retained_dragonfly_asset' => 'test', 'paperclip_asset' => 'test', 'delete_paperclip_asset' => 'test', - }.merge(defined?(Refile) ? {'refile_asset' => 'test', 'remove_refile_asset' => 'test'} : {}). - merge(defined?(ActiveStorage) ? {'active_storage_asset' => 'test', 'remove_active_storage_asset' => 'test', 'active_storage_assets' => 'test', 'remove_active_storage_assets' => 'test'} : {}). + }.merge(defined?(ActiveStorage) ? {'active_storage_asset' => 'test', 'remove_active_storage_asset' => 'test', 'active_storage_assets' => 'test', 'remove_active_storage_assets' => 'test'} : {}). merge(defined?(Shrine) ? {'shrine_asset' => 'test', 'remove_shrine_asset' => 'test'} : {})) end diff --git a/spec/dummy_app/Gemfile b/spec/dummy_app/Gemfile index 8eab6c54aa..f70e9cae91 100644 --- a/spec/dummy_app/Gemfile +++ b/spec/dummy_app/Gemfile @@ -27,7 +27,6 @@ group :mongoid do gem 'kaminari-mongoid' gem 'mongoid-paperclip', '>= 0.0.8', require: 'mongoid_paperclip' gem 'carrierwave-mongoid', '>= 0.6.3', require: 'carrierwave/mongoid' - # gem 'refile-mongoid', '>= 0.0.1', platforms: [:ruby_21, :ruby_22] gem 'shrine-mongoid' end @@ -41,11 +40,6 @@ gem 'rails_admin', path: '../../' gem 'shrine', '~> 2.0' gem 'shrine-memory' -platforms :mri do - # gem 'refile', '>= 0.5', require: 'refile/rails' - # gem 'refile-mini_magick', '>= 0.1.0' -end - # Gems used only for assets and not required # in production environments by default. group :assets do diff --git a/spec/dummy_app/app/active_record/field_test.rb b/spec/dummy_app/app/active_record/field_test.rb index b8cfe82525..b8324b73b1 100644 --- a/spec/dummy_app/app/active_record/field_test.rb +++ b/spec/dummy_app/app/active_record/field_test.rb @@ -17,8 +17,6 @@ class FieldTest < ActiveRecord::Base mount_uploaders :carrierwave_assets, CarrierwaveUploader serialize :carrierwave_assets, JSON - attachment :refile_asset if defined?(Refile) - if defined?(ActiveStorage) has_one_attached :active_storage_asset attr_accessor :remove_active_storage_asset diff --git a/spec/dummy_app/app/mongoid/field_test.rb b/spec/dummy_app/app/mongoid/field_test.rb index 515bf8088f..427db8a9a3 100644 --- a/spec/dummy_app/app/mongoid/field_test.rb +++ b/spec/dummy_app/app/mongoid/field_test.rb @@ -62,14 +62,5 @@ class FieldTest # https://github.com/carrierwaveuploader/carrierwave-mongoid/issues/138 mount_uploader :carrierwave_assets, CarrierwaveUploader - if defined?(Refile) - extend Refile::Mongoid::Attachment - - field :refile_asset_filename - field :refile_asset_size - field :refile_asset_content_type - attachment :refile_asset - end - validates :short_text, length: {maximum: 255} end diff --git a/spec/rails_admin/config/fields/base_spec.rb b/spec/rails_admin/config/fields/base_spec.rb index 2965d7cb86..2bfd142b5c 100644 --- a/spec/rails_admin/config/fields/base_spec.rb +++ b/spec/rails_admin/config/fields/base_spec.rb @@ -177,14 +177,6 @@ class CommentReversed < Tableless end end - if defined?(Refile) - context 'of a Refile installation' do - it 'is a _id field' do - expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :refile_asset }.children_fields).to eq([:refile_asset_id, :refile_asset_filename, :refile_asset_size, :refile_asset_content_type]) - end - end - end - if defined?(ActiveStorage) context 'of a ActiveStorage installation' do it 'is _attachment and _blob fields' do @@ -410,12 +402,6 @@ class CommentReversed < Tableless it 'of carrierwave should find the underlying column on the base table' do expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :carrierwave_asset }.searchable_columns.collect { |c| c[:column] }).to eq(['field_tests.carrierwave_asset']) end - - if defined?(Refile) - it 'of refile should find the underlying column on the base table' do - expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :refile_asset }.searchable_columns.collect { |c| c[:column] }).to eq(['field_tests.refile_asset_id']) - end - end end end @@ -447,13 +433,6 @@ class CommentReversed < Tableless expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :carrierwave_asset }.searchable).to eq(:carrierwave_asset) expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :carrierwave_asset }.sortable).to eq(:carrierwave_asset) end - - if defined?(Refile) - it 'of refile should target the first children field' do - expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :refile_asset }.searchable).to eq(:refile_asset_id) - expect(RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :refile_asset }.sortable).to eq(:refile_asset_id) - end - end end end diff --git a/spec/rails_admin/config/fields/types/file_upload_spec.rb b/spec/rails_admin/config/fields/types/file_upload_spec.rb index 48decb654d..3b310bec29 100644 --- a/spec/rails_admin/config/fields/types/file_upload_spec.rb +++ b/spec/rails_admin/config/fields/types/file_upload_spec.rb @@ -12,7 +12,6 @@ field :paperclip_asset do delete_method :delete_paperclip_asset end - field :refile_asset field :active_storage_asset do delete_method :remove_active_storage_asset end if defined?(ActiveStorage) @@ -25,7 +24,6 @@ expect(RailsAdmin.config(FieldTest).field(:carrierwave_asset).allowed_methods.collect(&:to_s)).to eq %w(carrierwave_asset remove_carrierwave_asset carrierwave_asset_cache) expect(RailsAdmin.config(FieldTest).field(:dragonfly_asset).allowed_methods.collect(&:to_s)).to eq %w(dragonfly_asset remove_dragonfly_asset retained_dragonfly_asset) expect(RailsAdmin.config(FieldTest).field(:paperclip_asset).allowed_methods.collect(&:to_s)).to eq %w(paperclip_asset delete_paperclip_asset) - expect(RailsAdmin.config(FieldTest).field(:refile_asset).allowed_methods.collect(&:to_s)).to eq %w(refile_asset remove_refile_asset) if defined?(Refile) expect(RailsAdmin.config(FieldTest).field(:active_storage_asset).allowed_methods.collect(&:to_s)).to eq %w(active_storage_asset remove_active_storage_asset) if defined?(ActiveStorage) expect(RailsAdmin.config(FieldTest).field(:shrine_asset).allowed_methods.collect(&:to_s)).to eq %w(shrine_asset remove_shrine_asset cached_shrine_asset_data) if defined?(Shrine) end