Sha256: 0dc3b55c0d9d5a77e3639bd2a009f9a45e0de30c56aff329635d0d6420e5463e

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 KB

Contents

require 'rails_helper'

describe ActiveAdmin::MenuCollection do

  let(:menus) { ActiveAdmin::MenuCollection.new }

  describe "#add" do

    it "should initialize a new menu when first item" do
      menus.add :default, label: "Hello World"

      expect(menus.fetch(:default).items.size).to eq 1
      expect(menus.fetch(:default)["Hello World"]).to be_an_instance_of(ActiveAdmin::MenuItem)
    end

    it "should add items to an existing menu" do
      menus.add :default, label: "Hello World"
      menus.add :default, label: "Hello World Again"

      expect(menus.fetch(:default).items.size).to eq 2
    end

  end

  describe "#clear!" do

    it "should remove all menus" do
      menus.add :default, label: "Hello World"

      menus.clear!

      expect {
        menus.fetch(:non_default_menu)
      }.to raise_error(ActiveAdmin::NoMenuError)

    end

  end

  describe "#on_build" do

    it "runs a callback when fetching a menu" do
      menus.on_build do |m|
        m.add :default, label: "Hello World"
      end

      expect(menus.fetch(:default)["Hello World"]).to_not be_nil
    end

    it "re-runs the callbacks when the menu is cleared" do
      menus.on_build do |m|
        m.add :default, label: "Hello World"
      end

      expect(menus.fetch(:default)["Hello World"]).to_not be_nil
      menus.clear!
      expect(menus.fetch(:default)["Hello World"]).to_not be_nil
    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/menu_collection_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/menu_collection_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/menu_collection_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/menu_collection_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/menu_collection_spec.rb
activeadmin-1.0.0.pre2 spec/unit/menu_collection_spec.rb
activeadmin-1.0.0.pre1 spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.7.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.6.pre spec/unit/menu_collection_spec.rb
yousty-activeadmin-1.0.5.pre spec/unit/menu_collection_spec.rb