debian-mirror-gitlab/spec/features/issues/notes_on_issues_spec.rb

95 lines
2.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe 'Create notes on issues', :js do
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
2018-12-05 23:21:45 +05:30
def submit_comment(text)
fill_in 'note[note]', with: text
click_button 'Comment'
wait_for_requests
end
2017-08-17 22:00:37 +05:30
shared_examples 'notes with reference' do
let(:issue) { create(:issue, project: project) }
let(:note_text) { "Check #{mention.to_reference}" }
before do
2018-03-17 18:26:18 +05:30
project.add_developer(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
visit project_issue_path(project, issue)
2017-08-17 22:00:37 +05:30
2018-12-05 23:21:45 +05:30
submit_comment(note_text)
2017-08-17 22:00:37 +05:30
end
2019-12-26 22:10:19 +05:30
it 'creates a note with reference and cross references the issue', :sidekiq_might_not_need_inline do
2017-08-17 22:00:37 +05:30
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
let(:project) { create(:project, :private) }
let(:mention) { create(:issue, project: project) }
end
end
context 'mentioning issue on an internal project' do
it_behaves_like 'notes with reference' do
let(:project) { create(:project, :internal) }
let(:mention) { create(:issue, project: project) }
end
end
context 'mentioning issue on a public project' do
it_behaves_like 'notes with reference' do
let(:project) { create(:project, :public) }
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-09-10 17:25:29 +05:30
let(:project) { create(:project, :private, :repository) }
2017-08-17 22:00:37 +05:30
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-09-10 17:25:29 +05:30
let(:project) { create(:project, :internal, :repository) }
2017-08-17 22:00:37 +05:30
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-09-10 17:25:29 +05:30
let(:project) { create(:project, :public, :repository) }
2017-08-17 22:00:37 +05:30
let(:mention) { create(:merge_request, source_project: project) }
end
end
2018-12-05 23:21:45 +05:30
it 'highlights the current user in a comment' do
project = create(:project)
issue = create(:issue, project: project)
project.add_developer(user)
sign_in(user)
visit project_issue_path(project, issue)
submit_comment("@#{user.username} note to self")
expect(page).to have_selector '.gfm-project_member.current-user', text: user.username
end
2017-08-17 22:00:37 +05:30
end