diff --git a/Gemfile b/Gemfile index 302a0bc7..5343f70c 100644 --- a/Gemfile +++ b/Gemfile @@ -25,13 +25,16 @@ gem "puma", "~> 6.4.0" # Default database gem "sqlite3", "~> 1.7.0" +# Enhanced SQLite3 adapter +gem "activerecord-enhancedsqlite3-adapter", "~> 0.7.0" + # Cache store gem "solid_cache", "~> 0.4.2" # Background job processing gem "solid_queue", "~> 0.2.1" -# Default stack for cache and pub/sub +# Default stack for pub/sub gem "litestack", "~> 0.4.2" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/Gemfile.lock b/Gemfile.lock index 45049def..42cbb1b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,6 +58,9 @@ GEM activemodel (= 7.1.1) activesupport (= 7.1.1) timeout (>= 0.4.0) + activerecord-enhancedsqlite3-adapter (0.7.0) + activerecord (>= 7.1) + sqlite3 (>= 1.6) activestorage (7.1.1) actionpack (= 7.1.1) activejob (= 7.1.1) @@ -336,7 +339,7 @@ GEM railties (>= 7) solid_queue (0.2.1) rails (~> 7.1) - sqlite3 (1.7.0) + sqlite3 (1.7.3) mini_portile2 (~> 2.8.0) sshkit (1.22.1) base64 @@ -389,6 +392,7 @@ PLATFORMS ruby DEPENDENCIES + activerecord-enhancedsqlite3-adapter (~> 0.7.0) acts_as_list (~> 1.1.0) bcrypt (~> 3.1.11) bootsnap (~> 1.17.0) diff --git a/app/models/concerns/imageable_concern.rb b/app/models/concerns/imageable_concern.rb index 485cbfca..7a62474d 100644 --- a/app/models/concerns/imageable_concern.rb +++ b/app/models/concerns/imageable_concern.rb @@ -6,13 +6,11 @@ module ImageableConcern included do has_one_attached :cover_image do |attachable| attachable.variant :small, resize_to_fill: [200, 200] - attachable.variant :medium, resize_to_fill: [400, 400] + attachable.variant :medium, resize_to_fill: [400, 400], preprocessed: true attachable.variant :large, resize_to_fill: [600, 600] end validate :content_type_of_cover_image - - after_commit :transform_cover_image, if: :has_cover_image? end def has_cover_image? @@ -28,8 +26,4 @@ def content_type_of_cover_image errors.add(:cover_image, :invalid_content_type) end end - - def transform_cover_image - cover_image.variant(:medium).processed - end end diff --git a/config/application.rb b/config/application.rb index e54b09bb..d34dae98 100644 --- a/config/application.rb +++ b/config/application.rb @@ -37,7 +37,6 @@ class Application < Rails::Application config.exceptions_app = routes config.active_storage.resolve_model_to_route = :rails_storage_proxy - config.active_storage.analyzers.delete ActiveStorage::Analyzer::ImageAnalyzer::Vips config.solid_queue.silence_polling = true config.solid_queue.preserve_finished_jobs = false diff --git a/test/models/album_test.rb b/test/models/album_test.rb index ecafcec1..9295758e 100644 --- a/test/models/album_test.rb +++ b/test/models/album_test.rb @@ -83,15 +83,4 @@ class AlbumTest < ActiveSupport::TestCase test "should use default sort when use invalid sort value" do assert_equal %w[album1 album2 album3 album4], Album.sort_records(:invalid).pluck(:name) end - - test "should transform cover image after attached" do - album = albums(:album1) - album.cover_image.attach( - io: StringIO.new(file_fixture("cover_image.jpg").read), - filename: "cover.jpg", - content_type: "image/jpeg" - ) - - assert album.cover_image.variant(:medium).send(:processed?) - end end diff --git a/test/models/artist_test.rb b/test/models/artist_test.rb index 5a1e1ce9..81ff05dd 100644 --- a/test/models/artist_test.rb +++ b/test/models/artist_test.rb @@ -48,15 +48,4 @@ class ArtistTest < ActiveSupport::TestCase test "should use default sort when use invalid sort value" do assert_equal %w[artist1 artist2 various_artists], Artist.sort_records(:invalid).pluck(:name).compact end - - test "should transform cover image after attached" do - artist = artists(:artist1) - artist.cover_image.attach( - io: StringIO.new(file_fixture("cover_image.jpg").read), - filename: "cover.jpg", - content_type: "image/jpeg" - ) - - assert artist.cover_image.variant(:medium).send(:processed?) - end end