Skip to content

Commit 25a6aa3

Browse files
author
Mattia Roccoberton
committed
feat: apply RuboCop auto correct
1 parent 4a6e7e8 commit 25a6aa3

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

lib/tasks/active_storage_db_tasks.rake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ end
1919
namespace :asdb do
2020
desc 'ActiveStorageDB: list attachments ordered by blob id desc'
2121
task list: [:environment] do |_t, _args|
22-
query = ::ActiveStorage::Blob.order(id: :desc).limit(100)
22+
query = ActiveStorage::Blob.order(id: :desc).limit(100)
2323
digits = query.ids.inject(0) { |ret, id| size = id.to_s.size; [size, ret].max }
2424

25-
::ActiveStorage::Tasks.print_blob_header(digits: digits)
25+
ActiveStorage::Tasks.print_blob_header(digits: digits)
2626
query.each do |blob|
27-
::ActiveStorage::Tasks.print_blob(blob, digits: digits)
27+
ActiveStorage::Tasks.print_blob(blob, digits: digits)
2828
end
2929
end
3030

@@ -34,7 +34,7 @@ namespace :asdb do
3434
destination = args[:destination]&.strip || Dir.pwd
3535
abort('Required arguments: source blob id, destination path') if blob_id.blank? || destination.blank?
3636

37-
blob = ::ActiveStorage::Blob.find_by(id: blob_id)
37+
blob = ActiveStorage::Blob.find_by(id: blob_id)
3838
abort('Source file not found') unless blob
3939

4040
destination = "#{destination}/#{blob.filename}" if Dir.exist?(destination)
@@ -50,12 +50,12 @@ namespace :asdb do
5050
filename = args[:filename]&.strip
5151
abort('Required arguments: filename') if filename.blank?
5252

53-
blobs = ::ActiveStorage::Blob.where('filename LIKE ?', "%#{filename}%").order(id: :desc)
53+
blobs = ActiveStorage::Blob.where('filename LIKE ?', "%#{filename}%").order(id: :desc)
5454
if blobs.any?
5555
digits = blobs.ids.inject(0) { |ret, id| size = id.to_s.size; [size, ret].max }
56-
::ActiveStorage::Tasks.print_blob_header(digits: digits)
56+
ActiveStorage::Tasks.print_blob_header(digits: digits)
5757
blobs.each do |blob|
58-
::ActiveStorage::Tasks.print_blob(blob, digits: digits)
58+
ActiveStorage::Tasks.print_blob(blob, digits: digits)
5959
end
6060
else
6161
puts 'No results'

spec/rails_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
add_filter %r{^/spec/}
2121
add_filter %r{^/vendor/}
2222

23-
case ENV['RAILS']
23+
case ENV.fetch('RAILS', nil)
2424
when '6.0' then add_filter /_rails61|_rails70/
2525
when '6.1' then add_filter /_rails60|_rails70/
2626
when '7.0' then add_filter /_rails60|_rails61/
@@ -49,7 +49,7 @@
4949

5050
RSpec.configure do |config|
5151
config.filter_rails_from_backtrace!
52-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
52+
config.fixture_path = "#{Rails.root}/spec/fixtures"
5353
config.infer_spec_type_from_file_location!
5454
config.use_transactional_fixtures = true
5555

spec/requests/file_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_blob_before_direct_upload(byte_size:, checksum:, filename: 'hello.txt
2929
}
3030
end
3131
let(:host) { "#{url_options[:protocol]}#{url_options[:host]}:#{url_options[:port]}" }
32-
let(:engine_url_helpers) { ::ActiveStorageDB::Engine.routes.url_helpers }
32+
let(:engine_url_helpers) { ActiveStorageDB::Engine.routes.url_helpers }
3333

3434
before do
3535
if ActiveStorage::Current.respond_to? :url_options
@@ -142,7 +142,7 @@ def create_blob_before_direct_upload(byte_size:, checksum:, filename: 'hello.txt
142142
let(:invalid_file) { create(:active_storage_db_file, data: 'Some other data') }
143143

144144
before do
145-
allow(::ActiveStorageDB::File).to receive(:find_by).and_return(invalid_file)
145+
allow(ActiveStorageDB::File).to receive(:find_by).and_return(invalid_file)
146146
end
147147

148148
it 'fails to upload' do

spec/requests/file_url_spec.rb

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

33
RSpec.describe 'File URL', type: :request do
44
let(:app_url_helpers) { Rails.application.routes.url_helpers }
5-
let(:engine_url_helpers) { ::ActiveStorageDB::Engine.routes.url_helpers }
5+
let(:engine_url_helpers) { ActiveStorageDB::Engine.routes.url_helpers }
66

77
it 'has the service URL in the engine URL helpers' do
88
expect(app_url_helpers).to respond_to :active_storage_db_path

spec/service/active_storage/service/db_service_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
let!(:db_file3) { create(:active_storage_db_file, ref: 'key3', data: 'third file') }
5858

5959
it 'composes the source files' do
60-
expect { compose }.to change { ::ActiveStorageDB::File.where(ref: 'dest_key').count }.by(1)
61-
expect(compose).to be_kind_of ::ActiveStorageDB::File
60+
expect { compose }.to change { ActiveStorageDB::File.where(ref: 'dest_key').count }.by(1)
61+
expect(compose).to be_a ActiveStorageDB::File
6262
expect(compose.data).to eq [db_file1.data, db_file2.data, db_file3.data].join
6363
end
6464
end
@@ -154,7 +154,7 @@
154154

155155
describe '.upload' do
156156
it 'uploads the data' do
157-
expect(upload).to be_kind_of ActiveStorageDB::File
157+
expect(upload).to be_a ActiveStorageDB::File
158158
ensure
159159
service.delete(key)
160160
end
@@ -163,7 +163,7 @@
163163
let(:upload) { service.upload(key, StringIO.new(fixture_data), checksum: checksum) }
164164

165165
it 'uploads the data' do
166-
expect(upload).to be_kind_of ActiveStorageDB::File
166+
expect(upload).to be_a ActiveStorageDB::File
167167
ensure
168168
service.delete(key)
169169
end

0 commit comments

Comments
 (0)