Skip to content

Commit

Permalink
Merge pull request #3179 from samvera/carrierwave
Browse files Browse the repository at this point in the history
Update carrierwave to 1.0, which supports rails 5
  • Loading branch information
mjgiarlo authored Sep 7, 2017
2 parents 78507ae + a5d58f4 commit 3489a14
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/uploaders/sufia/avatar_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions app/uploaders/sufia/uploaded_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/uploaders/tinymce_asset_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions config/locales/sufia.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
4 changes: 2 additions & 2 deletions spec/services/sufia/statistics/depositors/summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion spec/views/sufia/admin/admin_sets/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]')
expect(rendered).to have_css("td", text: /^0$/)
expect(rendered).to have_css("td", text: /^99$/)
end
end
end
2 changes: 1 addition & 1 deletion sufia.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 3489a14

Please sign in to comment.