Sha256: a446be842ee20387b1cfd263d9480965fc399303b2366407117333ab0bb8d5e4

Contents?: true

Size: 1.12 KB

Versions: 59

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper' 

module ActiveAdmin
  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
        config.scopes.first.should be_a(ActiveAdmin::Scope)
        config.scopes.first.name.should == "Published"
      end

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

      it "should not add a scope with the same name twice" do
        config.scope :published
        config.scope :published
        config.scopes.size.should == 1
      end

      it "should update a scope with the same id" do
        config.scope :published
        config.scopes.first.scope_block.should be_nil
        config.scope(:published){  }
        config.scopes.first.scope_block.should_not be_nil
      end

    end
  end
end

Version data entries

59 entries across 59 versions & 3 rubygems

Version Path
lalala-4.0.0.dev.141 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/spec/unit/resource/scopes_spec.rb