Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
inherit_from:
- .rubocop_todo.yml
- https://relaxed.ruby.style/rubocop.yml

require:
Expand All @@ -16,9 +15,17 @@ AllCops:
- vendor/**/*
TargetRubyVersion: 2.6

Lint/MissingSuper:
Exclude:
- 'lib/active_storage/service/db_service.rb'

Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: true

RSpec/DescribeClass:
Exclude:
- spec/tasks/active_storage_db_tasks_spec.rb

RSpec/ExampleLength:
# Default is 5
Max: 10
Expand All @@ -34,3 +41,7 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NestedGroups:
# Default is 3
Max: 5

Style/ClassAndModuleChildren:
Exclude:
- 'lib/active_storage/service/db_service.rb'
53 changes: 0 additions & 53 deletions .rubocop_todo.yml

This file was deleted.

4 changes: 2 additions & 2 deletions lib/active_storage/service/db_service.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

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

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/active_storage_db_file_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

data do
(+"\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)
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/file_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create_blob(data: 'Hello world!', filename: 'hello.txt', content_type: 'text
)
end

def create_blob_before_direct_upload(filename: 'hello.txt', byte_size:, checksum:, content_type: 'text/plain')
def create_blob_before_direct_upload(byte_size:, checksum:, filename: 'hello.txt', content_type: 'text/plain')
ActiveStorage::Blob.create_before_direct_upload!(
filename: filename,
byte_size: byte_size,
Expand Down
15 changes: 7 additions & 8 deletions spec/tasks/active_storage_db_tasks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe 'ActiveStorageDB tasks' do # rubocop:disable RSpec/DescribeClass
RSpec.describe 'ActiveStorageDB tasks' do
include_context 'with rake tasks'

describe 'asdb:list' do
Expand All @@ -22,9 +22,7 @@
end

describe 'asdb:get' do
subject(:task) { execute_task('asdb:get', options) }

let(:options) {}
subject(:task) { execute_task('asdb:get') }

it 'exits showing the required arguments' do
with_captured_stderr do
Expand All @@ -33,7 +31,7 @@
end

context 'with only the source specified' do
let(:options) { { src: 'some_file' } }
subject(:task) { execute_task('asdb:get', src: 'some_file') }

it 'exits showing the required arguments' do
with_captured_stderr do
Expand All @@ -43,7 +41,7 @@
end

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

before do
allow(File).to receive(:writable?).and_return(false)
Expand All @@ -57,7 +55,7 @@
end

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

before do
allow(File).to receive(:writable?).and_return(true)
Expand All @@ -71,9 +69,10 @@
end

context 'with valid arguments' do
subject(:task) { execute_task('asdb:get', src: blob.filename.to_s, dst: 'some_path') }

let(:blob) { build_stubbed(:active_storage_blob) }
let(:blobs) { instance_double(ActiveRecord::Relation) }
let(:options) { { src: blob.filename.to_s, dst: 'some_path' } }

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