Commit c3f858b7 authored by Fatih Acet's avatar Fatih Acet

Merge branch 'emoji-btn-disabled' into 'master'

Disabled award emoji button when user is not logged in

## What does this MR do?

The award emoji buttons are now disabled when the user is not signed in, stopping them from clicking it & then getting an error.

## Screenshots (if relevant)

![Screen_Shot_2016-11-22_at_10.25.20](/uploads/210378bde90e689fbc12940ce271c05e/Screen_Shot_2016-11-22_at_10.25.20.png)

## What are the relevant issue numbers?

Closes #24680

See merge request !7651
parents 3cefaca2 9d3186e4
- grouped_emojis = awardable.grouped_awards(with_thumbs: inline)
.awards.js-awards-block{ class: ("hidden" if !inline && grouped_emojis.empty?), data: { award_url: toggle_award_url(awardable) } }
- awards_sort(grouped_emojis).each do |emoji, awards|
%button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button", class: (award_active_class(awards, current_user)), data: { placement: "bottom", title: award_user_list(awards, current_user) } }
%button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button",
disabled: !current_user,
class: (award_active_class(awards, current_user)),
data: { placement: "bottom", title: award_user_list(awards, current_user) } }
= emoji_icon(emoji, sprite: false)
%span.award-control-text.js-counter
= awards.count
......
---
title: Disabled emoji buttons when user is not logged in
merge_request:
author:
......@@ -3,72 +3,83 @@ require 'rails_helper'
describe 'Awards Emoji', feature: true do
include WaitForAjax
let!(:project) { create(:project) }
let!(:project) { create(:project, :public) }
let!(:user) { create(:user) }
before do
project.team << [user, :master]
login_as(user)
let(:issue) do
create(:issue,
assignee: @user,
project: project)
end
describe 'Click award emoji from issue#show' do
let!(:issue) do
create(:issue,
assignee: @user,
project: project)
end
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
context 'authorized user' do
before do
visit namespace_project_issue_path(project.namespace, project, issue)
project.team << [user, :master]
login_as(user)
end
it 'increments the thumbsdown emoji', js: true do
find('[data-emoji="thumbsdown"]').click
wait_for_ajax
expect(thumbsdown_emoji).to have_text("1")
end
describe 'Click award emoji from issue#show' do
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
context 'click the thumbsup emoji' do
it 'increments the thumbsup emoji', js: true do
find('[data-emoji="thumbsup"]').click
wait_for_ajax
expect(thumbsup_emoji).to have_text("1")
before do
visit namespace_project_issue_path(project.namespace, project, issue)
end
it 'decrements the thumbsdown emoji', js: true do
expect(thumbsdown_emoji).to have_text("0")
end
end
context 'click the thumbsdown emoji' do
it 'increments the thumbsdown emoji', js: true do
find('[data-emoji="thumbsdown"]').click
wait_for_ajax
expect(thumbsdown_emoji).to have_text("1")
end
it 'decrements the thumbsup emoji', js: true do
expect(thumbsup_emoji).to have_text("0")
context 'click the thumbsup emoji' do
it 'increments the thumbsup emoji', js: true do
find('[data-emoji="thumbsup"]').click
wait_for_ajax
expect(thumbsup_emoji).to have_text("1")
end
it 'decrements the thumbsdown emoji', js: true do
expect(thumbsdown_emoji).to have_text("0")
end
end
end
it 'toggles the smiley emoji on a note', js: true do
toggle_smiley_emoji(true)
context 'click the thumbsdown emoji' do
it 'increments the thumbsdown emoji', js: true do
find('[data-emoji="thumbsdown"]').click
wait_for_ajax
expect(thumbsdown_emoji).to have_text("1")
end
within('.note-awards') do
expect(find(emoji_counter)).to have_text("1")
it 'decrements the thumbsup emoji', js: true do
expect(thumbsup_emoji).to have_text("0")
end
end
toggle_smiley_emoji(false)
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)
within('.note-awards') do
expect(page).not_to have_selector(emoji_counter)
end
end
end
end
context 'unauthorized user', js: true do
before do
visit namespace_project_issue_path(project.namespace, project, issue)
end
it 'has disabled emoji button' do
expect(first('.award-control')[:disabled]).to be(true)
end
end
def thumbsup_emoji
page.all(emoji_counter).first
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment