BigW Consortium Gitlab

award_spec.rb 1.44 KB
Newer Older
Phil Hughes committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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
    before do
      login_as(user)
      visit namespace_project_issue_path(project.namespace, project, issue)
    end

    it 'should add award to issue' do
      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_issue_path(project.namespace, project, issue)
      expect(first('.js-emoji-btn')).to have_content '1'
Phil Hughes committed
21 22 23 24 25 26
    end

    it 'should remove award from issue' do
      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_issue_path(project.namespace, project, issue)
      expect(first('.js-emoji-btn')).to have_content '0'
Phil Hughes committed
30 31 32 33 34 35
    end

    it 'should only have one menu on the page' do
      first('.js-add-award').click
      expect(page).to have_selector('.emoji-menu')

36
      expect(page).to have_selector('.emoji-menu', count: 1)
Phil Hughes committed
37 38 39 40 41 42 43 44 45 46 47 48 49
    end
  end

  describe 'logged out' do
    before do
      visit namespace_project_issue_path(project.namespace, project, issue)
    end

    it 'should not see award menu button' do
      expect(page).not_to have_selector('.js-award-holder')
    end
  end
end