Sha256: 697fb484fe40da8bb98002409ac6fe4c6d6ecef543cf0ab037cdf66ea1eef3eb

Contents?: true

Size: 1.4 KB

Versions: 72

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe ActiveAdmin::Resource::ActionItems do

  let(:resource) do
    namespace = ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin)
    namespace.register(Post)
  end

  describe "adding a new action item" do

    before do
      resource.clear_action_items!
      resource.add_action_item do
        # Empty ...
      end
    end

    it "should add an action item" do
      resource.action_items.size.should == 1
    end

    it "should store an instance of ActionItem" do
      resource.action_items.first.should be_an_instance_of(ActiveAdmin::ActionItem)
    end

    it "should store the block in the action item" do
      resource.action_items.first.block.should_not be_nil
    end

  end

  describe "setting an action item to only display on specific controller actions" do

    before do
      resource.clear_action_items!
      resource.add_action_item :only => :index do
        raise StandardError
      end
      resource.add_action_item :only => :show do
        # Empty ...
      end
    end

    it "should return only relevant action items" do
      resource.action_items_for(:index).size.should == 1
      lambda {
        resource.action_items_for(:index).first.call
      }.should raise_exception(StandardError)
    end

  end

  describe "default action items" do

    it "should have 3 action items" do
      resource.action_items.size.should == 3
    end

  end

end

Version data entries

72 entries across 72 versions & 4 rubygems

Version Path
lalala-4.0.0.dev.116 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.94 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.92 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.90 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.84 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.80 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.79 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.78 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.77 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.74 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.73 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.72 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.71 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.66 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb
lalala-4.0.0.dev.65 vendor/deps/active_admin/spec/unit/resource/action_items_spec.rb