Feature #42630 » update-reaction-style.diff
| app/assets/stylesheets/application.css | ||
|---|---|---|
| 2116 | 2116 |
.reaction-button.reacted:hover .icon-svg {
|
| 2117 | 2117 |
fill: #c61a1a; |
| 2118 | 2118 |
} |
| 2119 |
.reaction-button:hover, .reaction-button:active {
|
|
| 2120 |
text-decoration: none; |
|
| 2121 |
} |
|
| 2119 | 2122 |
.reaction-button .icon-label {
|
| 2120 | 2123 |
margin-left: 3px; |
| 2121 | 2124 |
margin-bottom: -1px; |
| 2125 |
font-weight: bold; |
|
| 2122 | 2126 |
} |
| 2123 | 2127 |
.reaction-button.readonly {
|
| 2124 | 2128 |
cursor: default; |
| app/helpers/reactions_helper.rb | ||
|---|---|---|
| 52 | 52 |
def reaction_button_reacted(object, reaction, count, tooltip) |
| 53 | 53 |
reaction_button_wrapper object do |
| 54 | 54 |
link_to( |
| 55 |
sprite_icon('thumb-up-filled', count),
|
|
| 55 |
sprite_icon('thumb-up-filled', count.nonzero?),
|
|
| 56 | 56 |
reaction_path(reaction, object_type: object.class.name, object_id: object), |
| 57 | 57 |
remote: true, method: :delete, |
| 58 | 58 |
class: ['icon', 'reaction-button', 'reacted'], |
| ... | ... | |
| 64 | 64 |
def reaction_button_not_reacted(object, count, tooltip) |
| 65 | 65 |
reaction_button_wrapper object do |
| 66 | 66 |
link_to( |
| 67 |
sprite_icon('thumb-up', count),
|
|
| 67 |
sprite_icon('thumb-up', count.nonzero?),
|
|
| 68 | 68 |
reactions_path(object_type: object.class.name, object_id: object), |
| 69 | 69 |
remote: true, method: :post, |
| 70 | 70 |
class: 'icon reaction-button', |
| ... | ... | |
| 76 | 76 |
def reaction_button_readonly(object, count, tooltip) |
| 77 | 77 |
reaction_button_wrapper object do |
| 78 | 78 |
tag.span(class: 'icon reaction-button readonly', title: tooltip) do |
| 79 |
sprite_icon('thumb-up', count)
|
|
| 79 |
sprite_icon('thumb-up', count.nonzero?)
|
|
| 80 | 80 |
end |
| 81 | 81 |
end |
| 82 | 82 |
end |
| test/helpers/reactions_helper_test.rb | ||
|---|---|---|
| 106 | 106 |
assert_select_in result, 'a.reaction-button[title=?]', expected_tooltip |
| 107 | 107 |
end |
| 108 | 108 | |
| 109 |
test 'reaction_button should be label less when no reactions' do |
|
| 110 |
issue = issues(:issues_002) |
|
| 111 | ||
| 112 |
result = with_locale('en') do
|
|
| 113 |
reaction_button(issue) |
|
| 114 |
end |
|
| 115 |
assert_select_in result, 'a.reaction-button' do |
|
| 116 |
assert_select 'span.icon-label', false |
|
| 117 |
end |
|
| 118 | ||
| 119 |
# readonly |
|
| 120 |
User.current = nil |
|
| 121 |
result = with_locale('en') do
|
|
| 122 |
reaction_button(issue) |
|
| 123 |
end |
|
| 124 |
assert_select_in result, 'span.reaction-button.readonly' do |
|
| 125 |
assert_select 'span.icon-label', false |
|
| 126 |
end |
|
| 127 |
end |
|
| 128 | ||
| 109 | 129 |
test 'reaction_button should not count and display non-visible users' do |
| 110 | 130 |
issue2 = issues(:issues_002) |
| 111 | 131 | |
| ... | ... | |
| 130 | 150 | |
| 131 | 151 |
assert_select_in result, 'a.reaction-button[title]', false |
| 132 | 152 |
assert_select_in result, 'a.reaction-button' do |
| 133 |
assert_select 'span.icon-label', '0'
|
|
| 153 |
assert_select 'span.icon-label', false
|
|
| 134 | 154 |
end |
| 135 | 155 |
end |
| 136 | 156 | |
| test/system/reactions_test.rb | ||
|---|---|---|
| 126 | 126 |
# Remove the reaction |
| 127 | 127 |
within(reaction_button) { find('a.reacted').click }
|
| 128 | 128 |
within(reaction_button) { assert_selector('a.reaction-button:not(.reacted)') }
|
| 129 |
assert_equal "0", reaction_button.text
|
|
| 129 |
assert_equal "", reaction_button.text |
|
| 130 | 130 |
assert_equal 0, expected_subject.reactions.count |
| 131 | 131 |
end |
| 132 | 132 |
end |