activeadmin 0.3.4 → 0.4.0
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 +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +164 -5
- data/CONTRIBUTING.md +113 -0
- data/Gemfile +7 -9
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +4 -2
- data/app/assets/javascripts/active_admin/application.js +9 -0
- data/app/assets/javascripts/active_admin/base.js +4 -12
- data/app/assets/stylesheets/active_admin/_base.css.scss +17 -341
- data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -7
- data/app/assets/stylesheets/active_admin/_header.css.scss +23 -4
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +2 -0
- data/app/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/app/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/app/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +101 -0
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +43 -2
- data/app/assets/stylesheets/active_admin/mixins/_all.css.scss +2 -1
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +50 -13
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +7 -5
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +9 -0
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/new.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 +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
- data/app/views/active_admin/page/index.html.arb +1 -0
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +3 -2
- data/docs/1-general-configuration.md +46 -10
- data/docs/6-show-screens.md +7 -0
- data/docs/8-custom-actions.md +12 -2
- data/docs/9-custom-pages.md +84 -0
- data/features/belongs_to.feature +27 -0
- data/features/comments/commenting.feature +3 -2
- data/features/dashboard.feature +18 -0
- data/features/development_reloading.feature +43 -0
- data/features/index/filter_with_check_boxes.feature +25 -0
- data/features/index/index_as_table.feature +14 -0
- data/features/index/index_scopes.feature +59 -0
- data/features/index/pagination.feature +19 -1
- data/features/menu.feature +22 -2
- data/features/registering_assets.feature +2 -2
- data/features/registering_pages.feature +66 -0
- data/features/specifying_actions.feature +5 -0
- data/features/step_definitions/action_item_steps.rb +2 -6
- data/features/step_definitions/action_link_steps.rb +7 -0
- data/features/step_definitions/additional_web_steps.rb +11 -3
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/comment_steps.rb +3 -3
- data/features/step_definitions/configuration_steps.rb +69 -13
- data/features/step_definitions/dashboard_steps.rb +7 -3
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/format_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +18 -6
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/pagination_steps.rb +2 -2
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/step_definitions/tab_steps.rb +1 -1
- data/features/step_definitions/user_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +4 -4
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +26 -10
- data/lib/active_admin/application.rb +64 -22
- data/lib/active_admin/arbre.rb +0 -1
- data/lib/active_admin/arbre/builder.rb +8 -5
- data/lib/active_admin/arbre/context.rb +1 -1
- data/lib/active_admin/arbre/html/attributes.rb +1 -1
- data/lib/active_admin/arbre/html/class_list.rb +0 -4
- data/lib/active_admin/arbre/html/collection.rb +2 -2
- data/lib/active_admin/arbre/html/document.rb +1 -1
- data/lib/active_admin/arbre/html/element.rb +19 -9
- data/lib/active_admin/arbre/html/tag.rb +3 -3
- data/lib/active_admin/arbre/html/text_node.rb +2 -2
- data/lib/active_admin/asset_registration.rb +15 -2
- data/lib/active_admin/base_controller.rb +61 -0
- data/lib/active_admin/{resource_controller → base_controller}/menu.rb +1 -1
- data/lib/active_admin/callbacks.rb +16 -18
- data/lib/active_admin/comments.rb +48 -54
- data/lib/active_admin/comments/comment.rb +13 -2
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +7 -3
- data/lib/active_admin/dashboards.rb +4 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +21 -5
- data/lib/active_admin/dsl.rb +6 -159
- data/lib/active_admin/event.rb +5 -3
- data/lib/active_admin/filter_form_builder.rb +53 -0
- data/lib/active_admin/form_builder.rb +25 -19
- data/lib/active_admin/helpers/settings.rb +6 -10
- data/lib/active_admin/inputs.rb +14 -0
- data/lib/active_admin/inputs/datepicker_input.rb +11 -0
- data/lib/active_admin/inputs/filter_base.rb +46 -0
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +40 -0
- data/lib/active_admin/inputs/filter_date_range_input.rb +34 -0
- data/lib/active_admin/inputs/filter_numeric_input.rb +55 -0
- data/lib/active_admin/inputs/filter_select_input.rb +23 -0
- data/lib/active_admin/inputs/filter_string_input.rb +22 -0
- data/lib/active_admin/locales/ca.yml +44 -0
- data/lib/active_admin/locales/cs.yml +14 -10
- data/lib/active_admin/locales/de.yml +44 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/hu.yml +45 -0
- data/lib/active_admin/locales/it.yml +11 -6
- data/lib/active_admin/locales/ko.yml +40 -0
- data/lib/active_admin/locales/lv.yml +43 -0
- data/lib/active_admin/locales/nl.yml +40 -0
- data/lib/active_admin/locales/no-NB.yml +40 -0
- data/lib/active_admin/locales/pl.yml +7 -1
- data/lib/active_admin/locales/pt-BR.yml +6 -2
- data/lib/active_admin/menu_item.rb +25 -17
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +65 -0
- data/lib/active_admin/page_controller.rb +15 -0
- data/lib/active_admin/page_dsl.rb +21 -0
- data/lib/active_admin/page_presenter.rb +30 -0
- data/lib/active_admin/reloader.rb +109 -42
- data/lib/active_admin/resource.rb +38 -44
- data/lib/active_admin/resource/action_items.rb +5 -0
- data/lib/active_admin/resource/belongs_to.rb +4 -2
- data/lib/active_admin/resource/controllers.rb +35 -0
- data/lib/active_admin/resource/menu.rb +1 -2
- data/lib/active_admin/resource/naming.rb +53 -31
- data/lib/active_admin/resource/page_presenters.rb +28 -0
- data/lib/active_admin/resource/scopes.rb +16 -3
- data/lib/active_admin/resource/sidebars.rb +4 -0
- data/lib/active_admin/resource_collection.rb +88 -0
- data/lib/active_admin/resource_controller.rb +18 -54
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +8 -8
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +8 -4
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/resource_class_methods.rb +24 -0
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +157 -0
- data/lib/active_admin/router.rb +21 -14
- data/lib/active_admin/scope.rb +15 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +4 -3
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -10
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +25 -21
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -150
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/columns.rb +4 -4
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/panel.rb +8 -0
- data/lib/active_admin/views/components/scopes.rb +24 -18
- data/lib/active_admin/views/components/status_tag.rb +6 -5
- data/lib/active_admin/views/components/table_for.rb +6 -2
- data/lib/active_admin/views/header_renderer.rb +31 -12
- data/lib/active_admin/views/index_as_block.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +3 -3
- data/lib/active_admin/views/index_as_grid.rb +4 -4
- data/lib/active_admin/views/index_as_table.rb +13 -6
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/form.rb +49 -0
- data/lib/active_admin/views/pages/index.rb +18 -6
- data/lib/active_admin/views/pages/page.rb +24 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +19 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +38 -12
- data/lib/generators/active_admin/install/templates/dashboards.rb +6 -0
- data/script/use_rails +14 -7
- data/spec/spec_helper.rb +9 -14
- data/spec/spec_helper_without_rails.rb +10 -0
- data/spec/support/detect_rails_version.rb +22 -3
- data/spec/support/integration_example_group.rb +5 -7
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/rails_template_with_data.rb +25 -0
- data/spec/support/templates/cucumber_with_reloading.rb +5 -0
- data/spec/unit/active_admin_spec.rb +8 -0
- data/spec/unit/application_spec.rb +48 -2
- data/spec/unit/arbre/context_spec.rb +1 -1
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/arbre/html/element_spec.rb +18 -5
- data/spec/unit/arbre/html/tag_attributes_spec.rb +3 -3
- data/spec/unit/arbre/html/tag_spec.rb +1 -1
- data/spec/unit/arbre/html_spec.rb +32 -22
- data/spec/unit/asset_registration_spec.rb +9 -3
- data/spec/unit/auto_link_spec.rb +2 -2
- data/spec/unit/base_controller_shared_examples.rb +28 -0
- data/spec/unit/base_controller_spec.rb +8 -0
- data/spec/unit/belongs_to_spec.rb +30 -33
- data/spec/unit/comments_spec.rb +45 -15
- data/spec/unit/config_shared_examples.rb +119 -0
- data/spec/unit/dashboard_controller_spec.rb +44 -0
- data/spec/unit/event_spec.rb +6 -0
- data/spec/unit/filter_form_builder_spec.rb +9 -0
- data/spec/unit/form_builder_spec.rb +8 -14
- data/spec/unit/menu_item_spec.rb +25 -20
- data/spec/unit/namespace/register_page_spec.rb +102 -0
- data/spec/unit/namespace/register_resource_spec.rb +188 -0
- data/spec/unit/namespace_spec.rb +11 -183
- data/spec/unit/page_controller_spec.rb +8 -0
- data/spec/unit/page_spec.rb +60 -0
- data/spec/unit/reloader_spec.rb +82 -38
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +25 -20
- data/spec/unit/resource/page_presenters_spec.rb +32 -0
- data/spec/unit/resource/scopes_spec.rb +13 -0
- data/spec/unit/resource_collection_spec.rb +101 -0
- data/spec/unit/resource_controller_spec.rb +40 -32
- data/spec/unit/{registration_spec.rb → resource_registration_spec.rb} +0 -0
- data/spec/unit/resource_spec.rb +8 -24
- data/spec/unit/routing_spec.rb +50 -1
- data/spec/unit/scope_spec.rb +18 -4
- data/spec/unit/views/components/paginated_collection_spec.rb +163 -0
- data/spec/unit/views/components/panel_spec.rb +9 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -1
- data/tasks/test.rake +44 -26
- metadata +176 -69
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/arbre/core_extensions.rb +0 -5
- data/lib/active_admin/comments/configuration.rb +0 -18
- data/lib/active_admin/page_config.rb +0 -15
- data/lib/active_admin/resource_controller/form.rb +0 -42
- data/lib/active_admin/resource_controller/page_configurations.rb +0 -53
- data/lib/active_admin/views/pages/edit.rb +0 -28
- data/lib/active_admin/views/pages/new.rb +0 -28
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +0 -427
- data/spec/integration/belongs_to_spec.rb +0 -42
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: Belongs To
|
2
|
+
|
3
|
+
A resource belongs to another resource
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a configuration of:
|
7
|
+
"""
|
8
|
+
ActiveAdmin.register User
|
9
|
+
ActiveAdmin.register Post do
|
10
|
+
belongs_to :user
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
And I am logged in
|
14
|
+
And a post with the title "Hello World" written by "John Doe" exists
|
15
|
+
And a post with the title "Hello World" written by "Jane Doe" exists
|
16
|
+
|
17
|
+
Scenario: Viewing the child resource index page
|
18
|
+
When I go to the last author's posts
|
19
|
+
Then the "Users" tab should be selected
|
20
|
+
And I should see "Displaying 1 Post"
|
21
|
+
And I should see a link to "Users" in the breadcrumb
|
22
|
+
|
23
|
+
Scenario: Viewing a child resource page
|
24
|
+
When I go to the last author's posts
|
25
|
+
And I follow "View"
|
26
|
+
Then I should be on the last author's last post page
|
27
|
+
And the "Users" tab should be selected
|
@@ -39,7 +39,8 @@ Feature: Commenting
|
|
39
39
|
Scenario: View a resource in a namespace that doesn't have comments
|
40
40
|
Given a configuration of:
|
41
41
|
"""
|
42
|
-
ActiveAdmin.register Post, :namespace => :new_namespace
|
42
|
+
post_config = ActiveAdmin.register Post, :namespace => :new_namespace
|
43
|
+
post_config.namespace.allow_comments = false
|
43
44
|
"""
|
44
45
|
Given I am logged in
|
45
46
|
When I am on the index page for posts in the new_namespace namespace
|
@@ -49,12 +50,12 @@ Feature: Commenting
|
|
49
50
|
Scenario: Creating a comment in one namespace does not create it in another
|
50
51
|
Given a show configuration of:
|
51
52
|
"""
|
52
|
-
ActiveAdmin.application.allow_comments_in << :public
|
53
53
|
ActiveAdmin.register Post
|
54
54
|
ActiveAdmin.register Post, :namespace => :public
|
55
55
|
"""
|
56
56
|
When I add a comment "Hello world in admin namespace"
|
57
57
|
Then I should see "Hello world in admin namespace"
|
58
|
+
|
58
59
|
When I am on the index page for posts in the public namespace
|
59
60
|
And I follow "View"
|
60
61
|
Then I should not see "Hello world in admin namespace"
|
data/features/dashboard.feature
CHANGED
@@ -24,3 +24,21 @@ Feature: Dashboard
|
|
24
24
|
Then I should not see the default welcome message
|
25
25
|
And I should see a dashboard widget "Hello World"
|
26
26
|
And I should see "Hello world from the content"
|
27
|
+
|
28
|
+
Scenario: Displaying a dashboard widget using the ':if' option
|
29
|
+
Given a configuration of:
|
30
|
+
"""
|
31
|
+
ActiveAdmin::Dashboards.build do
|
32
|
+
section 'Hello World', :if => proc{ current_admin_user } do
|
33
|
+
"Hello world from the content"
|
34
|
+
end
|
35
|
+
|
36
|
+
section 'Hidden by If', :if => proc{ false } do
|
37
|
+
"Hello world from the content"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
When I go to the dashboard
|
42
|
+
Then I should not see the default welcome message
|
43
|
+
And I should see a dashboard widget "Hello World"
|
44
|
+
And I should not see a dashboard widget "Hidden by If"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: Development Reloading
|
2
|
+
|
3
|
+
In order to quickly develop applications
|
4
|
+
As a developer
|
5
|
+
I want the application to reload itself in development
|
6
|
+
|
7
|
+
@requires-reloading
|
8
|
+
Scenario: Reloading an updated model that a resource points to
|
9
|
+
Given "app/admin/posts.rb" contains:
|
10
|
+
"""
|
11
|
+
ActiveAdmin.register Post
|
12
|
+
"""
|
13
|
+
And I am logged in
|
14
|
+
And I create a new post with the title ""
|
15
|
+
Then I should see a successful create flash
|
16
|
+
Given I add "validates_presence_of :title" to the "post" model
|
17
|
+
And I create a new post with the title ""
|
18
|
+
Then I should not see a successful create flash
|
19
|
+
And I should see a validation error "can't be blank"
|
20
|
+
|
21
|
+
|
22
|
+
# TODO: Create a scenario that reloads one of the active admin
|
23
|
+
# configuration files.
|
24
|
+
#
|
25
|
+
# @requires-reloading
|
26
|
+
# Scenario: Reloading an updated model that a resource points to
|
27
|
+
# Given "app/admin/posts.rb" contains:
|
28
|
+
# """
|
29
|
+
# ActiveAdmin.register Post
|
30
|
+
# ActiveAdmin.register User
|
31
|
+
# """
|
32
|
+
# And I am logged in
|
33
|
+
# Then I should see a menu item for "Posts"
|
34
|
+
|
35
|
+
# Given "app/admin/posts.rb" contains:
|
36
|
+
# """
|
37
|
+
# ActiveAdmin.register Post, :as => "Blog"
|
38
|
+
# ActiveAdmin.register User
|
39
|
+
# """
|
40
|
+
# When I follow "Users"
|
41
|
+
# Then show me the page
|
42
|
+
# Then I should see a menu item for "Blogs"
|
43
|
+
# Then I should not see a menu item for "Posts"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Filter with check boxes
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given an index configuration of:
|
5
|
+
"""
|
6
|
+
ActiveAdmin.register Post do
|
7
|
+
filter :author, :as => :check_boxes
|
8
|
+
end
|
9
|
+
"""
|
10
|
+
And a post with the title "Hello World" written by "Jane Doe" exists
|
11
|
+
And 1 post exists
|
12
|
+
And I am on the index page for posts
|
13
|
+
|
14
|
+
Scenario: Filtering posts written by anyone
|
15
|
+
When I press "Filter"
|
16
|
+
Then I should see 2 posts in the table
|
17
|
+
And I should see "Hello World" within ".index_table"
|
18
|
+
And the "jane_doe" checkbox should not be checked
|
19
|
+
|
20
|
+
Scenario: Filtering posts written by Jane Doe
|
21
|
+
When I check "jane_doe"
|
22
|
+
And I press "Filter"
|
23
|
+
Then I should see 1 posts in the table
|
24
|
+
And I should see "Hello World" within ".index_table"
|
25
|
+
And the "jane_doe" checkbox should be checked
|
@@ -79,3 +79,17 @@ Feature: Index as Table
|
|
79
79
|
And I should not see a table header with "Body"
|
80
80
|
And I should see "Hello World"
|
81
81
|
And I should not see "From the body"
|
82
|
+
|
83
|
+
Scenario: Default Actions
|
84
|
+
Given a post with the title "Hello World" and body "From the body" exists
|
85
|
+
And an index configuration of:
|
86
|
+
"""
|
87
|
+
ActiveAdmin.register Post do
|
88
|
+
actions :index, :show, :edit, :update
|
89
|
+
end
|
90
|
+
"""
|
91
|
+
Then I should see a member link to "View"
|
92
|
+
And I should see a member link to "Edit"
|
93
|
+
And I should not see a member link to "Delete"
|
94
|
+
|
95
|
+
|
@@ -26,6 +26,65 @@ Feature: Index Scoping
|
|
26
26
|
And I should see the scope "All" with the count 10
|
27
27
|
And I should see 10 posts in the table
|
28
28
|
|
29
|
+
Scenario: Viewing resources with one scope and no results
|
30
|
+
Given 10 posts exist
|
31
|
+
And an index configuration of:
|
32
|
+
"""
|
33
|
+
ActiveAdmin.register Post do
|
34
|
+
scope :all, :default => true
|
35
|
+
filter :title
|
36
|
+
end
|
37
|
+
"""
|
38
|
+
|
39
|
+
When I fill in "Search Title" with "Hello World 17"
|
40
|
+
And I press "Filter"
|
41
|
+
And I should not see the scope "All"
|
42
|
+
|
43
|
+
When I am on the index page for posts
|
44
|
+
Then I should see the scope "All" selected
|
45
|
+
|
46
|
+
Scenario: Viewing resources when scoping
|
47
|
+
Given 6 posts exist
|
48
|
+
And 4 published posts exist
|
49
|
+
And an index configuration of:
|
50
|
+
"""
|
51
|
+
ActiveAdmin.register Post do
|
52
|
+
scope :all, :default => true
|
53
|
+
scope :published do |posts|
|
54
|
+
posts.where("published_at IS NOT NULL")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
"""
|
58
|
+
Then I should see the scope "All" with the count 10
|
59
|
+
And I should see 10 posts in the table
|
60
|
+
Then I should see the scope "Published" with the count 4
|
61
|
+
When I follow "Published"
|
62
|
+
Then I should see the scope "Published" selected
|
63
|
+
And I should see 4 posts in the table
|
64
|
+
|
65
|
+
Scenario: Viewing resources with optional scopes
|
66
|
+
Given 10 posts exist
|
67
|
+
And an index configuration of:
|
68
|
+
"""
|
69
|
+
ActiveAdmin.register Post do
|
70
|
+
scope :all, :if => proc { false }
|
71
|
+
scope "Shown", :if => proc { true } do |posts|
|
72
|
+
posts
|
73
|
+
end
|
74
|
+
scope "Default", :default => true do |posts|
|
75
|
+
posts
|
76
|
+
end
|
77
|
+
scope 'Today', :if => proc { false } do |posts|
|
78
|
+
posts.where(["created_at > ? AND created_at < ?", ::Time.zone.now.beginning_of_day, ::Time.zone.now.end_of_day])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
"""
|
82
|
+
Then I should see the scope "Default" selected
|
83
|
+
And I should not see the scope "All"
|
84
|
+
And I should not see the scope "Today"
|
85
|
+
And I should see the scope "Shown"
|
86
|
+
And I should see the scope "Default" with the count 10
|
87
|
+
|
29
88
|
Scenario: Viewing resources with mulitple scopes as blocks
|
30
89
|
Given 10 posts exist
|
31
90
|
And an index configuration of:
|
@@ -1,17 +1,35 @@
|
|
1
1
|
Feature: Index Pagination
|
2
2
|
|
3
3
|
Background:
|
4
|
+
Scenario: Viewing index when one page of resources exist
|
4
5
|
Given an index configuration of:
|
5
6
|
"""
|
6
7
|
ActiveAdmin.register Post
|
7
8
|
"""
|
8
|
-
Scenario: Viewing index when one page of resources exist
|
9
9
|
Given 20 posts exist
|
10
10
|
When I am on the index page for posts
|
11
11
|
Then I should see "Displaying all 20 Posts"
|
12
12
|
And I should not see pagination
|
13
13
|
|
14
14
|
Scenario: Viewing index when multiple pages of resources exist
|
15
|
+
Given an index configuration of:
|
16
|
+
"""
|
17
|
+
ActiveAdmin.register Post
|
18
|
+
"""
|
15
19
|
Given 31 posts exist
|
16
20
|
When I am on the index page for posts
|
17
21
|
Then I should see pagination with 2 pages
|
22
|
+
|
23
|
+
Scenario: Viewing index with a custom per page set
|
24
|
+
Given an index configuration of:
|
25
|
+
"""
|
26
|
+
ActiveAdmin.register Post do
|
27
|
+
before_filter :only => :index do |controller|
|
28
|
+
@per_page = 10
|
29
|
+
end
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
Given 11 posts exist
|
33
|
+
When I am on the index page for posts
|
34
|
+
Then I should see pagination with 2 pages
|
35
|
+
And I should see "Displaying Posts 1 - 10 of 11 in total"
|
data/features/menu.feature
CHANGED
@@ -31,7 +31,27 @@ Feature: Menu
|
|
31
31
|
ActiveAdmin.application.site_title_link = "http://www.google.com/"
|
32
32
|
"""
|
33
33
|
When I am on the dashboard
|
34
|
-
And I should see "My Great Site"
|
34
|
+
And I should see the site title "My Great Site"
|
35
35
|
When I follow "My Great Site"
|
36
36
|
Then I should see "Ruby on Rails: Welcome aboard"
|
37
|
-
# Why won't it take me to the Googles??? It takes me to / instead. Oh well
|
37
|
+
# Why won't it take me to the Googles??? It takes me to / instead. Oh well
|
38
|
+
|
39
|
+
Scenario: Set the site title image
|
40
|
+
Given a configuration of:
|
41
|
+
"""
|
42
|
+
ActiveAdmin.application.site_title = "My Great Site"
|
43
|
+
ActiveAdmin.application.site_title_image = "http://railscasts.com/assets/episodes/stills/284-active-admin.png?1316476106"
|
44
|
+
"""
|
45
|
+
When I am on the dashboard
|
46
|
+
And I should not see the site title "My Great Site"
|
47
|
+
And I should see the site title image "http://railscasts.com/assets/episodes/stills/284-active-admin.png?1316476106"
|
48
|
+
|
49
|
+
Scenario: Set the site title image with link
|
50
|
+
Given a configuration of:
|
51
|
+
"""
|
52
|
+
ActiveAdmin.application.site_title_link = "http://www.google.com"
|
53
|
+
ActiveAdmin.application.site_title_image = "http://railscasts.com/assets/episodes/stills/284-active-admin.png?1316476106"
|
54
|
+
"""
|
55
|
+
When I am on the dashboard
|
56
|
+
And I should see the site title image "http://railscasts.com/assets/episodes/stills/284-active-admin.png?1316476106"
|
57
|
+
And I should see the site title image linked to "http://www.google.com"
|
@@ -19,11 +19,11 @@ Feature: Registering Assets
|
|
19
19
|
Scenario: Registering a CSS file
|
20
20
|
Given a configuration of:
|
21
21
|
"""
|
22
|
-
ActiveAdmin.application.register_stylesheet "some-random-css.css"
|
22
|
+
ActiveAdmin.application.register_stylesheet "some-random-css.css", :media => :print
|
23
23
|
ActiveAdmin.register Post
|
24
24
|
"""
|
25
25
|
When I am on the index page for posts
|
26
|
-
Then I should see the css file "some-random-css.css"
|
26
|
+
Then I should see the css file "some-random-css.css" of media "print"
|
27
27
|
|
28
28
|
Scenario: Registering a JS file
|
29
29
|
Given a configuration of:
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Feature: Registering Pages
|
2
|
+
|
3
|
+
Registering pages within Active Admin
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am logged in
|
7
|
+
|
8
|
+
Scenario: Registering a page
|
9
|
+
Given a configuration of:
|
10
|
+
"""
|
11
|
+
ActiveAdmin.register_page "Status" do
|
12
|
+
content do
|
13
|
+
"I love chocolate."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I go to the dashboard
|
18
|
+
And I follow "Status"
|
19
|
+
Then I should see the page title "Status"
|
20
|
+
And I should see the Active Admin layout
|
21
|
+
And I should see the content "I love chocolate."
|
22
|
+
|
23
|
+
Scenario: Registering an empty page
|
24
|
+
Given a configuration of:
|
25
|
+
"""
|
26
|
+
ActiveAdmin.register_page "Status"
|
27
|
+
"""
|
28
|
+
When I go to the dashboard
|
29
|
+
And I follow "Status"
|
30
|
+
Then I should see the page title "Status"
|
31
|
+
And I should see the Active Admin layout
|
32
|
+
|
33
|
+
Scenario: Adding a sidebar section to a page
|
34
|
+
Given a configuration of:
|
35
|
+
"""
|
36
|
+
ActiveAdmin.register_page "Status" do
|
37
|
+
sidebar :help do
|
38
|
+
"Need help? Email us at help@example.com"
|
39
|
+
end
|
40
|
+
|
41
|
+
content do
|
42
|
+
"I love chocolate."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
"""
|
46
|
+
When I go to the dashboard
|
47
|
+
And I follow "Status"
|
48
|
+
Then I should see a sidebar titled "Help"
|
49
|
+
|
50
|
+
|
51
|
+
Scenario: Adding an action item to a page
|
52
|
+
Given a configuration of:
|
53
|
+
"""
|
54
|
+
ActiveAdmin.register_page "Status" do
|
55
|
+
action_item do
|
56
|
+
link_to "Visit", "/"
|
57
|
+
end
|
58
|
+
|
59
|
+
content do
|
60
|
+
"I love chocolate."
|
61
|
+
end
|
62
|
+
end
|
63
|
+
"""
|
64
|
+
When I go to the dashboard
|
65
|
+
And I follow "Status"
|
66
|
+
Then I should see an action item link to "Visit"
|
@@ -1,7 +1,3 @@
|
|
1
|
-
Then /^I should see an action item
|
2
|
-
page.should have_css(
|
3
|
-
end
|
4
|
-
|
5
|
-
Then /^I should not see an action item button "([^"]*)"$/ do |content|
|
6
|
-
page.should_not have_css(".action_items", :text => content)
|
1
|
+
Then /^I should see an action item link to "([^"]*)"$/ do |link|
|
2
|
+
page.should have_css('.action_item a', :text => link)
|
7
3
|
end
|
@@ -11,7 +11,7 @@ Then /^I should see a sortable table header with "([^"]*)"$/ do |content|
|
|
11
11
|
end
|
12
12
|
|
13
13
|
Then /^I should not see a sortable table header$/ do
|
14
|
-
|
14
|
+
step "I should not see \"th.sortable\""
|
15
15
|
end
|
16
16
|
|
17
17
|
Then /^the table "([^"]*)" should have (\d+) rows/ do |selector, count|
|
@@ -48,7 +48,7 @@ end
|
|
48
48
|
|
49
49
|
Then /^an "([^"]*)" exception should be raised when I follow "([^"]*)"$/ do |error, link|
|
50
50
|
lambda {
|
51
|
-
|
51
|
+
step "I follow \"#{link}\""
|
52
52
|
}.should raise_error(error.constantize)
|
53
53
|
end
|
54
54
|
|
@@ -58,7 +58,7 @@ end
|
|
58
58
|
|
59
59
|
Then /^I should wait and see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
60
60
|
sleep 1
|
61
|
-
|
61
|
+
step 'show me the page'
|
62
62
|
selector ||= "*"
|
63
63
|
locate(:xpath, "//#{selector}[text()='#{text}']")
|
64
64
|
end
|
@@ -75,3 +75,11 @@ Then /^the "([^"]*)" field should contain the option "([^"]*)"$/ do |field, opti
|
|
75
75
|
field = find_field(field)
|
76
76
|
field.should have_css("option", :text => option)
|
77
77
|
end
|
78
|
+
|
79
|
+
Then /^I should see the content "([^"]*)"$/ do |content|
|
80
|
+
page.should have_css("#active_admin_content", :text => content)
|
81
|
+
end
|
82
|
+
|
83
|
+
Then /^I should see a validation error "([^"]*)"$/ do |error_message|
|
84
|
+
page.should have_css(".inline-errors", :text => error_message)
|
85
|
+
end
|