From b36b4b7d9f9e092c7a5e0472b858cdf69c0328f7 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Thu, 7 Sep 2017 10:13:01 -0400 Subject: [PATCH 1/5] Update carrierwave dependency to allow for upgrade to rails 5.0 --- sufia.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sufia.gemspec b/sufia.gemspec index 9cc310add9..f5d9972f2f 100644 --- a/sufia.gemspec +++ b/sufia.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'json-schema' spec.add_dependency 'nest', '~> 2.0' spec.add_dependency 'mailboxer', '~> 0.12' - spec.add_dependency 'carrierwave', '~> 0.9' + spec.add_dependency 'carrierwave', '~> 1.0' spec.add_dependency 'oauth' spec.add_dependency 'oauth2', '~> 1.2' spec.add_dependency 'signet' From e7b22019b006d2b0d1542733b110cca8c6401864 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Thu, 7 Sep 2017 13:19:09 -0400 Subject: [PATCH 2/5] Update file_uploader to stop overriding method defined in carrierwave backport from hyrax https://github.com/samvera/hyrax/commit/6ca1f779fe08311986c6a34fc3eecadbf0ed7f28 --- app/uploaders/sufia/uploaded_file_uploader.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/uploaders/sufia/uploaded_file_uploader.rb b/app/uploaders/sufia/uploaded_file_uploader.rb index 68b5a0066c..334c3624ff 100644 --- a/app/uploaders/sufia/uploaded_file_uploader.rb +++ b/app/uploaders/sufia/uploaded_file_uploader.rb @@ -3,20 +3,20 @@ class UploadedFileUploader < CarrierWave::Uploader::Base # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - base_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + configured_upload_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def cache_dir - cache_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + configured_cache_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end private - def base_path + def configured_upload_path Sufia.config.upload_path.call end - def cache_path + def configured_cache_path Sufia.config.cache_path.call end end From 0e41903534c856ca6b09ac936f4a22b963a1b7df Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Thu, 7 Sep 2017 14:03:55 -0400 Subject: [PATCH 3/5] Updates to api, i18n required for carrierwave 1.0 Essentially a backport of https://github.com/samvera/hyrax/commit/ba38041345d11fb8d9c57833cb1c08a8df6a24fa --- app/uploaders/sufia/avatar_uploader.rb | 2 +- app/uploaders/tinymce_asset_uploader.rb | 2 +- config/locales/sufia.en.yml | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/uploaders/sufia/avatar_uploader.rb b/app/uploaders/sufia/avatar_uploader.rb index f051c42c14..287cb21900 100644 --- a/app/uploaders/sufia/avatar_uploader.rb +++ b/app/uploaders/sufia/avatar_uploader.rb @@ -10,7 +10,7 @@ class Sufia::AvatarUploader < CarrierWave::Uploader::Base process resize_to_limit: [100, 100] end - def extension_white_list + def extension_whitelist %w(jpg jpeg png gif bmp tif tiff) end end diff --git a/app/uploaders/tinymce_asset_uploader.rb b/app/uploaders/tinymce_asset_uploader.rb index dbdf51d12c..3ebbcf6b78 100644 --- a/app/uploaders/tinymce_asset_uploader.rb +++ b/app/uploaders/tinymce_asset_uploader.rb @@ -33,7 +33,7 @@ def store_dir # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: - # def extension_white_list + # def extension_whitelist # %w(jpg jpeg gif png) # end diff --git a/config/locales/sufia.en.yml b/config/locales/sufia.en.yml index 784291bc4c..65cccef188 100644 --- a/config/locales/sufia.en.yml +++ b/config/locales/sufia.en.yml @@ -531,3 +531,9 @@ en: create: 'Add' create: 'Save' update: 'Save' + errors: + messages: + carrierwave_processing_error: "Cannot resize image." + carrierwave_integrity_error: "Not an image." + carrierwave_download_error: "Couldn't download image." + extension_whitelist_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}" From 167a40ae91d33de21fb3a7c297b039cad32543d1 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Thu, 7 Sep 2017 14:09:25 -0400 Subject: [PATCH 4/5] Fix view test that was failing intermittently backport of https://github.com/samvera/hyrax/commit/1822524f2f23c9648ad2f1834d6c9a06ddb9b8ba --- spec/views/sufia/admin/admin_sets/index.html.erb_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/views/sufia/admin/admin_sets/index.html.erb_spec.rb b/spec/views/sufia/admin/admin_sets/index.html.erb_spec.rb index 2f3bd36bb8..c836a7021e 100644 --- a/spec/views/sufia/admin/admin_sets/index.html.erb_spec.rb +++ b/spec/views/sufia/admin/admin_sets/index.html.erb_spec.rb @@ -11,17 +11,19 @@ let(:solr_doc) { SolrDocument.new(admin_set.to_solr) } let(:admin_sets) { [solr_doc] } let(:presenter_class) { Sufia::AdminSetPresenter } + let(:presenter) { instance_double(presenter_class, total_items: 99) } let(:ability) { instance_double("Ability") } before do allow(controller).to receive(:current_ability).and_return(ability) allow(controller).to receive(:presenter_class).and_return(presenter_class) + allow(presenter_class).to receive(:new).and_return(presenter) assign(:admin_sets, admin_sets) end it "lists admin set" do render expect(rendered).to have_content('Example Admin Set') expect(rendered).to have_content('jdoe@example.com') - expect(rendered).to have_css("td", text: /^0$/) + expect(rendered).to have_css("td", text: /^99$/) end end end From a5d58f48ef53446f87b9d7c000dba24adfcc491b Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Thu, 7 Sep 2017 15:05:17 -0400 Subject: [PATCH 5/5] Fix test to allow array elements in any order was failing intermittently; backports https://github.com/samvera/hyrax/commit/82138ee24bca3553f2ca1f00ca4707a03c62233a --- spec/services/sufia/statistics/depositors/summary_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/services/sufia/statistics/depositors/summary_spec.rb b/spec/services/sufia/statistics/depositors/summary_spec.rb index 8093b6eb6e..75b2989d9f 100644 --- a/spec/services/sufia/statistics/depositors/summary_spec.rb +++ b/spec/services/sufia/statistics/depositors/summary_spec.rb @@ -31,8 +31,8 @@ let(:start_date) { 1.day.ago.beginning_of_day } let(:end_date) { 0.days.ago.end_of_day } it "gathers user deposits during a date range" do - expect(subject).to eq [{ key: user1.user_key, deposits: 1, user: user1 }, - { key: user2.user_key, deposits: 1, user: user2 }] + expect(subject).to match_array [{ key: user1.user_key, deposits: 1, user: user1 }, + { key: user2.user_key, deposits: 1, user: user2 }] end end end