Allows blocks in has_orders concern
This commit is contained in:
@@ -7,10 +7,15 @@ describe 'HasOrders' do
|
||||
controller(FakeController) do
|
||||
include HasOrders
|
||||
has_orders ['created_at', 'votes_count', 'flags_count'], only: :index
|
||||
has_orders ->{ ['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
|
||||
@@ -18,6 +23,11 @@ describe 'HasOrders' do
|
||||
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
|
||||
|
||||
describe "the current order" do
|
||||
it "defaults to the first one on the list" do
|
||||
get :index
|
||||
|
||||
Reference in New Issue
Block a user