Fix rspec tests for search pagination.

This commit is contained in:
Jakub Macina 2017-07-26 12:10:19 +02:00
parent 2d45b3fc6d
commit f8edf2636c
2 changed files with 9 additions and 2 deletions

View File

@ -164,7 +164,7 @@ export default Ember.Controller.extend({
@computed('page') @computed('page')
isLastPage(page) { isLastPage(page) {
return page == PAGE_LIMIT; return page === PAGE_LIMIT;
}, },
_search() { _search() {

View File

@ -804,8 +804,12 @@ describe Search do
context 'pagination' do context 'pagination' do
let(:number_of_results) { 2 } 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 before do
5.times { Fabricate(:post) }
Search.stubs(:per_filter).returns(number_of_results) Search.stubs(:per_filter).returns(number_of_results)
end end
@ -814,8 +818,10 @@ describe Search do
results2 = Search.execute('hello', type_filter: 'topic', page: 2) results2 = Search.execute('hello', type_filter: 'topic', page: 2)
expect(results.posts.length).to eq(number_of_results) 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(results.more_full_page_results).to eq(true)
expect(results2.posts.length).to eq(number_of_results) 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) expect(results2.more_full_page_results).to eq(true)
end end
@ -825,6 +831,7 @@ describe Search do
expect(search.offset).to eq(2 * number_of_results) expect(search.offset).to eq(2 * number_of_results)
expect(results.posts.length).to eq(1) expect(results.posts.length).to eq(1)
expect(results.posts).to eq([post5])
expect(results.more_full_page_results).to eq(nil) expect(results.more_full_page_results).to eq(nil)
end end