2017-05-10 11:13:33 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'Create notes on issues', :js do
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
shared_examples 'notes with reference' do
|
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let(:note_text) { "Check #{mention.to_reference}" }
|
|
|
|
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_issue_path(project, issue)
|
2017-05-10 11:13:33 +00:00
|
|
|
|
|
|
|
fill_in 'note[note]', with: note_text
|
|
|
|
click_button 'Comment'
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-05-10 11:13:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a note with reference and cross references the issue' do
|
|
|
|
page.within('div#notes li.note div.note-text') do
|
|
|
|
expect(page).to have_content(note_text)
|
|
|
|
expect(page.find('a')).to have_content(mention.to_reference)
|
|
|
|
end
|
|
|
|
|
|
|
|
find('div#notes li.note div.note-text a').click
|
|
|
|
|
|
|
|
page.within('div#notes li.note .system-note-message') do
|
|
|
|
expect(page).to have_content('mentioned in issue')
|
|
|
|
expect(page.find('a')).to have_content(issue.to_reference)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mentioning issue on a private project' do
|
|
|
|
it_behaves_like 'notes with reference' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :private) }
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:mention) { create(:issue, project: project) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mentioning issue on an internal project' do
|
|
|
|
it_behaves_like 'notes with reference' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :internal) }
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:mention) { create(:issue, project: project) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mentioning issue on a public project' do
|
|
|
|
it_behaves_like 'notes with reference' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:mention) { create(:issue, project: project) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mentioning merge request on a private project' do
|
|
|
|
it_behaves_like 'notes with reference' do
|
2017-07-26 21:49:06 +00:00
|
|
|
let(:project) { create(:project, :private, :repository) }
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:mention) { create(:merge_request, source_project: project) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mentioning merge request on an internal project' do
|
|
|
|
it_behaves_like 'notes with reference' do
|
2017-07-26 21:49:06 +00:00
|
|
|
let(:project) { create(:project, :internal, :repository) }
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:mention) { create(:merge_request, source_project: project) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mentioning merge request on a public project' do
|
|
|
|
it_behaves_like 'notes with reference' do
|
2017-07-26 21:49:06 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-05-10 11:13:33 +00:00
|
|
|
let(:mention) { create(:merge_request, source_project: project) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|