Feature #42630 » update-reaction-style.diff
| app/assets/stylesheets/application.css | ||
|---|---|---|
|
.reaction-button.reacted:hover .icon-svg {
|
||
|
fill: #c61a1a;
|
||
|
}
|
||
|
.reaction-button:hover, .reaction-button:active {
|
||
|
text-decoration: none;
|
||
|
}
|
||
|
.reaction-button .icon-label {
|
||
|
margin-left: 3px;
|
||
|
margin-bottom: -1px;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
.reaction-button.readonly {
|
||
|
cursor: default;
|
||
| app/helpers/reactions_helper.rb | ||
|---|---|---|
|
def reaction_button_reacted(object, reaction, count, tooltip)
|
||
|
reaction_button_wrapper object do
|
||
|
link_to(
|
||
|
sprite_icon('thumb-up-filled', count),
|
||
|
sprite_icon('thumb-up-filled', count.nonzero?),
|
||
|
reaction_path(reaction, object_type: object.class.name, object_id: object),
|
||
|
remote: true, method: :delete,
|
||
|
class: ['icon', 'reaction-button', 'reacted'],
|
||
| ... | ... | |
|
def reaction_button_not_reacted(object, count, tooltip)
|
||
|
reaction_button_wrapper object do
|
||
|
link_to(
|
||
|
sprite_icon('thumb-up', count),
|
||
|
sprite_icon('thumb-up', count.nonzero?),
|
||
|
reactions_path(object_type: object.class.name, object_id: object),
|
||
|
remote: true, method: :post,
|
||
|
class: 'icon reaction-button',
|
||
| ... | ... | |
|
def reaction_button_readonly(object, count, tooltip)
|
||
|
reaction_button_wrapper object do
|
||
|
tag.span(class: 'icon reaction-button readonly', title: tooltip) do
|
||
|
sprite_icon('thumb-up', count)
|
||
|
sprite_icon('thumb-up', count.nonzero?)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/helpers/reactions_helper_test.rb | ||
|---|---|---|
|
assert_select_in result, 'a.reaction-button[title=?]', expected_tooltip
|
||
|
end
|
||
|
test 'reaction_button should be label less when no reactions' do
|
||
|
issue = issues(:issues_002)
|
||
|
result = with_locale('en') do
|
||
|
reaction_button(issue)
|
||
|
end
|
||
|
assert_select_in result, 'a.reaction-button' do
|
||
|
assert_select 'span.icon-label', false
|
||
|
end
|
||
|
# readonly
|
||
|
User.current = nil
|
||
|
result = with_locale('en') do
|
||
|
reaction_button(issue)
|
||
|
end
|
||
|
assert_select_in result, 'span.reaction-button.readonly' do
|
||
|
assert_select 'span.icon-label', false
|
||
|
end
|
||
|
end
|
||
|
test 'reaction_button should not count and display non-visible users' do
|
||
|
issue2 = issues(:issues_002)
|
||
| ... | ... | |
|
assert_select_in result, 'a.reaction-button[title]', false
|
||
|
assert_select_in result, 'a.reaction-button' do
|
||
|
assert_select 'span.icon-label', '0'
|
||
|
assert_select 'span.icon-label', false
|
||
|
end
|
||
|
end
|
||
| test/system/reactions_test.rb | ||
|---|---|---|
|
# Remove the reaction
|
||
|
within(reaction_button) { find('a.reacted').click }
|
||
|
within(reaction_button) { assert_selector('a.reaction-button:not(.reacted)') }
|
||
|
assert_equal "0", reaction_button.text
|
||
|
assert_equal "", reaction_button.text
|
||
|
assert_equal 0, expected_subject.reactions.count
|
||
|
end
|
||
|
end
|
||