2016-10-01 15:18:49 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe 'Project snippets', :js do
|
2016-10-01 15:18:49 +05:30
|
|
|
context 'when the project has snippets' do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :public) }
|
2016-10-01 15:18:49 +05:30
|
|
|
let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:other_snippet) { create(:project_snippet) }
|
|
|
|
|
|
|
|
context 'pagination' do
|
|
|
|
before do
|
|
|
|
allow(Snippet).to receive(:default_per_page).and_return(1)
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_snippets_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'paginated snippets'
|
2016-10-01 15:18:49 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'list content' do
|
|
|
|
it 'contains all project snippets' do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_snippets_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
context 'when submitting a note' do
|
|
|
|
before do
|
|
|
|
sign_in(create(:admin))
|
|
|
|
visit project_snippet_path(project, snippets[0])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have autocomplete' do
|
|
|
|
find('#note_note').native.send_keys('')
|
|
|
|
fill_in 'note[note]', with: '@'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-view')
|
|
|
|
end
|
|
|
|
end
|
2016-10-01 15:18:49 +05:30
|
|
|
end
|
|
|
|
end
|