summaryrefslogtreecommitdiff
path: root/spec/features/users/snippets_spec.rb
blob: 356a8d668b03a19b0b42b279a33a598d7e138934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'

describe 'Snippets tab on a user profile', feature: true, js: true do
  include WaitForAjax

  let(:user) { create(:user) }

  context 'when the user has snippets' do
    before do
      create_list(:snippet, 25, :public, author: user)

      visit user_path(user)
      page.within('.user-profile-nav') { click_link 'Snippets' }
      wait_for_ajax
    end

    it 'is limited to 20 items per page' do
      expect(page.all('.snippets-list-holder .snippet-row').count).to eq(20)
    end

    context 'clicking on the link to the second page' do
      before { click_link('2') }

      it 'shows the remaining snippets' do
        expect(page.all('.snippets-list-holder .snippet-row').count).to eq(5)
      end
    end
  end
end