debian-mirror-gitlab/spec/features/issues/award_emoji_spec.rb

98 lines
2.2 KiB
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
require 'rails_helper'
describe 'Awards Emoji', feature: true do
2016-11-03 12:29:30 +05:30
include WaitForAjax
2016-06-02 11:05:42 +05:30
let!(:project) { create(:project) }
let!(:user) { create(:user) }
before do
project.team << [user, :master]
login_as(user)
end
describe 'Click award emoji from issue#show' do
let!(:issue) do
create(:issue,
assignee: @user,
project: project)
end
2016-11-03 12:29:30 +05:30
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
2016-06-02 11:05:42 +05:30
before do
visit namespace_project_issue_path(project.namespace, project, issue)
end
2016-09-13 17:45:13 +05:30
it 'increments the thumbsdown emoji', js: true do
2016-06-02 11:05:42 +05:30
find('[data-emoji="thumbsdown"]').click
2016-11-03 12:29:30 +05:30
wait_for_ajax
2016-06-02 11:05:42 +05:30
expect(thumbsdown_emoji).to have_text("1")
end
context 'click the thumbsup emoji' do
2016-09-13 17:45:13 +05:30
it 'increments the thumbsup emoji', js: true do
2016-06-02 11:05:42 +05:30
find('[data-emoji="thumbsup"]').click
2016-11-03 12:29:30 +05:30
wait_for_ajax
2016-06-02 11:05:42 +05:30
expect(thumbsup_emoji).to have_text("1")
end
2016-09-13 17:45:13 +05:30
it 'decrements the thumbsdown emoji', js: true do
2016-06-02 11:05:42 +05:30
expect(thumbsdown_emoji).to have_text("0")
end
end
context 'click the thumbsdown emoji' do
2016-09-13 17:45:13 +05:30
it 'increments the thumbsdown emoji', js: true do
2016-06-02 11:05:42 +05:30
find('[data-emoji="thumbsdown"]').click
2016-11-03 12:29:30 +05:30
wait_for_ajax
2016-06-02 11:05:42 +05:30
expect(thumbsdown_emoji).to have_text("1")
end
2016-09-13 17:45:13 +05:30
it 'decrements the thumbsup emoji', js: true do
2016-06-02 11:05:42 +05:30
expect(thumbsup_emoji).to have_text("0")
end
end
2016-11-03 12:29:30 +05:30
it 'toggles the smiley emoji on a note', js: true do
toggle_smiley_emoji(true)
within('.note-awards') do
expect(find(emoji_counter)).to have_text("1")
end
toggle_smiley_emoji(false)
within('.note-awards') do
expect(page).not_to have_selector(emoji_counter)
end
end
2016-06-02 11:05:42 +05:30
end
def thumbsup_emoji
2016-11-03 12:29:30 +05:30
page.all(emoji_counter).first
2016-06-02 11:05:42 +05:30
end
def thumbsdown_emoji
2016-11-03 12:29:30 +05:30
page.all(emoji_counter).last
end
def emoji_counter
'span.js-counter'
end
def toggle_smiley_emoji(status)
within('.note') do
find('.note-emoji-button').click
end
unless status
first('[data-emoji="smiley"]').click
else
find('[data-emoji="smiley"]').click
end
wait_for_ajax
2016-06-02 11:05:42 +05:30
end
end