Skip to content

Commit

Permalink
Fix ActiveStorage type detection for email files
Browse files Browse the repository at this point in the history
Fixes #555
  • Loading branch information
const-cloudinary authored Aug 18, 2024
1 parent a634428 commit a5eb80e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/active_storage/service/cloudinary_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def content_type_to_resource_type(content_type)
case type
when 'video', 'audio'
'video'
when 'text'
when 'text', 'message'
'raw'
when 'application'
case subtype
Expand Down
2 changes: 1 addition & 1 deletion spec/account_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
expect(key_del_res["message"]).to eq "ok"

named_key_del_res = @api.delete_access_key(cloud_id, nil, named_key_name)
expect(named_key_del_res["message"]).to eq "sok"
expect(named_key_del_res["message"]).to eq "ok"
end
end
end
11 changes: 9 additions & 2 deletions spec/active_storage/database/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ class << self
alias_method :load, :unsafe_load if YAML.respond_to? :unsafe_load
end
end
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.connection.migration_context.migrate

connection = ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
if connection.respond_to?(:migration_context)
connection.migration_context.migrate
else
# Fallback for older versions of Rails
ActiveRecord::Base.connection.migration_context.migrate
end

ActiveStorageCreateUsers.migrate(:up)
2 changes: 1 addition & 1 deletion spec/active_storage/service/cloudinary_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

it "should set raw resource_type for raw formats" do
key = SecureRandom.base58(24)
types = %w[text/* application/*]
types = %w[text/* application/* message/*]

types.each do |content_type|
url = @service.url_for_direct_upload(key, content_type: content_type)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SUFFIX = ENV['TRAVIS_JOB_ID'] || rand(999999999).to_s

require 'bundler/setup'
require 'rspec'
require 'rspec/retry'
require 'rexml/parsers/ultralightparser'
Expand Down

0 comments on commit a5eb80e

Please sign in to comment.