andrewroth_activeadmin 0.3.4 → 0.3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +159 -3
- data/CONTRIBUTING.md +113 -0
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +3 -1
- 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 +16 -340
- 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/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/_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 +19 -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 +42 -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 +8 -0
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/configuration_steps.rb +56 -8
- data/features/step_definitions/dashboard_steps.rb +5 -1
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +16 -4
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +25 -10
- data/lib/active_admin/application.rb +63 -20
- data/lib/active_admin/arbre/html/element.rb +10 -0
- 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/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 +20 -4
- 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/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 +43 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- 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/namespace.rb +48 -33
- data/lib/active_admin/page.rb +54 -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/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 +43 -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 +1 -1
- 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/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/scopes.rb +17 -17
- 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/spec/spec_helper.rb +4 -0
- data/spec/support/rails_template.rb +11 -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/html/element_finder_methods_spec.rb +58 -2
- 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 +108 -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/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/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +24 -19
- 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 +150 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/tasks/test.rake +43 -27
- metadata +140 -31
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- 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,19 @@
|
|
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 a configuration of:
|
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"
|
@@ -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,48 @@ 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 when scoping
|
30
|
+
Given 6 posts exist
|
31
|
+
And 4 published posts exist
|
32
|
+
And an index configuration of:
|
33
|
+
"""
|
34
|
+
ActiveAdmin.register Post do
|
35
|
+
scope :all, :default => true
|
36
|
+
scope :published do |posts|
|
37
|
+
posts.where("published_at IS NOT NULL")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
Then I should see the scope "All" with the count 10
|
42
|
+
And I should see 10 posts in the table
|
43
|
+
Then I should see the scope "Published" with the count 4
|
44
|
+
When I follow "Published"
|
45
|
+
Then I should see the scope "Published" selected
|
46
|
+
And I should see 4 posts in the table
|
47
|
+
|
48
|
+
Scenario: Viewing resources with optional scopes
|
49
|
+
Given 10 posts exist
|
50
|
+
And an index configuration of:
|
51
|
+
"""
|
52
|
+
ActiveAdmin.register Post do
|
53
|
+
scope :all, :if => proc { false }
|
54
|
+
scope "Shown", :if => proc { true } do |posts|
|
55
|
+
posts
|
56
|
+
end
|
57
|
+
scope "Default", :default => true do |posts|
|
58
|
+
posts
|
59
|
+
end
|
60
|
+
scope 'Today', :if => proc { false } do |posts|
|
61
|
+
posts.where(["created_at > ? AND created_at < ?", ::Time.zone.now.beginning_of_day, ::Time.zone.now.end_of_day])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
"""
|
65
|
+
Then I should see the scope "Default" selected
|
66
|
+
And I should not see the scope "All"
|
67
|
+
And I should not see the scope "Today"
|
68
|
+
And I should see the scope "Shown"
|
69
|
+
And I should see the scope "Default" with the count 10
|
70
|
+
|
29
71
|
Scenario: Viewing resources with mulitple scopes as blocks
|
30
72
|
Given 10 posts exist
|
31
73
|
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
|
@@ -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
|
@@ -1,5 +1,9 @@
|
|
1
1
|
Then /^I should see the css file "([^"]*)"$/ do |path|
|
2
|
-
|
2
|
+
Then %{I should see the css file "#{path}" of media "screen"}
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should see the css file "([^"]*)" of media "([^"]*)"$/ do |path, media|
|
6
|
+
page.should have_xpath("//link[contains(@href, /stylesheets/#{path}) and contains(@media, #{media})]")
|
3
7
|
end
|
4
8
|
|
5
9
|
Then /^I should see the js file "([^"]*)"$/ do |path|
|
@@ -1,22 +1,57 @@
|
|
1
|
+
module ActiveAdminReloading
|
2
|
+
|
3
|
+
def load_active_admin_configuration(configuration_content)
|
4
|
+
eval(configuration_content)
|
5
|
+
ActiveAdmin::Event.dispatch ActiveAdmin::Application::LoadEvent, ActiveAdmin.application
|
6
|
+
Rails.application.reload_routes!
|
7
|
+
ActiveAdmin.application.namespaces.values.each{|n| n.load_menu! }
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
module ActiveAdminContentsRollback
|
13
|
+
|
14
|
+
def self.recorded_files
|
15
|
+
@files ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
# Records the contents of a file the first time we are
|
19
|
+
# about to change it
|
20
|
+
def self.record(filename)
|
21
|
+
recorded_files[filename] ||= File.read(filename)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Rolls the recorded files back to their original states
|
25
|
+
def self.rollback!
|
26
|
+
recorded_files.each do |filename, contents|
|
27
|
+
File.open(filename, "w+") do |f|
|
28
|
+
f << contents
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
World(ActiveAdminReloading)
|
36
|
+
|
37
|
+
After do
|
38
|
+
ActiveAdminContentsRollback.rollback!
|
39
|
+
end
|
40
|
+
|
1
41
|
Given /^a configuration of:$/ do |configuration_content|
|
2
|
-
|
3
|
-
Rails.application.reload_routes!
|
42
|
+
load_active_admin_configuration(configuration_content)
|
4
43
|
ActiveAdmin.application.namespaces.values.each{|n| n.load_menu! }
|
5
44
|
end
|
6
45
|
|
7
46
|
Given /^an index configuration of:$/ do |configuration_content|
|
8
|
-
|
9
|
-
Rails.application.reload_routes!
|
10
|
-
ActiveAdmin.application.namespaces.values.each{|n| n.load_menu! }
|
47
|
+
load_active_admin_configuration(configuration_content)
|
11
48
|
|
12
49
|
And 'I am logged in'
|
13
50
|
When "I am on the index page for posts"
|
14
51
|
end
|
15
52
|
|
16
53
|
Given /^a show configuration of:$/ do |configuration_content|
|
17
|
-
|
18
|
-
Rails.application.reload_routes!
|
19
|
-
ActiveAdmin.application.namespaces.values.each{|n| n.load_menu! }
|
54
|
+
load_active_admin_configuration(configuration_content)
|
20
55
|
|
21
56
|
And 'I am logged in'
|
22
57
|
When "I am on the index page for posts"
|
@@ -29,3 +64,16 @@ Given /^"([^"]*)" contains:$/ do |filename, contents|
|
|
29
64
|
FileUtils.mkdir_p File.dirname(filepath)
|
30
65
|
File.open(filepath, 'w+'){|f| f << contents }
|
31
66
|
end
|
67
|
+
|
68
|
+
Given /^I add "([^"]*)" to the "([^"]*)" model$/ do |code, model_name|
|
69
|
+
filename = File.join(Rails.root, "app", "models", "#{model_name}.rb")
|
70
|
+
ActiveAdminContentsRollback.record(filename)
|
71
|
+
|
72
|
+
# Update the file
|
73
|
+
contents = File.read(filename)
|
74
|
+
File.open(filename, "w+") do |f|
|
75
|
+
f << contents.gsub(/^(class .+)$/, "\\1\n #{code}\n")
|
76
|
+
end
|
77
|
+
|
78
|
+
ActiveSupport::Dependencies.clear
|
79
|
+
end
|