activeadmin 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -1
- data/.travis.yml +1 -1
- data/.yardopts +2 -3
- data/CHANGELOG.md +180 -36
- data/CONTRIBUTING.md +12 -2
- data/Gemfile +9 -3
- data/README.rdoc +38 -65
- data/Rakefile +1 -3
- data/activeadmin.gemspec +10 -11
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +1 -1
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +2 -1
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +6 -1
- data/app/assets/stylesheets/active_admin/_base.css.scss +29 -34
- data/app/assets/stylesheets/active_admin/_forms.css.scss +65 -62
- data/app/assets/stylesheets/active_admin/_header.css.scss +57 -45
- data/app/assets/stylesheets/active_admin/_typography.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +5 -5
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +20 -20
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +16 -16
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +25 -23
- data/app/assets/stylesheets/active_admin/components/_grid.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_panels.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +27 -27
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +4 -7
- data/app/assets/stylesheets/active_admin/mixins/_reset.css.scss +5 -5
- data/app/assets/stylesheets/active_admin/mixins/_rounded.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +6 -6
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +8 -8
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -8
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +5 -5
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +13 -13
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +14 -14
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +8 -1
- data/app/views/active_admin/resource/index.csv.erb +3 -3
- data/app/views/layouts/active_admin_logged_out.html.erb +5 -3
- data/config/locales/bg.yml +101 -0
- data/{lib/active_admin → config}/locales/ca.yml +24 -7
- data/{lib/active_admin → config}/locales/cs.yml +34 -12
- data/{lib/active_admin → config}/locales/da.yml +29 -7
- data/config/locales/de-CH.yml +117 -0
- data/{lib/active_admin → config}/locales/de.yml +19 -9
- data/config/locales/en-GB.yml +90 -0
- data/{lib/active_admin → config}/locales/en.yml +16 -6
- data/config/locales/es.yml +106 -0
- data/{lib/active_admin/locales/es.yml → config/locales/es_MX.yml} +14 -8
- data/{lib/active_admin → config}/locales/fr.yml +14 -6
- data/{lib/active_admin → config}/locales/he.yml +16 -6
- data/{lib/active_admin → config}/locales/hr.yml +14 -6
- data/{lib/active_admin → config}/locales/hu.yml +31 -6
- data/{lib/active_admin → config}/locales/it.yml +14 -6
- data/{lib/active_admin → config}/locales/ja.yml +32 -7
- data/{lib/active_admin → config}/locales/ko.yml +14 -6
- data/{lib/active_admin → config}/locales/lt.yml +15 -6
- data/{lib/active_admin → config}/locales/lv.yml +14 -6
- data/{lib/active_admin → config}/locales/nl.yml +14 -6
- data/{lib/active_admin → config}/locales/no-NB.yml +14 -6
- data/{lib/active_admin → config}/locales/pl.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-BR.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-PT.yml +14 -6
- data/{lib/active_admin → config}/locales/ro.yml +32 -7
- data/{lib/active_admin → config}/locales/ru.yml +30 -8
- data/{lib/active_admin → config}/locales/sv-SE.yml +14 -6
- data/{lib/active_admin → config}/locales/tr.yml +15 -6
- data/config/locales/uk.yml +100 -0
- data/{lib/active_admin → config}/locales/vi.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-CN.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-TW.yml +15 -6
- data/docs/0-installation.md +22 -18
- data/docs/1-general-configuration.md +1 -1
- data/docs/10-custom-pages.md +3 -3
- data/docs/11-decorators.md +18 -2
- data/docs/12-arbre-components.md +53 -54
- data/docs/13-authorization-adapter.md +31 -10
- data/docs/2-resource-customization.md +16 -1
- data/docs/3-index-pages.md +13 -1
- data/docs/3-index-pages/create-an-index.md +4 -4
- data/docs/3-index-pages/index-as-block.md +1 -1
- data/docs/3-index-pages/index-as-blog.md +1 -1
- data/docs/3-index-pages/index-as-grid.md +1 -1
- data/docs/4-csv-format.md +4 -4
- data/docs/5-forms.md +46 -3
- data/docs/{6-show-screens.md → 6-show-pages.md} +3 -3
- data/docs/8-custom-actions.md +3 -3
- data/docs/9-batch-actions.md +9 -1
- data/features/action_item.feature +6 -6
- data/features/authorization_cancan.feature +1 -1
- data/features/belongs_to.feature +3 -3
- data/features/breadcrumb.feature +2 -2
- data/features/comments/commenting.feature +7 -5
- data/features/dashboard.feature +0 -51
- data/features/favicon.feature +20 -0
- data/features/global_navigation.feature +0 -1
- data/features/index/batch_actions.feature +12 -11
- data/features/index/filters.feature +6 -6
- data/features/index/format_as_csv.feature +4 -5
- data/features/index/index_as_blog.feature +20 -1
- data/features/index/index_as_table.feature +1 -1
- data/features/index/index_blank_slate.feature +3 -3
- data/features/index/index_parameters.feature +4 -10
- data/features/index/index_scope_to.feature +24 -0
- data/features/index/index_scopes.feature +17 -5
- data/features/index/pagination.feature +15 -0
- data/features/registering_pages.feature +1 -1
- data/features/registering_resources.feature +2 -2
- data/features/show/default_content.feature +3 -3
- data/features/sidebar_sections.feature +3 -3
- data/features/specifying_actions.feature +1 -1
- data/features/step_definitions/additional_web_steps.rb +3 -16
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/attribute_steps.rb +4 -4
- data/features/step_definitions/batch_action_steps.rb +25 -74
- data/features/step_definitions/breadcrumb_steps.rb +1 -3
- data/features/step_definitions/comment_steps.rb +0 -1
- data/features/step_definitions/configuration_steps.rb +53 -69
- data/features/step_definitions/dashboard_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +17 -33
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +10 -14
- data/features/step_definitions/index_scope_steps.rb +9 -25
- data/features/step_definitions/index_views_steps.rb +1 -1
- data/features/step_definitions/sidebar_steps.rb +2 -1
- data/features/step_definitions/site_title_steps.rb +1 -1
- data/features/step_definitions/table_steps.rb +6 -1
- data/features/step_definitions/user_steps.rb +23 -38
- data/features/step_definitions/web_steps.rb +18 -147
- data/features/support/env.rb +13 -34
- data/features/support/paths.rb +2 -0
- data/features/users/logging_in.feature +2 -2
- data/features/users/logging_out.feature +0 -12
- data/features/users/resetting_password.feature +1 -1
- data/lib/active_admin.rb +4 -17
- data/lib/active_admin/abstract_view_factory.rb +1 -1
- data/lib/active_admin/application.rb +19 -28
- data/lib/active_admin/asset_registration.rb +7 -25
- data/lib/active_admin/authorization_adapter.rb +9 -5
- data/lib/active_admin/base_controller.rb +2 -2
- data/lib/active_admin/base_controller/authorization.rb +25 -27
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -3
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +2 -2
- data/lib/active_admin/comments.rb +32 -38
- data/lib/active_admin/comments/comment.rb +6 -8
- data/lib/active_admin/comments/views.rb +0 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +27 -38
- data/lib/active_admin/csv_builder.rb +4 -6
- data/lib/active_admin/dependency_checker.rb +4 -0
- data/lib/active_admin/deprecation.rb +3 -3
- data/lib/active_admin/dsl.rb +5 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters.rb +2 -1
- data/lib/active_admin/filters/forms.rb +36 -43
- data/lib/active_admin/filters/formtastic_addons.rb +45 -0
- data/lib/active_admin/filters/resource_extension.rb +9 -1
- data/lib/active_admin/form_builder.rb +30 -19
- data/lib/active_admin/helpers/optional_display.rb +11 -13
- data/lib/active_admin/helpers/settings.rb +50 -8
- data/lib/active_admin/inputs/filter_base.rb +5 -18
- data/lib/active_admin/inputs/filter_base/search_method_select.rb +73 -0
- data/lib/active_admin/inputs/filter_boolean_input.rb +6 -14
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +1 -1
- data/lib/active_admin/inputs/filter_numeric_input.rb +2 -47
- data/lib/active_admin/inputs/filter_select_input.rb +32 -10
- data/lib/active_admin/inputs/filter_string_input.rb +12 -14
- data/lib/active_admin/namespace.rb +8 -40
- data/lib/active_admin/page.rb +2 -2
- data/lib/active_admin/page_dsl.rb +1 -1
- data/lib/active_admin/reloader.rb +3 -3
- data/lib/active_admin/resource.rb +16 -23
- data/lib/active_admin/resource/belongs_to.rb +8 -5
- data/lib/active_admin/resource/menu.rb +10 -23
- data/lib/active_admin/resource/naming.rb +3 -3
- data/lib/active_admin/resource/page_presenters.rb +2 -2
- data/lib/active_admin/resource/routes.rb +74 -21
- data/lib/active_admin/resource/scope_to.rb +74 -0
- data/lib/active_admin/resource/scopes.rb +8 -4
- data/lib/active_admin/resource_collection.rb +20 -66
- data/lib/active_admin/resource_controller.rb +12 -16
- data/lib/active_admin/resource_controller/data_access.rb +19 -22
- data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -2
- data/lib/active_admin/resource_controller/scoping.rb +4 -9
- data/lib/active_admin/resource_dsl.rb +5 -32
- data/lib/active_admin/router.rb +34 -47
- data/lib/active_admin/scope.rb +5 -3
- data/lib/active_admin/sidebar_section.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +8 -8
- data/lib/active_admin/view_helpers/display_helper.rb +15 -6
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +2 -2
- data/lib/active_admin/view_helpers/form_helper.rb +6 -1
- data/lib/active_admin/view_helpers/icon_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -5
- data/lib/active_admin/view_helpers/title_helper.rb +1 -1
- data/lib/active_admin/views/components/action_list_popover.rb +6 -6
- data/lib/active_admin/views/components/attributes_table.rb +9 -12
- data/lib/active_admin/views/components/blank_slate.rb +4 -4
- data/lib/active_admin/views/components/columns.rb +1 -1
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +20 -12
- data/lib/active_admin/views/components/panel.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +2 -1
- data/lib/active_admin/views/components/sidebar_section.rb +1 -1
- data/lib/active_admin/views/components/status_tag.rb +1 -1
- data/lib/active_admin/views/header.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +16 -3
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +8 -3
- data/lib/active_admin/views/pages/form.rb +2 -2
- data/lib/active_admin/views/pages/index.rb +19 -17
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -1
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +1 -13
- data/lib/generators/active_admin/devise/devise_generator.rb +22 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -5
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +40 -19
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +18 -18
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb +19 -0
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
- data/script/use_rails +1 -1
- data/spec/integration/memory_spec.rb +3 -2
- data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +4 -4
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +1 -1
- data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +2 -2
- data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +4 -4
- data/spec/javascripts/compiled/jquery.aa.popover-spec.js +1 -1
- data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +2 -2
- data/spec/spec_helper.rb +16 -6
- data/spec/spec_helper_without_rails.rb +2 -0
- data/spec/support/deferred_garbage_collection.rb +19 -0
- data/spec/support/jslint.yml +1 -1
- data/spec/support/rails_template.rb +29 -27
- data/spec/support/templates/admin/stores.rb +5 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +7 -7
- data/spec/unit/active_admin_spec.rb +0 -14
- data/spec/unit/application_spec.rb +16 -17
- data/spec/unit/asset_registration_spec.rb +21 -8
- data/spec/unit/authorization/authorization_adapter_spec.rb +3 -3
- data/spec/unit/authorization/controller_authorization_spec.rb +16 -24
- data/spec/unit/batch_actions/resource_spec.rb +11 -11
- data/spec/unit/belongs_to_spec.rb +1 -1
- data/spec/unit/cancan_adapter_spec.rb +11 -3
- data/spec/unit/comments_spec.rb +10 -28
- data/spec/unit/controller_filters_spec.rb +22 -24
- data/spec/unit/csv_builder_spec.rb +3 -3
- data/spec/unit/devise_spec.rb +10 -10
- data/spec/unit/filters/filter_form_builder_spec.rb +140 -45
- data/spec/unit/filters/resource_spec.rb +20 -19
- data/spec/unit/form_builder_spec.rb +122 -70
- data/spec/unit/menu_item_spec.rb +3 -3
- data/spec/unit/namespace/authorization_spec.rb +4 -8
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/namespace/register_resource_spec.rb +12 -7
- data/spec/unit/namespace_spec.rb +4 -10
- data/spec/unit/page_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +9 -0
- data/spec/unit/resource/pagination_spec.rb +2 -2
- data/spec/unit/resource/routes_spec.rb +73 -0
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +95 -43
- data/spec/unit/resource_registration_spec.rb +3 -12
- data/spec/unit/resource_spec.rb +41 -48
- data/spec/unit/routing_spec.rb +10 -64
- data/spec/unit/scope_spec.rb +19 -0
- data/spec/unit/settings_spec.rb +88 -0
- data/spec/unit/view_factory_spec.rb +1 -0
- data/spec/unit/{breadcrumbs_spec.rb → view_helpers/breadcrumbs_spec.rb} +16 -7
- data/spec/unit/view_helpers/display_name_spec.rb +41 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +36 -2
- data/spec/unit/views/components/attributes_table_spec.rb +17 -9
- data/spec/unit/views/components/batch_action_popover_spec.rb +4 -4
- data/spec/unit/views/components/index_list_spec.rb +2 -2
- data/spec/unit/views/components/paginated_collection_spec.rb +42 -0
- data/spec/unit/views/components/panel_spec.rb +8 -0
- data/spec/unit/views/components/site_title_spec.rb +2 -2
- data/spec/unit/views/components/table_for_spec.rb +4 -4
- data/spec/unit/views/pages/form_spec.rb +35 -0
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +10 -10
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -1
- metadata +117 -106
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +0 -5
- data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
- data/lib/active_admin/dashboards.rb +0 -68
- data/lib/active_admin/dashboards/dashboard_controller.rb +0 -50
- data/lib/active_admin/dashboards/section.rb +0 -34
- data/lib/active_admin/locales/bg.yml +0 -77
- data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +0 -17
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +0 -26
- data/spec/unit/base_controller_spec.rb +0 -6
- data/spec/unit/dashboard_controller_spec.rb +0 -76
- data/spec/unit/dashboard_section_spec.rb +0 -56
- data/spec/unit/dashboards_spec.rb +0 -59
- data/spec/unit/display_name_spec.rb +0 -29
data/spec/unit/page_spec.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
module ActiveAdmin
|
|
@@ -74,6 +76,13 @@ module ActiveAdmin
|
|
|
74
76
|
end
|
|
75
77
|
end
|
|
76
78
|
|
|
79
|
+
describe "plural label with not default locale" do
|
|
80
|
+
it "should return the titleized plural version defined by i18n with custom :count if available" do
|
|
81
|
+
config.resource_name.should_receive(:translate).at_least(:once).and_return "Категории"
|
|
82
|
+
config.plural_resource_label(:count => 3).should == "Категории"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
77
86
|
context "when the :as option is given" do
|
|
78
87
|
describe "singular label" do
|
|
79
88
|
it "should translate the custom name" do
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module ActiveAdmin
|
|
4
4
|
describe Resource, "Pagination" do
|
|
@@ -28,7 +28,7 @@ module ActiveAdmin
|
|
|
28
28
|
namespace.should_receive(:default_per_page).and_return(5)
|
|
29
29
|
config.per_page.should == 5
|
|
30
30
|
end
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
it "should be settable" do
|
|
33
33
|
config.per_page = 5
|
|
34
34
|
config.per_page.should == 5
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module ActiveAdmin
|
|
4
|
+
describe Resource::Routes do
|
|
5
|
+
before { load_defaults! }
|
|
6
|
+
|
|
7
|
+
describe "route names" do
|
|
8
|
+
context "when in the admin namespace" do
|
|
9
|
+
let!(:config) { ActiveAdmin.register Category }
|
|
10
|
+
let(:category) { Category.new { |c| c.id = 123 } }
|
|
11
|
+
|
|
12
|
+
it "should return the route prefix" do
|
|
13
|
+
config.route_prefix.should eq 'admin'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should return the route collection path" do
|
|
17
|
+
config.route_collection_path.should eq '/admin/categories'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return the route instance path" do
|
|
21
|
+
config.route_instance_path(category).should eq '/admin/categories/123'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "when in the root namespace" do
|
|
26
|
+
let!(:config) { ActiveAdmin.register Category, :namespace => false }
|
|
27
|
+
it "should have a nil route_prefix" do
|
|
28
|
+
config.route_prefix.should be_nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should generate a correct route" do
|
|
32
|
+
reload_routes!
|
|
33
|
+
config.route_collection_path.should == "/categories"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "when registering a plural resource" do
|
|
38
|
+
class ::News; def self.has_many(*); end end
|
|
39
|
+
let!(:config) { ActiveAdmin.register News }
|
|
40
|
+
before{ reload_routes! }
|
|
41
|
+
|
|
42
|
+
it "should return the plural route with _index" do
|
|
43
|
+
config.route_collection_path.should == "/admin/news"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "when the resource belongs to another resource" do
|
|
48
|
+
let! :config do
|
|
49
|
+
ActiveAdmin.register Post do
|
|
50
|
+
belongs_to :category
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
let :post do
|
|
55
|
+
Post.new do |p|
|
|
56
|
+
p.id = 3
|
|
57
|
+
p.category = Category.new{ |c| c.id = 1 }
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
before{ reload_routes! }
|
|
62
|
+
|
|
63
|
+
it "should nest the collection path" do
|
|
64
|
+
config.route_collection_path(category_id: 1).should == "/admin/categories/1/posts"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should nest the instance path" do
|
|
68
|
+
config.route_instance_path(post).should == "/admin/categories/1/posts/3"
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -4,27 +4,29 @@ require 'active_admin/resource_collection'
|
|
|
4
4
|
include ActiveAdmin
|
|
5
5
|
|
|
6
6
|
describe ActiveAdmin::ResourceCollection do
|
|
7
|
+
let(:application) { ActiveAdmin::Application.new }
|
|
8
|
+
let(:namespace) { ActiveAdmin::Namespace.new(application, :admin) }
|
|
7
9
|
|
|
8
10
|
let(:collection){ ResourceCollection.new }
|
|
9
11
|
|
|
10
12
|
it "should have no resources when new" do
|
|
11
|
-
collection.
|
|
13
|
+
collection.should be_empty
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it "should be enumerable" do
|
|
15
|
-
resource = mock
|
|
17
|
+
resource = mock :resource_name => "MyResource"
|
|
16
18
|
collection.add(resource)
|
|
17
|
-
collection.each{|r| r.should == resource }
|
|
19
|
+
collection.each{ |r| r.should == resource }
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
it "should return the available keys" do
|
|
21
|
-
resource = mock
|
|
23
|
+
resource = mock :resource_name => "MyResource"
|
|
22
24
|
collection.add resource
|
|
23
25
|
collection.keys.should == [resource.resource_name]
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
describe "adding a new resource" do
|
|
27
|
-
let(:resource){ mock
|
|
29
|
+
let(:resource){ mock :resource_name => "MyResource" }
|
|
28
30
|
|
|
29
31
|
it "should return the resource" do
|
|
30
32
|
collection.add(resource).should == resource
|
|
@@ -32,69 +34,119 @@ describe ActiveAdmin::ResourceCollection do
|
|
|
32
34
|
|
|
33
35
|
it "should add a new resource" do
|
|
34
36
|
collection.add(resource)
|
|
35
|
-
collection.
|
|
37
|
+
collection.values.should == [resource]
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
it "should be available by name" do
|
|
39
41
|
collection.add(resource)
|
|
40
|
-
collection
|
|
42
|
+
collection[resource.resource_name].should == resource
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
describe "adding a new resource when the key already exists" do
|
|
45
|
-
let(:
|
|
46
|
-
let(:resource){ mock(:resource_name => "MyResource") }
|
|
47
|
+
let(:resource){ mock :resource_name => "MyResource" }
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
collection.add(
|
|
49
|
+
it "should not add a new resource" do
|
|
50
|
+
collection.add(resource); collection.add(resource)
|
|
51
|
+
collection.values.should == [resource]
|
|
50
52
|
end
|
|
53
|
+
end
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
describe "#[]" do
|
|
56
|
+
let(:resource) { Resource.new(namespace, resource_class) }
|
|
57
|
+
let(:inherited_resource) { Resource.new(namespace, inherited_resource_class) }
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
let(:resource_class) { User }
|
|
60
|
+
let(:inherited_resource_class) { Publisher }
|
|
61
|
+
let(:unregistered_class) { Category }
|
|
62
|
+
|
|
63
|
+
context "with resources" do
|
|
64
|
+
before do
|
|
65
|
+
collection.add resource
|
|
66
|
+
collection.add inherited_resource
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should find resource by class" do
|
|
70
|
+
collection[resource_class].should == resource
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should find resource by class string" do
|
|
74
|
+
collection[resource_class.to_s].should == resource
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should find inherited resource by class" do
|
|
78
|
+
collection[inherited_resource_class].should == inherited_resource
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should find inherited resource by class string" do
|
|
82
|
+
collection[inherited_resource_class.to_s].should == inherited_resource
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should return nil when the resource_class does not respond to base_class and it is not in the collection" do
|
|
86
|
+
collection[mock].should == nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should return nil when a resource class is NOT in the collection" do
|
|
90
|
+
collection[unregistered_class].should == nil
|
|
91
|
+
end
|
|
59
92
|
end
|
|
60
|
-
end
|
|
61
93
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
94
|
+
context "without inherited resources" do
|
|
95
|
+
before do
|
|
96
|
+
collection.add resource
|
|
97
|
+
end
|
|
65
98
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
collection.add(resource)
|
|
70
|
-
}.should raise_error(ActiveAdmin::ResourceMismatchError)
|
|
99
|
+
it "should find resource by inherited class" do
|
|
100
|
+
collection[inherited_resource_class].should == resource
|
|
101
|
+
end
|
|
71
102
|
end
|
|
72
103
|
|
|
73
|
-
|
|
104
|
+
context "with a renamed resource" do
|
|
105
|
+
let(:renamed_resource) { Resource.new(namespace, resource_class, :as => name) }
|
|
106
|
+
let(:name) { "Administrators" }
|
|
74
107
|
|
|
75
|
-
|
|
108
|
+
before do
|
|
109
|
+
collection.add renamed_resource
|
|
110
|
+
end
|
|
76
111
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let(:resource){ mock(:resource_name => "MyResource", :resource_class => resource_class) }
|
|
112
|
+
it "should find resource by class" do
|
|
113
|
+
collection[resource_class].should == renamed_resource
|
|
114
|
+
end
|
|
81
115
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
end
|
|
116
|
+
it "should find resource by class string" do
|
|
117
|
+
collection[resource_class.to_s].should == renamed_resource
|
|
118
|
+
end
|
|
86
119
|
|
|
87
|
-
|
|
88
|
-
|
|
120
|
+
it "should find resource by name" do
|
|
121
|
+
collection[name].should == renamed_resource
|
|
122
|
+
end
|
|
89
123
|
end
|
|
124
|
+
end
|
|
90
125
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
126
|
+
describe ".add" do
|
|
127
|
+
let(:resource) { Resource.new(namespace, Category) }
|
|
128
|
+
let(:resource_renamed) { Resource.new(namespace, Category, as: "Subcategory") }
|
|
129
|
+
|
|
130
|
+
context "when renamed resource is added first" do
|
|
131
|
+
before do
|
|
132
|
+
collection.add(resource_renamed)
|
|
133
|
+
collection.add(resource)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "contains both resources" do
|
|
137
|
+
collection.values.should include(resource, resource_renamed)
|
|
138
|
+
end
|
|
94
139
|
end
|
|
95
140
|
|
|
96
|
-
|
|
97
|
-
|
|
141
|
+
context "when resource is added first" do
|
|
142
|
+
before do
|
|
143
|
+
collection.add(resource)
|
|
144
|
+
collection.add(resource_renamed)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "contains both resources" do
|
|
148
|
+
collection.values.should include(resource, resource_renamed)
|
|
149
|
+
end
|
|
98
150
|
end
|
|
99
151
|
end
|
|
100
152
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "Registering an object to administer" do
|
|
4
|
-
|
|
4
|
+
application = ActiveAdmin::Application.new
|
|
5
5
|
|
|
6
6
|
context "with no configuration" do
|
|
7
|
-
|
|
7
|
+
namespace = ActiveAdmin::Namespace.new(application, :admin)
|
|
8
8
|
it "should call register on the namespace" do
|
|
9
9
|
application.namespaces[namespace.name] = namespace
|
|
10
10
|
namespace.should_receive(:register)
|
|
@@ -51,15 +51,6 @@ describe "Registering an object to administer" do
|
|
|
51
51
|
config_1.should == config_2
|
|
52
52
|
config_1.filters.size.should == 2
|
|
53
53
|
end
|
|
54
|
-
|
|
55
|
-
context "with different resource classes" do
|
|
56
|
-
it "should raise an ActiveAdmin::ResourceMismatch" do
|
|
57
|
-
lambda {
|
|
58
|
-
ActiveAdmin.register Category
|
|
59
|
-
ActiveAdmin.register Post, :as => "Category"
|
|
60
|
-
}.should raise_error(ActiveAdmin::ResourceMismatchError)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
54
|
end
|
|
64
55
|
|
|
65
56
|
end
|
data/spec/unit/resource_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require File.expand_path('config_shared_examples', File.dirname(__FILE__))
|
|
3
3
|
|
|
4
4
|
module ActiveAdmin
|
|
@@ -87,45 +87,13 @@ module ActiveAdmin
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "should set the target menu to the belongs to target" do
|
|
90
|
-
config.
|
|
90
|
+
config.navigation_menu_name.should == ActiveAdmin::DEFAULT_MENU
|
|
91
91
|
config.belongs_to :posts
|
|
92
|
-
config.
|
|
92
|
+
config.navigation_menu_name.should == :posts
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
describe "route names" do
|
|
98
|
-
it "should return the route prefix" do
|
|
99
|
-
config.route_prefix.should == "admin"
|
|
100
|
-
end
|
|
101
|
-
it "should return the route collection path" do
|
|
102
|
-
config.route_collection_path.should == "/admin/categories"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context "when in the root namespace" do
|
|
106
|
-
let(:config){ application.register Category, :namespace => false}
|
|
107
|
-
it "should have a nil route_prefix" do
|
|
108
|
-
config.route_prefix.should == nil
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "should generate a correct route" do
|
|
112
|
-
config
|
|
113
|
-
reload_routes!
|
|
114
|
-
config.route_collection_path.should == "/categories"
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
context "when registering a plural resource" do
|
|
119
|
-
class ::News; def self.has_many(*); end end
|
|
120
|
-
|
|
121
|
-
it "should return the plurali route with _index" do
|
|
122
|
-
config = application.register News
|
|
123
|
-
reload_routes!
|
|
124
|
-
config.route_collection_path.should == "/admin/news"
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
97
|
describe "scoping" do
|
|
130
98
|
context "when using a block" do
|
|
131
99
|
before do
|
|
@@ -155,19 +123,6 @@ module ActiveAdmin
|
|
|
155
123
|
end
|
|
156
124
|
end
|
|
157
125
|
|
|
158
|
-
context "when not using a block or symbol" do
|
|
159
|
-
before do
|
|
160
|
-
@resource = application.register Category do
|
|
161
|
-
scope_to "Some string"
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
it "should raise and exception" do
|
|
165
|
-
lambda {
|
|
166
|
-
@resource.controller.new.send(:begin_of_association_chain)
|
|
167
|
-
}.should raise_error(ArgumentError)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
|
|
171
126
|
describe "getting the method for the association chain" do
|
|
172
127
|
context "when a simple registration" do
|
|
173
128
|
before do
|
|
@@ -229,6 +184,13 @@ module ActiveAdmin
|
|
|
229
184
|
config.scope :published
|
|
230
185
|
config.get_scope_by_id(:published).name.should == "Published"
|
|
231
186
|
end
|
|
187
|
+
|
|
188
|
+
it "should retrieve the default scope by proc" do
|
|
189
|
+
config.scope :published, :default => proc{ true }
|
|
190
|
+
config.scope :all
|
|
191
|
+
config.default_scope.name.should == "Published"
|
|
192
|
+
end
|
|
193
|
+
|
|
232
194
|
end
|
|
233
195
|
|
|
234
196
|
describe "#csv_builder" do
|
|
@@ -246,5 +208,36 @@ module ActiveAdmin
|
|
|
246
208
|
end
|
|
247
209
|
end
|
|
248
210
|
end
|
|
211
|
+
|
|
212
|
+
describe '#find_resource' do
|
|
213
|
+
let(:resource) { namespace.register(Post) }
|
|
214
|
+
let(:post) { stub }
|
|
215
|
+
before do
|
|
216
|
+
Post.stub(:where).with('id' => '12345').and_return { [post] }
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'can find the resource' do
|
|
220
|
+
resource.find_resource('12345').should == post
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
context 'with a decorator' do
|
|
224
|
+
let(:resource) { namespace.register(Post) { decorate_with PostDecorator } }
|
|
225
|
+
it 'decorates the resource' do
|
|
226
|
+
resource.find_resource('12345').should == PostDecorator.new(post)
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
context 'when using a nonstandard primary key' do
|
|
231
|
+
let(:different_post) { stub }
|
|
232
|
+
before do
|
|
233
|
+
Post.stub(:primary_key).and_return 'something_else'
|
|
234
|
+
Post.stub(:where).with('something_else' => '55555').and_return { [different_post] }
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it 'can find the post by the custom primary key' do
|
|
238
|
+
resource.find_resource('55555').should == different_post
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
249
242
|
end
|
|
250
243
|
end
|