Skip to content

Commit

Permalink
Merge pull request #102 from publify/update-carrierwave
Browse files Browse the repository at this point in the history
Update CarrierWave to version 3.0
  • Loading branch information
mvz authored Aug 26, 2023
2 parents 91388fc + c08db29 commit e685060
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
12 changes: 3 additions & 9 deletions app/uploaders/resource_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ def image?(new_file)
end

def check_content_type!(new_file)
detected_type = if image? new_file
file_content_content_type(new_file)
else
file_content_type(new_file)
end
return unless image? new_file

detected_type = file_content_content_type(new_file)
if detected_type != new_file.content_type
raise CarrierWave::IntegrityError, "has MIME type mismatch"
end
Expand All @@ -72,8 +70,4 @@ def check_content_type!(new_file)
def file_content_content_type(new_file)
Marcel::MimeType.for Pathname.new(new_file.path)
end

def file_content_type(new_file)
Marcel::MimeType.for Pathname.new(new_file.path), name: new_file.filename
end
end
2 changes: 1 addition & 1 deletion publify_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency "aasm", "~> 5.0"
s.add_dependency "akismet", "~> 3.0"
s.add_dependency "cancancan", "~> 3.0"
s.add_dependency "carrierwave", "~> 2.2.1"
s.add_dependency "carrierwave", "~> 3.0"
s.add_dependency "commonmarker", "~> 0.23.2"
s.add_dependency "devise", ">= 4.8", "< 4.10"
s.add_dependency "devise-i18n", "~> 1.2"
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/admin/resources_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@
post :upload, params: { upload: upload }
result = assigns(:up)
expect(result.errors[:upload])
.to contain_exactly("has MIME type mismatch", "can't be blank")
.to contain_exactly(%r{You are not allowed to upload text/html files},
"can't be blank")
end

it "sets the flash to failure" do
Expand Down

0 comments on commit e685060

Please sign in to comment.