-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
ordering_spec.rb
28 lines (25 loc) · 971 Bytes
/
ordering_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'rails_helper'
module ActiveAdmin
RSpec.describe Resource, "Ordering" do
describe "#order_by" do
let(:application) { ActiveAdmin::Application.new }
let(:namespace) { ActiveAdmin::Namespace.new application, :admin }
let(:resource_config) { ActiveAdmin::Resource.new namespace, Post }
let(:dsl){ ActiveAdmin::ResourceDSL.new(resource_config) }
it "should register the ordering in the config" do
dsl.run_registration_block do
order_by(:age, &:to_sql)
end
expect(resource_config.ordering.size).to eq(1)
end
it "should allow to setup custom ordering class" do
MyOrderClause = Class.new(ActiveAdmin::OrderClause)
dsl.run_registration_block do
config.order_clause = MyOrderClause
end
expect(resource_config.order_clause).to eq(MyOrderClause)
expect(application.order_clause).to eq(ActiveAdmin::OrderClause)
end
end
end
end