Skip to content

Commit 2a8c15d

Browse files
author
Mattia Roccoberton
committed
feat: correct RuboCop offenses
1 parent 25a6aa3 commit 2a8c15d

7 files changed

Lines changed: 16 additions & 21 deletions

File tree

.rubocop.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Lint/UnusedMethodArgument:
2222
AllowUnusedKeywordArguments: true
2323

2424
RSpec/DescribeClass:
25-
Exclude:
26-
- spec/tasks/active_storage_db_tasks_spec.rb
25+
Enabled: false
2726

2827
RSpec/ExampleLength:
2928
# Default is 5

active_storage_db.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
2727
spec.add_dependency 'activestorage', '>= 6.0'
2828
spec.add_dependency 'rails', '>= 6.0'
2929

30-
spec.add_development_dependency 'appraisal', '~> 2.4'
31-
spec.add_development_dependency 'factory_bot_rails', '~> 6.1'
30+
spec.add_development_dependency 'appraisal', '~> 2.4' # rubocop:disable Gemspec/DevelopmentDependencies
31+
spec.add_development_dependency 'factory_bot_rails', '~> 6.1' # rubocop:disable Gemspec/DevelopmentDependencies
3232
end

spec/models/active_storage_db/file_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe ActiveStorageDB::File, type: :model do
3+
RSpec.describe ActiveStorageDB::File do
44
let(:file) { create(:active_storage_db_file, ref: 'just_some_key') }
55

66
context 'when creating a file with an already existing key' do

spec/requests/file_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe 'File controller', type: :request do
3+
RSpec.describe 'File controller' do
44
def create_blob(data: 'Hello world!', filename: 'hello.txt', content_type: 'text/plain', identify: true, record: nil)
55
ActiveStorage::Blob.create_and_upload!(
66
io: StringIO.new(data),

spec/requests/file_url_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

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

spec/service/active_storage/service/db_service_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
describe '.compose' do
5353
subject(:compose) { service.compose(%w[key1 key2 key3], 'dest_key') }
5454

55-
let!(:db_file1) { create(:active_storage_db_file, ref: 'key1', data: 'first file') }
56-
let!(:db_file2) { create(:active_storage_db_file, ref: 'key2', data: 'second file') }
57-
let!(:db_file3) { create(:active_storage_db_file, ref: 'key3', data: 'third file') }
55+
let!(:first_db_file) { create(:active_storage_db_file, ref: 'key1', data: 'first file') }
56+
let!(:second_db_file) { create(:active_storage_db_file, ref: 'key2', data: 'second file') }
57+
let!(:third_db_file) { create(:active_storage_db_file, ref: 'key3', data: 'third file') }
5858

5959
it 'composes the source files' do
6060
expect { compose }.to change { ActiveStorageDB::File.where(ref: 'dest_key').count }.by(1)
6161
expect(compose).to be_a ActiveStorageDB::File
62-
expect(compose.data).to eq [db_file1.data, db_file2.data, db_file3.data].join
62+
expect(compose.data).to eq [first_db_file.data, second_db_file.data, third_db_file.data].join
6363
end
6464
end
6565
end
@@ -70,7 +70,7 @@
7070
before { upload }
7171

7272
it 'deletes the file' do
73-
expect { delete }.to change { ActiveStorageDB::File.count }.from(1).to(0)
73+
expect { delete }.to change(ActiveStorageDB::File, :count).from(1).to(0)
7474
end
7575
end
7676

@@ -80,7 +80,7 @@
8080
before { upload }
8181

8282
it 'deletes the files' do
83-
expect { delete_prefixed }.to change { ActiveStorageDB::File.count }.from(1).to(0)
83+
expect { delete_prefixed }.to change(ActiveStorageDB::File, :count).from(1).to(0)
8484
end
8585
end
8686

spec/tasks/active_storage_db_tasks_spec.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
describe 'asdb:list' do
77
subject(:task) { execute_task('asdb:list') }
88

9-
let(:file1) { create(:active_storage_blob, filename: 'some file 1', created_at: Time.now - 1.hour) }
10-
let(:file2) { create(:active_storage_blob, filename: 'some file 2', created_at: Time.now - 5.hour) }
11-
let(:file3) { create(:active_storage_blob, filename: 'some file 3', created_at: Time.now - 3.hour) }
12-
13-
before do
14-
[file1, file2, file3]
15-
end
9+
let!(:first_file) { create(:active_storage_blob, filename: 'some file 1', created_at: Time.now - 1.hour) }
10+
let!(:second_file) { create(:active_storage_blob, filename: 'some file 2', created_at: Time.now - 5.hour) }
11+
let!(:third_file) { create(:active_storage_blob, filename: 'some file 3', created_at: Time.now - 3.hour) }
1612

1713
it 'prints the columns header + the list of 3 files', :aggregate_failures do
18-
pattern = /#{file3.id} #{file3.filename}.+#{file2.id} #{file2.filename}.+#{file1.id} #{file1.filename}/m
14+
pattern = /#{third_file.id} #{third_file.filename}.+#{second_file.id} #{second_file.filename}.+#{first_file.id} #{first_file.filename}/m
1915
expect(task).to match pattern
2016
expect(task.split("\n").size).to be 4
2117
end

0 commit comments

Comments
 (0)