participants_autocomplete_spec.rb 1.84 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
    note # actually create the note
11
    sign_in(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 project_issue_path(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 project_merge_request_path(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 58
      allow(User).to receive(:find_by_any_email)
        .with(noteable.author_email.downcase).and_return(author)
59

60
      visit project_commit_path(project, noteable)
61
    end
62

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