]> cat aescling's git repositories - mastodon.git/commitdiff
Don't send Link header when don't know prev and next links (#4633)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Fri, 18 Aug 2017 08:42:59 +0000 (17:42 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Aug 2017 08:42:59 +0000 (10:42 +0200)
app/controllers/api/base_controller.rb
spec/controllers/api/v1/favourites_controller_spec.rb

index 6ede63c79096e85b8cf382a64797bbdc51e207b6..7cfe8fe71cbff44f1185d52085a076e5e4bd6c1a 100644 (file)
@@ -43,7 +43,7 @@ class Api::BaseController < ApplicationController
     links = []
     links << [next_path, [%w(rel next)]] if next_path
     links << [prev_path, [%w(rel prev)]] if prev_path
-    response.headers['Link'] = LinkHeader.new(links)
+    response.headers['Link'] = LinkHeader.new(links) unless links.empty?
   end
 
   def limit_param(default_limit)
index 3de045377fa24abdba81d50181795b6fa7c99785..46cf70f4d273557acb63df512e486e5f6c8ed2eb 100644 (file)
@@ -70,8 +70,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
         it 'does not add pagination headers if not necessary' do
           get :index
 
-          expect(response.headers['Link'].find_link(['rel', 'next'])).to eq nil
-          expect(response.headers['Link'].find_link(['rel', 'prev'])).to eq nil
+          expect(response.headers['Link']).to eq nil
         end
       end
     end