activeadmin 0.4.4 → 0.5.0.pre
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 +3 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +50 -0
- data/CONTRIBUTING.md +2 -4
- data/Gemfile +10 -4
- data/Guardfile +0 -1
- data/LICENSE +1 -1
- data/README.rdoc +19 -8
- data/Rakefile +10 -1
- data/activeadmin.gemspec +2 -1
- data/app/assets/javascripts/active_admin/application.js +3 -9
- data/app/assets/javascripts/active_admin/base.js +1 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +64 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +107 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +100 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +27 -0
- data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +3 -0
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -0
- data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +26 -0
- data/app/assets/stylesheets/active_admin/_base.css.scss +32 -26
- data/app/assets/stylesheets/active_admin/_forms.css.scss +12 -5
- data/app/assets/stylesheets/active_admin/_header.css.scss +1 -2
- data/app/assets/stylesheets/active_admin/_typography.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +11 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +1 -2
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +151 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +123 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +20 -27
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +38 -36
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -5
- data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +7 -3
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +19 -17
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +2 -2
- data/app/assets/stylesheets/active_admin/print.css.scss +290 -0
- data/app/views/active_admin/dashboard/index.html.arb +1 -1
- data/app/views/active_admin/devise/passwords/edit.html.erb +17 -14
- data/app/views/active_admin/devise/passwords/new.html.erb +4 -4
- data/app/views/active_admin/devise/sessions/new.html.erb +6 -6
- data/app/views/active_admin/devise/shared/_links.erb +6 -6
- data/app/views/active_admin/page/index.html.arb +1 -1
- data/app/views/active_admin/resource/edit.html.arb +1 -1
- data/app/views/active_admin/resource/index.csv.erb +1 -1
- data/app/views/active_admin/resource/index.html.arb +1 -1
- data/app/views/active_admin/resource/new.html.arb +1 -1
- data/app/views/active_admin/resource/show.html.arb +1 -1
- data/app/views/layouts/active_admin.html.arb +1 -1
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +1 -1
- data/docs/0-installation.md +10 -1
- data/docs/{9-custom-pages.md → 10-custom-pages.md} +0 -0
- data/docs/2-resource-customization.md +19 -1
- data/docs/3-index-pages.md +31 -0
- data/docs/4-csv-format.md +9 -0
- data/docs/6-show-screens.md +1 -1
- data/docs/9-batch-actions.md +161 -0
- data/features/dashboard.feature +31 -8
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +3 -3
- data/features/i18n.feature +35 -0
- data/features/index/batch_actions.feature +98 -0
- data/features/index/filters.feature +26 -0
- data/features/index/format_as_csv.feature +35 -0
- data/features/index/index_as_table.feature +30 -2
- data/features/index/index_blank_slate.feature +8 -3
- data/features/index/index_scopes.feature +130 -24
- data/features/index/page_title.feature +12 -0
- data/features/new_page.feature +3 -3
- data/features/registering_pages.feature +61 -0
- data/features/root_to.feature +17 -0
- data/features/show/default_content.feature +1 -1
- data/features/show/page_title.feature +14 -0
- data/features/sidebar_sections.feature +26 -0
- data/features/site_title.feature +1 -1
- data/features/specifying_actions.feature +7 -6
- data/features/step_definitions/action_link_steps.rb +1 -1
- data/features/step_definitions/additional_web_steps.rb +7 -1
- data/features/step_definitions/batch_action_steps.rb +94 -0
- data/features/step_definitions/configuration_steps.rb +30 -8
- data/features/step_definitions/factory_steps.rb +12 -0
- data/features/step_definitions/format_steps.rb +6 -2
- data/features/step_definitions/i18n_steps.rb +3 -0
- data/features/step_definitions/table_steps.rb +114 -0
- data/features/step_definitions/user_steps.rb +30 -4
- data/features/support/env.rb +54 -15
- data/features/support/paths.rb +2 -0
- data/features/users/logging_in.feature +1 -1
- data/features/users/logging_out.feature +2 -1
- data/features/users/resetting_password.feature +34 -0
- data/lib/active_admin.rb +46 -7
- data/lib/active_admin/application.rb +30 -15
- data/lib/active_admin/base_controller/menu.rb +3 -3
- data/lib/active_admin/batch_actions.rb +17 -0
- data/lib/active_admin/batch_actions/controller.rb +25 -0
- data/lib/active_admin/batch_actions/resource_extension.rb +126 -0
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +35 -0
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +28 -0
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +63 -0
- data/lib/active_admin/batch_actions/views/selection_cells.rb +37 -0
- data/lib/active_admin/comments.rb +5 -2
- data/lib/active_admin/comments/comment.rb +4 -3
- data/lib/active_admin/comments/views/active_admin_comments.rb +5 -5
- data/lib/active_admin/component.rb +1 -18
- data/lib/active_admin/csv_builder.rb +8 -3
- data/lib/active_admin/dashboards.rb +21 -4
- data/lib/active_admin/dashboards/dashboard_controller.rb +1 -5
- data/lib/active_admin/dependency_checker.rb +1 -1
- data/lib/active_admin/dsl.rb +61 -4
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters.rb +8 -0
- data/lib/active_admin/filters/dsl.rb +12 -0
- data/lib/active_admin/filters/forms.rb +93 -0
- data/lib/active_admin/filters/resource_extension.rb +92 -0
- data/lib/active_admin/form_builder.rb +88 -33
- data/lib/active_admin/helpers/collection.rb +23 -0
- data/lib/active_admin/helpers/optional_display.rb +1 -1
- data/lib/active_admin/inputs/filter_select_input.rb +1 -1
- data/lib/active_admin/locales/bg.yml +37 -1
- data/lib/active_admin/locales/ca.yml +36 -0
- data/lib/active_admin/locales/cs.yml +36 -0
- data/lib/active_admin/locales/da.yml +36 -0
- data/lib/active_admin/locales/de.yml +42 -0
- data/lib/active_admin/locales/en.yml +27 -2
- data/lib/active_admin/locales/es.yml +45 -4
- data/lib/active_admin/locales/fr.yml +22 -0
- data/lib/active_admin/locales/{he_il.yml → he.yml} +37 -2
- data/lib/active_admin/locales/hr.yml +49 -5
- data/lib/active_admin/locales/hu.yml +21 -0
- data/lib/active_admin/locales/it.yml +36 -1
- data/lib/active_admin/locales/ja.yml +36 -0
- data/lib/active_admin/locales/ko.yml +36 -1
- data/lib/active_admin/locales/lv.yml +28 -2
- data/lib/active_admin/locales/nl.yml +42 -1
- data/lib/active_admin/locales/no-NB.yml +15 -0
- data/lib/active_admin/locales/pl.yml +45 -1
- data/lib/active_admin/locales/pt-BR.yml +36 -1
- data/lib/active_admin/locales/ro.yml +67 -0
- data/lib/active_admin/locales/ru.yml +43 -3
- data/lib/active_admin/locales/sv-SE.yml +41 -1
- data/lib/active_admin/locales/tr.yml +80 -0
- data/lib/active_admin/locales/vi.yml +80 -0
- data/lib/active_admin/locales/{zh_cn.yml → zh-CN.yml} +42 -2
- data/lib/active_admin/locales/zh-TW.yml +36 -1
- data/lib/active_admin/menu.rb +55 -30
- data/lib/active_admin/menu_builder.rb +65 -0
- data/lib/active_admin/menu_item.rb +55 -14
- data/lib/active_admin/namespace.rb +25 -55
- data/lib/active_admin/page.rb +15 -10
- data/lib/active_admin/resource.rb +9 -0
- data/lib/active_admin/resource/action_items.rb +4 -4
- data/lib/active_admin/resource/controllers.rb +1 -1
- data/lib/active_admin/resource/menu.rb +19 -21
- data/lib/active_admin/resource/naming.rb +55 -45
- data/lib/active_admin/resource/sidebars.rb +0 -13
- data/lib/active_admin/resource_collection.rb +10 -10
- data/lib/active_admin/resource_controller.rb +5 -5
- data/lib/active_admin/resource_controller/actions.rb +2 -0
- data/lib/active_admin/resource_controller/collection.rb +13 -4
- data/lib/active_admin/resource_dsl.rb +12 -6
- data/lib/active_admin/router.rb +27 -8
- data/lib/active_admin/scope.rb +1 -0
- data/lib/active_admin/sidebar_section.rb +2 -6
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +18 -13
- data/lib/active_admin/view_helpers.rb +0 -2
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +24 -25
- data/lib/active_admin/view_helpers/display_helper.rb +1 -1
- data/lib/active_admin/view_helpers/fields_for.rb +44 -0
- data/lib/active_admin/view_helpers/form_helper.rb +6 -0
- data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -1
- data/lib/active_admin/views/components/action_list_popover.rb +29 -0
- data/lib/active_admin/views/components/attributes_table.rb +6 -2
- data/lib/active_admin/views/components/dropdown_menu.rb +73 -0
- data/lib/active_admin/views/components/paginated_collection.rb +13 -14
- data/lib/active_admin/views/components/popover.rb +27 -0
- data/lib/active_admin/views/components/scopes.rb +8 -13
- data/lib/active_admin/views/components/sidebar_section.rb +1 -1
- data/lib/active_admin/views/components/site_title.rb +55 -0
- data/lib/active_admin/views/components/status_tag.rb +4 -4
- data/lib/active_admin/views/components/table_for.rb +18 -18
- data/lib/active_admin/views/dashboard_section_renderer.rb +1 -1
- data/lib/active_admin/views/footer.rb +18 -0
- data/lib/active_admin/views/header.rb +31 -0
- data/lib/active_admin/views/index_as_block.rb +3 -0
- data/lib/active_admin/views/index_as_blog.rb +4 -0
- data/lib/active_admin/views/index_as_grid.rb +2 -0
- data/lib/active_admin/views/index_as_table.rb +19 -6
- data/lib/active_admin/views/pages/base.rb +14 -48
- data/lib/active_admin/views/pages/form.rb +3 -3
- data/lib/active_admin/views/pages/index.rb +56 -24
- data/lib/active_admin/views/pages/layout.rb +2 -2
- data/lib/active_admin/views/pages/page.rb +10 -4
- data/lib/active_admin/views/pages/show.rb +11 -8
- data/lib/active_admin/views/tabbed_navigation.rb +3 -3
- data/lib/active_admin/views/title_bar.rb +50 -0
- data/lib/active_admin/views/utility_nav.rb +41 -0
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -0
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +26 -3
- data/lib/generators/active_admin/devise/devise_generator.rb +2 -2
- data/lib/generators/active_admin/install/install_generator.rb +10 -10
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +21 -1
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +20 -0
- data/lib/generators/active_admin/install/templates/dashboard.rb +33 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
- data/spec/integration/memory_spec.rb +1 -11
- data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +50 -0
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +82 -0
- data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +34 -0
- data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +60 -0
- data/spec/javascripts/compiled/jquery.aa.popover-spec.js +106 -0
- data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +37 -0
- data/spec/javascripts/fixtures/checkboxes.html +9 -0
- data/spec/javascripts/fixtures/table_checkboxes.html +17 -0
- data/spec/javascripts/helpers/SpecHelper.js +3 -0
- data/spec/javascripts/helpers/vendor/jasmine-fixture-0.0.5.js +108 -0
- data/spec/javascripts/helpers/vendor/jasmine-jquery.js +288 -0
- data/spec/javascripts/helpers/vendor/sinon-1.2.0.js +2915 -0
- data/spec/javascripts/support/jasmine.yml +74 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/javascripts/support/jquery-ui-1.8.16.custom.min.js +34 -0
- data/spec/javascripts/support/jquery.min.js +4 -0
- data/spec/spec_helper.rb +13 -13
- data/spec/spec_helper_without_rails.rb +2 -3
- data/spec/support/detect_rails_version.rb +16 -10
- data/spec/support/rails_template.rb +13 -1
- data/spec/support/templates/admin/stores.rb +1 -0
- data/spec/support/templates/en.yml +6 -0
- data/spec/unit/action_builder_spec.rb +38 -0
- data/spec/unit/application_spec.rb +12 -16
- data/spec/unit/base_controller_shared_examples.rb +3 -6
- data/spec/unit/batch_actions/resource_spec.rb +91 -0
- data/spec/unit/batch_actions/settings_spec.rb +61 -0
- data/spec/unit/breadcrumbs_spec.rb +33 -0
- data/spec/unit/comments_spec.rb +6 -0
- data/spec/unit/config_shared_examples.rb +17 -64
- data/spec/unit/csv_builder_spec.rb +12 -2
- data/spec/unit/dashboard_controller_spec.rb +11 -5
- data/spec/unit/dsl_include_spec.rb +20 -0
- data/spec/unit/{filter_form_builder_spec.rb → filters/filter_form_builder_spec.rb} +10 -7
- data/spec/unit/filters/resource_spec.rb +60 -0
- data/spec/unit/form_builder_spec.rb +180 -28
- data/spec/unit/helpers/collection_spec.rb +65 -0
- data/spec/unit/menu_item_spec.rb +48 -53
- data/spec/unit/menu_spec.rb +46 -32
- data/spec/unit/namespace/register_page_spec.rb +0 -6
- data/spec/unit/namespace/register_resource_spec.rb +1 -8
- data/spec/unit/namespace_spec.rb +8 -2
- data/spec/unit/page_spec.rb +20 -8
- data/spec/unit/resource/naming_spec.rb +27 -26
- data/spec/unit/resource/sidebars_spec.rb +0 -7
- data/spec/unit/resource_collection_spec.rb +11 -11
- data/spec/unit/resource_controller/collection_spec.rb +23 -1
- data/spec/unit/resource_controller/sidebars_spec.rb +46 -0
- data/spec/unit/resource_controller_spec.rb +43 -0
- data/spec/unit/resource_registration_spec.rb +2 -13
- data/spec/unit/resource_spec.rb +0 -42
- data/spec/unit/routing_spec.rb +60 -14
- data/spec/unit/scope_spec.rb +7 -0
- data/spec/unit/view_factory_spec.rb +9 -6
- data/spec/unit/view_helpers/fields_for_spec.rb +41 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +18 -0
- data/spec/unit/views/components/action_list_popover_spec.rb +30 -0
- data/spec/unit/views/components/attributes_table_spec.rb +32 -20
- data/spec/unit/views/components/batch_action_popover_spec.rb +33 -0
- data/spec/unit/views/components/blank_slate_spec.rb +5 -3
- data/spec/unit/views/components/columns_spec.rb +32 -22
- data/spec/unit/views/components/paginated_collection_spec.rb +54 -12
- data/spec/unit/views/components/panel_spec.rb +11 -6
- data/spec/unit/views/components/popover_spec.rb +33 -0
- data/spec/unit/views/components/sidebar_section_spec.rb +6 -6
- data/spec/unit/views/components/site_title_spec.rb +78 -0
- data/spec/unit/views/components/status_tag_spec.rb +17 -10
- data/spec/unit/views/components/table_for_spec.rb +37 -17
- data/spec/unit/views/pages/layout_spec.rb +51 -10
- data/spec/unit/views/tabbed_navigation_spec.rb +44 -23
- data/tasks/js.rake +32 -0
- data/tasks/test.rake +1 -1
- metadata +233 -200
- data/lib/active_admin/arbre.rb +0 -22
- data/lib/active_admin/arbre/builder.rb +0 -125
- data/lib/active_admin/arbre/context.rb +0 -45
- data/lib/active_admin/arbre/html/attributes.rb +0 -20
- data/lib/active_admin/arbre/html/class_list.rb +0 -24
- data/lib/active_admin/arbre/html/collection.rb +0 -27
- data/lib/active_admin/arbre/html/document.rb +0 -42
- data/lib/active_admin/arbre/html/element.rb +0 -161
- data/lib/active_admin/arbre/html/html5_elements.rb +0 -47
- data/lib/active_admin/arbre/html/tag.rb +0 -145
- data/lib/active_admin/arbre/html/text_node.rb +0 -35
- data/lib/active_admin/filter_form_builder.rb +0 -53
- data/lib/active_admin/renderer.rb +0 -87
- data/lib/active_admin/resource_controller/filters.rb +0 -58
- data/lib/active_admin/stylesheets/active_admin/mixins/_utilities.scss +0 -0
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -36
- data/lib/active_admin/view_helpers/renderer_helper.rb +0 -29
- data/lib/active_admin/views/header_renderer.rb +0 -82
- data/lib/generators/active_admin/assets/templates/dashboards.rb +0 -36
- data/lib/generators/active_admin/install/templates/dashboards.rb +0 -44
- data/spec/unit/arbre/context_spec.rb +0 -35
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +0 -110
- data/spec/unit/arbre/html/element_spec.rb +0 -236
- data/spec/unit/arbre/html/tag_attributes_spec.rb +0 -61
- data/spec/unit/arbre/html/tag_spec.rb +0 -63
- data/spec/unit/arbre/html_spec.rb +0 -228
- data/spec/unit/renderer_spec.rb +0 -126
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveAdmin::Views::SiteTitle do
|
4
|
+
|
5
|
+
let(:helpers){ mock_action_view }
|
6
|
+
|
7
|
+
def build_title(namespace)
|
8
|
+
render_arbre_component({:namespace => namespace}, helpers) do
|
9
|
+
insert_tag ActiveAdmin::Views::SiteTitle, assigns[:namespace]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when a value" do
|
14
|
+
|
15
|
+
it "renders the string when a string is passed in" do
|
16
|
+
namespace = mock :site_title => "Hello World",
|
17
|
+
:site_title_image => nil,
|
18
|
+
:site_title_link => nil
|
19
|
+
|
20
|
+
site_title = build_title(namespace)
|
21
|
+
site_title.content.should == "Hello World"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "renders the return value of a method when a symbol" do
|
25
|
+
helpers.should_receive(:hello_world).and_return("Hello World")
|
26
|
+
|
27
|
+
namespace = mock :site_title => :hello_world,
|
28
|
+
:site_title_image => nil,
|
29
|
+
:site_title_link => nil
|
30
|
+
|
31
|
+
site_title = build_title(namespace)
|
32
|
+
site_title.content.should == "Hello World"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "renders the return value of a proc" do
|
36
|
+
namespace = mock :site_title => proc{ "Hello World" },
|
37
|
+
:site_title_image => nil,
|
38
|
+
:site_title_link => nil
|
39
|
+
|
40
|
+
site_title = build_title(namespace)
|
41
|
+
site_title.content.should == "Hello World"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when an image" do
|
47
|
+
|
48
|
+
it "renders the string when a string is passed in" do
|
49
|
+
helpers.should_receive(:image_tag).
|
50
|
+
with("an/image.png", {:alt => nil, :id => "site_title_image"}).
|
51
|
+
and_return("<img src=\"/assets/an/image.png\" />".html_safe)
|
52
|
+
|
53
|
+
namespace = mock :site_title => nil,
|
54
|
+
:site_title_image => "an/image.png",
|
55
|
+
:site_title_link => nil
|
56
|
+
|
57
|
+
site_title = build_title(namespace)
|
58
|
+
site_title.content.strip.should == "<img src=\"/assets/an/image.png\" />"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when a link is present" do
|
64
|
+
|
65
|
+
it "renders the string when a string is passed in" do
|
66
|
+
namespace = mock :site_title => "Hello World",
|
67
|
+
:site_title_image => nil,
|
68
|
+
:site_title_link => "/"
|
69
|
+
|
70
|
+
site_title = build_title(namespace)
|
71
|
+
site_title.content.should == "<a href=\"/\">Hello World</a>"
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
end
|
@@ -2,19 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveAdmin::Views::StatusTag do
|
4
4
|
|
5
|
-
setup_arbre_context!
|
6
|
-
|
7
5
|
describe "#status_tag" do
|
6
|
+
|
7
|
+
# Helper method to build StatusTag objects in an Arbre context
|
8
|
+
def status_tag(*args)
|
9
|
+
render_arbre_component(:status_tag_args => args) do
|
10
|
+
status_tag(*assigns[:status_tag_args])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
subject { status_tag(nil) }
|
9
15
|
|
16
|
+
|
10
17
|
its(:tag_name) { should == 'span' }
|
11
|
-
its(:class_list) { should include('
|
18
|
+
its(:class_list) { should include('status_tag') }
|
12
19
|
|
13
20
|
context "when status is 'completed'" do
|
14
21
|
subject { status_tag('completed') }
|
15
22
|
|
16
23
|
its(:tag_name) { should == 'span' }
|
17
|
-
its(:class_list) { should include('
|
24
|
+
its(:class_list) { should include('status_tag') }
|
18
25
|
its(:class_list) { should include('completed') }
|
19
26
|
its(:content) { should == 'Completed' }
|
20
27
|
end
|
@@ -36,21 +43,21 @@ describe ActiveAdmin::Views::StatusTag do
|
|
36
43
|
context "when status is an empty string" do
|
37
44
|
subject { status_tag('') }
|
38
45
|
|
39
|
-
its(:class_list) { should include('
|
46
|
+
its(:class_list) { should include('status_tag') }
|
40
47
|
its(:content) { should == '' }
|
41
48
|
end
|
42
49
|
|
43
50
|
context "when status is nil" do
|
44
51
|
subject { status_tag(nil) }
|
45
52
|
|
46
|
-
its(:class_list) { should include('
|
53
|
+
its(:class_list) { should include('status_tag') }
|
47
54
|
its(:content) { should == '' }
|
48
55
|
end
|
49
56
|
|
50
57
|
context "when status is 'Active' and type is :ok" do
|
51
58
|
subject { status_tag('Active', :ok) }
|
52
59
|
|
53
|
-
its(:class_list) { should include('
|
60
|
+
its(:class_list) { should include('status_tag') }
|
54
61
|
its(:class_list) { should include('active') }
|
55
62
|
its(:class_list) { should include('ok') }
|
56
63
|
end
|
@@ -58,7 +65,7 @@ describe ActiveAdmin::Views::StatusTag do
|
|
58
65
|
context "when status is 'Active' and class is 'ok'" do
|
59
66
|
subject { status_tag('Active', :class => 'ok') }
|
60
67
|
|
61
|
-
its(:class_list) { should include('
|
68
|
+
its(:class_list) { should include('status_tag') }
|
62
69
|
its(:class_list) { should include('active') }
|
63
70
|
its(:class_list) { should include('ok') }
|
64
71
|
end
|
@@ -67,7 +74,7 @@ describe ActiveAdmin::Views::StatusTag do
|
|
67
74
|
subject { status_tag('Active', :label => 'on') }
|
68
75
|
|
69
76
|
its(:content) { should == 'on' }
|
70
|
-
its(:class_list) { should include('
|
77
|
+
its(:class_list) { should include('status_tag') }
|
71
78
|
its(:class_list) { should include('active') }
|
72
79
|
its(:class_list) { should_not include('on') }
|
73
80
|
end
|
@@ -76,7 +83,7 @@ describe ActiveAdmin::Views::StatusTag do
|
|
76
83
|
subject { status_tag('So useless', :ok, :class => 'woot awesome', :id => 'useless') }
|
77
84
|
|
78
85
|
its(:content) { should == 'So Useless' }
|
79
|
-
its(:class_list) { should include('
|
86
|
+
its(:class_list) { should include('status_tag') }
|
80
87
|
its(:class_list) { should include('ok') }
|
81
88
|
its(:class_list) { should include('so_useless') }
|
82
89
|
its(:class_list) { should include('woot') }
|
@@ -3,19 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveAdmin::Views::TableFor do
|
4
4
|
describe "creating with the dsl" do
|
5
5
|
|
6
|
-
setup_arbre_context!
|
7
|
-
|
8
|
-
let(:assigns){ {} }
|
9
|
-
let(:helpers){ mock_action_view }
|
10
|
-
|
11
6
|
let(:collection) do
|
12
7
|
[Post.new(:title => "First Post"), Post.new(:title => "Second Post"), Post.new(:title => "Third Post")]
|
13
8
|
end
|
14
9
|
|
10
|
+
let(:assigns){ { :collection => collection } }
|
11
|
+
let(:helpers){ mock_action_view }
|
12
|
+
|
15
13
|
context "when creating a column with a symbol" do
|
16
14
|
let(:table) do
|
17
|
-
|
18
|
-
|
15
|
+
render_arbre_component assigns, helpers do
|
16
|
+
table_for(collection) do
|
17
|
+
column :title
|
18
|
+
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -36,9 +36,11 @@ describe ActiveAdmin::Views::TableFor do
|
|
36
36
|
|
37
37
|
context "when creating many columns with symbols" do
|
38
38
|
let(:table) do
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
render_arbre_component assigns, helpers do
|
40
|
+
table_for(collection) do
|
41
|
+
column :title
|
42
|
+
column :created_at
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -46,6 +48,11 @@ describe ActiveAdmin::Views::TableFor do
|
|
46
48
|
table.find_by_tag("th").first.content.should == "Title"
|
47
49
|
table.find_by_tag("th").last.content.should == "Created At"
|
48
50
|
end
|
51
|
+
|
52
|
+
it "should add a class to each table header based on the col name" do
|
53
|
+
table.find_by_tag("th").first.class_list.should include("title")
|
54
|
+
table.find_by_tag("th").last.class_list.should include("created_at")
|
55
|
+
end
|
49
56
|
|
50
57
|
it "should create a table row for each element in the collection" do
|
51
58
|
table.find_by_tag("tr").size.should == 4 # 1 for head, 3 for rows
|
@@ -54,13 +61,20 @@ describe ActiveAdmin::Views::TableFor do
|
|
54
61
|
it "should create a cell for each column" do
|
55
62
|
table.find_by_tag("td").size.should == 6
|
56
63
|
end
|
64
|
+
|
65
|
+
it "should add a class for each cell based on the col name" do
|
66
|
+
table.find_by_tag("td").first.class_list.should include("title")
|
67
|
+
table.find_by_tag("td").last.class_list.should include("created_at")
|
68
|
+
end
|
57
69
|
end
|
58
70
|
|
59
71
|
context "when creating a column with block content" do
|
60
72
|
let(:table) do
|
61
|
-
|
62
|
-
|
63
|
-
|
73
|
+
render_arbre_component assigns, helpers do
|
74
|
+
table_for(collection) do
|
75
|
+
column :title do |post|
|
76
|
+
span(post.title)
|
77
|
+
end
|
64
78
|
end
|
65
79
|
end
|
66
80
|
end
|
@@ -76,10 +90,12 @@ describe ActiveAdmin::Views::TableFor do
|
|
76
90
|
|
77
91
|
context "when creating a column with multiple block content" do
|
78
92
|
let(:table) do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
93
|
+
render_arbre_component assigns, helpers do
|
94
|
+
table_for(collection) do
|
95
|
+
column :title do |post|
|
96
|
+
span(post.title)
|
97
|
+
span(post.title)
|
98
|
+
end
|
83
99
|
end
|
84
100
|
end
|
85
101
|
end
|
@@ -127,5 +143,9 @@ describe ActiveAdmin::Views::TableFor do
|
|
127
143
|
it { should_not be_sortable }
|
128
144
|
end
|
129
145
|
|
146
|
+
context "when :sortable column is an association" do
|
147
|
+
let(:table_column){ build_column("Category", :category, Post) }
|
148
|
+
it { should_not be_sortable }
|
149
|
+
end
|
130
150
|
end
|
131
151
|
end
|
@@ -2,19 +2,60 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveAdmin::Views::Pages::Layout do
|
4
4
|
|
5
|
-
|
5
|
+
let(:assigns){ {} }
|
6
|
+
let(:helpers) do
|
7
|
+
helpers = mock_action_view
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
helpers.stub :active_admin_application => active_admin_application,
|
10
|
+
:active_admin_config => mock('Config', :action_items? => nil, :sidebar_sections? => nil),
|
11
|
+
:active_admin_namespace => active_admin_namespace,
|
12
|
+
:breadcrumb_links => [],
|
13
|
+
:content_for => "",
|
14
|
+
:csrf_meta_tag => "",
|
15
|
+
:current_active_admin_user => nil,
|
16
|
+
:current_active_admin_user? => false,
|
17
|
+
:current_menu => mock('Menu', :items => []),
|
18
|
+
:flash => {},
|
19
|
+
:javascript_path => "/dummy/",
|
20
|
+
:link_to => "",
|
21
|
+
:render_or_call_method_or_proc_on => "",
|
22
|
+
:stylesheet_link_tag => mock(:html_safe => ""),
|
23
|
+
:view_factory => view_factory,
|
24
|
+
:params => {:controller => 'UsersController', :action => 'edit'}
|
25
|
+
|
26
|
+
helpers
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:active_admin_namespace){ ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :myspace) }
|
30
|
+
let(:active_admin_application){ ActiveAdmin.application }
|
31
|
+
let(:view_factory) { ActiveAdmin::ViewFactory.new }
|
32
|
+
|
33
|
+
let(:layout) do
|
34
|
+
render_arbre_component assigns, helpers do
|
35
|
+
insert_tag ActiveAdmin::Views::Pages::Layout
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be the @page_title if assigned in the controller" do
|
40
|
+
assigns[:page_title] = "My Page Title"
|
41
|
+
|
42
|
+
layout.title.should == "My Page Title"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be the default translation" do
|
46
|
+
helpers.params[:action] = "edit"
|
47
|
+
|
48
|
+
layout.title.should == "Edit"
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "the body" do
|
52
|
+
|
53
|
+
it "should have class 'active_admin'" do
|
54
|
+
layout.build.class_list.should include 'active_admin'
|
11
55
|
end
|
12
56
|
|
13
|
-
it "should
|
14
|
-
|
15
|
-
helpers = mock(:params => {:action => 'edit'})
|
16
|
-
layout = ActiveAdmin::Views::Pages::Layout.new(assigns, helpers)
|
17
|
-
layout.title.should == "Edit"
|
57
|
+
it "should have namespace class" do
|
58
|
+
layout.build.class_list.should include "#{active_admin_namespace.name}_namespace"
|
18
59
|
end
|
19
60
|
|
20
61
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
include ActiveAdmin
|
3
4
|
describe ActiveAdmin::Views::TabbedNavigation do
|
4
5
|
|
5
|
-
setup_arbre_context!
|
6
|
-
include ActiveAdmin::ViewHelpers
|
7
|
-
|
8
6
|
let(:menu){ ActiveAdmin::Menu.new }
|
9
|
-
|
7
|
+
|
8
|
+
let(:assigns){ { :active_admin_menu => menu } }
|
9
|
+
let(:helpers){ mock_action_view }
|
10
|
+
|
11
|
+
let(:tabbed_navigation) do
|
12
|
+
arbre(assigns, helpers) {
|
13
|
+
insert_tag(ActiveAdmin::Views::TabbedNavigation, active_admin_menu)
|
14
|
+
}.children.first
|
15
|
+
end
|
16
|
+
|
10
17
|
let(:html) { tabbed_navigation.to_s }
|
11
18
|
|
12
19
|
before do
|
@@ -16,18 +23,30 @@ describe ActiveAdmin::Views::TabbedNavigation do
|
|
16
23
|
describe "rendering a menu" do
|
17
24
|
|
18
25
|
before do
|
19
|
-
menu.add "Blog Posts", :admin_posts_path
|
20
|
-
menu.add "Reports", "/admin/reports"
|
26
|
+
menu.add MenuItem.new(:label => "Blog Posts", :url => :admin_posts_path)
|
27
|
+
menu.add MenuItem.new(:label => "Reports", :url => "/admin/reports")
|
28
|
+
menu.add MenuItem.new(:label => "Administration", :url => "/admin/administration")
|
29
|
+
menu.add MenuItem.new(:label => "Management", :url => "#")
|
30
|
+
|
21
31
|
reports = menu["Reports"]
|
22
|
-
reports.add "A Sub Reports", "/admin/a-sub-reports"
|
23
|
-
reports.add "B Sub Reports", "/admin/b-sub-reports"
|
24
|
-
|
32
|
+
reports.add MenuItem.new(:label => "A Sub Reports", :url => "/admin/a-sub-reports")
|
33
|
+
reports.add MenuItem.new(:label => "B Sub Reports", :url => "/admin/b-sub-reports")
|
34
|
+
|
25
35
|
administration = menu["Administration"]
|
26
|
-
administration.add "User administration",
|
27
|
-
|
36
|
+
administration.add MenuItem.new(:label => "User administration",
|
37
|
+
:url => '/admin/user-administration',
|
38
|
+
:priority => 10,
|
39
|
+
:if => proc { false })
|
40
|
+
|
28
41
|
management = menu["Management"]
|
29
|
-
management.add "Order management",
|
30
|
-
|
42
|
+
management.add MenuItem.new(:label => "Order management",
|
43
|
+
:url => '/admin/order-management',
|
44
|
+
:priority => 10,
|
45
|
+
:if => proc { false })
|
46
|
+
management.add MenuItem.new(:label => "Bill management",
|
47
|
+
:url => '/admin/bill-management',
|
48
|
+
:priority => 10,
|
49
|
+
:if => :admin_logged_in?)
|
31
50
|
end
|
32
51
|
|
33
52
|
it "should generate a ul" do
|
@@ -74,12 +93,12 @@ describe ActiveAdmin::Views::TabbedNavigation do
|
|
74
93
|
describe "marking current item" do
|
75
94
|
|
76
95
|
it "should add the 'current' class to the li" do
|
77
|
-
assigns[:current_tab] = "Blog Posts"
|
96
|
+
assigns[:current_tab] = menu["Blog Posts"]
|
78
97
|
html.should have_tag("li", :attributes => { :class => "current" })
|
79
98
|
end
|
80
99
|
|
81
100
|
it "should add the 'current' and 'has_nested' classes to the li and 'current' to the sub li" do
|
82
|
-
assigns[:current_tab] = "Reports
|
101
|
+
assigns[:current_tab] = menu["Reports"]["A Sub Reports"]
|
83
102
|
html.should have_tag("li", :attributes => { :id => "reports", :class => /current/ })
|
84
103
|
html.should have_tag("li", :attributes => { :id => "reports", :class => /has_nested/ })
|
85
104
|
html.should have_tag("li", :attributes => { :id => "a_sub_reports", :class => "current" })
|
@@ -92,32 +111,34 @@ describe ActiveAdmin::Views::TabbedNavigation do
|
|
92
111
|
describe "returning the menu items to display" do
|
93
112
|
|
94
113
|
it "should be reture one item with no if block" do
|
95
|
-
menu.add "Hello World", "/"
|
114
|
+
menu.add MenuItem.new(:label => "Hello World", :url => "/")
|
96
115
|
tabbed_navigation.menu_items.should == menu.items
|
97
116
|
end
|
98
117
|
|
99
118
|
it "should not include a menu items with an if block that returns false" do
|
100
|
-
menu.add "Don't Show", "/", 10, :if => proc{ false }
|
119
|
+
menu.add MenuItem.new(:label => "Don't Show", :url => "/", :priority => 10, :if => proc{ false })
|
101
120
|
tabbed_navigation.menu_items.should == []
|
102
121
|
end
|
103
122
|
|
104
123
|
it "should not include menu items with an if block that calls a method that returns false" do
|
105
|
-
menu.add "Don't Show", "/", 10, :if => :admin_logged_in?
|
124
|
+
menu.add MenuItem.new(:label => "Don't Show", :url => "/", :priority => 10, :if => :admin_logged_in?)
|
106
125
|
tabbed_navigation.menu_items.should == []
|
107
126
|
end
|
108
127
|
|
109
128
|
it "should not display any items that have no children to display" do
|
110
|
-
|
111
|
-
p.add "Child", "/", 10, :if => proc{ false }
|
129
|
+
item = MenuItem.new(:label => "Parent", :url => "#") do |p|
|
130
|
+
p.add MenuItem.new(:label => "Child", :url => "/", :priority => 10, :if => proc{ false })
|
112
131
|
end
|
132
|
+
menu.add item
|
113
133
|
tabbed_navigation.menu_items.should == []
|
114
134
|
end
|
115
135
|
|
116
136
|
it "should display a parent that has a child to display" do
|
117
|
-
|
118
|
-
p.add "Hidden Child", "/", 10, :if => proc{ false }
|
119
|
-
p.add "Child", "/"
|
137
|
+
item = MenuItem.new(:label => "Parent", :url => "#") do |p|
|
138
|
+
p.add MenuItem.new(:label => "Hidden Child", :url => "/", :priority => 10, :if => proc{ false })
|
139
|
+
p.add MenuItem.new(:label => "Child", :url => "/")
|
120
140
|
end
|
141
|
+
menu.add item
|
121
142
|
tabbed_navigation.should have(1).menu_items
|
122
143
|
end
|
123
144
|
|