BigW Consortium Gitlab

snippets_spec.rb 1.29 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Project snippets', :js, feature: true do
4 5 6
  context 'when the project has snippets' do
    let(:project) { create(:empty_project, :public) }
    let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
7 8 9 10 11 12 13 14 15 16
    let!(:other_snippet) { create(:project_snippet) }

    context 'pagination' do
      before do
        allow(Snippet).to receive(:default_per_page).and_return(1)

        visit namespace_project_snippets_path(project.namespace, project)
      end

      it_behaves_like 'paginated snippets'
17 18
    end

19 20 21 22 23 24 25 26 27 28
    context 'list content' do
      it 'contains all project snippets' do
        visit namespace_project_snippets_path(project.namespace, project)

        expect(page).to have_selector('.snippet-row', count: 2)

        expect(page).to have_content(snippets[0].title)
        expect(page).to have_content(snippets[1].title)
      end
    end
29 30 31

    context 'when submitting a note' do
      before do
32
        gitlab_sign_in :admin
33 34 35
        visit namespace_project_snippet_path(project.namespace, project, snippets[0])
      end

36
      it 'should have autocomplete' do
37 38 39
        find('#note_note').native.send_keys('')
        fill_in 'note[note]', with: '@'

40
        expect(page).to have_selector('.atwho-view')
41 42
      end
    end
43 44
  end
end