BigW Consortium Gitlab

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

3
feature 'Member autocomplete', :js do
4
  let(:project) { create(:empty_project, :public) }
5 6
  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
  context 'adding a new note on a Merge Request' do
39
    let(:project) { create(:project, :public, :repository) }
40 41 42 43
    let(:noteable) do
      create(:merge_request, source_project: project,
                             target_project: project, author: author)
    end
44
    before do
45
      visit namespace_project_merge_request_path(project.namespace, project, noteable)
46 47
    end

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

51
  context 'adding a new note on a Commit' do
52
    let(:project) { create(:project, :public, :repository) }
53 54
    let(:noteable) { project.commit }
    let(:note) { create(:note_on_commit, project: project, commit_id: project.commit.id) }
55 56

    before do
57
      allow_any_instance_of(Commit).to receive(:author).and_return(author)
58

59
      visit namespace_project_commit_path(project.namespace, project, noteable)
60
    end
61

62
    include_examples "open suggestions when typing @"
63
  end
64
end