diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-10-09 07:10:46 +0200 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2020-02-20 23:25:39 -0600 |
commit | 95e88ba4347a8c2d2aa3ee8762b32d524e5629a2 (patch) | |
tree | fd889fc67708e384cc661a0295db1f47f8c29a1c /spec/models/concerns/remotable_spec.rb | |
parent | a373fdc1c3b1e6646ffc243f3f5bd926aeda041f (diff) |
port tootsuite/#12125 to monsterfork: Fix attachment not being re-downloaded even if file is not stored
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.
Diffstat (limited to 'spec/models/concerns/remotable_spec.rb')
-rw-r--r-- | spec/models/concerns/remotable_spec.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/models/concerns/remotable_spec.rb b/spec/models/concerns/remotable_spec.rb index a4289cc45..99a60cbf6 100644 --- a/spec/models/concerns/remotable_spec.rb +++ b/spec/models/concerns/remotable_spec.rb @@ -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 |