Sha256: 83059e67f7be5ff0d2fea837f3b70233cd833cf79a5fe8ce3006f392bbc0c49a

Contents?: true

Size: 1.46 KB

Versions: 20

Compression:

Stored size: 1.46 KB

Contents

require 'rails_helper'

module ActiveAdmin
  RSpec.describe Resource, "Scopes" do

    before { load_defaults! }

    let(:application){ ActiveAdmin::Application.new }
    let(:namespace){ Namespace.new(application, :admin) }

    def config(options = {})
      @config ||= Resource.new(namespace, Category, options)
    end

    describe "adding a scope" do

      it "should add a scope" do
        config.scope :published
        expect(config.scopes.first).to be_a(ActiveAdmin::Scope)
        expect(config.scopes.first.name).to eq "Published"
      end

      it "should retrive a scope by its id" do
        config.scope :published
        expect(config.get_scope_by_id(:published).name).to eq "Published"
      end

      it "should retrieve a string scope with spaces by its id without conflicts" do
        aspace_1 = config.scope "a space"
        aspace_2 = config.scope "as pace"
        expect(config.get_scope_by_id(aspace_1.id).name).to eq "a space"
        expect(config.get_scope_by_id(aspace_2.id).name).to eq "as pace"
      end

      it "should not add a scope with the same name twice" do
        config.scope :published
        config.scope :published
        expect(config.scopes.size).to eq 1
      end

      it "should update a scope with the same id" do
        config.scope :published
        expect(config.scopes.first.scope_block).to eq nil
        config.scope(:published){ }
        expect(config.scopes.first.scope_block).to_not eq nil
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 4 rubygems

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