filters reset to page 1. Fixes #445

This commit is contained in:
kikito
2015-09-11 13:04:43 +02:00
parent 7b672d3ecb
commit 1f28e97c2e
3 changed files with 6 additions and 2 deletions

View File

@@ -30,7 +30,7 @@
<select class="js-location-changer" name="order-selector">
<% @valid_orders.each do |order| %>
<option <%= 'selected' if order == @order %>
value='<%= current_path_with_query_params(order: order) %>'>
value='<%= current_path_with_query_params(order: order, page: 1) %>'>
<%= t("debates.index.orders.#{order}") %>
</option>
<% end %>

View File

@@ -11,7 +11,7 @@
<dd class="active"><%= t("#{i18n_namespace}.filters.#{filter}") %></dd>
<% else %>
<dd><%= link_to t("#{i18n_namespace}.filters.#{filter}"),
current_path_with_query_params(filter: filter) %></dd>
current_path_with_query_params(filter: filter, page: 1) %></dd>
<% end %>
<% end %>
</dl>

View File

@@ -384,6 +384,7 @@ feature 'Debates' do
end
expect(current_url).to include('order=hot_score')
expect(current_url).to include('page=1')
end
scenario 'Debates are ordered by most commented', :js do
@@ -400,6 +401,7 @@ feature 'Debates' do
end
expect(current_url).to include('order=most_commented')
expect(current_url).to include('page=1')
end
scenario 'Debates are ordered by newest', :js do
@@ -416,6 +418,7 @@ feature 'Debates' do
end
expect(current_url).to include('order=created_at')
expect(current_url).to include('page=1')
end
scenario 'Debates are ordered randomly', :js do
@@ -432,6 +435,7 @@ feature 'Debates' do
debates_second_time = find("#debates.js-order-random").text
expect(debates_first_time).to_not eq(debates_second_time)
expect(current_url).to include('page=1')
end
end