From 28913d6c0d393804393e8cb85273df08bf7ae4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20K=C3=B6hlbrugge?= Date: Sat, 6 Jun 2020 18:22:57 +0200 Subject: [PATCH] Use proper attributes for "previous" links (#244) --- lib/pagy/extras/support.rb | 2 +- test/pagy/extras/support_test.rb | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/pagy/extras/support.rb b/lib/pagy/extras/support.rb index b5654c2c8..a02391076 100644 --- a/lib/pagy/extras/support.rb +++ b/lib/pagy/extras/support.rb @@ -15,7 +15,7 @@ def pagy_next_url(pagy) end def pagy_prev_link(pagy, text = pagy_t('pagy.nav.prev'), link_extra = '') - pagy.prev ? %() + pagy.prev ? %() : %(#{text}) end diff --git a/test/pagy/extras/support_test.rb b/test/pagy/extras/support_test.rb index ae056d10f..53481be85 100644 --- a/test/pagy/extras/support_test.rb +++ b/test/pagy/extras/support_test.rb @@ -87,22 +87,22 @@ it 'renders the prev link for page 3' do pagy = Pagy.new count: 1000, page: 3 pagy_countless = Pagy::Countless.new(page: 3).finalize(21) - _(view.pagy_prev_link(pagy)).must_equal "‹ Prev" - _(view.pagy_prev_link(pagy_countless)).must_equal "‹ Prev" + _(view.pagy_prev_link(pagy)).must_equal "‹ Prev" + _(view.pagy_prev_link(pagy_countless)).must_equal "‹ Prev" end it 'renders the prev link for page 6' do pagy = Pagy.new count: 1000, page: 6 pagy_countless = Pagy::Countless.new(page: 6).finalize(21) - _(view.pagy_prev_link(pagy)).must_equal "‹ Prev" - _(view.pagy_prev_link(pagy_countless)).must_equal "‹ Prev" + _(view.pagy_prev_link(pagy)).must_equal "‹ Prev" + _(view.pagy_prev_link(pagy_countless)).must_equal "‹ Prev" end it 'renders the prev link for last page' do pagy = Pagy.new count: 1000, page: 50 pagy_countless = Pagy::Countless.new(page: 50).finalize(20) - _(view.pagy_prev_link(pagy)).must_equal "‹ Prev" - _(view.pagy_prev_link(pagy_countless)).must_equal "‹ Prev" + _(view.pagy_prev_link(pagy)).must_equal "‹ Prev" + _(view.pagy_prev_link(pagy_countless)).must_equal "‹ Prev" end end @@ -140,4 +140,3 @@ end end -