BigW Consortium Gitlab

award_spec.rb 1.54 KB
Newer Older
Phil Hughes committed
1 2 3 4 5 6 7 8
require 'rails_helper'

feature 'Issue awards', js: true, feature: true do
  let(:user)      { create(:user) }
  let(:project)   { create(:project, :public) }
  let(:issue)     { create(:issue, project: project) }

  describe 'logged in' do
9 10
    include WaitForVueResource

Phil Hughes committed
11 12 13
    before do
      login_as(user)
      visit namespace_project_issue_path(project.namespace, project, issue)
14
      wait_for_vue_resource
Phil Hughes committed
15 16
    end

17
    it 'adds award to issue' do
Phil Hughes committed
18 19 20
      first('.js-emoji-btn').click
      expect(page).to have_selector('.js-emoji-btn.active')
      expect(first('.js-emoji-btn')).to have_content '1'
21 22 23

      visit namespace_project_issue_path(project.namespace, project, issue)
      expect(first('.js-emoji-btn')).to have_content '1'
Phil Hughes committed
24 25
    end

26
    it 'removes award from issue' do
Phil Hughes committed
27 28 29
      first('.js-emoji-btn').click
      find('.js-emoji-btn.active').click
      expect(first('.js-emoji-btn')).to have_content '0'
30 31 32

      visit namespace_project_issue_path(project.namespace, project, issue)
      expect(first('.js-emoji-btn')).to have_content '0'
Phil Hughes committed
33 34
    end

35
    it 'only has one menu on the page' do
Phil Hughes committed
36 37 38
      first('.js-add-award').click
      expect(page).to have_selector('.emoji-menu')

39
      expect(page).to have_selector('.emoji-menu', count: 1)
Phil Hughes committed
40 41 42 43
    end
  end

  describe 'logged out' do
44 45
    include WaitForVueResource
    
Phil Hughes committed
46 47
    before do
      visit namespace_project_issue_path(project.namespace, project, issue)
48
      wait_for_vue_resource
Phil Hughes committed
49 50
    end

51
    it 'does not see award menu button' do
Phil Hughes committed
52 53 54 55
      expect(page).not_to have_selector('.js-award-holder')
    end
  end
end