Sha256: 0c579729f9b179264855c6f1512397794cfd6a81c52ee522eb38524b35967d66

Contents?: true

Size: 1000 Bytes

Versions: 72

Compression:

Stored size: 1000 Bytes

Contents

require 'spec_helper'

describe ActiveAdmin::ScopeChain do

  include ActiveAdmin::ScopeChain

  describe "#scope_chain" do
    let(:relation) { mock }

    context "when Scope has a scope method" do
      let(:scope) { ActiveAdmin::Scope.new :published }

      it "should call the method on the relation and return it" do
        relation.should_receive(:published).and_return(:scoped_relation)
        scope_chain(scope, relation).should == :scoped_relation
      end
    end

    context "when Scope has the scope method method ':all'" do
      let(:scope) { ActiveAdmin::Scope.new :all }

      it "should return the relation" do
        scope_chain(scope, relation).should == relation
      end
    end

    context "when Scope has a name and a scope block" do
      let(:scope) { ActiveAdmin::Scope.new("My Scope"){|s| :scoped_relation } }

      it "should instance_exec the block and return it" do
        scope_chain(scope, relation).should == :scoped_relation
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 4 rubygems

Version Path
activeadmin-0.6.6 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.6.5 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.6.4 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.6.3 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.6.2 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.6.1 spec/unit/helpers/scope_chain_spec.rb
aa-rails4-0.6.0 spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.141 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/spec/unit/helpers/scope_chain_spec.rb