Przeglądaj źródła

Don't send Link header when don't know prev and next links (#4633)

master
Yamagishi Kazutoshi 6 lat temu
committed by Eugen Rochko
rodzic
commit
2edfdab6e6
2 zmienionych plików z 2 dodań i 3 usunięć
  1. +1
    -1
      app/controllers/api/base_controller.rb
  2. +1
    -2
      spec/controllers/api/v1/favourites_controller_spec.rb

+ 1
- 1
app/controllers/api/base_controller.rb Wyświetl plik

@@ -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)


+ 1
- 2
spec/controllers/api/v1/favourites_controller_spec.rb Wyświetl plik

@@ -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


Ładowanie…
Anuluj
Zapisz