Sha256: 1e9a01c0497dc1859fa199a2af929acdc27515a875442d903f1f6b48bfef9df8

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 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
      expect {
        resource.action_items_for(:index).first.call
      }.to 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

6 entries across 6 versions & 2 rubygems

Version Path
yousty-activeadmin-1.0.4.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.3.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.2.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.1.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.0.pre spec/unit/resource/action_items_spec.rb
aa-rails4-0.6.0 spec/unit/resource/action_items_spec.rb