about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorKazushige Tominaga <kazu9su@gmail.com>2018-02-08 08:17:53 +0900
committerYamagishi Kazutoshi <ykzts@desire.sh>2018-02-08 08:17:53 +0900
commit2bb393684baf5da1112923db7bcda920d606be78 (patch)
tree5efed0bcc3f9b6342be6c83b03848dce49b3b001 /spec/services
parent67f7ffa79270e3591478a95a1a083bfffa1fd218 (diff)
Added #link_header spec (#6439)
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/fetch_atom_service_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/services/fetch_atom_service_spec.rb b/spec/services/fetch_atom_service_spec.rb
index 5491fd027..fcba55e8d 100644
--- a/spec/services/fetch_atom_service_spec.rb
+++ b/spec/services/fetch_atom_service_spec.rb
@@ -1,4 +1,24 @@
 require 'rails_helper'
 
 RSpec.describe FetchAtomService do
+  describe '#link_header' do
+    context 'Link is Array' do
+      target = FetchAtomService.new
+      target.instance_variable_set('@response', 'Link' => [
+        '<http://example.com/>; rel="up"; meta="bar"',
+        '<http://example.com/foo>; rel="self"',
+      ])
+
+      it 'set first link as link_header' do
+        expect(target.send(:link_header).links[0].href).to eq 'http://example.com/'
+      end
+    end
+
+    context 'Link is not Array' do
+      target = FetchAtomService.new
+      target.instance_variable_set('@response', 'Link' => '<http://example.com/foo>; rel="self", <http://example.com/>; rel = "up"')
+
+      it { expect(target.send(:link_header).links[0].href).to eq 'http://example.com/foo' }
+    end
+  end
 end