Merge branch 'master' into legislation-module-stable

This commit is contained in:
Amaia Castro
2017-01-11 22:54:41 +01:00
235 changed files with 9717 additions and 656 deletions

View File

@@ -6,18 +6,41 @@ describe 'HasOrders' do
controller(FakeController) do
include HasOrders
has_orders ['created_at', 'votes_count', 'flags_count'], only: :index
has_orders ['created_at', 'votes_count', 'flags_count', 'relevance'], only: :index
has_orders -> (c) { ['votes_count', 'flags_count'] }, only: :new
def index
render text: "#{@current_order} (#{@valid_orders.join(' ')})"
end
def new
render text: "#{@current_order} (#{@valid_orders.join(' ')})"
end
end
it "has the valid orders set up" do
it "displays all the orders except relevance when not searching" do
get :index
expect(response.body).to eq('created_at (created_at votes_count flags_count)')
end
it "allows specifying the orders via a lambda" do
get :new
expect(response.body).to eq('votes_count (votes_count flags_count)')
end
it "displays relevance when searching" do
get :index, search: 'ipsum'
expect(response.body).to eq('created_at (created_at votes_count flags_count relevance)')
end
it "does not overwrite the has_orders options when doing several requests" do
get :index
# Since has_orders did valid_options.delete, the first call to :index might remove 'relevance' from
# the list by mistake.
get :index, search: 'ipsum'
expect(response.body).to eq('created_at (created_at votes_count flags_count relevance)')
end
describe "the current order" do
it "defaults to the first one on the list" do
get :index