2016-09-23 13:28:14 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe 'Project snippets', :js do
|
2016-09-23 13:28:14 -04:00
|
|
|
context 'when the project has snippets' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-09-23 13:28:14 -04:00
|
|
|
let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
|
2017-04-28 18:06:27 -04:00
|
|
|
let!(:other_snippet) { create(:project_snippet) }
|
|
|
|
|
|
|
|
context 'pagination' do
|
|
|
|
before do
|
|
|
|
allow(Snippet).to receive(:default_per_page).and_return(1)
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_snippets_path(project)
|
2017-04-28 18:06:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'paginated snippets'
|
2016-09-23 13:28:14 -04:00
|
|
|
end
|
|
|
|
|
2017-04-28 18:06:27 -04:00
|
|
|
context 'list content' do
|
|
|
|
it 'contains all project snippets' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_snippets_path(project)
|
2017-04-28 18:06:27 -04:00
|
|
|
|
|
|
|
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-06-12 15:42:12 -04:00
|
|
|
|
|
|
|
context 'when submitting a note' do
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_snippet_path(project, snippets[0])
|
2017-06-12 15:42:12 -04:00
|
|
|
end
|
|
|
|
|
2017-06-19 17:29:58 -04:00
|
|
|
it 'should have autocomplete' do
|
2017-06-12 15:42:12 -04:00
|
|
|
find('#note_note').native.send_keys('')
|
|
|
|
fill_in 'note[note]', with: '@'
|
|
|
|
|
2017-06-19 17:29:58 -04:00
|
|
|
expect(page).to have_selector('.atwho-view')
|
2017-06-12 15:42:12 -04:00
|
|
|
end
|
|
|
|
end
|
2016-09-23 13:28:14 -04:00
|
|
|
end
|
|
|
|
end
|