2016-04-08 20:35:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
feature 'Member autocomplete', :js do
|
2016-04-08 20:35:43 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:author) { create(:user) }
|
2017-03-22 14:04:29 -04:00
|
|
|
let(:note) { create(:note, noteable: noteable, project: noteable.project) }
|
2016-04-08 20:35:43 -04:00
|
|
|
|
|
|
|
before do
|
2017-03-22 14:04:29 -04:00
|
|
|
note # actually create the note
|
|
|
|
login_as(user)
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
shared_examples "open suggestions when typing @" do
|
|
|
|
before do
|
|
|
|
page.within('.new-note') do
|
|
|
|
find('#note_note').send_keys('@')
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
it 'suggests noteable author and note author' do
|
2016-04-09 02:34:07 -04:00
|
|
|
page.within('.atwho-view', visible: true) do
|
2017-03-22 14:04:29 -04:00
|
|
|
expect(page).to have_content(author.username)
|
|
|
|
expect(page).to have_content(note.author.username)
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
context 'adding a new note on a Issue' do
|
|
|
|
let(:noteable) { create(:issue, author: author, project: project) }
|
2016-04-08 20:35:43 -04:00
|
|
|
before do
|
2017-03-22 14:04:29 -04:00
|
|
|
visit namespace_project_issue_path(project.namespace, project, noteable)
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
include_examples "open suggestions when typing @"
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
context 'adding a new note on a Merge Request' do
|
|
|
|
let(:noteable) do
|
|
|
|
create(:merge_request, source_project: project,
|
|
|
|
target_project: project, author: author)
|
|
|
|
end
|
2016-04-09 02:34:07 -04:00
|
|
|
before do
|
2017-03-22 14:04:29 -04:00
|
|
|
visit namespace_project_merge_request_path(project.namespace, project, noteable)
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
include_examples "open suggestions when typing @"
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
context 'adding a new note on a Commit' do
|
|
|
|
let(:noteable) { project.commit }
|
|
|
|
let(:note) { create(:note_on_commit, project: project, commit_id: project.commit.id) }
|
2016-04-13 14:50:17 -04:00
|
|
|
|
|
|
|
before do
|
2017-03-22 14:04:29 -04:00
|
|
|
allow_any_instance_of(Commit).to receive(:author).and_return(author)
|
2016-04-13 14:50:17 -04:00
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
visit namespace_project_commit_path(project.namespace, project, noteable)
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
2016-04-13 14:50:17 -04:00
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
include_examples "open suggestions when typing @"
|
2016-04-13 14:50:17 -04:00
|
|
|
end
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|