diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-23 20:28:14 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-26 13:42:12 +0300 |
commit | f99d8786b74cbd8d37308217b914bceaccbdc71d (patch) | |
tree | f35de5a0f70ba1c8d71b7e2d897ae79abfc5e46e /spec/support | |
parent | fca610e5cbf5382f3814120227a0ca11440c8a9f (diff) |
Fix snippets pagination
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/snippets_shared_examples.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/support/snippets_shared_examples.rb b/spec/support/snippets_shared_examples.rb new file mode 100644 index 00000000000..57dfff3471f --- /dev/null +++ b/spec/support/snippets_shared_examples.rb @@ -0,0 +1,18 @@ +# These shared examples expect a `snippets` array of snippets +RSpec.shared_examples 'paginated snippets' do |remote: false| + it "is limited to #{Snippet.default_per_page} items per page" do + expect(page.all('.snippets-list-holder .snippet-row').count).to eq(Snippet.default_per_page) + end + + context 'clicking on the link to the second page' do + before do + click_link('2') + wait_for_ajax if remote + end + + it 'shows the remaining snippets' do + remaining_snippets_count = [snippets.size - Snippet.default_per_page, Snippet.default_per_page].min + expect(page).to have_selector('.snippets-list-holder .snippet-row', count: remaining_snippets_count) + end + end +end |