Skip to content

Commit

Permalink
Merge pull request #2383 from mamhoff/document-links-with-format
Browse files Browse the repository at this point in the history
Always provide format with attachment URLs
  • Loading branch information
tvdeyen authored Nov 18, 2022
2 parents f99cef5 + ea99ab0 commit ea1f617
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/models/alchemy/attachment/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/models/alchemy/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ea1f617

Please sign in to comment.