Fix attachment not being re-downloaded even if file is not stored (#12125)

Change the behaviour of remotable concern. Previously, it would skip
downloading an attachment if the stored remote URL is identical to
the new one. Now it would not be skipped if the attachment is not
actually currently stored by Paperclip.
This commit is contained in:
Eugen Rochko 2019-10-09 07:10:46 +02:00 committed by GitHub
parent 538db85d3c
commit 354fdd317e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 18 deletions

View file

@ -18,6 +18,8 @@ RSpec.describe Remotable do
def hoge=(arg); end
def hoge_file_name; end
def hoge_file_name=(arg); end
def has_attribute?(arg); end
@ -109,12 +111,21 @@ RSpec.describe Remotable do
end
context 'foo[attribute_name] == url' do
it 'makes no request' do
it 'makes no request if file is saved' do
allow(foo).to receive(:[]).with(attribute_name).and_return(url)
allow(foo).to receive(:hoge_file_name).and_return('foo.jpg')
foo.hoge_remote_url = url
expect(request).not_to have_been_requested
end
it 'makes request if file is not saved' do
allow(foo).to receive(:[]).with(attribute_name).and_return(url)
allow(foo).to receive(:hoge_file_name).and_return(nil)
foo.hoge_remote_url = url
expect(request).to have_been_requested
end
end
context "scheme is https, parsed_url.host isn't empty, and foo[attribute_name] != url" do