activeadmin 0.6.0 → 0.6.1
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.
- 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/features/support/env.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
-
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
-
# newer version of cucumber-rails. Consider adding your own code to a new file
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
5
|
# files.
|
6
6
|
|
@@ -43,7 +43,7 @@ require 'capybara/session'
|
|
43
43
|
# steps to use the XPath syntax.
|
44
44
|
Capybara.default_selector = :css
|
45
45
|
|
46
|
-
# If you set this to false, any error raised from within your app will bubble
|
46
|
+
# If you set this to false, any error raised from within your app will bubble
|
47
47
|
# up to your step definition and out to cucumber unless you catch it somewhere
|
48
48
|
# on the way. You can make Rails rescue errors and render error pages on a
|
49
49
|
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
@@ -55,15 +55,15 @@ Capybara.default_selector = :css
|
|
55
55
|
ActionController::Base.allow_rescue = false
|
56
56
|
|
57
57
|
# If you set this to true, each scenario will run in a database transaction.
|
58
|
-
# You can still turn off transactions on a per-scenario basis, simply tagging
|
58
|
+
# You can still turn off transactions on a per-scenario basis, simply tagging
|
59
59
|
# a feature or scenario with the @no-txn tag. If you are using Capybara,
|
60
60
|
# tagging with @culerity or @javascript will also turn transactions off.
|
61
61
|
#
|
62
62
|
# If you set this to false, transactions will be off for all scenarios,
|
63
63
|
# regardless of whether you use @no-txn or not.
|
64
64
|
#
|
65
|
-
# Beware that turning transactions off will leave data in your database
|
66
|
-
# after each scenario, which can lead to hard-to-debug failures in
|
65
|
+
# Beware that turning transactions off will leave data in your database
|
66
|
+
# after each scenario, which can lead to hard-to-debug failures in
|
67
67
|
# subsequent scenarios. If you do this, we recommend you create a Before
|
68
68
|
# block that will explicitly put your database in a known state.
|
69
69
|
Cucumber::Rails::World.use_transactional_fixtures = false
|
@@ -78,34 +78,11 @@ if defined?(ActiveRecord::Base)
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def add_default_dashboard
|
82
|
-
begin
|
83
|
-
dashboard_file = ENV['RAILS_ROOT'] + "/app/admin/dashboard.rb"
|
84
|
-
dashboard_template = File.expand_path('../../../lib/generators/active_admin/install/templates/dashboard.rb', __FILE__)
|
85
|
-
cmd = "cp #{dashboard_template} #{dashboard_file}"
|
86
|
-
system cmd
|
87
|
-
rescue
|
88
|
-
p $!
|
89
|
-
raise $!
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def delete_default_dashboard
|
94
|
-
begin
|
95
|
-
dashboard_file = ENV['RAILS_ROOT'] + "/app/admin/dashboard.rb"
|
96
|
-
File.delete(dashboard_file) if File.exists?(dashboard_file)
|
97
|
-
rescue
|
98
|
-
p $!
|
99
|
-
raise $!
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
81
|
# Warden helpers to speed up login
|
104
82
|
# See https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara
|
105
83
|
include Warden::Test::Helpers
|
106
84
|
|
107
85
|
After do
|
108
|
-
add_default_dashboard
|
109
86
|
Warden.test_reset!
|
110
87
|
|
111
88
|
# Reset back to the default auth adapter
|
@@ -113,12 +90,7 @@ After do
|
|
113
90
|
authorization_adapter = ActiveAdmin::AuthorizationAdapter
|
114
91
|
end
|
115
92
|
|
116
|
-
Before '@dashboard' do
|
117
|
-
delete_default_dashboard
|
118
|
-
end
|
119
|
-
|
120
93
|
Before do
|
121
|
-
add_default_dashboard
|
122
94
|
|
123
95
|
begin
|
124
96
|
# We are caching classes, but need to manually clear references to
|
@@ -137,3 +109,10 @@ end
|
|
137
109
|
# improve the performance of the specs suite by not logging anything
|
138
110
|
# see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
|
139
111
|
Rails.logger.level = 4
|
112
|
+
|
113
|
+
# Improves performance by forcing the garbage collector to run less often.
|
114
|
+
unless ENV['DEFER_GC'] == '0' || ENV['DEFER_GC'] == 'false'
|
115
|
+
require File.expand_path('../../../spec/support/deferred_garbage_collection', __FILE__)
|
116
|
+
Before { DeferredGarbageCollection.start }
|
117
|
+
After { DeferredGarbageCollection.reconsider }
|
118
|
+
end
|
data/features/support/paths.rb
CHANGED
@@ -14,6 +14,8 @@ module NavigationHelpers
|
|
14
14
|
"/admin"
|
15
15
|
when /the new post page/
|
16
16
|
"/admin/posts/new"
|
17
|
+
when /the login page/
|
18
|
+
"/admin/login"
|
17
19
|
when /the admin password reset form with reset password token "([^"]*)"/
|
18
20
|
"/admin/password/edit?reset_password_token=#{$1}"
|
19
21
|
|
@@ -16,8 +16,8 @@ Feature: User Logging In
|
|
16
16
|
And I fill in "Password" with "password"
|
17
17
|
And I press "Login"
|
18
18
|
Then I should be on the the dashboard
|
19
|
-
And I should see "Logout"
|
20
|
-
And I should see "admin@example.com"
|
19
|
+
And I should see the element "a[href='/admin/logout' ]:contains('Logout')"
|
20
|
+
And I should see the element "a[href='/admin/admin_users/1']:contains('admin@example.com')"
|
21
21
|
|
22
22
|
Scenario: Attempting to log in with an incorrect email address
|
23
23
|
When I fill in "Email" with "not-an-admin@example.com"
|
@@ -11,15 +11,3 @@ Feature: User Logging out
|
|
11
11
|
When I go to the dashboard
|
12
12
|
And I follow "Logout"
|
13
13
|
Then I should see "Login"
|
14
|
-
|
15
|
-
Scenario: With logout_link_path set to :logout_path (the symbol)
|
16
|
-
Given a configuration of:
|
17
|
-
"""
|
18
|
-
ActiveAdmin.setup do |config|
|
19
|
-
config.logout_link_path = :logout_path
|
20
|
-
end
|
21
|
-
"""
|
22
|
-
And I am logged in
|
23
|
-
When I go to the dashboard
|
24
|
-
And I follow "Logout"
|
25
|
-
Then I should see "Login"
|
data/lib/active_admin.rb
CHANGED
@@ -7,7 +7,7 @@ require 'sass'
|
|
7
7
|
require 'inherited_resources'
|
8
8
|
require 'jquery-rails'
|
9
9
|
require 'arbre'
|
10
|
-
require 'active_admin/dependency_checker'
|
10
|
+
require 'active_admin/dependency_checker'
|
11
11
|
require 'active_admin/sass/helpers'
|
12
12
|
require 'active_admin/engine'
|
13
13
|
|
@@ -19,13 +19,11 @@ module ActiveAdmin
|
|
19
19
|
autoload :Authorization, 'active_admin/authorization_adapter'
|
20
20
|
autoload :AuthorizationAdapter, 'active_admin/authorization_adapter'
|
21
21
|
autoload :Breadcrumbs, 'active_admin/breadcrumbs'
|
22
|
-
autoload :CanCanAdapter, 'active_admin/cancan_adapter'
|
23
22
|
autoload :Callbacks, 'active_admin/callbacks'
|
24
23
|
autoload :Component, 'active_admin/component'
|
25
24
|
autoload :BaseController, 'active_admin/base_controller'
|
26
25
|
autoload :ControllerAction, 'active_admin/controller_action'
|
27
26
|
autoload :CSVBuilder, 'active_admin/csv_builder'
|
28
|
-
autoload :Dashboards, 'active_admin/dashboards'
|
29
27
|
autoload :Deprecation, 'active_admin/deprecation'
|
30
28
|
autoload :Devise, 'active_admin/devise'
|
31
29
|
autoload :DSL, 'active_admin/dsl'
|
@@ -53,14 +51,6 @@ module ActiveAdmin
|
|
53
51
|
autoload :ViewHelpers, 'active_admin/view_helpers'
|
54
52
|
autoload :Views, 'active_admin/views'
|
55
53
|
|
56
|
-
class Railtie < ::Rails::Railtie
|
57
|
-
config.after_initialize do
|
58
|
-
# Add load paths straight to I18n, so engines and application can overwrite it.
|
59
|
-
require 'active_support/i18n'
|
60
|
-
I18n.load_path.unshift *Dir[File.expand_path('../active_admin/locales/*.yml', __FILE__)]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
54
|
class << self
|
65
55
|
|
66
56
|
attr_accessor :application
|
@@ -88,12 +78,6 @@ module ActiveAdmin
|
|
88
78
|
DependencyChecker.rails_3_1? && Rails.application.config.try(:assets).try(:enabled)
|
89
79
|
end
|
90
80
|
|
91
|
-
# Migration MoveAdminNotesToComments generated with version 0.2.2 might reference
|
92
|
-
# to ActiveAdmin.default_namespace.
|
93
|
-
delegate :default_namespace, :to => :application
|
94
|
-
ActiveAdmin::Deprecation.deprecate self, :default_namespace,
|
95
|
-
"ActiveAdmin.default_namespace is deprecated. Please use ActiveAdmin.application.default_namespace"
|
96
|
-
|
97
81
|
# A callback is triggered each time (before) Active Admin loads the configuration files.
|
98
82
|
# In development mode, this will happen whenever the user changes files. In production
|
99
83
|
# it only happens on boot.
|
@@ -139,3 +123,6 @@ ActiveAdmin::DependencyChecker.check!
|
|
139
123
|
require 'active_admin/comments'
|
140
124
|
require 'active_admin/batch_actions'
|
141
125
|
require 'active_admin/filters'
|
126
|
+
|
127
|
+
# Load gem-specific code only if that gem is being used
|
128
|
+
require 'active_admin/cancan_adapter' if ActiveAdmin::DependencyChecker.cancan?
|
@@ -4,18 +4,9 @@ require 'active_admin/helpers/settings'
|
|
4
4
|
module ActiveAdmin
|
5
5
|
class Application
|
6
6
|
include Settings
|
7
|
+
include Settings::Inheritance
|
7
8
|
|
8
|
-
|
9
|
-
# so that they can be configured independantly.
|
10
|
-
def self.inheritable_setting(name, default)
|
11
|
-
Namespace.setting name, nil
|
12
|
-
setting name, default
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.deprecated_inheritable_setting(name, default)
|
16
|
-
Namespace.deprecated_setting name, nil
|
17
|
-
deprecated_setting name, default
|
18
|
-
end
|
9
|
+
settings_inherited_by Namespace
|
19
10
|
|
20
11
|
# The default namespace to put controllers and routes inside. Set this
|
21
12
|
# in config/initializers/active_admin.rb using:
|
@@ -24,8 +15,10 @@ module ActiveAdmin
|
|
24
15
|
#
|
25
16
|
setting :default_namespace, :admin
|
26
17
|
|
27
|
-
|
28
|
-
|
18
|
+
attr_reader :namespaces
|
19
|
+
def initialize
|
20
|
+
@namespaces = {}
|
21
|
+
end
|
29
22
|
|
30
23
|
# Load paths for admin configurations. Add folders to this load path
|
31
24
|
# to load up other resources for administration. External gems can
|
@@ -43,6 +36,9 @@ module ActiveAdmin
|
|
43
36
|
|
44
37
|
# Set the site title image displayed in the main layout (has precendence over :site_title)
|
45
38
|
inheritable_setting :site_title_image, ""
|
39
|
+
|
40
|
+
# Set a favicon
|
41
|
+
inheritable_setting :favicon, false
|
46
42
|
|
47
43
|
# The view factory to use to generate all the view classes. Take
|
48
44
|
# a look at ActiveAdmin::ViewFactory
|
@@ -72,7 +68,7 @@ module ActiveAdmin
|
|
72
68
|
inheritable_setting :root_to, 'dashboard#index'
|
73
69
|
|
74
70
|
# Default CSV options
|
75
|
-
inheritable_setting :csv_options, {}
|
71
|
+
inheritable_setting :csv_options, {:col_sep => ','}
|
76
72
|
|
77
73
|
# Default Download Links options
|
78
74
|
inheritable_setting :download_links, true
|
@@ -96,15 +92,7 @@ module ActiveAdmin
|
|
96
92
|
|
97
93
|
# == Deprecated Settings
|
98
94
|
|
99
|
-
#
|
100
|
-
deprecated_inheritable_setting :csv_column_separator, ','
|
101
|
-
|
102
|
-
# @deprecated The default sort order for index pages
|
103
|
-
deprecated_setting :default_sort_order, 'id_desc'
|
104
|
-
|
105
|
-
# DEPRECATED: This option is deprecated and will be removed. Use
|
106
|
-
# the #allow_comments_in option instead
|
107
|
-
attr_accessor :admin_notes
|
95
|
+
# (none currently)
|
108
96
|
|
109
97
|
include AssetRegistration
|
110
98
|
|
@@ -177,7 +165,7 @@ module ActiveAdmin
|
|
177
165
|
unless loaded?
|
178
166
|
ActiveAdmin::Event.dispatch BeforeLoadEvent, self # before_load hook
|
179
167
|
files.each{ |file| load file } # load files
|
180
|
-
namespace(
|
168
|
+
namespace(default_namespace) # init AA resources
|
181
169
|
ActiveAdmin::Event.dispatch AfterLoadEvent, self # after_load hook
|
182
170
|
@@loaded = true
|
183
171
|
end
|
@@ -198,13 +186,16 @@ module ActiveAdmin
|
|
198
186
|
router.apply(rails_router)
|
199
187
|
end
|
200
188
|
|
201
|
-
#
|
202
|
-
#
|
189
|
+
# Adds before, around and after filters to all controllers.
|
190
|
+
# Example usage:
|
203
191
|
# ActiveAdmin.before_filter :authenticate_admin!
|
204
192
|
#
|
205
|
-
%w(before_filter skip_before_filter after_filter around_filter).each do |name|
|
193
|
+
%w(before_filter skip_before_filter after_filter around_filter skip_filter).each do |name|
|
206
194
|
define_method name do |*args, &block|
|
207
|
-
BaseController.send
|
195
|
+
ActiveAdmin::BaseController.send name, *args, &block
|
196
|
+
ActiveAdmin::Devise::PasswordsController.send name, *args, &block
|
197
|
+
ActiveAdmin::Devise::SessionsController.send name, *args, &block
|
198
|
+
ActiveAdmin::Devise::UnlocksController.send name, *args, &block
|
208
199
|
end
|
209
200
|
end
|
210
201
|
|
@@ -1,47 +1,29 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
module AssetRegistration
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
def register_stylesheet(*args)
|
7
|
-
stylesheets << ActiveAdmin::Stylesheet.new(*args)
|
4
|
+
def register_stylesheet(path, options = {})
|
5
|
+
stylesheets[path] = options
|
8
6
|
end
|
9
7
|
|
10
8
|
def stylesheets
|
11
|
-
@stylesheets ||=
|
9
|
+
@stylesheets ||= {}
|
12
10
|
end
|
13
11
|
|
14
12
|
def clear_stylesheets!
|
15
|
-
@stylesheets =
|
13
|
+
@stylesheets = {}
|
16
14
|
end
|
17
15
|
|
18
|
-
|
19
|
-
# Javascripts
|
20
|
-
|
21
16
|
def register_javascript(name)
|
22
|
-
javascripts
|
17
|
+
javascripts.add name
|
23
18
|
end
|
24
19
|
|
25
20
|
def javascripts
|
26
|
-
@javascripts ||=
|
21
|
+
@javascripts ||= Set.new
|
27
22
|
end
|
28
23
|
|
29
24
|
def clear_javascripts!
|
30
|
-
@javascripts =
|
25
|
+
@javascripts = Set.new
|
31
26
|
end
|
32
27
|
|
33
28
|
end
|
34
|
-
|
35
|
-
# Wrapper class for stylesheet registration
|
36
|
-
class Stylesheet
|
37
|
-
|
38
|
-
attr_reader :options, :path
|
39
|
-
|
40
|
-
def initialize(*args)
|
41
|
-
@options = args.extract_options!
|
42
|
-
@path = args.first if args.first
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
29
|
end
|
@@ -43,9 +43,9 @@ module ActiveAdmin
|
|
43
43
|
# one of the `ActiveAdmin::Auth::*` symbols.
|
44
44
|
#
|
45
45
|
# @param [any] subject The subject the action is being performed on usually this
|
46
|
-
# is a model object. Note, that this is NOT always in instance, it can be
|
46
|
+
# is a model object. Note, that this is NOT always in instance, it can be
|
47
47
|
# the class of the subject also. For example, Active Admin uses the class
|
48
|
-
# of the resource to decide if the resource should be displayed in the
|
48
|
+
# of the resource to decide if the resource should be displayed in the
|
49
49
|
# global navigation. To deal with this nicely in a case statement, take
|
50
50
|
# a look at `#normalized(klasss)`
|
51
51
|
#
|
@@ -62,9 +62,13 @@ module ActiveAdmin
|
|
62
62
|
# @param [ActiveRecord::Relation] collection The collection the user is
|
63
63
|
# attempting to view.
|
64
64
|
#
|
65
|
-
# @
|
65
|
+
# @param [Symbol] action The name of the action to perform. Usually this will be
|
66
|
+
# one of the `ActiveAdmin::Auth::*` symbols. Defaults to `Auth::READ` if
|
67
|
+
# no action passed in.
|
68
|
+
#
|
69
|
+
# @returns [ActiveRecord::Relation] A new collection, scoped to the
|
66
70
|
# objects that the current user has access to.
|
67
|
-
def scope_collection(collection)
|
71
|
+
def scope_collection(collection, action = Auth::READ)
|
68
72
|
collection
|
69
73
|
end
|
70
74
|
|
@@ -72,7 +76,7 @@ module ActiveAdmin
|
|
72
76
|
|
73
77
|
# The `#authorized?` method's subject can be set to both instances as well
|
74
78
|
# as classes of objects. This can make it much difficult to create simple
|
75
|
-
# case statements for authorization since you have to handle both the
|
79
|
+
# case statements for authorization since you have to handle both the
|
76
80
|
# class level match and the instance level match.
|
77
81
|
#
|
78
82
|
# For example:
|
@@ -4,7 +4,7 @@ require 'active_admin/base_controller/authorization'
|
|
4
4
|
require 'active_admin/base_controller/menu'
|
5
5
|
|
6
6
|
module ActiveAdmin
|
7
|
-
# BaseController for ActiveAdmin.
|
7
|
+
# BaseController for ActiveAdmin.
|
8
8
|
# It implements ActiveAdmin controllers core features.
|
9
9
|
class BaseController < ::InheritedResources::Base
|
10
10
|
helper ::ActiveAdmin::ViewHelpers
|
@@ -46,7 +46,7 @@ module ActiveAdmin
|
|
46
46
|
helper_method :current_active_admin_user
|
47
47
|
|
48
48
|
def current_active_admin_user?
|
49
|
-
|
49
|
+
!!current_active_admin_user
|
50
50
|
end
|
51
51
|
helper_method :current_active_admin_user?
|
52
52
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
|
3
3
|
# Exception class to raise when there is an authorized access
|
4
|
-
# exception thrown. The exception has a few goodies that may
|
4
|
+
# exception thrown. The exception has a few goodies that may
|
5
5
|
# be useful for capturing / recognizing security issues.
|
6
6
|
class AccessDenied < StandardError
|
7
7
|
attr_reader :user, :action, :subject
|
@@ -17,7 +17,6 @@ module ActiveAdmin
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
20
|
class BaseController < ::InheritedResources::Base
|
22
21
|
module Authorization
|
23
22
|
include MethodOrProcHelper
|
@@ -43,7 +42,7 @@ module ActiveAdmin
|
|
43
42
|
protected
|
44
43
|
|
45
44
|
# Authorize the action and subject. Available in the controller
|
46
|
-
# as well as all the views.
|
45
|
+
# as well as all the views.
|
47
46
|
#
|
48
47
|
# @param [Symbol] action The action to check if the user has permission
|
49
48
|
# to perform on the subject.
|
@@ -90,17 +89,19 @@ module ActiveAdmin
|
|
90
89
|
#
|
91
90
|
# @returns [ActiveAdmin::AuthorizationAdapter]
|
92
91
|
def active_admin_authorization
|
93
|
-
@active_admin_authorization ||=
|
92
|
+
@active_admin_authorization ||=
|
93
|
+
active_admin_authorization_adapter.new active_admin_config, current_active_admin_user
|
94
94
|
end
|
95
95
|
|
96
96
|
# Returns the class to be used as the authorization adapter
|
97
97
|
#
|
98
98
|
# @returns [Class]
|
99
99
|
def active_admin_authorization_adapter
|
100
|
-
|
101
|
-
|
100
|
+
adapter = active_admin_namespace.authorization_adapter
|
101
|
+
if adapter.is_a? String
|
102
|
+
ActiveSupport::Dependencies.constantize adapter
|
102
103
|
else
|
103
|
-
|
104
|
+
adapter
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
@@ -112,14 +113,8 @@ module ActiveAdmin
|
|
112
113
|
#
|
113
114
|
# @returns [Symbol] The permission name to use.
|
114
115
|
def action_to_permission(action)
|
115
|
-
|
116
|
-
|
117
|
-
action = action.to_sym
|
118
|
-
|
119
|
-
if Authorization::ACTIONS_DICTIONARY.has_key?(action)
|
120
|
-
Authorization::ACTIONS_DICTIONARY[action]
|
121
|
-
else
|
122
|
-
action
|
116
|
+
if action && action = action.to_sym
|
117
|
+
Authorization::ACTIONS_DICTIONARY[action] || action
|
123
118
|
end
|
124
119
|
end
|
125
120
|
|
@@ -128,23 +123,26 @@ module ActiveAdmin
|
|
128
123
|
end
|
129
124
|
|
130
125
|
def rescue_active_admin_access_denied(exception)
|
131
|
-
|
126
|
+
error = exception.message
|
132
127
|
|
133
128
|
respond_to do |format|
|
134
129
|
format.html do
|
135
|
-
flash[:error] =
|
136
|
-
|
137
|
-
if request.headers.keys.include?("HTTP_REFERER")
|
138
|
-
redirect_to :back
|
139
|
-
else
|
140
|
-
controller, action = active_admin_namespace.root_to.split("#")
|
141
|
-
redirect_to :controller => controller, :action => action
|
142
|
-
end
|
130
|
+
flash[:error] = error
|
131
|
+
redirect_backwards_or_to_root
|
143
132
|
end
|
144
133
|
|
145
|
-
format.csv
|
146
|
-
format.json { render :
|
147
|
-
format.xml
|
134
|
+
format.csv { render text: error, status: :unauthorized }
|
135
|
+
format.json { render json: { error: error }, status: :unauthorized }
|
136
|
+
format.xml { render xml: "<error>#{error}</error>", status: :unauthorized }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def redirect_backwards_or_to_root
|
141
|
+
if request.headers.key? "HTTP_REFERER"
|
142
|
+
redirect_to :back
|
143
|
+
else
|
144
|
+
controller, action = active_admin_namespace.root_to.split '#'
|
145
|
+
redirect_to controller: controller, action: action
|
148
146
|
end
|
149
147
|
end
|
150
148
|
|