From dc9cf5da55e0eb360791c2186193d16e811b7ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 21 Sep 2018 13:43:07 +0200 Subject: [PATCH] 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. --- app/models/legislation/proposal.rb | 2 +- spec/features/admin/legislation/proposals_spec.rb | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/models/legislation/proposal.rb b/app/models/legislation/proposal.rb index ad6691578..61398f178 100644 --- a/app/models/legislation/proposal.rb +++ b/app/models/legislation/proposal.rb @@ -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)} diff --git a/spec/features/admin/legislation/proposals_spec.rb b/spec/features/admin/legislation/proposals_spec.rb index 2ea10786e..394a32ad7 100644 --- a/spec/features/admin/legislation/proposals_spec.rb +++ b/spec/features/admin/legislation/proposals_spec.rb @@ -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