Commit 9d3186e4 authored by Phil Hughes's avatar Phil Hughes

Disabled award emoji button when user is not logged in

Closes #24680
parent 0f590750
- grouped_emojis = awardable.grouped_awards(with_thumbs: inline) - 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.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| - 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) = emoji_icon(emoji, sprite: false)
%span.award-control-text.js-counter %span.award-control-text.js-counter
= awards.count = awards.count
......
---
title: Disabled emoji buttons when user is not logged in
merge_request:
author:
...@@ -3,21 +3,21 @@ require 'rails_helper' ...@@ -3,21 +3,21 @@ require 'rails_helper'
describe 'Awards Emoji', feature: true do describe 'Awards Emoji', feature: true do
include WaitForAjax include WaitForAjax
let!(:project) { create(:project) } let!(:project) { create(:project, :public) }
let!(:user) { create(:user) } let!(:user) { create(:user) }
let(:issue) do
create(:issue,
assignee: @user,
project: project)
end
context 'authorized user' do
before do before do
project.team << [user, :master] project.team << [user, :master]
login_as(user) login_as(user)
end end
describe 'Click award emoji from issue#show' do 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") } let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
before do before do
...@@ -68,6 +68,17 @@ describe 'Awards Emoji', feature: true do ...@@ -68,6 +68,17 @@ describe 'Awards Emoji', feature: true do
end end
end 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 def thumbsup_emoji
page.all(emoji_counter).first page.all(emoji_counter).first
......
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