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
|
@@ -63,7 +63,13 @@ module ActiveAdmin
|
|
|
63
63
|
build_batch_actions_selector
|
|
64
64
|
build_scopes
|
|
65
65
|
build_index_list
|
|
66
|
-
end
|
|
66
|
+
end if any_table_tools?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def any_table_tools?
|
|
70
|
+
active_admin_config.batch_actions.any? ||
|
|
71
|
+
active_admin_config.scopes.any? ||
|
|
72
|
+
active_admin_config.page_presenters[:index].try(:size).try(:>, 1)
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
def build_batch_actions_selector
|
|
@@ -90,7 +96,7 @@ module ActiveAdmin
|
|
|
90
96
|
active_admin_config.page_presenters[:index].each do |type, page_presenter|
|
|
91
97
|
index_classes << find_index_renderer_class(page_presenter[:as])
|
|
92
98
|
end
|
|
93
|
-
|
|
99
|
+
|
|
94
100
|
index_list_renderer index_classes
|
|
95
101
|
end
|
|
96
102
|
end
|
|
@@ -110,17 +116,11 @@ module ActiveAdmin
|
|
|
110
116
|
|
|
111
117
|
# Returns the actual class for renderering the main content on the index
|
|
112
118
|
# page. To set this, use the :as option in the page_presenter block.
|
|
113
|
-
def find_index_renderer_class(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
::ActiveAdmin::Views.const_get("IndexAs" + symbol_or_class.to_s.camelcase)
|
|
117
|
-
when Class
|
|
118
|
-
symbol_or_class
|
|
119
|
-
else
|
|
120
|
-
raise ArgumentError, "'as' requires a class or a symbol"
|
|
121
|
-
end
|
|
119
|
+
def find_index_renderer_class(klass)
|
|
120
|
+
klass.is_a?(Class) ? klass :
|
|
121
|
+
::ActiveAdmin::Views.const_get("IndexAs" + klass.to_s.camelcase)
|
|
122
122
|
end
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
def render_blank_slate
|
|
125
125
|
blank_slate_content = I18n.t("active_admin.blank_slate.content", :resource_name => active_admin_config.plural_resource_label)
|
|
126
126
|
if controller.action_methods.include?('new')
|
|
@@ -128,21 +128,23 @@ module ActiveAdmin
|
|
|
128
128
|
end
|
|
129
129
|
insert_tag(view_factory.blank_slate, blank_slate_content)
|
|
130
130
|
end
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
def render_empty_results
|
|
133
133
|
empty_results_content = I18n.t("active_admin.pagination.empty", :model => active_admin_config.plural_resource_label)
|
|
134
134
|
insert_tag(view_factory.blank_slate, empty_results_content)
|
|
135
135
|
end
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
def render_index
|
|
138
138
|
renderer_class = find_index_renderer_class(config[:as])
|
|
139
139
|
paginator = config[:paginator].nil? ? true : config[:paginator]
|
|
140
140
|
download_links = config[:download_links].nil? ? active_admin_config.namespace.download_links : config[:download_links]
|
|
141
|
-
|
|
141
|
+
pagination_total = config[:pagination_total].nil? ? true : config[:pagination_total]
|
|
142
|
+
|
|
142
143
|
paginated_collection(collection, :entry_name => active_admin_config.resource_label,
|
|
143
|
-
:entries_name => active_admin_config.plural_resource_label,
|
|
144
|
+
:entries_name => active_admin_config.plural_resource_label(:count => collection_size),
|
|
144
145
|
:download_links => download_links,
|
|
145
|
-
:paginator => paginator
|
|
146
|
+
:paginator => paginator,
|
|
147
|
+
:pagination_total => pagination_total) do
|
|
146
148
|
div :class => 'index_content' do
|
|
147
149
|
insert_tag(renderer_class, config, collection)
|
|
148
150
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){window.
|
|
1
|
+
(function(){window.ActiveAdmin={},window.AA||(window.AA=window.ActiveAdmin)}).call(this),function(){window.ActiveAdmin.CheckboxToggler=ActiveAdmin.CheckboxToggler=function(){function t(t,e){var n;this.options=t,this.container=e,n={},this.options=$.extend({},n,t),this._init(),this._bind()}return t.prototype._init=function(){if(!this.container)throw new Error("Container element not found");if(this.$container=$(this.container),!this.$container.find(".toggle_all").length)throw new Error('"toggle all" checkbox not found');return this.toggle_all_checkbox=this.$container.find(".toggle_all"),this.checkboxes=this.$container.find(":checkbox").not(this.toggle_all_checkbox)},t.prototype._bind=function(){var t=this;return this.checkboxes.change(function(e){return t._didChangeCheckbox(e.target)}),this.toggle_all_checkbox.change(function(){return t._didChangeToggleAllCheckbox()})},t.prototype._didChangeCheckbox=function(){switch(this.checkboxes.filter(":checked").length){case this.checkboxes.length-1:return this.toggle_all_checkbox.prop({checked:null});case this.checkboxes.length:return this.toggle_all_checkbox.prop({checked:!0})}},t.prototype._didChangeToggleAllCheckbox=function(){var t,e=this;return t=this.toggle_all_checkbox.prop("checked")?!0:null,this.checkboxes.each(function(n,i){return $(i).prop({checked:t}),e._didChangeCheckbox(i)})},t}(),jQuery(function(t){return t.widget.bridge("checkboxToggler",ActiveAdmin.CheckboxToggler)})}.call(this),function(){window.ActiveAdmin.DropdownMenu=ActiveAdmin.DropdownMenu=function(){function t(t,e){var n;this.options=t,this.element=e,this.$element=$(this.element),n={fadeInDuration:20,fadeOutDuration:100,onClickActionItemCallback:null},this.options=$.extend({},n,t),this.$menuButton=this.$element.find(".dropdown_menu_button"),this.$menuList=this.$element.find(".dropdown_menu_list_wrapper"),this.isOpen=!1,this._buildMenuList(),this._bind()}return t.prototype.open=function(){return this.isOpen=!0,this.$menuList.fadeIn(this.options.fadeInDuration),this._positionMenuList(),this._positionNipple(),this},t.prototype.close=function(){return this.isOpen=!1,this.$menuList.fadeOut(this.options.fadeOutDuration),this},t.prototype.destroy=function(){return this.$element.unbind(),this.$element=null,this},t.prototype.isDisabled=function(){return this.$menuButton.hasClass("disabled")},t.prototype.disable=function(){return this.$menuButton.addClass("disabled")},t.prototype.enable=function(){return this.$menuButton.removeClass("disabled")},t.prototype.option=function(t,e){return $.isPlainObject(t)?this.options=$.extend(!0,this.options,t):null!=t?this.options[t]:this.options[t]=e},t.prototype._buildMenuList=function(){return this.$menuList.prepend('<div class="dropdown_menu_nipple"></div>'),this.$menuList.hide()},t.prototype._bind=function(){var t=this;return $("body").bind("click",function(){return t.isOpen===!0?t.close():void 0}),this.$menuButton.bind("click",function(){return t.isDisabled()||(t.isOpen===!0?t.close():t.open()),!1})},t.prototype._positionMenuList=function(){var t,e,n;return t=this.$menuButton.position().left+this.$menuButton.outerWidth()/2,e=this.$menuList.outerWidth()/2,n=t-e,this.$menuList.css("left",n)},t.prototype._positionNipple=function(){var t,e,n,i,o;return n=this.$menuList.outerWidth()/2,e=this.$menuButton.position().top+this.$menuButton.outerHeight()+10,this.$menuList.css("top",e),t=this.$menuList.find(".dropdown_menu_nipple"),i=t.outerWidth()/2,o=n-i,t.css("left",o)},t}(),function(t){return t.widget.bridge("aaDropdownMenu",ActiveAdmin.DropdownMenu),t(function(){return t(".dropdown_menu").aaDropdownMenu()})}(jQuery)}.call(this),function(){window.ActiveAdmin.Popover=ActiveAdmin.Popover=function(){function t(t,e){var n;this.options=t,this.element=e,this.$element=$(this.element),n={fadeInDuration:20,fadeOutDuration:100,autoOpen:!0,pageWrapperElement:"#wrapper",onClickActionItemCallback:null},this.options=$.extend({},n,t),this.$popover=null,this.isOpen=!1,this.$popover=$(this.$element.attr("href")).length>0?$(this.$element.attr("href")):this.$element.next(".popover"),this._buildPopover(),this._bind()}return t.prototype.open=function(){return this.isOpen=!0,this.$popover.fadeIn(this.options.fadeInDuration),this._positionPopover(),this._positionNipple(),this},t.prototype.close=function(){return this.isOpen=!1,this.$popover.fadeOut(this.options.fadeOutDuration),this},t.prototype.destroy=function(){return this.$element.removeData("popover"),this.$element.unbind(),this.$element=null,this},t.prototype.option=function(){},t.prototype._buildPopover=function(){return this.$popover.prepend('<div class="popover_nipple"></div>'),this.$popover.hide(),this.$popover.addClass("popover")},t.prototype._bind=function(){var t=this;return $(this.options.pageWrapperElement).bind("click",function(){return t.isOpen===!0?t.close():void 0}),this.options.autoOpen===!0?this.$element.bind("click",function(){return t.isOpen===!0?t.close():t.open(),!1}):void 0},t.prototype._positionPopover=function(){var t,e,n;return t=this.$element.offset().left+this.$element.outerWidth()/2,e=this.$popover.outerWidth()/2,n=t-e,this.$popover.css("left",n)},t.prototype._positionNipple=function(){var t,e,n,i,o;return n=this.$popover.outerWidth()/2,e=this.$element.offset().top+this.$element.outerHeight()+10,this.$popover.css("top",e),t=this.$popover.find(".popover_nipple"),i=t.outerWidth()/2,o=n-i,t.css("left",o)},t}(),function(t){return t.widget.bridge("popover",ActiveAdmin.Popover)}(jQuery)}.call(this),function(){var t,e={}.hasOwnProperty,n=function(t,n){function i(){this.constructor=t}for(var o in n)e.call(n,o)&&(t[o]=n[o]);return i.prototype=n.prototype,t.prototype=new i,t.__super__=n.prototype,t};window.ActiveAdmin.TableCheckboxToggler=ActiveAdmin.TableCheckboxToggler=function(e){function i(){return t=i.__super__.constructor.apply(this,arguments)}return n(i,e),i.prototype._init=function(){return i.__super__._init.apply(this,arguments)},i.prototype._bind=function(){var t=this;return i.__super__._bind.apply(this,arguments),this.$container.find("tbody td").click(function(e){return"checkbox"!==e.target.type?t._didClickCell(e.target):void 0})},i.prototype._didChangeCheckbox=function(t){var e;return i.__super__._didChangeCheckbox.apply(this,arguments),e=$(t).parents("tr"),t.checked?e.addClass("selected"):e.removeClass("selected")},i.prototype._didClickCell=function(t){return $(t).parent("tr").find(":checkbox").click()},i}(ActiveAdmin.CheckboxToggler),jQuery(function(t){return t.widget.bridge("tableCheckboxToggler",ActiveAdmin.TableCheckboxToggler)})}.call(this),function(){$(function(){return $(document).on("focus",".datepicker:not(.hasDatepicker)",function(){return $(this).datepicker({dateFormat:"yy-mm-dd"})}),$(".clear_filters_btn").click(function(){return window.location.search=""}),$(".dropdown_button").popover(),$(".filter_form").submit(function(){return $(this).find(":input").filter(function(){return""===this.value}).prop("disabled",!0)}),$(".filter_form_field.select_and_search select").change(function(){return $(this).siblings("input").prop({name:"q["+this.value+"]"})})})}.call(this),function(){jQuery(function(t){return t(document).delegate("#batch_actions_selector li a","click.rails",function(){return t("#batch_action").val(t(this).attr("data-action")),t("#collection_selection").submit()}),t("#batch_actions_selector").length&&t(":checkbox.toggle_all").length?(t(".paginated_collection table.index_table").length?t(".paginated_collection table.index_table").tableCheckboxToggler():t(".paginated_collection").checkboxToggler(),t(".paginated_collection").find(":checkbox").bind("change",function(){return t(".paginated_collection").find(":checkbox").filter(":checked").length>0?t("#batch_actions_selector").aaDropdownMenu("enable"):t("#batch_actions_selector").aaDropdownMenu("disable")})):void 0})}.call(this);
|
|
@@ -14,16 +14,4 @@
|
|
|
14
14
|
// Overriding any non-variable SASS must be done after the fact.
|
|
15
15
|
// For example, to change the default status-tag color:
|
|
16
16
|
//
|
|
17
|
-
//
|
|
18
|
-
// .status_tag { background: #6090DB; }
|
|
19
|
-
// }
|
|
20
|
-
//
|
|
21
|
-
// Notice that Active Admin CSS rules are nested within a
|
|
22
|
-
// 'body.active_admin' selector to prevent conflicts with
|
|
23
|
-
// other pages in the app. It is best to wrap your changes in a
|
|
24
|
-
// namespace so they are properly recognized. You have options
|
|
25
|
-
// if you e.g. want different styles for different namespaces:
|
|
26
|
-
//
|
|
27
|
-
// .active_admin applies to any Active Admin namespace
|
|
28
|
-
// .admin_namespace applies to the admin namespace (eg: /admin)
|
|
29
|
-
// .other_namespace applies to a custom namespace named other (eg: /other)
|
|
17
|
+
// .status_tag { background: #6090DB; }
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
module ActiveAdmin
|
|
2
2
|
module Generators
|
|
3
|
+
class Error < Rails::Generators::Error
|
|
4
|
+
end
|
|
5
|
+
|
|
3
6
|
class DeviseGenerator < Rails::Generators::NamedBase
|
|
4
7
|
desc "Creates an admin user and uses Devise for authentication"
|
|
5
8
|
argument :name, :type => :string, :default => "AdminUser"
|
|
@@ -7,6 +10,8 @@ module ActiveAdmin
|
|
|
7
10
|
class_option :registerable, :type => :boolean, :default => false,
|
|
8
11
|
:desc => "Should the generated resource be registerable?"
|
|
9
12
|
|
|
13
|
+
RESERVED_NAMES = [:active_admin_user]
|
|
14
|
+
|
|
10
15
|
def install_devise
|
|
11
16
|
require 'devise'
|
|
12
17
|
if File.exists?(File.join(destination_root, "config", "initializers", "devise.rb"))
|
|
@@ -18,6 +23,9 @@ module ActiveAdmin
|
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
def create_admin_user
|
|
26
|
+
if RESERVED_NAMES.include?(name.underscore)
|
|
27
|
+
raise Error, "The name #{name} is reserved by Active Admin"
|
|
28
|
+
end
|
|
21
29
|
invoke "devise", [name]
|
|
22
30
|
end
|
|
23
31
|
|
|
@@ -28,6 +36,19 @@ module ActiveAdmin
|
|
|
28
36
|
end
|
|
29
37
|
end
|
|
30
38
|
|
|
39
|
+
# This fixes a bug in the 3.0.0 release of Devise. For more info:
|
|
40
|
+
# https://github.com/plataformatec/devise/issues/2515
|
|
41
|
+
def add_attr_accessible_if_missing
|
|
42
|
+
require 'devise/version'
|
|
43
|
+
if ::Devise::VERSION == '3.0.0'
|
|
44
|
+
if Rails::VERSION::MAJOR == 3 && !defined?(ActionController::StrongParameters)
|
|
45
|
+
model = File.join(destination_root, "app", "models", "#{file_path}.rb")
|
|
46
|
+
inject_into_file model, "\n attr_accessible :email, :password, :password_confirmation, :remember_me\n",
|
|
47
|
+
:before => /end\s*\z/
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
31
52
|
def set_namespace_for_path
|
|
32
53
|
routes_file = File.join(destination_root, "config", "routes.rb")
|
|
33
54
|
gsub_file routes_file, /devise_for :#{plural_table_name}/, "devise_for :#{plural_table_name}, ActiveAdmin::Devise.config"
|
|
@@ -42,7 +63,7 @@ module ActiveAdmin
|
|
|
42
63
|
|
|
43
64
|
if devise_migration_content["def change"]
|
|
44
65
|
inject_into_file devise_migration_file,
|
|
45
|
-
"def migrate(direction)\n super\n # Create a default user\n #{class_name}.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up\n end\n\n ",
|
|
66
|
+
"def migrate(direction)\n super\n # Create a default user\n #{class_name}.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up\n end\n\n ",
|
|
46
67
|
:before => "def change"
|
|
47
68
|
elsif devise_migration_content[/def (self.)?up/]
|
|
48
69
|
inject_into_file devise_migration_file,
|
|
@@ -39,11 +39,7 @@ module ActiveAdmin
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def create_migrations
|
|
42
|
-
|
|
43
|
-
name = File.basename(filepath)
|
|
44
|
-
migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
|
|
45
|
-
sleep 1
|
|
46
|
-
end
|
|
42
|
+
migration_template 'migrations/create_active_admin_comments.rb', 'db/migrate/create_active_admin_comments.rb'
|
|
47
43
|
end
|
|
48
44
|
end
|
|
49
45
|
end
|
|
@@ -57,6 +57,23 @@ ActiveAdmin.setup do |config|
|
|
|
57
57
|
# within the controller.
|
|
58
58
|
config.authentication_method = :authenticate_<%= @underscored_user_name %>!
|
|
59
59
|
|
|
60
|
+
# == User Authorization
|
|
61
|
+
#
|
|
62
|
+
# Active Admin will automatically call an authorization
|
|
63
|
+
# method in a before filter of all controller actions to
|
|
64
|
+
# ensure that there is a user with proper rights. You can use
|
|
65
|
+
# CanCanAdapter or make your own. Please refer to documentation.
|
|
66
|
+
# config.authorization_adapter = ActiveAdmin::CanCanAdapter
|
|
67
|
+
|
|
68
|
+
# You can customize your CanCan Ability class name here.
|
|
69
|
+
# config.cancan_ability_class = "Ability"
|
|
70
|
+
|
|
71
|
+
# You can specify a method to be called on unauthorized access.
|
|
72
|
+
# This is necessary in order to prevent a redirect loop which happens
|
|
73
|
+
# because, by default, user gets redirected to Dashboard. If user
|
|
74
|
+
# doesn't have access to Dashboard, he'll end up in a redirect loop.
|
|
75
|
+
# Method provided here should be defined in application_controller.rb.
|
|
76
|
+
# config.on_unauthorized_access = :access_denied
|
|
60
77
|
|
|
61
78
|
# == Current User
|
|
62
79
|
#
|
|
@@ -86,6 +103,7 @@ ActiveAdmin.setup do |config|
|
|
|
86
103
|
# Default:
|
|
87
104
|
# config.logout_link_method = :get
|
|
88
105
|
|
|
106
|
+
|
|
89
107
|
# == Root
|
|
90
108
|
#
|
|
91
109
|
# Set the action to call for the root path. You can set different
|
|
@@ -94,21 +112,19 @@ ActiveAdmin.setup do |config|
|
|
|
94
112
|
# Default:
|
|
95
113
|
# config.root_to = 'dashboard#index'
|
|
96
114
|
|
|
115
|
+
|
|
97
116
|
# == Admin Comments
|
|
98
117
|
#
|
|
99
|
-
#
|
|
100
|
-
# Admin comments are enabled by default.
|
|
118
|
+
# This allows your users to comment on any resource registered with Active Admin.
|
|
101
119
|
#
|
|
102
|
-
#
|
|
103
|
-
# config.allow_comments =
|
|
120
|
+
# You can completely disable comments:
|
|
121
|
+
# config.allow_comments = false
|
|
104
122
|
#
|
|
105
|
-
# You can
|
|
106
|
-
#
|
|
123
|
+
# You can disable the menu item for the comments index page:
|
|
124
|
+
# config.show_comments_in_menu = false
|
|
107
125
|
#
|
|
108
|
-
#
|
|
109
|
-
#
|
|
110
|
-
# without_comments.allow_comments = false
|
|
111
|
-
# end
|
|
126
|
+
# You can change the name under which comments are registered:
|
|
127
|
+
# config.comments_registration_name = 'AdminComment'
|
|
112
128
|
|
|
113
129
|
|
|
114
130
|
# == Batch Actions
|
|
@@ -124,6 +140,11 @@ ActiveAdmin.setup do |config|
|
|
|
124
140
|
# Active Admin resources and pages from here.
|
|
125
141
|
#
|
|
126
142
|
# config.before_filter :do_something_awesome
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# == Setting a Favicon
|
|
146
|
+
#
|
|
147
|
+
# config.favicon = '/assets/favicon.ico'
|
|
127
148
|
|
|
128
149
|
|
|
129
150
|
# == Register Stylesheets & Javascripts
|
|
@@ -134,7 +155,7 @@ ActiveAdmin.setup do |config|
|
|
|
134
155
|
#
|
|
135
156
|
# To load a stylesheet:
|
|
136
157
|
# config.register_stylesheet 'my_stylesheet.css'
|
|
137
|
-
|
|
158
|
+
#
|
|
138
159
|
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
|
|
139
160
|
# config.register_stylesheet 'my_print_stylesheet.css', :media => :print
|
|
140
161
|
#
|
|
@@ -144,19 +165,19 @@ ActiveAdmin.setup do |config|
|
|
|
144
165
|
|
|
145
166
|
# == CSV options
|
|
146
167
|
#
|
|
147
|
-
# Set the CSV builder separator
|
|
148
|
-
# config.
|
|
168
|
+
# Set the CSV builder separator
|
|
169
|
+
# config.csv_options = { :col_sep => ';' }
|
|
149
170
|
#
|
|
150
|
-
#
|
|
151
|
-
# config.csv_options = {}
|
|
171
|
+
# Force the use of quotes
|
|
172
|
+
# config.csv_options = { :force_quotes => true }
|
|
152
173
|
|
|
153
174
|
|
|
154
175
|
# == Menu System
|
|
155
176
|
#
|
|
156
177
|
# You can add a navigation menu to be used in your application, or configure a provided menu
|
|
157
|
-
#
|
|
178
|
+
#
|
|
158
179
|
# To change the default utility navigation to show a link to your website & a logout btn
|
|
159
|
-
#
|
|
180
|
+
#
|
|
160
181
|
# config.namespace :admin do |admin|
|
|
161
182
|
# admin.build_menu :utility_navigation do |menu|
|
|
162
183
|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
|
|
@@ -172,6 +193,7 @@ ActiveAdmin.setup do |config|
|
|
|
172
193
|
# end
|
|
173
194
|
# end
|
|
174
195
|
|
|
196
|
+
|
|
175
197
|
# == Download Links
|
|
176
198
|
#
|
|
177
199
|
# You can disable download links on resource listing pages,
|
|
@@ -200,11 +222,10 @@ ActiveAdmin.setup do |config|
|
|
|
200
222
|
|
|
201
223
|
# == Filters
|
|
202
224
|
#
|
|
203
|
-
# By default the index screen includes a “Filters” sidebar on the right
|
|
225
|
+
# By default the index screen includes a “Filters” sidebar on the right
|
|
204
226
|
# hand side with a filter for each attribute of the registered model.
|
|
205
227
|
# You can enable or disable them for all resources here.
|
|
206
228
|
#
|
|
207
229
|
# config.filters = true
|
|
208
230
|
|
|
209
|
-
|
|
210
231
|
end
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
ActiveAdmin.register <%= @user_class %> do
|
|
2
|
-
index do
|
|
3
|
-
column :email
|
|
4
|
-
column :current_sign_in_at
|
|
5
|
-
column :last_sign_in_at
|
|
6
|
-
column :sign_in_count
|
|
7
|
-
default_actions
|
|
8
|
-
end
|
|
1
|
+
ActiveAdmin.register <%= @user_class %> do
|
|
2
|
+
index do
|
|
3
|
+
column :email
|
|
4
|
+
column :current_sign_in_at
|
|
5
|
+
column :last_sign_in_at
|
|
6
|
+
column :sign_in_count
|
|
7
|
+
default_actions
|
|
8
|
+
end
|
|
9
9
|
|
|
10
|
-
filter :email
|
|
10
|
+
filter :email
|
|
11
11
|
|
|
12
|
-
form do |f|
|
|
13
|
-
f.inputs "Admin Details" do
|
|
14
|
-
f.input :email
|
|
15
|
-
f.input :password
|
|
16
|
-
f.input :password_confirmation
|
|
17
|
-
end
|
|
18
|
-
f.actions
|
|
19
|
-
end
|
|
20
|
-
end
|
|
12
|
+
form do |f|
|
|
13
|
+
f.inputs "Admin Details" do
|
|
14
|
+
f.input :email
|
|
15
|
+
f.input :password
|
|
16
|
+
f.input :password_confirmation
|
|
17
|
+
end
|
|
18
|
+
f.actions
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class CreateActiveAdminComments < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :active_admin_comments do |t|
|
|
4
|
+
t.string :namespace
|
|
5
|
+
t.text :body
|
|
6
|
+
t.string :resource_id, :null => false
|
|
7
|
+
t.string :resource_type, :null => false
|
|
8
|
+
t.references :author, :polymorphic => true
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
add_index :active_admin_comments, [:namespace]
|
|
12
|
+
add_index :active_admin_comments, [:author_type, :author_id]
|
|
13
|
+
add_index :active_admin_comments, [:resource_type, :resource_id]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.down
|
|
17
|
+
drop_table :active_admin_comments
|
|
18
|
+
end
|
|
19
|
+
end
|
data/script/use_rails
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
#
|
|
3
3
|
# Switches the development environment to use the given
|
|
4
|
-
# version of rails. Caches the Gemfile.locks so that
|
|
4
|
+
# version of rails. Caches the Gemfile.locks so that
|
|
5
5
|
# switching it very fast.
|
|
6
6
|
#
|
|
7
7
|
require File.expand_path("../../spec/support/detect_rails_version", __FILE__)
|
|
@@ -11,13 +11,14 @@ describe "Memory Leak" do
|
|
|
11
11
|
|
|
12
12
|
def self.it_should_not_leak(klass)
|
|
13
13
|
it "should not leak #{klass}" do
|
|
14
|
+
previously_disabled = GC.enable # returns true if the garbage collector was disabled
|
|
14
15
|
GC.start
|
|
15
|
-
|
|
16
16
|
count = count_instances_of(klass)
|
|
17
17
|
|
|
18
18
|
load_defaults!
|
|
19
|
-
GC.start
|
|
20
19
|
|
|
20
|
+
GC.start
|
|
21
|
+
GC.disable if previously_disabled
|
|
21
22
|
count_instances_of(klass).should <= count
|
|
22
23
|
end
|
|
23
24
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
describe "
|
|
1
|
+
describe "ActiveAdmin.CheckboxToggler", ->
|
|
2
2
|
|
|
3
3
|
beforeEach ->
|
|
4
4
|
loadFixtures('checkboxes.html')
|
|
@@ -9,15 +9,15 @@ describe "AA.CheckboxToggler", ->
|
|
|
9
9
|
@checkboxes = @collection.find(":checkbox").not(@toggle_all)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
new
|
|
12
|
+
new ActiveAdmin.CheckboxToggler({}, @collection)
|
|
13
13
|
|
|
14
14
|
describe "on init", ->
|
|
15
15
|
it "should raise an error if container not found", ->
|
|
16
|
-
expect( => new
|
|
16
|
+
expect( => new ActiveAdmin.CheckboxToggler({}) ).toThrow("Container element not found")
|
|
17
17
|
|
|
18
18
|
it "should raise an error if 'toggle all' checkbox not found", ->
|
|
19
19
|
@toggle_all.remove()
|
|
20
|
-
expect( => new
|
|
20
|
+
expect( => new ActiveAdmin.CheckboxToggler({}, @collection); ).toThrow("'toggle all' checkbox not found")
|
|
21
21
|
|
|
22
22
|
describe "'toggle all' checkbox", ->
|
|
23
23
|
it "should check all checkboxes when checked", ->
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
describe "
|
|
1
|
+
describe "ActiveAdmin.TableCheckboxToggler", ->
|
|
2
2
|
|
|
3
3
|
beforeEach ->
|
|
4
4
|
loadFixtures('table_checkboxes.html');
|
|
@@ -8,7 +8,7 @@ describe "AA.TableCheckboxToggler", ->
|
|
|
8
8
|
|
|
9
9
|
@checkboxes = @collection.find(":checkbox").not(@toggle_all)
|
|
10
10
|
|
|
11
|
-
new
|
|
11
|
+
new ActiveAdmin.TableCheckboxToggler({}, @collection)
|
|
12
12
|
|
|
13
13
|
describe "'selected' class for table row", ->
|
|
14
14
|
it "should add the class 'selected' to rows when their checkbox is checked ", ->
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
|
|
3
|
-
describe("
|
|
3
|
+
describe("ActiveAdmin.CheckboxToggler", function() {
|
|
4
4
|
beforeEach(function() {
|
|
5
5
|
loadFixtures('checkboxes.html');
|
|
6
6
|
this.collection = $("#collection");
|
|
7
7
|
this.toggle_all = this.collection.find(".toggle_all");
|
|
8
8
|
this.checkboxes = this.collection.find(":checkbox").not(this.toggle_all);
|
|
9
|
-
return new
|
|
9
|
+
return new ActiveAdmin.CheckboxToggler({}, this.collection);
|
|
10
10
|
});
|
|
11
11
|
describe("on init", function() {
|
|
12
12
|
it("should raise an error if container not found", function() {
|
|
13
13
|
var _this = this;
|
|
14
14
|
return expect(function() {
|
|
15
|
-
return new
|
|
15
|
+
return new ActiveAdmin.CheckboxToggler({});
|
|
16
16
|
}).toThrow("Container element not found");
|
|
17
17
|
});
|
|
18
18
|
return it("should raise an error if 'toggle all' checkbox not found", function() {
|
|
19
19
|
var _this = this;
|
|
20
20
|
this.toggle_all.remove();
|
|
21
21
|
return expect(function() {
|
|
22
|
-
return new
|
|
22
|
+
return new ActiveAdmin.CheckboxToggler({}, _this.collection);
|
|
23
23
|
}).toThrow("'toggle all' checkbox not found");
|
|
24
24
|
});
|
|
25
25
|
});
|