[24539] Respect project_id identifier in search links

pull/5143/head
Oliver Günther 8 years ago
parent deae8e64ca
commit 1c20fbc99d
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 2
      app/helpers/search_helper.rb
  2. 30
      spec/features/search_spec.rb

@ -126,6 +126,7 @@ module SearchHelper
def link_to_previous_search_page(pagination_previous_date)
link_to_content_update(l(:label_previous),
@search_params.merge(previous: 1,
project_id: @project.try(:identifier),
offset: pagination_previous_date.to_r.to_s),
class: 'navigate-left')
end
@ -133,6 +134,7 @@ module SearchHelper
def link_to_next_search_page(pagination_next_date)
link_to_content_update(l(:label_next),
@search_params.merge(previous: nil,
project_id: @project.try(:identifier),
offset: pagination_next_date.to_r.to_s),
class: 'navigate-right')
end

@ -31,6 +31,7 @@ require 'spec_helper'
describe 'Search', type: :feature do
describe 'pagination' do
let(:project) { FactoryGirl.create :project }
let(:user) { FactoryGirl.create :admin }
let!(:work_packages) do
(1..23).map do |n|
@ -41,14 +42,34 @@ describe 'Search', type: :feature do
let(:query) { "Subject" }
def expect_range(a, b)
(a..b).each { |n| expect(page.body).to include ("No. #{n}") }
end
context 'project search' do
before do
login_as FactoryGirl.create(:admin)
login_as user
visit "/search?q=#{query}"
visit search_path(project, q: query)
end
it "works" do
expect_range 14, 23
def expect_range(a, b)
(a..b).each { |n| expect(page.body).to include ("No. #{n}") }
click_on "Next", match: :first
expect_range 4, 13
expect(current_path).to match "/projects/#{project.identifier}/search"
click_on "Previous", match: :first
expect_range 14, 23
expect(current_path).to match "/projects/#{project.identifier}/search"
end
end
context 'global search' do
before do
login_as user
visit "/search?q=#{query}"
end
it "works" do
@ -61,4 +82,5 @@ describe 'Search', type: :feature do
expect_range 14, 23
end
end
end
end
Loading…
Cancel
Save