Sha256: 7ffdf1133086cd3a56332be55f9f9eb12ca6a36129091e9ecdabd693689c5f9a

Contents?: true

Size: 1.91 KB

Versions: 20

Compression:

Stored size: 1.91 KB

Contents

require 'rails_helper'

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 be_falsey
    expect(ns.batch_actions).to be_falsey
    expect(post_resource.batch_actions_enabled?).to be_falsey
  end

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

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

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

    expect(app.batch_actions).to be_truthy
    expect(ns.batch_actions).to be_falsey
  end

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

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

    post_resource.batch_actions = true
    expect(post_resource.batch_actions_enabled?).to be_truthy
    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 be_truthy
    expect(post_resource.batch_actions).to_not be_empty

    post_resource.batch_actions = nil
    expect(post_resource.batch_actions_enabled?).to be_truthy # inherited from namespace
    expect(post_resource.batch_actions).to_not be_empty
  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/batch_actions/settings_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/batch_actions/settings_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/batch_actions/settings_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/batch_actions/settings_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/batch_actions/settings_spec.rb
activeadmin-1.0.0.pre2 spec/unit/batch_actions/settings_spec.rb
activeadmin-1.0.0.pre1 spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.7.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.6.pre spec/unit/batch_actions/settings_spec.rb
yousty-activeadmin-1.0.5.pre spec/unit/batch_actions/settings_spec.rb