Removes the tag selector from debate#index view & refactors i18n

This commit is contained in:
kikito
2015-09-03 11:15:05 +02:00
parent c7b44485b3
commit 002d86884b
4 changed files with 26 additions and 60 deletions

View File

@@ -3,30 +3,24 @@
<div class="filters row"> <div class="filters row">
<div class="small-9 column"> <div class="small-9 column">
<div class="inline-block" >
<% if @tag_filter %> <% if @tag_filter %>
<div class="inline-block small-8" >
<h2> <h2>
<%= t("debates.index.filter_topic", <%= t("debates.index.filter_topic",
number: @debates.size, count: @debates.size,
topic: @tag_filter) %> topic: @tag_filter) %>
</h2> </h2>
<% else %>
<h2><%= t("debates.index.select_topic") %></h2>
<form class="inline-block">
<select class="js-location-changer" name="tag-filter">
<option value="/" selected="selected"><%= t("debates.index.all") %></option>
<% @tags.each do |tag| %>
<option value='<%= current_path_with_query_params(tag: tag.name) %>'>
<%= tag.name %>
</option>
<% end %>
</select>
</form>
<% end %>
</div> </div>
<% end %>
<div class="inline-block right"> <div class="inline-block <%= 'right' if @tag_filter %>">
<h6 class="inline-block"><%= t("debates.index.select_order") %></h6> <h6 class="inline-block">
<% if @tag_filter %>
<%= t("debates.index.select_order") %>
<% else %>
<%= t("debates.index.select_order_long") %>
<% end %>
</h6>
<form class="inline-block"> <form class="inline-block">
<select class="js-location-changer" name="order-selector"> <select class="js-location-changer" name="order-selector">
<% @valid_orders.each do |order| %> <% @valid_orders.each do |order| %>

View File

@@ -62,13 +62,14 @@ en:
index: index:
create_debate: Create a debate create_debate: Create a debate
select_order: Order by select_order: Order by
select_order_long: Order debates by
orders: orders:
created_at: newest created_at: newest
total_votes: most voted total_votes: most voted
likes: best rated likes: best rated
select_topic: "Filter by topic:" filter_topic:
filter_topic: "You are seeing %{number} debates with the topic '%{topic}'" one: "You are seeing one debate with the topic '%{topic}'"
all: All other: "You are seeing %{count} debates with the topic '%{topic}'"
debate: debate:
debate: Debate debate: Debate
comments: comments:

View File

@@ -62,13 +62,14 @@ es:
index: index:
create_debate: Crea un debate create_debate: Crea un debate
select_order: Ordenar por select_order: Ordenar por
select_order_long: Estás viendo los debates
orders: orders:
created_at: "más nuevos" created_at: "más nuevos"
total_votes: "más votados" total_votes: "más votados"
likes: mejor valorados likes: "mejor valorados"
select_topic: "Filtrar por tema:" filter_topic:
filter_topic: "Estás viendo %{number} debates con el tema '%{topic}'" one: "Estás viendo un debate con el tema ''%{topic}''"
all: Todos other: "Estás viendo %{count} debates con el tema '%{topic}'"
debate: debate:
debate: Debate debate: Debate
comments: comments:

View File

@@ -407,34 +407,4 @@ feature 'Debates' do
expect(@most_liked_debate.title).to appear_before(@most_voted_debate.title) expect(@most_liked_debate.title).to appear_before(@most_voted_debate.title)
end end
end end
feature 'Debates can be filtered by tags', :js do
let!(:debate1) { create(:debate, tag_list: ["Deporte", "Corrupción"]) }
let!(:debate2) { create(:debate, tag_list: ["Deporte", "Fiestas populares"]) }
let!(:debate3) { create(:debate, tag_list: ["Corrupción", "Fiestas populares"]) }
scenario 'By default no tag filter is applied' do
visit debates_path
expect(page).to have_content('Filter by topic')
expect(page).not_to have_content('with the topic')
expect(page).to have_selector('#debates .debate', count: 3)
end
scenario 'Debates are filtered by single tag' do
visit debates_path
select('Deporte', from: 'tag-filter')
expect(page).not_to have_content('Filter by topic')
expect(page).not_to have_select('tag-filter')
expect(page).to have_content('with the topic')
expect(current_url).to include('tag=Deporte')
expect(page).to have_selector('#debates .debate', count: 2)
expect(page).to_not have_content(debate3.title)
expect(page).to have_content(debate1.title)
expect(page).to have_content(debate2.title)
end
end
end end