Change names of debate order filters

* 'news' to 'created_at'
* 'votes' to 'total_votes'
* 'rated' to 'likes'
This commit is contained in:
Marko Lovic
2015-08-27 09:38:02 +02:00
parent 2d48966de3
commit 6f32801a88
5 changed files with 15 additions and 15 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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