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.4.1 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.4.0 spec/unit/helpers/scope_chain_spec.rb
andrewroth_activeadmin-0.3.4.4 spec/unit/helpers/scope_chain_spec.rb
andrewroth_activeadmin-0.3.4.3 spec/unit/helpers/scope_chain_spec.rb
andrewroth_activeadmin-0.3.4.2 spec/unit/helpers/scope_chain_spec.rb
andrewroth_activeadmin-0.3.4.1 spec/unit/helpers/scope_chain_spec.rb
andrewroth_activeadmin-0.3.4 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.3.4 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.3.3 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.3.2 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.3.1 spec/unit/helpers/scope_chain_spec.rb
activeadmin-0.3.0 spec/unit/helpers/scope_chain_spec.rb