Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Fixed

- Fix `calc_hashsums` info option name.
- Fix enabling `use_s3_urls` or `use_gcs_urls` without using S3 or GCS service

## [3.0.0] - 2023-12-28

Expand Down
4 changes: 4 additions & 0 deletions lib/imgproxy/url_adapters/active_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def s3_url(image)
end

def use_s3_url(image)
return unless defined?(::ActiveStorage::Service::S3Service)

config.use_s3_urls && service(image).is_a?(::ActiveStorage::Service::S3Service)
end

Expand All @@ -38,6 +40,8 @@ def gcs_url(image)
end

def use_gcs_url(image)
return unless defined?(::ActiveStorage::Service::GCSService)

config.use_gcs_urls && service(image).is_a?(::ActiveStorage::Service::GCSService)
end

Expand Down
18 changes: 18 additions & 0 deletions spec/url_adapters/active_storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@
end
end

context 'with non-S3 service' do
let(:active_storage_service_name) { :local }

it 'builds http URL' do
expect(Imgproxy.url_for(user.avatar)).to end_with \
"/plain/#{Rails.application.routes.url_helpers.url_for(user.avatar)}"
end
end

describe "extension" do
it "builds URL with ActiveStorage extension" do
expect(user.avatar.imgproxy_url(width: 200)).to eq(
Expand Down Expand Up @@ -134,6 +143,15 @@
end
end

context 'with non-GCS service' do
let(:active_storage_service_name) { :local }

it 'builds http URL' do
expect(Imgproxy.url_for(user.avatar)).to end_with \
"/plain/#{Rails.application.routes.url_helpers.url_for(user.avatar)}"
end
end

describe "extension" do
it "build URL with ActiveStorage extension" do
expect(user.avatar.imgproxy_url(width: 200)).to eq(
Expand Down