orders summary groups alphabetically
This commit is contained in:
@@ -71,7 +71,7 @@ class Proposal < ActiveRecord::Base
|
||||
|
||||
def self.for_summary
|
||||
summary = {}
|
||||
categories = ActsAsTaggableOn::Tag.category_names
|
||||
categories = ActsAsTaggableOn::Tag.category_names.sort
|
||||
categories.each do |category|
|
||||
summary[category] = search(category).last_week.sort_by_confidence_score.limit(3)
|
||||
end
|
||||
|
||||
@@ -669,7 +669,7 @@ describe Proposal do
|
||||
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
||||
end
|
||||
|
||||
it "should order by votes" do
|
||||
it "should order proposals by votes" do
|
||||
create(:tag, kind: 'category', name: 'culture')
|
||||
create(:proposal, tag_list: 'culture').update_column(:confidence_score, 2)
|
||||
create(:proposal, tag_list: 'culture').update_column(:confidence_score, 10)
|
||||
@@ -682,6 +682,22 @@ describe Proposal do
|
||||
expect(results.third.confidence_score).to be(2)
|
||||
end
|
||||
|
||||
it "should order groups alphabetically" do
|
||||
create(:tag, kind: 'category', name: 'health')
|
||||
create(:tag, kind: 'category', name: 'culture')
|
||||
create(:tag, kind: 'category', name: 'social services')
|
||||
|
||||
health_proposal = create(:proposal, tag_list: 'health')
|
||||
culture_proposal = create(:proposal, tag_list: 'culture')
|
||||
social_proposal = create(:proposal, tag_list: 'social services')
|
||||
|
||||
results = Proposal.for_summary.values.flatten
|
||||
|
||||
expect(results.first).to eq(culture_proposal)
|
||||
expect(results.second).to eq(health_proposal)
|
||||
expect(results.third).to eq(social_proposal)
|
||||
end
|
||||
|
||||
it "should return proposals grouped by tag" do
|
||||
create(:tag, kind: 'category', name: 'culture')
|
||||
create(:tag, kind: 'category', name: 'health')
|
||||
|
||||
Reference in New Issue
Block a user