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