Merge pull request #6394 from opf/fix/external_attachment_location

fix wrong method name for external attachments
pull/6393/head
ulferts 6 years ago committed by GitHub
commit 7586622e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      lib/api/v3/attachments/attachment_representer.rb
  2. 8
      spec/lib/api/v3/attachments/attachment_representer_spec.rb
  3. 6
      spec/requests/api/v3/attachments/attachment_resource_spec.rb

@ -72,7 +72,7 @@ module API
link :downloadLocation do
location = if represented.external_storage?
represented.remote_url
represented.external_url
else
api_v3_paths.attachment_content(represented.id)
end

@ -127,20 +127,20 @@ describe ::API::V3::Attachments::AttachmentRepresenter do
end
context 'for a remote attachment' do
let(:remote_url) { 'https://some.bogus/download/xyz' }
let(:external_url) { 'https://some.bogus/download/xyz' }
before do
allow(attachment)
.to receive(:external_storage?)
.and_return(true)
allow(attachment)
.to receive(:remote_url)
.and_return(remote_url)
.to receive(:external_url)
.and_return(external_url)
end
it_behaves_like 'has an untitled link' do
let(:link) { 'downloadLocation' }
let(:href) { remote_url }
let(:href) { external_url }
end
end
end

@ -289,21 +289,21 @@ describe 'API v3 Attachment resource', type: :request, content_type: :json do
end
context 'for a remote file' do
let(:remote_url) { 'http://some_service.org/blubs.gif' }
let(:external_url) { 'http://some_service.org/blubs.gif' }
let(:mock_file) { FileHelpers.mock_uploaded_file name: 'foobar.txt' }
let(:attachment) do
FactoryBot.create(:attachment, container: container, file: mock_file) do |a|
# need to mock here to avoid dependency on external service
allow_any_instance_of(Attachment)
.to receive(:external_url)
.and_return(remote_url)
.and_return(external_url)
end
end
it 'responds with 302 Redirect' do
expect(subject.status).to eq 302
expect(subject.headers['Location'])
.to eql remote_url
.to eql external_url
end
end
end

Loading…
Cancel
Save