Commit 195dc3a7 authored by Valery Sizov's avatar Valery Sizov

add sorting of awards

parent a1b63e12
...@@ -120,6 +120,18 @@ module IssuesHelper ...@@ -120,6 +120,18 @@ module IssuesHelper
end end
end end
def awards_sort(awards)
awards.sort_by do |award, notes|
if award == "thumbsup"
0
elsif award == "thumbsdown"
1
else
2
end
end.to_h
end
# Required for Banzai::Filter::IssueReferenceFilter # Required for Banzai::Filter::IssueReferenceFilter
module_function :url_for_issue module_function :url_for_issue
end end
.awards.votes-block .awards.votes-block
- votable.notes.awards.grouped_awards.each do |emoji, notes| - awards_sort(votable.notes.awards.grouped_awards).each do |emoji, notes|
.award{class: (note_active_class(notes, current_user)), title: emoji_author_list(notes, current_user)} .award{class: (note_active_class(notes, current_user)), title: emoji_author_list(notes, current_user)}
= emoji_icon(emoji) = emoji_icon(emoji)
.counter .counter
......
...@@ -37,7 +37,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps ...@@ -37,7 +37,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
step 'I have award added' do step 'I have award added' do
page.within '.awards' do page.within '.awards' do
expect(page).to have_selector '.award' expect(page).to have_selector '.award'
expect(page.find('.award .counter')).to have_content '1' expect(page.find('.award.active .counter')).to have_content '1'
end end
end end
......
...@@ -141,4 +141,11 @@ describe IssuesHelper do ...@@ -141,4 +141,11 @@ describe IssuesHelper do
expect(note_active_class(Note.all, @note.author)).to eq("active") expect(note_active_class(Note.all, @note.author)).to eq("active")
end end
end end
describe "#awards_sort" do
it "sorts a hash so thumbsup and thumbsdown are always on top" do
data = {"thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value"}
expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"])
end
end
end 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