Skip to content

Commit a5eb80e

Browse files
Fix ActiveStorage type detection for email files
Fixes #555
1 parent a634428 commit a5eb80e

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

lib/active_storage/service/cloudinary_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def content_type_to_resource_type(content_type)
255255
case type
256256
when 'video', 'audio'
257257
'video'
258-
when 'text'
258+
when 'text', 'message'
259259
'raw'
260260
when 'application'
261261
case subtype

spec/account_api_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
expect(key_del_res["message"]).to eq "ok"
239239

240240
named_key_del_res = @api.delete_access_key(cloud_id, nil, named_key_name)
241-
expect(named_key_del_res["message"]).to eq "sok"
241+
expect(named_key_del_res["message"]).to eq "ok"
242242
end
243243
end
244244
end

spec/active_storage/database/setup.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ class << self
77
alias_method :load, :unsafe_load if YAML.respond_to? :unsafe_load
88
end
99
end
10-
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
11-
ActiveRecord::Base.connection.migration_context.migrate
10+
11+
connection = ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
12+
if connection.respond_to?(:migration_context)
13+
connection.migration_context.migrate
14+
else
15+
# Fallback for older versions of Rails
16+
ActiveRecord::Base.connection.migration_context.migrate
17+
end
18+
1219
ActiveStorageCreateUsers.migrate(:up)

spec/active_storage/service/cloudinary_service_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108

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

113113
types.each do |content_type|
114114
url = @service.url_for_direct_upload(key, content_type: content_type)

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SUFFIX = ENV['TRAVIS_JOB_ID'] || rand(999999999).to_s
22

3+
require 'bundler/setup'
34
require 'rspec'
45
require 'rspec/retry'
56
require 'rexml/parsers/ultralightparser'

0 commit comments

Comments
 (0)