diff --git a/app/models/alchemy/attachment/url.rb b/app/models/alchemy/attachment/url.rb index 9a23e808b5..1a45204e5b 100644 --- a/app/models/alchemy/attachment/url.rb +++ b/app/models/alchemy/attachment/url.rb @@ -23,6 +23,7 @@ def initialize(attachment) # @return [String] # def call(options = {}) + options[:format] ||= @attachment.suffix if options.delete(:download) routes.download_attachment_path(@attachment, options) else diff --git a/spec/models/alchemy/attachment_spec.rb b/spec/models/alchemy/attachment_spec.rb index 8ae673a7ba..f8df895354 100644 --- a/spec/models/alchemy/attachment_spec.rb +++ b/spec/models/alchemy/attachment_spec.rb @@ -63,14 +63,14 @@ module Alchemy let(:attachment) { create(:alchemy_attachment) } it "returns local path" do - is_expected.to eq "/attachment/#{attachment.id}/show" + is_expected.to eq "/attachment/#{attachment.id}/show.png" end context "with download enabled" do subject { attachment.url(download: true) } it "returns local download path" do - is_expected.to eq "/attachment/#{attachment.id}/download" + is_expected.to eq "/attachment/#{attachment.id}/download.png" end context "with extra params given" do @@ -88,7 +88,7 @@ module Alchemy subject { attachment.url(download: false) } it "returns local path" do - is_expected.to eq "/attachment/#{attachment.id}/show" + is_expected.to eq "/attachment/#{attachment.id}/show.png" end context "with extra params given" do