Sha256: c69bda7c58fada86d006ef71fa815a4d074751be679b1eb7dc0a9864a7024da2

Contents?: true

Size: 1.09 KB

Versions: 19

Compression:

Stored size: 1.09 KB

Contents

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) do |order_clause|
            if order_clause.order == 'desc'
              [order_clause.to_sql, 'NULLS LAST'].join(' ')
            end
          end
        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

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
activeadmin-rails-1.7.1 spec/unit/resource/ordering_spec.rb
activeadmin-rails-1.7.0 spec/unit/resource/ordering_spec.rb
activeadmin-rb-1.6.0 spec/unit/resource/ordering_spec.rb
activeadmin-rb-1.5.2 spec/unit/resource/ordering_spec.rb
activeadmin-rb-1.5.1 spec/unit/resource/ordering_spec.rb
activeadmin-rb-1.5.0 spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin-rb-1.4.0 spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin-1.3.1 spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin-1.3.0 spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/ordering_spec.rb
activeadmin-1.2.1 spec/unit/resource/ordering_spec.rb
activeadmin-1.2.0 spec/unit/resource/ordering_spec.rb
activeadmin-1.1.0 spec/unit/resource/ordering_spec.rb