BigW Consortium Gitlab

award_spec.rb 1.4 KB
Newer Older
1 2
require 'rails_helper'

3
feature 'Merge request awards', :js do
4
  let(:user) { create(:user) }
5
  let(:project) { create(:project, :public, :repository) }
6
  let(:merge_request) { create(:merge_request, source_project: project) }
7 8 9

  describe 'logged in' do
    before do
10
      sign_in(user)
11
      visit project_merge_request_path(project, merge_request)
12 13
    end

14
    it 'adds award to merge request' do
15 16 17
      first('.js-emoji-btn').click
      expect(page).to have_selector('.js-emoji-btn.active')
      expect(first('.js-emoji-btn')).to have_content '1'
18

19
      visit project_merge_request_path(project, merge_request)
20
      expect(first('.js-emoji-btn')).to have_content '1'
21 22
    end

23
    it 'removes award from merge request' do
24 25 26
      first('.js-emoji-btn').click
      find('.js-emoji-btn.active').click
      expect(first('.js-emoji-btn')).to have_content '0'
27

28
      visit project_merge_request_path(project, merge_request)
29
      expect(first('.js-emoji-btn')).to have_content '0'
30 31
    end

32
    it 'has only one menu on the page' do
33 34 35
      first('.js-add-award').click
      expect(page).to have_selector('.emoji-menu')

36
      expect(page).to have_selector('.emoji-menu', count: 1)
37 38 39 40 41
    end
  end

  describe 'logged out' do
    before do
42
      visit project_merge_request_path(project, merge_request)
43 44
    end

45
    it 'does not see award menu button' do
46 47 48 49
      expect(page).not_to have_selector('.js-award-holder')
    end
  end
end