2016-04-08 20:35:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Member autocomplete', feature: true do
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:participant) { create(:user) }
|
|
|
|
let(:author) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2016-04-13 14:50:17 -04:00
|
|
|
allow_any_instance_of(Commit).to receive(:author).and_return(author)
|
2016-04-08 20:35:43 -04:00
|
|
|
login_as user
|
|
|
|
end
|
|
|
|
|
2016-04-09 02:34:07 -04:00
|
|
|
shared_examples "open suggestions" do
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'displays suggestions' do
|
2016-04-09 02:34:07 -04:00
|
|
|
expect(page).to have_selector('.atwho-view', visible: true)
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'suggests author' do
|
2016-04-09 02:34:07 -04:00
|
|
|
page.within('.atwho-view', visible: true) do
|
|
|
|
expect(page).to have_content(author.username)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'suggests participant' do
|
2016-04-09 02:34:07 -04:00
|
|
|
page.within('.atwho-view', visible: true) do
|
|
|
|
expect(page).to have_content(participant.username)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-11 15:02:00 -04:00
|
|
|
context 'adding a new note on a Issue', js: true do
|
2016-04-08 20:35:43 -04:00
|
|
|
before do
|
2016-04-09 02:34:07 -04:00
|
|
|
issue = create(:issue, author: author, project: project)
|
2016-04-26 07:52:18 -04:00
|
|
|
create(:note, note: 'Ultralight Beam', noteable: issue,
|
|
|
|
project: project, author: participant)
|
2016-04-08 20:35:43 -04:00
|
|
|
visit_issue(project, issue)
|
|
|
|
end
|
|
|
|
|
2016-04-09 02:34:07 -04:00
|
|
|
context 'when typing @' do
|
|
|
|
include_examples "open suggestions"
|
|
|
|
before do
|
|
|
|
open_member_suggestions
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-11 15:02:00 -04:00
|
|
|
context 'adding a new note on a Merge Request ', js: true do
|
2016-04-09 02:34:07 -04:00
|
|
|
before do
|
|
|
|
merge = create(:merge_request, source_project: project, target_project: project, author: author)
|
2016-04-26 07:52:18 -04:00
|
|
|
create(:note, note: 'Ultralight Beam', noteable: merge,
|
|
|
|
project: project, author: participant)
|
2016-04-09 02:34:07 -04:00
|
|
|
visit_merge_request(project, merge)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when typing @' do
|
|
|
|
include_examples "open suggestions"
|
|
|
|
before do
|
|
|
|
open_member_suggestions
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-13 14:50:17 -04:00
|
|
|
context 'adding a new note on a Commit ', js: true do
|
|
|
|
let(:commit) { project.commit }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(commit).to receive(:author).and_return(author)
|
|
|
|
create(:note_on_commit, author: participant, project: project, commit_id: project.repository.commit.id, note: 'No More Parties in LA')
|
|
|
|
visit_commit(project, commit)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when typing @' do
|
|
|
|
include_examples "open suggestions"
|
|
|
|
before do
|
|
|
|
open_member_suggestions
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-09 02:34:07 -04:00
|
|
|
def open_member_suggestions
|
|
|
|
sleep 1
|
|
|
|
page.within('.new-note') do
|
|
|
|
sleep 1
|
|
|
|
find('#note_note').native.send_keys('@')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-08 20:35:43 -04:00
|
|
|
def visit_issue(project, issue)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
2016-04-09 02:34:07 -04:00
|
|
|
|
|
|
|
def visit_merge_request(project, merge)
|
|
|
|
visit namespace_project_merge_request_path(project.namespace, project, merge)
|
|
|
|
end
|
2016-04-13 14:50:17 -04:00
|
|
|
|
|
|
|
def visit_commit(project, commit)
|
|
|
|
visit namespace_project_commit_path(project.namespace, project, commit)
|
|
|
|
end
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|