Sha256: 0e4ae314b01fa0bffedbcca94d2801e206d578760b2877fd4ec0041127fd4ec8

Contents?: true

Size: 1.55 KB

Versions: 20

Compression:

Stored size: 1.55 KB

Contents

require 'rails_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 :empty do
        # Empty ...
      end
    end

    it "should add an action item" do
      expect(resource.action_items.size).to eq 1
    end

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

    it "should store the block in the action item" do
      expect(resource.action_items.first.block).to_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 :new, only: :index do
        raise StandardError
      end
      resource.add_action_item :edit, only: :show do
        # Empty ...
      end
    end

    it "should return only relevant action items" do
      expect(resource.action_items_for(:index).size).to eq 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
      expect(resource.action_items.size).to eq 3
    end

    it 'can be removed by name' do
      resource.remove_action_item :new
      expect(resource.action_items.size).to eq 2
    end
  end

end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/action_items_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/resource/action_items_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/action_items_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/action_items_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/resource/action_items_spec.rb
activeadmin-1.0.0.pre2 spec/unit/resource/action_items_spec.rb
activeadmin-1.0.0.pre1 spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.7.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.6.pre spec/unit/resource/action_items_spec.rb
yousty-activeadmin-1.0.5.pre spec/unit/resource/action_items_spec.rb