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
@@ -46,30 +46,31 @@ describe ActiveAdmin::Filters::ResourceExtension do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
context "adding a filter" do
|
50
|
+
it "should work" do
|
51
|
+
resource.add_filter :title
|
52
|
+
resource.filters.should == [{:attribute => :title}]
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
it "should work with specified options" do
|
56
|
+
resource.add_filter :title, :as => :string
|
57
|
+
resource.filters.should == [{:attribute => :title, :as => :string}]
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
it "should preserve default filters" do
|
61
|
+
resource.preserve_default_filters!
|
62
|
+
resource.add_filter :count, :as => :string
|
63
|
+
resource.filters.map { |f| f[:attribute].to_s }.sort.should == %w{
|
64
64
|
author body category count created_at published_at starred title updated_at
|
65
65
|
}
|
66
|
-
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
it "should raise an exception when filters are disabled" do
|
69
|
+
resource.filters = false
|
70
|
+
expect {
|
71
|
+
resource.add_filter :title
|
72
|
+
}.should raise_error(RuntimeError)
|
73
|
+
end
|
73
74
|
end
|
74
75
|
|
75
76
|
it "should reset filters" do
|
@@ -69,38 +69,6 @@ describe ActiveAdmin::FormBuilder do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context "in general with actions" do
|
73
|
-
let :body do
|
74
|
-
build_form do |f|
|
75
|
-
f.inputs do
|
76
|
-
f.input :title
|
77
|
-
f.input :body
|
78
|
-
end
|
79
|
-
f.actions do
|
80
|
-
f.action :submit, :button_html => { :value => "Submit Me" }
|
81
|
-
f.action :submit, :button_html => { :value => "Another Button" }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should generate a text input" do
|
87
|
-
body.should have_tag("input", :attributes => { :type => "text",
|
88
|
-
:name => "post[title]" })
|
89
|
-
end
|
90
|
-
it "should generate a textarea" do
|
91
|
-
body.should have_tag("textarea", :attributes => { :name => "post[body]" })
|
92
|
-
end
|
93
|
-
it "should only generate the form once" do
|
94
|
-
body.scan(/Title/).size.should == 1
|
95
|
-
end
|
96
|
-
it "should generate actions" do
|
97
|
-
body.should have_tag("input", :attributes => { :type => "submit",
|
98
|
-
:value => "Submit Me" })
|
99
|
-
body.should have_tag("input", :attributes => { :type => "submit",
|
100
|
-
:value => "Another Button" })
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
72
|
context "when polymorphic relationship" do
|
105
73
|
it "should raise error" do
|
106
74
|
lambda {
|
@@ -145,14 +113,14 @@ describe ActiveAdmin::FormBuilder do
|
|
145
113
|
end
|
146
114
|
f.actions
|
147
115
|
end
|
148
|
-
body.scan(/id
|
116
|
+
body.scan(/id="post_title"/).size.should == 1
|
149
117
|
end
|
150
118
|
it "should generate one button and a cancel link" do
|
151
119
|
body = build_form do |f|
|
152
120
|
f.actions
|
153
121
|
end
|
154
|
-
body.scan(/type
|
155
|
-
body.scan(/class
|
122
|
+
body.scan(/type="submit"/).size.should == 1
|
123
|
+
body.scan(/class="cancel"/).size.should == 1
|
156
124
|
end
|
157
125
|
it "should generate multiple actions" do
|
158
126
|
body = build_form do |f|
|
@@ -161,13 +129,13 @@ describe ActiveAdmin::FormBuilder do
|
|
161
129
|
f.action :submit, :label => "Create & Edit"
|
162
130
|
end
|
163
131
|
end
|
164
|
-
body.scan(/type
|
165
|
-
body.scan(/class
|
132
|
+
body.scan(/type="submit"/).size.should == 2
|
133
|
+
body.scan(/class="cancel"/).size.should == 0
|
166
134
|
end
|
167
135
|
|
168
136
|
end
|
169
137
|
|
170
|
-
context "with
|
138
|
+
context "with actions" do
|
171
139
|
it "should generate the form once" do
|
172
140
|
body = build_form do |f|
|
173
141
|
f.inputs do
|
@@ -175,14 +143,14 @@ describe ActiveAdmin::FormBuilder do
|
|
175
143
|
end
|
176
144
|
f.actions
|
177
145
|
end
|
178
|
-
body.scan(/id
|
146
|
+
body.scan(/id="post_title"/).size.should == 1
|
179
147
|
end
|
180
148
|
it "should generate one button and a cancel link" do
|
181
149
|
body = build_form do |f|
|
182
150
|
f.actions
|
183
151
|
end
|
184
|
-
body.scan(/type
|
185
|
-
body.scan(/class
|
152
|
+
body.scan(/type="submit"/).size.should == 1
|
153
|
+
body.scan(/class="cancel"/).size.should == 1
|
186
154
|
end
|
187
155
|
it "should generate multiple actions" do
|
188
156
|
body = build_form do |f|
|
@@ -191,8 +159,8 @@ describe ActiveAdmin::FormBuilder do
|
|
191
159
|
f.action :submit, :label => "Create & Edit"
|
192
160
|
end
|
193
161
|
end
|
194
|
-
body.scan(/type
|
195
|
-
body.scan(/class
|
162
|
+
body.scan(/type="submit"/).size.should == 2
|
163
|
+
body.scan(/class="cancel"/).size.should == 0
|
196
164
|
end
|
197
165
|
end
|
198
166
|
|
@@ -244,7 +212,7 @@ describe ActiveAdmin::FormBuilder do
|
|
244
212
|
end
|
245
213
|
end
|
246
214
|
it "should create 2 options" do
|
247
|
-
body.scan(
|
215
|
+
body.scan(/<option/).size.should == 3
|
248
216
|
end
|
249
217
|
end
|
250
218
|
|
@@ -255,7 +223,7 @@ describe ActiveAdmin::FormBuilder do
|
|
255
223
|
end
|
256
224
|
end
|
257
225
|
it "should create 2 radio buttons" do
|
258
|
-
body.scan(/type
|
226
|
+
body.scan(/type="radio"/).size.should == 2
|
259
227
|
end
|
260
228
|
end
|
261
229
|
|
@@ -326,6 +294,15 @@ describe ActiveAdmin::FormBuilder do
|
|
326
294
|
end
|
327
295
|
end
|
328
296
|
|
297
|
+
it "should translate the attribute name" do
|
298
|
+
begin
|
299
|
+
I18n.backend.store_translations :en, :activerecord => { :attributes => { :post => { :title => 'A very nice title' } } }
|
300
|
+
body.should have_tag 'label', 'A very nice title'
|
301
|
+
ensure
|
302
|
+
I18n.backend.reload!
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
329
306
|
it "should use model name when there is no translation for given model in has many new button" do
|
330
307
|
body.should have_tag('a', 'Add New Post')
|
331
308
|
end
|
@@ -335,7 +312,7 @@ describe ActiveAdmin::FormBuilder do
|
|
335
312
|
end
|
336
313
|
|
337
314
|
it "should add a link to remove new nested records" do
|
338
|
-
Capybara.string(body).should have_css(".has_many > fieldset > ol > li > a", :class => "button", :href => "#", :content => "Delete")
|
315
|
+
Capybara.string(body).should have_css(".has_many > fieldset > ol > li.has_many_delete > a", :class => "button", :href => "#", :content => "Delete")
|
339
316
|
end
|
340
317
|
|
341
318
|
it "should include the nested record's class name in the js" do
|
@@ -360,6 +337,91 @@ describe ActiveAdmin::FormBuilder do
|
|
360
337
|
it "should accept a block with a second argument" do
|
361
338
|
body.should have_tag("label", "Title 1")
|
362
339
|
end
|
340
|
+
|
341
|
+
it "should add a custom header" do
|
342
|
+
body.should have_tag('h3', 'Post')
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
describe "without heading and new record link" do
|
348
|
+
let :body do
|
349
|
+
build_form({:url => '/categories'}, Category.new) do |f|
|
350
|
+
f.object.posts.build
|
351
|
+
f.has_many :posts, :heading => false, :new_record => false do |p|
|
352
|
+
p.input :title
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should not add a header" do
|
358
|
+
body.should_not have_tag('h3', 'Post')
|
359
|
+
end
|
360
|
+
|
361
|
+
it "should not add link to new nested records" do
|
362
|
+
body.should_not have_tag('a', 'Add New Post')
|
363
|
+
end
|
364
|
+
|
365
|
+
end
|
366
|
+
|
367
|
+
describe "with custom heading" do
|
368
|
+
let :body do
|
369
|
+
build_form({:url => '/categories'}, Category.new) do |f|
|
370
|
+
f.object.posts.build
|
371
|
+
f.has_many :posts, :heading => "Test heading" do |p|
|
372
|
+
p.input :title
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
it "should add a custom header" do
|
378
|
+
body.should have_tag('h3', 'Test heading')
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
describe "with allow destroy" do
|
384
|
+
context "with an existing post" do
|
385
|
+
let :body do
|
386
|
+
build_form({:url => '/categories'}, Category.new) do |f|
|
387
|
+
f.object.posts.build.stub!(:new_record? => false)
|
388
|
+
f.has_many :posts, :allow_destroy => true do |p|
|
389
|
+
p.input :title
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
it "should include a boolean field for _destroy" do
|
395
|
+
body.should have_tag("input", :attributes => {:name => "category[posts_attributes][0][_destroy]"})
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should have a check box with 'Remove' as its label" do
|
399
|
+
body.should have_tag("label", :attributes => {:for => "category_posts_attributes_0__destroy"}, :content => "Remove")
|
400
|
+
end
|
401
|
+
|
402
|
+
it "should wrap the destroy field in an li with class 'has_many_remove'" do
|
403
|
+
Capybara.string(body).should have_css(".has_many > fieldset > ol > li.has_many_remove > input")
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
context "with a new post" do
|
408
|
+
let :body do
|
409
|
+
build_form({:url => '/categories'}, Category.new) do |f|
|
410
|
+
f.object.posts.build
|
411
|
+
f.has_many :posts, :allow_destroy => true do |p|
|
412
|
+
p.input :title
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
it "should not have a boolean field for _destroy" do
|
418
|
+
body.should_not have_tag("input", :attributes => {:name => "category[posts_attributes][0][_destroy]"})
|
419
|
+
end
|
420
|
+
|
421
|
+
it "should not have a check box with 'Remove' as its label" do
|
422
|
+
body.should_not have_tag("label", :attributes => {:for => "category_posts_attributes_0__destroy"}, :content => "Remove")
|
423
|
+
end
|
424
|
+
end
|
363
425
|
end
|
364
426
|
|
365
427
|
pending "should render the block if it returns nil" do
|
@@ -375,18 +437,23 @@ describe ActiveAdmin::FormBuilder do
|
|
375
437
|
end
|
376
438
|
end
|
377
439
|
|
378
|
-
{
|
379
|
-
"input :title, :as => :string" => /id
|
380
|
-
"input :title, :as => :text" => /id
|
381
|
-
"input :created_at, :as => :time_select" => /id
|
382
|
-
"input :created_at, :as => :datetime_select" => /id
|
383
|
-
"input :created_at, :as => :date_select" => /id
|
440
|
+
{ # Testing that the same input can be used multiple times
|
441
|
+
"f.input :title, :as => :string" => /id="post_title"/,
|
442
|
+
"f.input :title, :as => :text" => /id="post_title"/,
|
443
|
+
"f.input :created_at, :as => :time_select" => /id="post_created_at_2i"/,
|
444
|
+
"f.input :created_at, :as => :datetime_select" => /id="post_created_at_2i"/,
|
445
|
+
"f.input :created_at, :as => :date_select" => /id="post_created_at_2i"/,
|
446
|
+
# Testing that return values don't screw up the form
|
447
|
+
"f.input :title; nil" => /id="post_title"/,
|
448
|
+
"f.input :title; []" => /id="post_title"/,
|
449
|
+
"[:title].each{ |r| f.input r }" => /id="post_title"/,
|
450
|
+
"[:title].map { |r| f.input r }" => /id="post_title"/,
|
384
451
|
}.each do |source, regex|
|
385
|
-
it "should properly buffer
|
452
|
+
it "should properly buffer `#{source}`" do
|
386
453
|
body = build_form do |f|
|
387
454
|
f.inputs do
|
388
|
-
|
389
|
-
|
455
|
+
eval source
|
456
|
+
eval source
|
390
457
|
end
|
391
458
|
end
|
392
459
|
body.scan(regex).size.should == 2
|
@@ -408,19 +475,4 @@ describe ActiveAdmin::FormBuilder do
|
|
408
475
|
end
|
409
476
|
end
|
410
477
|
|
411
|
-
describe "inputs block with nil return value" do
|
412
|
-
let :body do
|
413
|
-
build_form do |f|
|
414
|
-
f.inputs do
|
415
|
-
f.input :title
|
416
|
-
nil
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
it "should generate a single input field" do
|
422
|
-
body.should have_tag("input", :attributes => { :type => "text", :name => "post[title]" })
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
478
|
end
|
data/spec/unit/menu_item_spec.rb
CHANGED
@@ -79,7 +79,7 @@ module ActiveAdmin
|
|
79
79
|
item['Blog'].label.should == 'Blog'
|
80
80
|
end
|
81
81
|
|
82
|
-
it "should sort items based on priority and name" do
|
82
|
+
it "should sort items based on priority and name" do
|
83
83
|
item.items[0].label.should == 'Users'
|
84
84
|
item.items[1].label.should == 'Settings'
|
85
85
|
item.items[2].label.should == 'Blog'
|
@@ -97,12 +97,12 @@ module ActiveAdmin
|
|
97
97
|
|
98
98
|
context "with no parent" do
|
99
99
|
it "should return an empty array" do
|
100
|
-
item.ancestors.should == []
|
100
|
+
item.ancestors.should == []
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
context "with one parent" do
|
105
|
-
let(:sub_item) do
|
105
|
+
let(:sub_item) do
|
106
106
|
item.add :label => "Create New"
|
107
107
|
item["Create New"]
|
108
108
|
end
|
@@ -9,23 +9,19 @@ describe ActiveAdmin::Resource, "authorization" do
|
|
9
9
|
describe "authorization_adapter" do
|
10
10
|
|
11
11
|
it "should return AuthorizationAdapter by default" do
|
12
|
-
|
12
|
+
app.authorization_adapter.should eq ActiveAdmin::AuthorizationAdapter
|
13
|
+
namespace.authorization_adapter.should eq ActiveAdmin::AuthorizationAdapter
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should be settable on the namespace" do
|
16
|
-
namespace.authorization_adapter.should == ActiveAdmin::AuthorizationAdapter
|
17
17
|
namespace.authorization_adapter = mock_auth
|
18
|
-
|
19
|
-
namespace.authorization_adapter.should == mock_auth
|
18
|
+
namespace.authorization_adapter.should eq mock_auth
|
20
19
|
end
|
21
20
|
|
22
21
|
it "should be settable on the application" do
|
23
|
-
namespace.authorization_adapter.should == ActiveAdmin::AuthorizationAdapter
|
24
22
|
app.authorization_adapter = mock_auth
|
25
|
-
|
26
|
-
namespace.authorization_adapter.should == mock_auth
|
23
|
+
app.authorization_adapter.should eq mock_auth
|
27
24
|
end
|
28
25
|
|
29
26
|
end
|
30
|
-
|
31
27
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# TODO: refactor this file so it doesn't depend on the Admin namespace in such a broken way.
|
4
|
+
# Specifically, the dashboard is already defined and we do let(:namespace) multiple times.
|
2
5
|
|
3
6
|
describe ActiveAdmin::Namespace, "registering a resource" do
|
4
7
|
|
@@ -18,8 +21,8 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
18
21
|
it "should create a new controller in the default namespace" do
|
19
22
|
defined?(Admin::CategoriesController).should be_true
|
20
23
|
end
|
21
|
-
|
22
|
-
defined?(Admin::DashboardController).
|
24
|
+
pending "should not create the dashboard controller" do
|
25
|
+
defined?(Admin::DashboardController).should_not be_true
|
23
26
|
end
|
24
27
|
it "should create a menu item" do
|
25
28
|
menu["Categories"].should be_a ActiveAdmin::MenuItem
|
@@ -144,14 +147,16 @@ describe ActiveAdmin::Namespace, "registering a resource" do
|
|
144
147
|
describe "dashboard controller name" do
|
145
148
|
context "when namespaced" do
|
146
149
|
it "should be namespaced" do
|
147
|
-
namespace = ActiveAdmin::Namespace.new(application, :
|
148
|
-
namespace.
|
150
|
+
namespace = ActiveAdmin::Namespace.new(application, :one)
|
151
|
+
namespace.register Category
|
152
|
+
defined?(One::CategoriesController).should be_true
|
149
153
|
end
|
150
154
|
end
|
151
155
|
context "when not namespaced" do
|
152
156
|
it "should not be namespaced" do
|
153
|
-
namespace = ActiveAdmin::Namespace.new(application, :
|
154
|
-
namespace.
|
157
|
+
namespace = ActiveAdmin::Namespace.new(application, :two)
|
158
|
+
namespace.register Category
|
159
|
+
defined?(Two::CategoriesController).should be_true
|
155
160
|
end
|
156
161
|
end
|
157
162
|
end # describe "dashboard controller name"
|
data/spec/unit/namespace_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveAdmin::Namespace do
|
4
4
|
|
@@ -16,17 +16,11 @@ describe ActiveAdmin::Namespace do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should have no resources" do
|
19
|
-
namespace.resources.
|
19
|
+
namespace.resources.should be_empty
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should not have any menu item" do
|
23
|
-
|
24
|
-
# DEPRECATED behavior. If a dashboard was built while running this
|
25
|
-
# spec, then an item gets added to the menu
|
26
|
-
namespace.fetch_menu(:default).children.should_not be_empty
|
27
|
-
else
|
28
|
-
namespace.fetch_menu(:default).children.should be_empty
|
29
|
-
end
|
23
|
+
namespace.fetch_menu(:default).children.should be_empty
|
30
24
|
end
|
31
25
|
end # context "when new"
|
32
26
|
|
@@ -86,7 +80,7 @@ describe ActiveAdmin::Namespace do
|
|
86
80
|
|
87
81
|
describe "utility navigation" do
|
88
82
|
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
89
|
-
let(:menu) do
|
83
|
+
let(:menu) do
|
90
84
|
namespace.build_menu :utility_navigation do |menu|
|
91
85
|
menu.add :label => "ActiveAdmin.info", :url => "http://www.activeadmin.info", :html_options => { :target => :blank }
|
92
86
|
namespace.add_logout_button_to_menu menu, 1, :class => "matt"
|