Skip to content

Commit 952c5a0

Browse files
author
Mattia Roccoberton
authored
Merge pull request #20 from blocknotes/fix-rubocop-issues
Fix some RuboCop issues
2 parents 73d730e + 21a9b62 commit 952c5a0

6 files changed

Lines changed: 23 additions & 66 deletions

File tree

.rubocop.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
inherit_from:
2-
- .rubocop_todo.yml
32
- https://relaxed.ruby.style/rubocop.yml
43

54
require:
@@ -16,9 +15,17 @@ AllCops:
1615
- vendor/**/*
1716
TargetRubyVersion: 2.6
1817

18+
Lint/MissingSuper:
19+
Exclude:
20+
- 'lib/active_storage/service/db_service.rb'
21+
1922
Lint/UnusedMethodArgument:
2023
AllowUnusedKeywordArguments: true
2124

25+
RSpec/DescribeClass:
26+
Exclude:
27+
- spec/tasks/active_storage_db_tasks_spec.rb
28+
2229
RSpec/ExampleLength:
2330
# Default is 5
2431
Max: 10
@@ -34,3 +41,7 @@ RSpec/MultipleMemoizedHelpers:
3441
RSpec/NestedGroups:
3542
# Default is 3
3643
Max: 5
44+
45+
Style/ClassAndModuleChildren:
46+
Exclude:
47+
- 'lib/active_storage/service/db_service.rb'

.rubocop_todo.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

lib/active_storage/service/db_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

33
module ActiveStorage
4-
class Service::DBService < Service # rubocop:disable Style/ClassAndModuleChildren
5-
def initialize(**_config)
4+
class Service::DBService < Service
5+
def initialize(**_options)
66
@chunk_size = ENV.fetch('ASDB_CHUNK_SIZE') { 1.megabytes }
77
end
88

spec/factories/active_storage_db_file_factory.rb

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

33
FactoryBot.define do
44
factory :active_storage_db_file, class: 'ActiveStorageDB::File' do
5-
ref { ('a'..'z').to_a.shuffle[0, 32].join } # rubocop:disable Style/Sample
5+
ref { ('a'..'z').to_a.sample(32).join }
66

77
data do
88
(+"\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000\020\000\000\000\020\001\003\000\000\000%=m\"\000\000\000\006PLTE\000\000\000\377\377\377\245\331\237\335\000\000\0003IDATx\234c\370\377\237\341\377_\206\377\237\031\016\2603\334?\314p\1772\303\315\315\f7\215\031\356\024\203\320\275\317\f\367\201R\314\f\017\300\350\377\177\000Q\206\027(\316]\233P\000\000\000\000IEND\256B`\202").force_encoding(Encoding::BINARY)

spec/requests/file_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def create_blob(data: 'Hello world!', filename: 'hello.txt', content_type: 'text
1111
)
1212
end
1313

14-
def create_blob_before_direct_upload(filename: 'hello.txt', byte_size:, checksum:, content_type: 'text/plain')
14+
def create_blob_before_direct_upload(byte_size:, checksum:, filename: 'hello.txt', content_type: 'text/plain')
1515
ActiveStorage::Blob.create_before_direct_upload!(
1616
filename: filename,
1717
byte_size: byte_size,

spec/tasks/active_storage_db_tasks_spec.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe 'ActiveStorageDB tasks' do # rubocop:disable RSpec/DescribeClass
3+
RSpec.describe 'ActiveStorageDB tasks' do
44
include_context 'with rake tasks'
55

66
describe 'asdb:list' do
@@ -22,9 +22,7 @@
2222
end
2323

2424
describe 'asdb:get' do
25-
subject(:task) { execute_task('asdb:get', options) }
26-
27-
let(:options) {}
25+
subject(:task) { execute_task('asdb:get') }
2826

2927
it 'exits showing the required arguments' do
3028
with_captured_stderr do
@@ -33,7 +31,7 @@
3331
end
3432

3533
context 'with only the source specified' do
36-
let(:options) { { src: 'some_file' } }
34+
subject(:task) { execute_task('asdb:get', src: 'some_file') }
3735

3836
it 'exits showing the required arguments' do
3937
with_captured_stderr do
@@ -43,7 +41,7 @@
4341
end
4442

4543
context 'with an invalid destination' do
46-
let(:options) { { src: 'some_file', dst: 'some_path' } }
44+
subject(:task) { execute_task('asdb:get', src: 'some_file', dst: 'some_path') }
4745

4846
before do
4947
allow(File).to receive(:writable?).and_return(false)
@@ -57,7 +55,7 @@
5755
end
5856

5957
context 'with a missing source' do
60-
let(:options) { { src: 'some_file', dst: 'some_path' } }
58+
subject(:task) { execute_task('asdb:get', src: 'some_file', dst: 'some_path') }
6159

6260
before do
6361
allow(File).to receive(:writable?).and_return(true)
@@ -71,9 +69,10 @@
7169
end
7270

7371
context 'with valid arguments' do
72+
subject(:task) { execute_task('asdb:get', src: blob.filename.to_s, dst: 'some_path') }
73+
7474
let(:blob) { build_stubbed(:active_storage_blob) }
7575
let(:blobs) { instance_double(ActiveRecord::Relation) }
76-
let(:options) { { src: blob.filename.to_s, dst: 'some_path' } }
7776

7877
before do
7978
allow(File).to receive_messages(binwrite: 1000, writable?: true)

0 commit comments

Comments
 (0)