add sorting of awards
This commit is contained in:
parent
a1b63e1252
commit
195dc3a746
|
@ -120,6 +120,18 @@ module IssuesHelper
|
|||
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
|
||||
module_function :url_for_issue
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.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)}
|
||||
= emoji_icon(emoji)
|
||||
.counter
|
||||
|
|
|
@ -37,7 +37,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
|
|||
step 'I have award added' do
|
||||
page.within '.awards' do
|
||||
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
|
||||
|
||||
|
|
|
@ -141,4 +141,11 @@ describe IssuesHelper do
|
|||
expect(note_active_class(Note.all, @note.author)).to eq("active")
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue