From f8edf2636cb18324a7f9972ff1a821e598f9b6fb Mon Sep 17 00:00:00 2001 From: Jakub Macina Date: Wed, 26 Jul 2017 12:10:19 +0200 Subject: [PATCH] Fix rspec tests for search pagination. --- .../discourse/controllers/full-page-search.js.es6 | 2 +- spec/components/search_spec.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index 3d77fcbc2dd..d153a234570 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -164,7 +164,7 @@ export default Ember.Controller.extend({ @computed('page') isLastPage(page) { - return page == PAGE_LIMIT; + return page === PAGE_LIMIT; }, _search() { diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb index 395255274e8..7ad0e7f0dfe 100644 --- a/spec/components/search_spec.rb +++ b/spec/components/search_spec.rb @@ -804,8 +804,12 @@ describe Search do context 'pagination' do let(:number_of_results) { 2 } + let!(:post1) { Fabricate(:post, raw: 'hello hello hello hello hello')} + let!(:post2) { Fabricate(:post, raw: 'hello hello hello hello')} + let!(:post3) { Fabricate(:post, raw: 'hello hello hello')} + let!(:post4) { Fabricate(:post, raw: 'hello hello')} + let!(:post5) { Fabricate(:post, raw: 'hello')} before do - 5.times { Fabricate(:post) } Search.stubs(:per_filter).returns(number_of_results) end @@ -814,8 +818,10 @@ describe Search do results2 = Search.execute('hello', type_filter: 'topic', page: 2) expect(results.posts.length).to eq(number_of_results) + expect(results.posts.map(&:id)).to eq([post1.id, post2.id]) expect(results.more_full_page_results).to eq(true) expect(results2.posts.length).to eq(number_of_results) + expect(results2.posts.map(&:id)).to eq([post3.id, post4.id]) expect(results2.more_full_page_results).to eq(true) end @@ -825,6 +831,7 @@ describe Search do expect(search.offset).to eq(2 * number_of_results) expect(results.posts.length).to eq(1) + expect(results.posts).to eq([post5]) expect(results.more_full_page_results).to eq(nil) end