activeadmin 1.0.0.pre2 → 1.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.hound.yml +7 -4
- data/.travis.yml +17 -15
- data/CHANGELOG.md +5 -1
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +26 -12
- data/README.md +24 -4
- data/activeadmin.gemspec +1 -0
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +7 -0
- data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +10 -0
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +15 -0
- data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +3 -0
- data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +1 -1
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -1
- data/config/locales/ar.yml +47 -43
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/locales/es-MX.yml +3 -3
- data/config/locales/es.yml +5 -4
- data/config/locales/fr.yml +2 -1
- data/config/locales/hu.yml +1 -1
- data/config/locales/id.yml +2 -1
- data/config/locales/it.yml +19 -0
- data/config/locales/ja.yml +2 -1
- data/config/locales/ko.yml +2 -1
- data/config/locales/nb.yml +6 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/pt-BR.yml +5 -1
- data/config/locales/ru.yml +4 -3
- data/config/locales/sv-SE.yml +3 -2
- data/config/locales/tr.yml +83 -44
- data/config/locales/uk.yml +13 -12
- data/config/locales/zh-CN.yml +2 -1
- data/config/locales/zh-TW.yml +10 -1
- data/cucumber.yml +1 -1
- data/docs/0-installation.md +24 -10
- data/docs/1-general-configuration.md +22 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/13-authorization-adapter.md +1 -1
- data/docs/14-gotchas.md +11 -3
- data/docs/2-resource-customization.md +16 -3
- data/docs/3-index-pages.md +1 -1
- data/docs/3-index-pages/index-as-table.md +13 -1
- data/docs/4-csv-format.md +19 -0
- data/docs/5-forms.md +14 -2
- data/docs/6-show-pages.md +1 -1
- data/features/decorators.feature +2 -0
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +4 -4
- data/features/index/batch_actions.feature +13 -0
- data/features/index/page_title.feature +2 -1
- data/features/new_page.feature +4 -4
- data/features/renamed_resource.feature +1 -1
- data/features/show/default_content.feature +1 -1
- data/features/show/page_title.feature +2 -1
- data/features/step_definitions/attribute_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +2 -2
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +1 -1
- data/features/sti_resource.feature +2 -2
- data/features/strong_parameters.feature +3 -3
- data/features/support/env.rb +21 -4
- data/lib/active_admin/application.rb +11 -4
- data/lib/active_admin/authorization_adapter.rb +1 -1
- data/lib/active_admin/base_controller.rb +12 -2
- data/lib/active_admin/base_controller/authorization.rb +4 -7
- data/lib/active_admin/base_controller/menu.rb +5 -1
- data/lib/active_admin/batch_actions/controller.rb +0 -1
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -2
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -0
- data/lib/active_admin/csv_builder.rb +18 -15
- data/lib/active_admin/dependency.rb +74 -1
- data/lib/active_admin/error.rb +1 -1
- data/lib/active_admin/filters/active.rb +4 -3
- data/lib/active_admin/filters/resource_extension.rb +7 -3
- data/lib/active_admin/generators/boilerplate.rb +8 -0
- data/lib/active_admin/inputs/filters/base.rb +3 -1
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +3 -3
- data/lib/active_admin/inputs/filters/date_range_input.rb +2 -2
- data/lib/active_admin/inputs/filters/select_input.rb +3 -2
- data/lib/active_admin/orm/active_record/comments.rb +13 -8
- data/lib/active_admin/page_controller.rb +5 -1
- data/lib/active_admin/reloader.rb +25 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource_controller/data_access.rb +33 -20
- data/lib/active_admin/resource_controller/decorators.rb +2 -2
- data/lib/active_admin/resource_controller/streaming.rb +7 -1
- data/lib/active_admin/resource_dsl.rb +15 -9
- data/lib/active_admin/router.rb +1 -1
- data/lib/active_admin/scope.rb +2 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +31 -0
- data/lib/active_admin/view_helpers/fields_for.rb +3 -2
- data/lib/active_admin/views/components/attributes_table.rb +5 -23
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +3 -3
- data/lib/active_admin/views/components/site_title.rb +1 -1
- data/lib/active_admin/views/components/table_for.rb +8 -27
- data/lib/active_admin/views/index_as_grid.rb +2 -2
- data/lib/active_admin/views/index_as_table.rb +24 -2
- data/lib/active_admin/views/pages/base.rb +1 -1
- data/lib/active_admin/views/pages/form.rb +6 -2
- data/lib/active_admin/views/title_bar.rb +1 -1
- data/lib/generators/active_admin/assets/templates/active_admin.scss +1 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +14 -4
- data/lib/generators/active_admin/resource/templates/admin.rb +8 -2
- data/lib/ransack_ext.rb +8 -0
- data/script/local +15 -6
- data/spec/rails_helper.rb +12 -1
- data/spec/requests/javascript_spec.rb +15 -13
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +117 -104
- data/spec/support/rails_template_with_data.rb +5 -9
- data/spec/support/templates/admin/stores.rb +1 -1
- data/spec/unit/action_builder_spec.rb +58 -56
- data/spec/unit/authorization/authorization_adapter_spec.rb +5 -5
- data/spec/unit/authorization/index_overriding_spec.rb +2 -1
- data/spec/unit/auto_link_spec.rb +1 -1
- data/spec/unit/batch_actions/resource_spec.rb +2 -2
- data/spec/unit/batch_actions/settings_spec.rb +13 -13
- data/spec/unit/comments_spec.rb +5 -5
- data/spec/unit/csv_builder_spec.rb +59 -0
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/filter_form_builder_spec.rb +5 -4
- data/spec/unit/filters/resource_spec.rb +7 -0
- data/spec/unit/form_builder_spec.rb +4 -1
- data/spec/unit/generators/install_spec.rb +4 -4
- data/spec/unit/helpers/collection_spec.rb +4 -4
- data/spec/unit/menu_collection_spec.rb +3 -3
- data/spec/unit/namespace/register_page_spec.rb +17 -18
- data/spec/unit/namespace/register_resource_spec.rb +20 -21
- data/spec/unit/namespace_spec.rb +4 -4
- data/spec/unit/pundit_adapter_spec.rb +3 -3
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +6 -2
- data/spec/unit/resource/scopes_spec.rb +2 -2
- data/spec/unit/resource_controller/decorators_spec.rb +11 -0
- data/spec/unit/resource_controller/sidebars_spec.rb +17 -24
- data/spec/unit/resource_spec.rb +14 -12
- data/spec/unit/routing_spec.rb +19 -14
- data/spec/unit/scope_spec.rb +28 -33
- data/spec/unit/view_helpers/display_helper_spec.rb +165 -0
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +9 -9
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +3 -3
- data/spec/unit/views/components/index_table_for_spec.rb +82 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +0 -1
- data/spec/unit/views/components/table_for_spec.rb +13 -8
- data/spec/unit/views/components/unsupported_browser_spec.rb +2 -8
- data/spec/unit/views/index_as_blog_spec.rb +76 -0
- data/spec/unit/views/pages/form_spec.rb +9 -0
- data/tasks/test.rake +13 -5
- metadata +27 -10
- data/app/assets/javascripts/active_admin/application.js.coffee +0 -37
- data/spec/support/templates/cucumber.rb +0 -24
- data/spec/support/templates/cucumber_with_reloading.rb +0 -5
- data/spec/unit/view_helpers/display_name_spec.rb +0 -71
data/spec/unit/dsl_spec.rb
CHANGED
@@ -97,7 +97,7 @@ describe ActiveAdmin::DSL do
|
|
97
97
|
dsl.run_registration_block do
|
98
98
|
sidebar :help
|
99
99
|
end
|
100
|
-
expect(dsl.config.sidebar_sections.map(&:name)).to match_array
|
100
|
+
expect(dsl.config.sidebar_sections.map(&:name)).to match_array ['filters', 'Search status:', 'email', 'help']
|
101
101
|
end
|
102
102
|
|
103
103
|
end
|
@@ -143,8 +143,9 @@ describe ActiveAdmin::Filters::ViewHelper do
|
|
143
143
|
|
144
144
|
it "should remove original ordering to prevent PostgreSQL error" do
|
145
145
|
expect(scope.object.klass).to receive(:reorder).with('title asc') {
|
146
|
-
|
147
|
-
|
146
|
+
distinct = ActiveAdmin::Dependency.rails >= 4 ? :distinct : :uniq
|
147
|
+
m = double distinct => double(pluck: ['A Title'])
|
148
|
+
expect(m.send(distinct)).to receive(:pluck).with :title
|
148
149
|
m
|
149
150
|
}
|
150
151
|
body
|
@@ -156,13 +157,13 @@ describe ActiveAdmin::Filters::ViewHelper do
|
|
156
157
|
let(:body) { Capybara.string(filter :created_at) }
|
157
158
|
|
158
159
|
it "should generate a date greater than" do
|
159
|
-
expect(body).to have_selector("input.datepicker[name='q[
|
160
|
+
expect(body).to have_selector("input.datepicker[name='q[created_at_gteq_date]']")
|
160
161
|
end
|
161
162
|
it "should generate a seperator" do
|
162
163
|
expect(body).to have_selector("span.seperator")
|
163
164
|
end
|
164
165
|
it "should generate a date less than" do
|
165
|
-
expect(body).to have_selector("input.datepicker[name='q[
|
166
|
+
expect(body).to have_selector("input.datepicker[name='q[created_at_lteq_date]']")
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
@@ -32,6 +32,13 @@ describe ActiveAdmin::Filters::ResourceExtension do
|
|
32
32
|
expect(resource.filters).to be_empty
|
33
33
|
end
|
34
34
|
|
35
|
+
it "should return the defaults without associations if default association filters are disabled on the namespace" do
|
36
|
+
resource.namespace.include_default_association_filters = false
|
37
|
+
expect(resource.filters.keys).to match_array([
|
38
|
+
:body, :created_at, :custom_searcher, :position, :published_at, :starred, :title, :updated_at
|
39
|
+
])
|
40
|
+
end
|
41
|
+
|
35
42
|
describe "removing a filter" do
|
36
43
|
it "should work" do
|
37
44
|
expect(resource.filters.keys).to include :author
|
@@ -563,8 +563,11 @@ describe ActiveAdmin::FormBuilder do
|
|
563
563
|
describe "with allow destroy" do
|
564
564
|
context "with an existing post" do
|
565
565
|
let :body do
|
566
|
+
s = self
|
566
567
|
build_form({url: '/categories'}, Category.new) do |f|
|
567
|
-
|
568
|
+
s.instance_exec do
|
569
|
+
allow(f.object.posts.build).to receive(:new_record?).and_return(false)
|
570
|
+
end
|
568
571
|
f.has_many :posts, allow_destroy: true do |p|
|
569
572
|
p.input :title
|
570
573
|
end
|
@@ -5,19 +5,19 @@ describe "AA installation" do
|
|
5
5
|
|
6
6
|
it "active_admin.scss" do
|
7
7
|
path = Rails.root + "app/assets/stylesheets/active_admin.scss"
|
8
|
-
expect(File.exists? path).to
|
8
|
+
expect(File.exists? path).to eq true
|
9
9
|
end
|
10
10
|
|
11
11
|
it "active_admin.js.coffee" do
|
12
|
-
expect(File.exists?(Rails.root + "app/assets/javascripts/active_admin.js.coffee")).to
|
12
|
+
expect(File.exists?(Rails.root + "app/assets/javascripts/active_admin.js.coffee")).to eq true
|
13
13
|
end
|
14
14
|
|
15
15
|
it "the dashboard" do
|
16
|
-
expect(File.exists?(Rails.root + "app/admin/dashboard.rb")).to
|
16
|
+
expect(File.exists?(Rails.root + "app/admin/dashboard.rb")).to eq true
|
17
17
|
end
|
18
18
|
|
19
19
|
it "the initializer" do
|
20
|
-
expect(File.exists?(Rails.root + "config/initializers/active_admin.rb")).to
|
20
|
+
expect(File.exists?(Rails.root + "config/initializers/active_admin.rb")).to eq true
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -45,21 +45,21 @@ describe ActiveAdmin::Helpers::Collection do
|
|
45
45
|
|
46
46
|
describe "#collection_is_empty?" do
|
47
47
|
it "should return true when the collection is empty" do
|
48
|
-
expect(collection_is_empty?(Post.where(title: "Non existing post"))).to
|
48
|
+
expect(collection_is_empty?(Post.where(title: "Non existing post"))).to eq true
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should return false when the collection is not empty" do
|
52
|
-
expect(collection_is_empty?(Post.where(title: "A post"))).to
|
52
|
+
expect(collection_is_empty?(Post.where(title: "A post"))).to eq false
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should take the defined collection by default" do
|
56
56
|
def collection; Post.where(nil); end
|
57
57
|
|
58
|
-
expect(collection_is_empty?).to
|
58
|
+
expect(collection_is_empty?).to eq false
|
59
59
|
|
60
60
|
def collection; Post.where(title: "Non existing post"); end
|
61
61
|
|
62
|
-
expect(collection_is_empty?).to
|
62
|
+
expect(collection_is_empty?).to eq true
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -44,7 +44,7 @@ describe ActiveAdmin::MenuCollection do
|
|
44
44
|
m.add :default, label: "Hello World"
|
45
45
|
end
|
46
46
|
|
47
|
-
expect(menus.fetch(:default)["Hello World"]).to_not
|
47
|
+
expect(menus.fetch(:default)["Hello World"]).to_not eq nil
|
48
48
|
end
|
49
49
|
|
50
50
|
it "re-runs the callbacks when the menu is cleared" do
|
@@ -52,9 +52,9 @@ describe ActiveAdmin::MenuCollection do
|
|
52
52
|
m.add :default, label: "Hello World"
|
53
53
|
end
|
54
54
|
|
55
|
-
expect(menus.fetch(:default)["Hello World"]).to_not
|
55
|
+
expect(menus.fetch(:default)["Hello World"]).to_not eq nil
|
56
56
|
menus.clear!
|
57
|
-
expect(menus.fetch(:default)["Hello World"]).to_not
|
57
|
+
expect(menus.fetch(:default)["Hello World"]).to_not eq nil
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe ActiveAdmin::Namespace, "registering a page" do
|
4
|
-
|
5
4
|
let(:application){ ActiveAdmin::Application.new }
|
6
|
-
|
7
5
|
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
8
6
|
let(:menu){ namespace.fetch_menu(:default) }
|
9
7
|
|
@@ -17,23 +15,21 @@ describe ActiveAdmin::Namespace, "registering a page" do
|
|
17
15
|
end
|
18
16
|
|
19
17
|
it "should create a new controller in the default namespace" do
|
20
|
-
expect(defined?(Admin::StatusController)).to
|
18
|
+
expect(defined?(Admin::StatusController)).to eq 'constant'
|
21
19
|
end
|
22
20
|
|
23
21
|
it "should create a menu item" do
|
24
22
|
expect(menu["Status"]).to be_an_instance_of(ActiveAdmin::MenuItem)
|
25
23
|
end
|
26
|
-
end
|
24
|
+
end
|
27
25
|
|
28
26
|
context "with a block configuration" do
|
29
27
|
it "should be evaluated in the dsl" do
|
30
|
-
expect
|
31
|
-
namespace.register_page "Status"
|
32
|
-
|
33
|
-
end
|
34
|
-
}.to raise_error
|
28
|
+
expect{ |block|
|
29
|
+
namespace.register_page "Status", &block
|
30
|
+
}.to yield_control
|
35
31
|
end
|
36
|
-
end
|
32
|
+
end
|
37
33
|
|
38
34
|
describe "adding to the menu" do
|
39
35
|
describe "adding as a top level item" do
|
@@ -42,9 +38,9 @@ describe ActiveAdmin::Namespace, "registering a page" do
|
|
42
38
|
end
|
43
39
|
|
44
40
|
it "should add a new menu item" do
|
45
|
-
expect(menu['Status']).to_not
|
41
|
+
expect(menu['Status']).to_not eq nil
|
46
42
|
end
|
47
|
-
end
|
43
|
+
end
|
48
44
|
|
49
45
|
describe "adding as a child" do
|
50
46
|
before do
|
@@ -52,13 +48,15 @@ describe ActiveAdmin::Namespace, "registering a page" do
|
|
52
48
|
menu parent: 'Extra'
|
53
49
|
end
|
54
50
|
end
|
51
|
+
|
55
52
|
it "should generate the parent menu item" do
|
56
|
-
expect( menu['Extra']).to_not
|
53
|
+
expect( menu['Extra']).to_not eq nil
|
57
54
|
end
|
55
|
+
|
58
56
|
it "should generate its own child item" do
|
59
|
-
expect(menu['Extra']['Status']).to_not
|
57
|
+
expect(menu['Extra']['Status']).to_not eq nil
|
60
58
|
end
|
61
|
-
end
|
59
|
+
end
|
62
60
|
|
63
61
|
describe "disabling the menu" do
|
64
62
|
before do
|
@@ -66,9 +64,10 @@ describe ActiveAdmin::Namespace, "registering a page" do
|
|
66
64
|
menu false
|
67
65
|
end
|
68
66
|
end
|
67
|
+
|
69
68
|
it "should not create a menu item" do
|
70
|
-
expect(menu["Status"]).to
|
69
|
+
expect(menu["Status"]).to eq nil
|
71
70
|
end
|
72
|
-
end
|
73
|
-
end
|
71
|
+
end
|
72
|
+
end
|
74
73
|
end
|
@@ -4,41 +4,40 @@ require 'rails_helper'
|
|
4
4
|
# Specifically, the dashboard is already defined.
|
5
5
|
|
6
6
|
describe ActiveAdmin::Namespace, "registering a resource" do
|
7
|
-
|
8
7
|
let(:application){ ActiveAdmin::Application.new }
|
9
|
-
|
10
8
|
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
11
|
-
|
12
9
|
let(:menu){ namespace.fetch_menu(:default) }
|
13
10
|
|
14
11
|
context "with no configuration" do
|
15
12
|
before do
|
16
13
|
namespace.register Category
|
17
14
|
end
|
15
|
+
|
18
16
|
it "should store the namespaced registered configuration" do
|
19
17
|
expect(namespace.resources.keys).to include('Category')
|
20
18
|
end
|
19
|
+
|
21
20
|
it "should create a new controller in the default namespace" do
|
22
|
-
expect(defined?(Admin::CategoriesController)).to
|
21
|
+
expect(defined?(Admin::CategoriesController)).to eq 'constant'
|
23
22
|
end
|
23
|
+
|
24
24
|
skip "should not create the dashboard controller" do
|
25
|
-
defined?(Admin::DashboardController).to_not
|
25
|
+
defined?(Admin::DashboardController).to_not eq 'constant'
|
26
26
|
end
|
27
|
+
|
27
28
|
it "should create a menu item" do
|
28
29
|
expect(menu["Categories"]).to be_a ActiveAdmin::MenuItem
|
29
30
|
expect(menu["Categories"].instance_variable_get(:@url)).to be_a Proc
|
30
31
|
end
|
31
|
-
end
|
32
|
+
end
|
32
33
|
|
33
34
|
context "with a block configuration" do
|
34
35
|
it "should be evaluated in the dsl" do
|
35
|
-
expect
|
36
|
-
namespace.register Category
|
37
|
-
|
38
|
-
end
|
39
|
-
}.to raise_error
|
36
|
+
expect{ |block|
|
37
|
+
namespace.register Category, &block
|
38
|
+
}.to yield_control
|
40
39
|
end
|
41
|
-
end
|
40
|
+
end
|
42
41
|
|
43
42
|
context "with a resource that's namespaced" do
|
44
43
|
before do
|
@@ -50,7 +49,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
50
49
|
expect(namespace.resources.keys).to include('Mock::Resource')
|
51
50
|
end
|
52
51
|
it "should create a new controller in the default namespace" do
|
53
|
-
expect(defined?(Admin::MockResourcesController)).to
|
52
|
+
expect(defined?(Admin::MockResourcesController)).to eq 'constant'
|
54
53
|
end
|
55
54
|
it "should create a menu item" do
|
56
55
|
expect(menu["Mock Resources"]).to be_an_instance_of(ActiveAdmin::MenuItem)
|
@@ -89,7 +88,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
89
88
|
namespace.register Category
|
90
89
|
end
|
91
90
|
it "should add a new menu item" do
|
92
|
-
expect(menu['Categories']).to_not
|
91
|
+
expect(menu['Categories']).to_not eq nil
|
93
92
|
end
|
94
93
|
end # describe "adding as a top level item"
|
95
94
|
|
@@ -100,10 +99,10 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
100
99
|
end
|
101
100
|
end
|
102
101
|
it "should generate the parent menu item" do
|
103
|
-
expect(menu['Blog']).to_not
|
102
|
+
expect(menu['Blog']).to_not eq nil
|
104
103
|
end
|
105
104
|
it "should generate its own child item" do
|
106
|
-
expect(menu['Blog']['Categories']).to_not
|
105
|
+
expect(menu['Blog']['Categories']).to_not eq nil
|
107
106
|
end
|
108
107
|
end # describe "adding as a child"
|
109
108
|
|
@@ -114,7 +113,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
114
113
|
end
|
115
114
|
end
|
116
115
|
it "should not create a menu item" do
|
117
|
-
expect(menu["Categories"]).to
|
116
|
+
expect(menu["Categories"]).to eq nil
|
118
117
|
end
|
119
118
|
end # describe "disabling the menu"
|
120
119
|
|
@@ -126,7 +125,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
126
125
|
end
|
127
126
|
end
|
128
127
|
it "should not show up in the menu" do
|
129
|
-
expect(menu["Posts"]).to
|
128
|
+
expect(menu["Posts"]).to eq nil
|
130
129
|
end
|
131
130
|
end
|
132
131
|
context "when optional" do
|
@@ -136,7 +135,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
136
135
|
end
|
137
136
|
end
|
138
137
|
it "should show up in the menu" do
|
139
|
-
expect(menu["Posts"]).to_not
|
138
|
+
expect(menu["Posts"]).to_not eq nil
|
140
139
|
end
|
141
140
|
end
|
142
141
|
end
|
@@ -147,14 +146,14 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
147
146
|
it "should be namespaced" do
|
148
147
|
namespace = ActiveAdmin::Namespace.new(application, :one)
|
149
148
|
namespace.register Category
|
150
|
-
expect(defined?(One::CategoriesController)).to
|
149
|
+
expect(defined?(One::CategoriesController)).to eq 'constant'
|
151
150
|
end
|
152
151
|
end
|
153
152
|
context "when not namespaced" do
|
154
153
|
it "should not be namespaced" do
|
155
154
|
namespace = ActiveAdmin::Namespace.new(application, :two)
|
156
155
|
namespace.register Category
|
157
|
-
expect(defined?(Two::CategoriesController)).to
|
156
|
+
expect(defined?(Two::CategoriesController)).to eq 'constant'
|
158
157
|
end
|
159
158
|
end
|
160
159
|
end # describe "dashboard controller name"
|
data/spec/unit/namespace_spec.rb
CHANGED
@@ -66,7 +66,7 @@ describe ActiveAdmin::Namespace do
|
|
66
66
|
menu.add label: "menu item"
|
67
67
|
end
|
68
68
|
|
69
|
-
expect(namespace.fetch_menu(:default)["menu item"]).to_not
|
69
|
+
expect(namespace.fetch_menu(:default)["menu item"]).to_not eq nil
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should set a block on a custom menu" do
|
@@ -74,7 +74,7 @@ describe ActiveAdmin::Namespace do
|
|
74
74
|
menu.add label: "menu item"
|
75
75
|
end
|
76
76
|
|
77
|
-
expect(namespace.fetch_menu(:test)["menu item"]).to_not
|
77
|
+
expect(namespace.fetch_menu(:test)["menu item"]).to_not eq nil
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -89,12 +89,12 @@ describe ActiveAdmin::Namespace do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should have a logout button to the far left" do
|
92
|
-
expect(menu["Logout"]).to_not
|
92
|
+
expect(menu["Logout"]).to_not eq nil
|
93
93
|
expect(menu["Logout"].priority).to eq 1
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should have a static link with a target of :blank" do
|
97
|
-
expect(menu["ActiveAdmin.info"]).to_not
|
97
|
+
expect(menu["ActiveAdmin.info"]).to_not eq nil
|
98
98
|
expect(menu["ActiveAdmin.info"].html_options).to include(target: :blank)
|
99
99
|
end
|
100
100
|
|
@@ -64,9 +64,9 @@ describe ActiveAdmin::PunditAdapter do
|
|
64
64
|
|
65
65
|
it "works well with method_missing" do
|
66
66
|
allow(auth).to receive(:retrieve_policy).and_return(DefaultPolicy.new(double, double))
|
67
|
-
expect(auth.authorized?(:foo_no)).to
|
68
|
-
expect(auth.authorized?(:foo_yes)).to
|
69
|
-
expect(auth.authorized?(:bar_yes)).to
|
67
|
+
expect(auth.authorized?(:foo_no)).to eq false
|
68
|
+
expect(auth.authorized?(:foo_yes)).to eq true
|
69
|
+
expect(auth.authorized?(:bar_yes)).to eq false
|
70
70
|
end
|
71
71
|
|
72
72
|
context 'when Pundit is unable to find policy scope' do
|
@@ -110,7 +110,7 @@ module ActiveAdmin
|
|
110
110
|
|
111
111
|
[:==, :===, :eql?].each do |method|
|
112
112
|
it "are equivalent when compared with #{method}" do
|
113
|
-
expect(resource_name.public_send(method, duplicate_resource_name)).to
|
113
|
+
expect(resource_name.public_send(method, duplicate_resource_name)).to eq true
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -2,7 +2,11 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
module ActiveAdmin
|
4
4
|
describe Resource::Routes do
|
5
|
-
|
5
|
+
|
6
|
+
after :all do
|
7
|
+
load_defaults!
|
8
|
+
reload_routes!
|
9
|
+
end
|
6
10
|
|
7
11
|
describe "route names" do
|
8
12
|
context "when in the admin namespace" do
|
@@ -25,7 +29,7 @@ module ActiveAdmin
|
|
25
29
|
context "when in the root namespace" do
|
26
30
|
let!(:config) { ActiveAdmin.register Category, namespace: false }
|
27
31
|
it "should have a nil route_prefix" do
|
28
|
-
expect(config.route_prefix).to
|
32
|
+
expect(config.route_prefix).to eq nil
|
29
33
|
end
|
30
34
|
|
31
35
|
it "should generate a correct route" do
|
@@ -40,9 +40,9 @@ module ActiveAdmin
|
|
40
40
|
|
41
41
|
it "should update a scope with the same id" do
|
42
42
|
config.scope :published
|
43
|
-
expect(config.scopes.first.scope_block).to
|
43
|
+
expect(config.scopes.first.scope_block).to eq nil
|
44
44
|
config.scope(:published){ }
|
45
|
-
expect(config.scopes.first.scope_block).to_not
|
45
|
+
expect(config.scopes.first.scope_block).to_not eq nil
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|