participants_autocomplete_spec.rb 1.76 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Member autocomplete', :js do
4 5 6
  let(:project) { create(:project, :public) }
  let(:user) { create(:user) }
  let(:author) { create(:user) }
7
  let(:note) { create(:note, noteable: noteable, project: noteable.project) }
8 9

  before do
10 11
    note # actually create the note
    login_as(user)
12 13
  end

14 15 16 17
  shared_examples "open suggestions when typing @" do
    before do
      page.within('.new-note') do
        find('#note_note').send_keys('@')
18 19 20
      end
    end

21
    it 'suggests noteable author and note author' do
22
      page.within('.atwho-view', visible: true) do
23 24
        expect(page).to have_content(author.username)
        expect(page).to have_content(note.author.username)
25 26 27 28
      end
    end
  end

29 30
  context 'adding a new note on a Issue' do
    let(:noteable) { create(:issue, author: author, project: project) }
31
    before do
32
      visit namespace_project_issue_path(project.namespace, project, noteable)
33 34
    end

35
    include_examples "open suggestions when typing @"
36 37
  end

38 39 40 41 42
  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
43
    before do
44
      visit namespace_project_merge_request_path(project.namespace, project, noteable)
45 46
    end

47
    include_examples "open suggestions when typing @"
48 49
  end

50 51 52
  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) }
53 54

    before do
55
      allow_any_instance_of(Commit).to receive(:author).and_return(author)
56

57
      visit namespace_project_commit_path(project.namespace, project, noteable)
58
    end
59

60
    include_examples "open suggestions when typing @"
61
  end
62
end