Sha256: a710df6e9274a61ad03d4dfb9b4008a8b4f2572d1582e9dbf0cbcd7787f640a6

Contents?: true

Size: 1 KB

Versions: 19

Compression:

Stored size: 1 KB

Contents

require 'rails_helper'

RSpec.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
        expect(relation).to receive(:published).and_return(:scoped_relation)
        expect(scope_chain(scope, relation)).to eq :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
        expect(scope_chain(scope, relation)).to eq 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
        expect(scope_chain(scope, relation)).to eq :scoped_relation
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
activeadmin-rails-1.7.1 spec/unit/helpers/scope_chain_spec.rb
activeadmin-rails-1.7.0 spec/unit/helpers/scope_chain_spec.rb
activeadmin-rb-1.6.0 spec/unit/helpers/scope_chain_spec.rb
activeadmin-rb-1.5.2 spec/unit/helpers/scope_chain_spec.rb
activeadmin-rb-1.5.1 spec/unit/helpers/scope_chain_spec.rb
activeadmin-rb-1.5.0 spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin-rb-1.4.0 spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin-1.3.1 spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin-1.3.0 spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/helpers/scope_chain_spec.rb
activeadmin-1.2.1 spec/unit/helpers/scope_chain_spec.rb
activeadmin-1.2.0 spec/unit/helpers/scope_chain_spec.rb
activeadmin-1.1.0 spec/unit/helpers/scope_chain_spec.rb