From 6f32801a88393e09617ca6045009026e750748d4 Mon Sep 17 00:00:00 2001 From: Marko Lovic Date: Thu, 27 Aug 2015 09:38:02 +0200 Subject: [PATCH] Change names of debate order filters * 'news' to 'created_at' * 'votes' to 'total_votes' * 'rated' to 'likes' --- app/controllers/debates_controller.rb | 4 ++-- app/models/debate.rb | 6 +++--- config/locales/en.yml | 6 +++--- config/locales/es.yml | 6 +++--- spec/features/debates_spec.rb | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 7f7556f96..bc733c67a 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -73,8 +73,8 @@ class DebatesController < ApplicationController end def parse_order - @valid_orders = ['votes', 'news', 'rated'] - @order = @valid_orders.include?(params[:order]) ? params[:order] : 'news' + @valid_orders = ['total_votes', 'created_at', 'likes'] + @order = @valid_orders.include?(params[:order]) ? params[:order] : 'created_at' end end diff --git a/app/models/debate.rb b/app/models/debate.rb index 9b815c6db..82931dfff 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -42,11 +42,11 @@ class Debate < ActiveRecord::Base def self.sort_by(order) case order - when 'votes' + when 'total_votes' reorder(cached_votes_total: :desc) - when 'news' + when 'created_at' reorder(created_at: :desc) - when 'rated' + when 'likes' reorder(cached_votes_up: :desc) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 4bc7f33e3..7e049594d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -33,9 +33,9 @@ en: index: create_debate: Create a debate showing: You are seeing debates - order_news: the newest - order_votes: the most voted - order_rated: the best rated + order_created_at: the newest + order_total_votes: the most voted + order_likes: the best rated filter_topic: "You are seeing %{number} debates with the topic '%{topic}'" debate: debate: Debate diff --git a/config/locales/es.yml b/config/locales/es.yml index dc133aaff..fce3bad63 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -33,9 +33,9 @@ es: index: create_debate: Crea un debate showing: "Estás viendo los debates" - order_news: "más nuevos" - order_votes: "más votados" - order_rated: mejor valorados + order_created_at: "más nuevos" + order_total_votes: "más votados" + order_likes: mejor valorados filter_topic: "Estás viendo %{number} debates con el tema '%{topic}'" debate: debate: Debate diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index c76e4971c..cf6c71829 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -366,7 +366,7 @@ feature 'Debates' do end end - scenario 'Default order is newest' do + scenario 'Default order is created_at' do visit debates_path expect(page).to have_select('order', selected: 'the newest') @@ -380,7 +380,7 @@ feature 'Debates' do expect(page).to have_select('order', selected: 'the most voted') expect(find("#debates .debate", match: :first)).to have_content(@debates[0].title) # Necessary to force capybara to wait for redirect - expect(current_url).to include('order=votes') + expect(current_url).to include('order=total_votes') expect_debate_order([0, 1, 2]) end @@ -390,7 +390,7 @@ feature 'Debates' do select 'the best rated', from: 'order' expect(find("#debates .debate", match: :first)).to have_content(@debates[1].title) - expect(current_url).to include('order=rated') + expect(current_url).to include('order=likes') expect_debate_order([1, 0, 2]) end @@ -403,7 +403,7 @@ feature 'Debates' do select 'the newest', from: 'order' expect(find("#debates .debate", match: :first)).to have_content(@debates[2].title) - expect(current_url).to include('order=news') + expect(current_url).to include('order=created_at') expect_debate_order([2, 1, 0]) end end