Sha256: 523f4bbb69a935aca46eb92eb9fb83cb75b6fcc2f379edf17b149bb0cceb8dbb

Contents?: true

Size: 1.9 KB

Versions: 22

Compression:

Stored size: 1.9 KB

Contents

require 'rails_helper'

RSpec.describe "Batch Actions Settings" do
  let(:app) { ActiveAdmin::Application.new }
  let(:ns) { ActiveAdmin::Namespace.new(app, "Admin") }
  let(:post_resource) { ns.register Post }

  it "should be disabled globally by default" do
    # Note: the default initializer would set it to true

    expect(app.batch_actions).to eq false
    expect(ns.batch_actions).to eq false
    expect(post_resource.batch_actions_enabled?).to eq false
  end

  it "should be settable to true" do
    app.batch_actions = true
    expect(app.batch_actions).to eq true
  end

  it "should be an inheritable_setting" do
    app.batch_actions = true
    expect(ns.batch_actions).to eq true
  end

  it "should be settable at the namespace level" do
    app.batch_actions = true
    ns.batch_actions = false

    expect(app.batch_actions).to eq true
    expect(ns.batch_actions).to eq false
  end

  it "should be settable at the resource level" do
    expect(post_resource.batch_actions_enabled?).to eq false
    post_resource.batch_actions = true
    expect(post_resource.batch_actions_enabled?).to eq true
  end

  it "should inherit the setting on the resource from the namespace" do
    ns.batch_actions = false
    expect(post_resource.batch_actions_enabled?).to eq false
    expect(post_resource.batch_actions).to be_empty

    post_resource.batch_actions = true
    expect(post_resource.batch_actions_enabled?).to eq true
    expect(post_resource.batch_actions).to_not be_empty
  end

  it "should inherit the setting from the namespace when set to nil" do
    ns.batch_actions = true

    post_resource.batch_actions = true
    expect(post_resource.batch_actions_enabled?).to eq true
    expect(post_resource.batch_actions).to_not be_empty

    post_resource.batch_actions = nil
    expect(post_resource.batch_actions_enabled?).to eq true # inherited from namespace
    expect(post_resource.batch_actions).to_not be_empty
  end
end

Version data entries

22 entries across 22 versions & 4 rubygems

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