BigW Consortium Gitlab

award_spec.rb 1.52 KB
Newer Older
1 2 3 4 5
require 'rails_helper'

feature 'Merge request awards', js: true, feature: true do
  let(:user) { create(:user) }
  let(:project) { create(:project, :public) }
6
  let(:merge_request) { create(:merge_request, source_project: project) }
7 8 9 10 11 12 13

  describe 'logged in' do
    before do
      login_as(user)
      visit namespace_project_merge_request_path(project.namespace, project, merge_request)
    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 20

      visit namespace_project_merge_request_path(project.namespace, project, merge_request)
      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 29

      visit namespace_project_merge_request_path(project.namespace, project, merge_request)
      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 42 43 44
    end
  end

  describe 'logged out' do
    before do
      visit namespace_project_merge_request_path(project.namespace, project, merge_request)
    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