activeadmin 1.0.0.pre4 → 1.0.0.pre5
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/.gitignore +3 -3
- data/.travis.yml +48 -26
- data/Appraisals +103 -0
- data/CHANGELOG.md +12 -1
- data/CONTRIBUTING.md +85 -32
- data/Gemfile +13 -38
- data/README.md +10 -26
- data/Rakefile +41 -9
- data/activeadmin.gemspec +7 -4
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +10 -3
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -4
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +8 -0
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +14 -3
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -0
- data/app/views/active_admin/devise/registrations/new.html.erb +1 -1
- data/codecov.yml +23 -0
- data/config/locales/es-MX.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +110 -0
- data/docs/0-installation.md +3 -0
- data/docs/1-general-configuration.md +11 -0
- data/docs/10-custom-pages.md +25 -0
- data/docs/11-decorators.md +3 -0
- data/docs/12-arbre-components.md +3 -0
- data/docs/13-authorization-adapter.md +3 -0
- data/docs/14-gotchas.md +19 -0
- data/docs/2-resource-customization.md +21 -2
- data/docs/3-index-pages.md +21 -0
- data/docs/3-index-pages/custom-index.md +3 -0
- data/docs/3-index-pages/index-as-block.md +3 -0
- data/docs/3-index-pages/index-as-blog.md +3 -0
- data/docs/3-index-pages/index-as-grid.md +3 -0
- data/docs/3-index-pages/index-as-table.md +22 -0
- data/docs/4-csv-format.md +15 -0
- data/docs/5-forms.md +7 -3
- data/docs/6-show-pages.md +3 -0
- data/docs/7-sidebars.md +3 -0
- data/docs/8-custom-actions.md +3 -0
- data/docs/9-batch-actions.md +4 -1
- data/docs/CNAME +1 -0
- data/docs/Gemfile +2 -0
- data/docs/_config.yml +2 -0
- data/docs/_includes/footer.html +8 -0
- data/docs/_includes/google-analytics.html +16 -0
- data/docs/_includes/head.html +7 -0
- data/docs/_includes/toc.html +97 -0
- data/docs/_includes/top-menu.html +9 -0
- data/docs/_layouts/default.html +21 -0
- data/docs/documentation.md +62 -0
- data/docs/images/activeadmin.png +0 -0
- data/docs/images/code-header.png +0 -0
- data/docs/images/divider.png +0 -0
- data/docs/images/features.png +0 -0
- data/docs/index.html +130 -0
- data/docs/stylesheets/main.css +1199 -0
- data/features/action_item.feature +2 -2
- data/features/authorization_cancan.feature +3 -3
- data/features/belongs_to.feature +60 -2
- data/features/comments/commenting.feature +7 -7
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +9 -9
- data/features/footer.feature +28 -0
- data/features/i18n.feature +11 -0
- data/features/index/batch_actions.feature +28 -6
- data/features/index/filters.feature +31 -11
- data/features/index/format_as_csv.feature +13 -13
- data/features/index/formats.feature +4 -4
- data/features/index/index_as_block.feature +1 -1
- data/features/index/index_as_blog.feature +6 -6
- data/features/index/index_as_grid.feature +3 -3
- data/features/index/index_as_table.feature +11 -11
- data/features/index/index_blank_slate.feature +4 -4
- data/features/index/index_parameters.feature +10 -10
- data/features/index/index_scope_to.feature +3 -3
- data/features/index/index_scopes.feature +37 -18
- data/features/index/page_title.feature +3 -3
- data/features/index/pagination.feature +1 -1
- data/features/index/switch_index_view.feature +8 -8
- data/features/menu.feature +3 -3
- data/features/new_page.feature +8 -8
- data/features/registering_assets.feature +1 -1
- data/features/registering_pages.feature +73 -2
- data/features/registering_resources.feature +1 -1
- data/features/renamed_resource.feature +1 -1
- data/features/show/page_title.feature +3 -3
- data/features/sidebar_sections.feature +6 -6
- data/features/specifying_actions.feature +29 -4
- data/features/step_definitions/factory_steps.rb +1 -1
- data/features/step_definitions/footer_steps.rb +11 -0
- data/features/step_definitions/i18n_steps.rb +8 -0
- data/features/step_definitions/index_scope_steps.rb +4 -0
- data/features/step_definitions/sidebar_steps.rb +1 -3
- data/features/step_definitions/table_steps.rb +1 -5
- data/features/step_definitions/user_steps.rb +7 -0
- data/features/support/env.rb +6 -33
- data/features/support/paths.rb +5 -0
- data/features/users/logging_in.feature +2 -0
- data/gemfiles/rails_32.gemfile +54 -0
- data/gemfiles/rails_40.gemfile +53 -0
- data/gemfiles/rails_41.gemfile +53 -0
- data/gemfiles/rails_42.gemfile +53 -0
- data/gemfiles/rails_50.gemfile +46 -0
- data/lib/active_admin.rb +1 -0
- data/lib/active_admin/application.rb +11 -0
- data/lib/active_admin/batch_actions/resource_extension.rb +0 -8
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/dsl.rb +0 -6
- data/lib/active_admin/filters/active.rb +9 -1
- data/lib/active_admin/filters/formtastic_addons.rb +1 -1
- data/lib/active_admin/filters/humanized.rb +1 -1
- data/lib/active_admin/filters/resource_extension.rb +2 -4
- data/lib/active_admin/form_builder.rb +12 -6
- data/lib/active_admin/helpers/collection.rb +2 -0
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +9 -4
- data/lib/active_admin/inputs/filters/text_input.rb +26 -0
- data/lib/active_admin/localizers.rb +11 -0
- data/lib/active_admin/localizers/resource_localizer.rb +35 -0
- data/lib/active_admin/namespace.rb +1 -1
- data/lib/active_admin/order_clause.rb +29 -7
- data/lib/active_admin/page.rb +18 -4
- data/lib/active_admin/page_dsl.rb +4 -0
- data/lib/active_admin/resource.rb +16 -1
- data/lib/active_admin/resource/action_items.rb +7 -4
- data/lib/active_admin/resource/belongs_to.rb +4 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource/ordering.rb +11 -0
- data/lib/active_admin/resource/routes.rb +34 -13
- data/lib/active_admin/resource/scopes.rb +1 -0
- data/lib/active_admin/resource_controller/data_access.rb +3 -10
- data/lib/active_admin/resource_dsl.rb +28 -1
- data/lib/active_admin/router.rb +5 -3
- data/lib/active_admin/scope.rb +3 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -2
- data/lib/active_admin/view_helpers/display_helper.rb +8 -3
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -1
- data/lib/active_admin/views/components/active_admin_form.rb +11 -10
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/columns.rb +3 -3
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +4 -1
- data/lib/active_admin/views/components/paginated_collection.rb +1 -0
- data/lib/active_admin/views/components/scopes.rb +8 -1
- data/lib/active_admin/views/components/site_title.rb +2 -2
- data/lib/active_admin/views/components/table_for.rb +3 -3
- data/lib/active_admin/views/footer.rb +17 -3
- data/lib/active_admin/views/index_as_table.rb +3 -3
- data/lib/active_admin/views/pages/base.rb +4 -2
- data/lib/active_admin/views/pages/form.rb +2 -3
- data/lib/active_admin/views/pages/show.rb +2 -1
- data/lib/bug_report_templates/rails_5_master.rb +120 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +6 -3
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +15 -1
- data/lib/generators/active_admin/install/templates/migrations/{create_active_admin_comments.rb → create_active_admin_comments.rb.erb} +14 -1
- data/lib/ransack_ext.rb +2 -2
- data/spec/bug_report_templates_spec.rb +27 -0
- data/spec/javascripts/support/jasmine_runner.rb +4 -17
- data/spec/rails_helper.rb +20 -109
- data/spec/requests/default_namespace_spec.rb +16 -28
- data/spec/requests/javascript_spec.rb +1 -1
- data/spec/requests/memory_spec.rb +5 -1
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -10
- data/spec/support/active_admin_integration_spec_helper.rb +66 -0
- data/spec/support/active_admin_request_helpers.rb +12 -0
- data/spec/support/rails_template.rb +42 -15
- data/spec/support/rails_template_with_data.rb +24 -5
- data/spec/support/templates/manifest.js +3 -0
- data/spec/support/templates/policies/application_policy.rb +1 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +3 -12
- data/spec/unit/active_admin_spec.rb +1 -1
- data/spec/unit/application_spec.rb +5 -1
- data/spec/unit/asset_registration_spec.rb +1 -1
- data/spec/unit/authorization/authorization_adapter_spec.rb +1 -1
- data/spec/unit/authorization/controller_authorization_spec.rb +13 -9
- data/spec/unit/authorization/index_overriding_spec.rb +6 -6
- data/spec/unit/auto_link_spec.rb +48 -24
- data/spec/unit/batch_actions/resource_spec.rb +1 -14
- data/spec/unit/batch_actions/settings_spec.rb +1 -1
- data/spec/unit/belongs_to_spec.rb +9 -1
- data/spec/unit/cancan_adapter_spec.rb +1 -1
- data/spec/unit/comments_spec.rb +26 -19
- data/spec/unit/component_spec.rb +1 -1
- data/spec/unit/config_shared_examples.rb +1 -1
- data/spec/unit/controller_filters_spec.rb +1 -1
- data/spec/unit/csv_builder_spec.rb +5 -5
- data/spec/unit/dependency_spec.rb +1 -1
- data/spec/unit/devise_spec.rb +17 -3
- data/spec/unit/dsl_spec.rb +2 -2
- data/spec/unit/filters/active_spec.rb +21 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +98 -31
- data/spec/unit/filters/humanized_spec.rb +9 -1
- data/spec/unit/filters/resource_spec.rb +5 -4
- data/spec/unit/form_builder_spec.rb +180 -33
- data/spec/unit/generators/install_spec.rb +12 -5
- data/spec/unit/helpers/collection_spec.rb +10 -7
- data/spec/unit/helpers/scope_chain_spec.rb +1 -1
- data/spec/unit/helpers/settings_spec.rb +1 -1
- data/spec/unit/i18n_spec.rb +1 -1
- data/spec/unit/localizers/resource_localizer_spec.rb +36 -0
- data/spec/unit/menu_collection_spec.rb +1 -1
- data/spec/unit/menu_item_spec.rb +1 -1
- data/spec/unit/menu_spec.rb +1 -1
- data/spec/unit/namespace/authorization_spec.rb +1 -1
- data/spec/unit/namespace/register_page_spec.rb +28 -2
- data/spec/unit/namespace/register_resource_spec.rb +3 -1
- data/spec/unit/namespace_spec.rb +23 -1
- data/spec/unit/order_clause_spec.rb +7 -7
- data/spec/unit/page_controller_spec.rb +1 -1
- data/spec/unit/page_spec.rb +55 -2
- data/spec/unit/pretty_format_spec.rb +8 -7
- data/spec/unit/pundit_adapter_spec.rb +1 -1
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/includes_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/ordering_spec.rb +38 -0
- data/spec/unit/resource/page_presenters_spec.rb +1 -1
- data/spec/unit/resource/pagination_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +101 -53
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource/sidebars_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +1 -1
- data/spec/unit/resource_controller/data_access_spec.rb +50 -1
- data/spec/unit/resource_controller/decorators_spec.rb +2 -2
- data/spec/unit/resource_controller/sidebars_spec.rb +16 -17
- data/spec/unit/resource_controller_spec.rb +50 -56
- data/spec/unit/resource_registration_spec.rb +9 -4
- data/spec/unit/resource_spec.rb +9 -1
- data/spec/unit/routing_spec.rb +30 -2
- data/spec/unit/scope_spec.rb +26 -2
- data/spec/unit/settings_spec.rb +2 -2
- data/spec/unit/view_factory_spec.rb +1 -1
- data/spec/unit/view_helpers/breadcrumbs_spec.rb +1 -1
- data/spec/unit/view_helpers/display_helper_spec.rb +18 -3
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +1 -1
- data/spec/unit/view_helpers/flash_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +1 -1
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/batch_action_selector_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +1 -1
- data/spec/unit/views/components/columns_spec.rb +1 -1
- data/spec/unit/views/components/index_list_spec.rb +18 -4
- data/spec/unit/views/components/index_table_for_spec.rb +1 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +1 -1
- data/spec/unit/views/components/panel_spec.rb +1 -1
- data/spec/unit/views/components/sidebar_section_spec.rb +1 -1
- data/spec/unit/views/components/site_title_spec.rb +1 -1
- data/spec/unit/views/components/status_tag_spec.rb +1 -1
- data/spec/unit/views/components/table_for_spec.rb +9 -7
- data/spec/unit/views/components/tabs_spec.rb +1 -1
- data/spec/unit/views/components/unsupported_browser_spec.rb +3 -3
- data/spec/unit/views/index_as_blog_spec.rb +1 -1
- data/spec/unit/views/pages/form_spec.rb +1 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -2
- data/tasks/local.rake +25 -0
- data/tasks/parallel_tests.rake +4 -4
- data/tasks/test.rake +8 -53
- metadata +61 -18
- data/Guardfile +0 -8
- data/script/local +0 -53
- data/script/travis_cache +0 -107
- data/script/use_rails +0 -53
- data/spec/javascripts/support/jasmine_config.rb +0 -23
- data/spec/support/detect_rails_version.rb +0 -34
@@ -1,55 +1,8 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe ActiveAdmin::ResourceController do
|
4
|
-
|
5
|
-
let(:controller) { ActiveAdmin::ResourceController.new }
|
6
|
-
|
7
|
-
describe "authenticating the user" do
|
8
|
-
let(:controller){ Admin::PostsController.new }
|
9
|
-
|
10
|
-
it "should do nothing when no authentication_method set" do
|
11
|
-
namespace = controller.class.active_admin_config.namespace
|
12
|
-
expect(namespace).to receive(:authentication_method).once.and_return(nil)
|
13
|
-
|
14
|
-
controller.send(:authenticate_active_admin_user)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should call the authentication_method when set" do
|
18
|
-
namespace = controller.class.active_admin_config.namespace
|
19
|
-
|
20
|
-
expect(namespace).to receive(:authentication_method).twice.
|
21
|
-
and_return(:authenticate_admin_user!)
|
22
|
-
|
23
|
-
expect(controller).to receive(:authenticate_admin_user!).and_return(true)
|
24
|
-
|
25
|
-
controller.send(:authenticate_active_admin_user)
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "retrieving the current user" do
|
31
|
-
let(:controller){ Admin::PostsController.new }
|
32
|
-
|
33
|
-
it "should return nil when no current_user_method set" do
|
34
|
-
namespace = controller.class.active_admin_config.namespace
|
35
|
-
expect(namespace).to receive(:current_user_method).once.and_return(nil)
|
36
|
-
|
37
|
-
expect(controller.send(:current_active_admin_user)).to eq nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should call the current_user_method when set" do
|
41
|
-
user = double
|
42
|
-
namespace = controller.class.active_admin_config.namespace
|
43
|
-
|
44
|
-
expect(namespace).to receive(:current_user_method).twice.
|
45
|
-
and_return(:current_admin_user)
|
46
|
-
|
47
|
-
expect(controller).to receive(:current_admin_user).and_return(user)
|
48
|
-
|
49
|
-
expect(controller.send(:current_active_admin_user)).to eq user
|
50
|
-
end
|
51
|
-
end
|
3
|
+
RSpec.describe ActiveAdmin::ResourceController do
|
52
4
|
|
5
|
+
let(:controller) { Admin::PostsController.new }
|
53
6
|
|
54
7
|
describe "callbacks" do
|
55
8
|
before :all do
|
@@ -81,7 +34,6 @@ describe ActiveAdmin::ResourceController do
|
|
81
34
|
end
|
82
35
|
|
83
36
|
describe "performing create" do
|
84
|
-
let(:controller){ Admin::PostsController.new }
|
85
37
|
let(:resource){ double("Resource", save: true) }
|
86
38
|
|
87
39
|
before do
|
@@ -107,7 +59,6 @@ describe ActiveAdmin::ResourceController do
|
|
107
59
|
end
|
108
60
|
|
109
61
|
describe "performing update" do
|
110
|
-
let(:controller){ Admin::PostsController.new }
|
111
62
|
let(:resource){ double("Resource", :attributes= => true, save: true) }
|
112
63
|
let(:attributes){ [{}] }
|
113
64
|
|
@@ -135,7 +86,6 @@ describe ActiveAdmin::ResourceController do
|
|
135
86
|
end
|
136
87
|
|
137
88
|
describe "performing destroy" do
|
138
|
-
let(:controller){ Admin::PostsController.new }
|
139
89
|
let(:resource){ double("Resource", destroy: true) }
|
140
90
|
|
141
91
|
before do
|
@@ -155,10 +105,56 @@ describe ActiveAdmin::ResourceController do
|
|
155
105
|
end
|
156
106
|
end
|
157
107
|
|
158
|
-
describe
|
108
|
+
RSpec.describe "A specific resource controller", type: :controller do
|
109
|
+
before do
|
110
|
+
load_resources { ActiveAdmin.register Post }
|
111
|
+
|
112
|
+
@controller = Admin::PostsController.new
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "authenticating the user" do
|
116
|
+
it "should do nothing when no authentication_method set" do
|
117
|
+
namespace = controller.class.active_admin_config.namespace
|
118
|
+
expect(namespace).to receive(:authentication_method).once.and_return(nil)
|
119
|
+
|
120
|
+
controller.send(:authenticate_active_admin_user)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should call the authentication_method when set" do
|
124
|
+
namespace = controller.class.active_admin_config.namespace
|
125
|
+
|
126
|
+
expect(namespace).to receive(:authentication_method).twice.
|
127
|
+
and_return(:authenticate_admin_user!)
|
128
|
+
|
129
|
+
expect(controller).to receive(:authenticate_admin_user!).and_return(true)
|
130
|
+
|
131
|
+
controller.send(:authenticate_active_admin_user)
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "retrieving the current user" do
|
137
|
+
it "should return nil when no current_user_method set" do
|
138
|
+
namespace = controller.class.active_admin_config.namespace
|
139
|
+
expect(namespace).to receive(:current_user_method).once.and_return(nil)
|
140
|
+
|
141
|
+
expect(controller.send(:current_active_admin_user)).to eq nil
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should call the current_user_method when set" do
|
145
|
+
user = double
|
146
|
+
namespace = controller.class.active_admin_config.namespace
|
147
|
+
|
148
|
+
expect(namespace).to receive(:current_user_method).twice.
|
149
|
+
and_return(:current_admin_user)
|
150
|
+
|
151
|
+
expect(controller).to receive(:current_admin_user).and_return(user)
|
152
|
+
|
153
|
+
expect(controller.send(:current_active_admin_user)).to eq user
|
154
|
+
end
|
155
|
+
end
|
159
156
|
|
160
157
|
describe 'retrieving the resource' do
|
161
|
-
let(:controller){ Admin::PostsController.new }
|
162
158
|
let(:post) { Post.new title: "An incledibly unique Post Title" }
|
163
159
|
|
164
160
|
before do
|
@@ -187,7 +183,6 @@ describe Admin::PostsController, type: "controller" do
|
|
187
183
|
end
|
188
184
|
|
189
185
|
describe 'retrieving the resource collection' do
|
190
|
-
let(:controller){ Admin::PostsController.new }
|
191
186
|
let(:config) { controller.class.active_admin_config }
|
192
187
|
before do
|
193
188
|
Post.create!(title: "An incledibly unique Post Title") if Post.count == 0
|
@@ -223,7 +218,6 @@ describe Admin::PostsController, type: "controller" do
|
|
223
218
|
|
224
219
|
|
225
220
|
describe "performing batch_action" do
|
226
|
-
let(:controller){ Admin::PostsController.new }
|
227
221
|
let(:batch_action) { ActiveAdmin::BatchAction.new :flag, "Flag", &batch_action_block }
|
228
222
|
let(:batch_action_block) { proc { } }
|
229
223
|
before do
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe "Registering an object to administer" do
|
4
|
-
application
|
3
|
+
RSpec.describe "Registering an object to administer" do
|
4
|
+
let(:application) { ActiveAdmin::Application.new }
|
5
5
|
|
6
6
|
context "with no configuration" do
|
7
|
-
namespace
|
8
|
-
|
7
|
+
let(:namespace) { ActiveAdmin::Namespace.new(application, :admin) }
|
8
|
+
|
9
|
+
before do
|
9
10
|
application.namespaces[namespace.name] = namespace
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should call register on the namespace" do
|
10
14
|
expect(namespace).to receive(:register)
|
11
15
|
|
12
16
|
application.register Category
|
@@ -14,6 +18,7 @@ describe "Registering an object to administer" do
|
|
14
18
|
|
15
19
|
it "should dispatch a Resource::RegisterEvent" do
|
16
20
|
expect(ActiveSupport::Notifications).to receive(:publish).with(ActiveAdmin::Resource::RegisterEvent, an_instance_of(ActiveAdmin::Resource))
|
21
|
+
|
17
22
|
application.register Category
|
18
23
|
end
|
19
24
|
end
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rails_helper'
|
|
2
2
|
require File.expand_path('config_shared_examples', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
module ActiveAdmin
|
5
|
-
describe Resource do
|
5
|
+
RSpec.describe Resource do
|
6
6
|
|
7
7
|
it_should_behave_like "ActiveAdmin::Resource"
|
8
8
|
before { load_defaults! }
|
@@ -148,6 +148,8 @@ module ActiveAdmin
|
|
148
148
|
|
149
149
|
|
150
150
|
describe "sort order" do
|
151
|
+
class MockResource
|
152
|
+
end
|
151
153
|
|
152
154
|
context "when resource class responds to primary_key" do
|
153
155
|
it "should sort by primary key desc by default" do
|
@@ -234,8 +236,10 @@ module ActiveAdmin
|
|
234
236
|
before do
|
235
237
|
if Rails::VERSION::MAJOR >= 4
|
236
238
|
allow(Post).to receive(:find_by).with("id" => "12345") { post }
|
239
|
+
allow(Post).to receive(:find_by).with("id" => "54321") { nil }
|
237
240
|
else
|
238
241
|
allow(Post).to receive(:find_by_id).with("12345") { post }
|
242
|
+
allow(Post).to receive(:find_by_id).with("54321") { nil }
|
239
243
|
end
|
240
244
|
end
|
241
245
|
|
@@ -248,6 +252,10 @@ module ActiveAdmin
|
|
248
252
|
it 'decorates the resource' do
|
249
253
|
expect(resource.find_resource('12345')).to eq PostDecorator.new(post)
|
250
254
|
end
|
255
|
+
|
256
|
+
it 'does not decorate a not found resource' do
|
257
|
+
expect(resource.find_resource('54321')).to equal nil
|
258
|
+
end
|
251
259
|
end
|
252
260
|
|
253
261
|
context 'when using a nonstandard primary key' do
|
data/spec/unit/routing_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
|
-
describe ActiveAdmin, "Routing", type: :routing do
|
5
|
+
RSpec.describe ActiveAdmin, "Routing", type: :routing do
|
6
6
|
|
7
7
|
before do
|
8
8
|
load_defaults!
|
@@ -14,8 +14,10 @@ describe ActiveAdmin, "Routing", type: :routing do
|
|
14
14
|
reload_routes!
|
15
15
|
end
|
16
16
|
|
17
|
+
let(:namespaces) { ActiveAdmin.application.namespaces }
|
18
|
+
|
17
19
|
it "should only have the namespaces necessary for route testing" do
|
18
|
-
expect(
|
20
|
+
expect(namespaces.names).to eq [:admin]
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should route to the admin dashboard" do
|
@@ -30,6 +32,24 @@ describe ActiveAdmin, "Routing", type: :routing do
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
describe "route_options" do
|
36
|
+
context "with a custom path set in route_options" do
|
37
|
+
before do
|
38
|
+
namespaces[:admin].route_options = { path: '/custom-path' }
|
39
|
+
reload_routes!
|
40
|
+
end
|
41
|
+
|
42
|
+
after do
|
43
|
+
namespaces[:admin].route_options = {}
|
44
|
+
reload_routes!
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should route using the custom path" do
|
48
|
+
expect(admin_posts_path).to eq "/custom-path/posts"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
33
53
|
describe "standard resources" do
|
34
54
|
context "when in admin namespace" do
|
35
55
|
it "should route the index path" do
|
@@ -54,6 +74,10 @@ describe ActiveAdmin, "Routing", type: :routing do
|
|
54
74
|
load_resources { ActiveAdmin.register(Post, namespace: false) }
|
55
75
|
end
|
56
76
|
|
77
|
+
after(:each) do
|
78
|
+
namespaces.instance_variable_get(:@namespaces).delete(:root)
|
79
|
+
end
|
80
|
+
|
57
81
|
it "should route the index path" do
|
58
82
|
expect(posts_path).to eq "/posts"
|
59
83
|
end
|
@@ -167,6 +191,10 @@ describe ActiveAdmin, "Routing", type: :routing do
|
|
167
191
|
load_resources { ActiveAdmin.register_page("Chocolate I lØve You!", namespace: false) }
|
168
192
|
end
|
169
193
|
|
194
|
+
after(:each) do
|
195
|
+
namespaces.instance_variable_get(:@namespaces).delete(:root)
|
196
|
+
end
|
197
|
+
|
170
198
|
it "should route to page under /" do
|
171
199
|
expect(chocolate_i_love_you_path).to eq "/chocolate_i_love_you"
|
172
200
|
end
|
data/spec/unit/scope_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe ActiveAdmin::Scope do
|
3
|
+
RSpec.describe ActiveAdmin::Scope do
|
4
4
|
|
5
5
|
describe "creating a scope" do
|
6
6
|
subject{ scope }
|
@@ -135,7 +135,31 @@ describe ActiveAdmin::Scope do
|
|
135
135
|
|
136
136
|
it "should properly render the proc" do
|
137
137
|
scope = ActiveAdmin::Scope.new proc{ Date.today.strftime '%A' }, :foobar
|
138
|
-
expect(scope.name).to eq Date.today.strftime '%A'
|
138
|
+
expect(scope.name.call).to eq Date.today.strftime '%A'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "with scope method and localizer" do
|
143
|
+
let(:localizer) do
|
144
|
+
loc = double(:localizer)
|
145
|
+
allow(loc).to receive(:t).with(:published, scope: 'scopes').and_return("All published")
|
146
|
+
loc
|
147
|
+
end
|
148
|
+
let(:scope) { ActiveAdmin::Scope.new :published, :published, localizer: localizer }
|
149
|
+
|
150
|
+
describe '#name' do
|
151
|
+
subject { super().name }
|
152
|
+
it { is_expected.to eq("All published")}
|
153
|
+
end
|
154
|
+
|
155
|
+
describe '#id' do
|
156
|
+
subject { super().id }
|
157
|
+
it { is_expected.to eq("published")}
|
158
|
+
end
|
159
|
+
|
160
|
+
describe '#scope_method' do
|
161
|
+
subject { super().scope_method }
|
162
|
+
it { is_expected.to eq(:published) }
|
139
163
|
end
|
140
164
|
end
|
141
165
|
|
data/spec/unit/settings_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe ActiveAdmin::Settings do
|
3
|
+
RSpec.describe ActiveAdmin::Settings do
|
4
4
|
|
5
5
|
subject{ Class.new{ include ActiveAdmin::Settings } }
|
6
6
|
|
@@ -46,7 +46,7 @@ describe ActiveAdmin::Settings do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
|
49
|
-
describe ActiveAdmin::Settings::Inheritance do
|
49
|
+
RSpec.describe ActiveAdmin::Settings::Inheritance do
|
50
50
|
|
51
51
|
subject do
|
52
52
|
Class.new do
|
@@ -6,7 +6,7 @@ def it_should_have_view(key, value)
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
describe ActiveAdmin::ViewFactory do
|
9
|
+
RSpec.describe ActiveAdmin::ViewFactory do
|
10
10
|
|
11
11
|
it_should_have_view :global_navigation, ActiveAdmin::Views::TabbedNavigation
|
12
12
|
it_should_have_view :utility_navigation, ActiveAdmin::Views::TabbedNavigation
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'rails_helper'
|
2
|
+
require 'active_admin/view_helpers/active_admin_application_helper'
|
3
|
+
require 'active_admin/view_helpers/auto_link_helper'
|
4
|
+
require 'active_admin/view_helpers/display_helper'
|
5
|
+
require 'active_admin/view_helpers/method_or_proc_helper'
|
2
6
|
|
3
|
-
describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
7
|
+
RSpec.describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
4
8
|
include ActiveAdmin::ViewHelpers::ActiveAdminApplicationHelper
|
5
9
|
include ActiveAdmin::ViewHelpers::AutoLinkHelper
|
6
10
|
include ActiveAdmin::ViewHelpers::DisplayHelper
|
@@ -16,6 +20,17 @@ describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
|
16
20
|
true
|
17
21
|
end
|
18
22
|
|
23
|
+
def url_options
|
24
|
+
{ locale: nil }
|
25
|
+
end
|
26
|
+
|
27
|
+
before do
|
28
|
+
load_resources do
|
29
|
+
ActiveAdmin.register(User)
|
30
|
+
ActiveAdmin.register(Post){ belongs_to :user, optional: true }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
19
34
|
describe '#display_name' do
|
20
35
|
ActiveAdmin::Application.new.display_name_methods.map(&:to_s).each do |m|
|
21
36
|
it "should return #{m} when defined" do
|
@@ -89,7 +104,7 @@ describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
|
89
104
|
it 'calls the provided block to format the value' do
|
90
105
|
value = format_attribute double(foo: 2), ->r { r.foo + 1 }
|
91
106
|
|
92
|
-
expect(value).to eq 3
|
107
|
+
expect(value).to eq '3'
|
93
108
|
end
|
94
109
|
|
95
110
|
it 'finds values as methods' do
|
@@ -104,7 +119,7 @@ describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
|
104
119
|
expect(value).to eq '100'
|
105
120
|
end
|
106
121
|
|
107
|
-
[1, 1.2, :a_symbol
|
122
|
+
[1, 1.2, :a_symbol].each do |val|
|
108
123
|
it "calls to_s to format the value of type #{val.class}" do
|
109
124
|
value = format_attribute double(foo: val), :foo
|
110
125
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'active_admin/view_helpers/fields_for'
|
2
2
|
|
3
|
-
describe ActiveAdmin::ViewHelpers::FormHelper, ".fields_for" do
|
3
|
+
RSpec.describe ActiveAdmin::ViewHelpers::FormHelper, ".fields_for" do
|
4
4
|
include ActiveAdmin::ViewHelpers::FormHelper
|
5
5
|
|
6
6
|
it "should skip :action, :controller and :commit" do
|