Skip to content

Commit 37dcc05

Browse files
author
Mattia Roccoberton
committed
Fixes for Ruby 3.0
1 parent a17a623 commit 37dcc05

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

lib/active_storage/service/db_service.rb

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

33
module ActiveStorage
44
class Service::DBService < Service
5-
def initialize(**_options)
5+
def initialize(**)
66
@chunk_size = ENV.fetch('ASDB_CHUNK_SIZE') { 1.megabytes }
77
end
88

spec/rails_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
config.before(:suite) do
3838
intro = ('-' * 80)
3939
intro << "\n"
40+
intro << "- Ruby: #{RUBY_VERSION}\n"
4041
intro << "- Rails: #{Rails.version}\n"
4142
intro << "- ActiveStorage: #{ActiveStorage.version}\n"
4243
intro << "- DB_TEST: #{ENV['DB_TEST']}\n"

spec/service/active_storage/service/db_service_spec.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
let(:checksum) { Digest::MD5.base64digest(fixture_data) }
1616
let(:key) { SecureRandom.base58(24) }
1717
let(:service) { described_class.configure(:tmp, tmp: { service: 'DB' }) }
18-
let(:upload_options) { {} }
19-
let(:upload) { service.upload(key, StringIO.new(fixture_data), upload_options) }
18+
let(:upload) { service.upload(key, StringIO.new(fixture_data)) }
2019

2120
before do
2221
allow(ENV).to receive(:fetch).and_call_original
@@ -119,7 +118,7 @@
119118
end
120119

121120
context 'with the checksum' do
122-
let(:upload_options) { { checksum: checksum } }
121+
let(:upload) { service.upload(key, StringIO.new(fixture_data), checksum: checksum) }
123122

124123
it 'uploads the data' do
125124
expect(upload).to be_kind_of ActiveStorageDB::File
@@ -129,7 +128,8 @@
129128
end
130129

131130
context 'with an invalid checksum' do
132-
let(:upload_options) { { checksum: Digest::MD5.base64digest('some other data') } }
131+
let(:checksum) { Digest::MD5.base64digest('some other data') }
132+
let(:upload) { service.upload(key, StringIO.new(fixture_data), checksum: checksum) }
133133

134134
it 'fails to upload the data' do
135135
expect { upload }.to raise_exception ActiveStorage::IntegrityError
@@ -159,10 +159,14 @@
159159
end
160160

161161
describe '.url_for_direct_upload' do
162-
subject { service.url_for_direct_upload(key, url_options) }
163-
164-
let(:url_options) do
165-
{ expires_in: 5.minutes, content_type: content_type, content_length: fixture_data.size, checksum: checksum }
162+
subject do
163+
service.url_for_direct_upload(
164+
key,
165+
expires_in: 5.minutes,
166+
content_type: content_type,
167+
content_length: fixture_data.size,
168+
checksum: checksum
169+
)
166170
end
167171

168172
before do

0 commit comments

Comments
 (0)