Order by supports in descending order

Just as we do with confidence score, and as admins expect when they
order by received supports: the ones with more supports appear first.
This commit is contained in:
Javi Martín
2018-09-21 13:43:07 +02:00
parent f1745f8040
commit dc9cf5da55
2 changed files with 4 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ class Legislation::Proposal < ActiveRecord::Base
scope :sort_by_most_commented, -> { reorder(comments_count: :desc) }
scope :sort_by_title, -> { reorder(title: :asc) }
scope :sort_by_id, -> { reorder(id: :asc) }
scope :sort_by_supports, -> { reorder(cached_votes_up: :asc) }
scope :sort_by_supports, -> { reorder(cached_votes_up: :desc) }
scope :sort_by_random, -> { reorder("RANDOM()") }
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)}

View File

@@ -62,15 +62,9 @@ feature 'Admin legislation processes' do
select "Supports", from: "order-selector-participation"
within('#proposals_table') do
within(:xpath, "//tbody/tr[1]") do
expect(page).to have_content('10')
end
within(:xpath, "//tbody/tr[2]") do
expect(page).to have_content('20')
end
within(:xpath, "//tbody/tr[3]") do
expect(page).to have_content('30')
end
within(:xpath, "//tbody/tr[1]") { expect(page).to have_content('30') }
within(:xpath, "//tbody/tr[2]") { expect(page).to have_content('20') }
within(:xpath, "//tbody/tr[3]") { expect(page).to have_content('10') }
end
end