Sha256: 75fbdaf97f1f71ac5b5f56f9119dffc3ed7b0fda15856fcea26bbff0ffdeef74

Contents?: true

Size: 1.12 KB

Versions: 12

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

12 entries across 12 versions & 3 rubygems

Version Path
activeadmin-0.6.6 spec/unit/resource/scopes_spec.rb
activeadmin-0.6.5 spec/unit/resource/scopes_spec.rb
activeadmin-0.6.4 spec/unit/resource/scopes_spec.rb
yousty-activeadmin-1.0.4.pre spec/unit/resource/scopes_spec.rb
yousty-activeadmin-1.0.3.pre spec/unit/resource/scopes_spec.rb
yousty-activeadmin-1.0.2.pre spec/unit/resource/scopes_spec.rb
activeadmin-0.6.3 spec/unit/resource/scopes_spec.rb
yousty-activeadmin-1.0.1.pre spec/unit/resource/scopes_spec.rb
yousty-activeadmin-1.0.0.pre spec/unit/resource/scopes_spec.rb
activeadmin-0.6.2 spec/unit/resource/scopes_spec.rb
activeadmin-0.6.1 spec/unit/resource/scopes_spec.rb
aa-rails4-0.6.0 spec/unit/resource/scopes_spec.rb