Sha256: 1b94759f728f13683fcf2192f5d420e27c43e77c0fa6d192dc70fbeb403f5661

Contents?: true

Size: 1002 Bytes

Versions: 5

Compression:

Stored size: 1002 Bytes

Contents

require 'spec_helper'

describe ActiveAdmin::ScopeChain do

  include ActiveAdmin::ScopeChain

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

    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

5 entries across 5 versions & 1 rubygems

Version Path
yousty-activeadmin-1.0.4.pre spec/unit/helpers/scope_chain_spec.rb
yousty-activeadmin-1.0.3.pre spec/unit/helpers/scope_chain_spec.rb
yousty-activeadmin-1.0.2.pre spec/unit/helpers/scope_chain_spec.rb
yousty-activeadmin-1.0.1.pre spec/unit/helpers/scope_chain_spec.rb
yousty-activeadmin-1.0.0.pre spec/unit/helpers/scope_chain_spec.rb