about summary refs log tree commit diff
path: root/spec/models/concerns/remotable_spec.rb
diff options
context:
space:
mode:
authorReverite <github@reverite.sh>2019-10-11 14:55:34 -0700
committerReverite <github@reverite.sh>2019-10-11 14:55:34 -0700
commitb63bcefbdf19eece58ae430bce14031d147ab796 (patch)
tree9ce7c29898ddf3f4c4af20890492409793d2fb0f /spec/models/concerns/remotable_spec.rb
parent38afc782051fe6faf06c2c9ca20304dd946cfb5c (diff)
parentfbe1de114fca16d63ff651425f69eb534ba013e9 (diff)
Merge branch 'glitch' into production
Diffstat (limited to 'spec/models/concerns/remotable_spec.rb')
-rw-r--r--spec/models/concerns/remotable_spec.rb13
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