activeadmin 1.0.0.pre1 → 1.0.0.pre2
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.
- checksums.yaml +4 -4
- data/.travis.yml +18 -16
- data/CHANGELOG.md +18 -1013
- data/Gemfile +18 -11
- data/LICENSE +0 -5
- data/README.md +0 -2
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
- data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
- data/app/assets/stylesheets/active_admin/_base.scss +1 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
- data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
- data/config/locales/ar.yml +14 -2
- data/config/locales/de-CH.yml +2 -0
- data/config/locales/de.yml +15 -0
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +26 -4
- data/config/locales/fr.yml +5 -0
- data/config/locales/id.yml +135 -0
- data/config/locales/ja.yml +21 -3
- data/config/locales/ko.yml +66 -36
- data/config/locales/nl.yml +14 -1
- data/config/locales/pt-BR.yml +11 -0
- data/config/locales/ru.yml +15 -1
- data/config/locales/sv-SE.yml +45 -5
- data/config/locales/uk.yml +16 -4
- data/config/locales/zh-CN.yml +5 -0
- data/config/locales/zh-TW.yml +32 -1
- data/docs/0-installation.md +7 -1
- data/docs/1-general-configuration.md +9 -0
- data/docs/10-custom-pages.md +10 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/14-gotchas.md +2 -2
- data/docs/2-resource-customization.md +5 -3
- data/docs/3-index-pages.md +7 -0
- data/docs/3-index-pages/index-as-table.md +4 -0
- data/docs/6-show-pages.md +1 -1
- data/docs/7-sidebars.md +8 -0
- data/features/index/batch_actions.feature +21 -2
- data/features/index/pagination.feature +16 -12
- data/features/meta_tags.feature +21 -0
- data/features/registering_assets.feature +1 -2
- data/features/show/columns.feature +40 -0
- data/features/show/default_content.feature +2 -1
- data/features/step_definitions/asset_steps.rb +3 -3
- data/features/step_definitions/batch_action_steps.rb +11 -2
- data/features/step_definitions/column_steps.rb +8 -0
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +3 -2
- data/features/step_definitions/meta_tag_steps.rb +3 -0
- data/features/step_definitions/pagination_steps.rb +8 -0
- data/features/step_definitions/table_steps.rb +2 -1
- data/lib/active_admin.rb +3 -3
- data/lib/active_admin/application.rb +66 -16
- data/lib/active_admin/batch_actions.rb +0 -1
- data/lib/active_admin/batch_actions/controller.rb +2 -2
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +18 -16
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/dsl.rb +1 -1
- data/lib/active_admin/event.rb +8 -17
- data/lib/active_admin/filters/active.rb +29 -0
- data/lib/active_admin/filters/forms.rb +6 -1
- data/lib/active_admin/filters/humanized.rb +68 -0
- data/lib/active_admin/filters/resource_extension.rb +48 -1
- data/lib/active_admin/form_builder.rb +4 -4
- data/lib/active_admin/generators/boilerplate.rb +37 -0
- data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/menu.rb +1 -0
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +5 -5
- data/lib/active_admin/orm/active_record/comments.rb +10 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
- data/lib/active_admin/resource.rb +9 -3
- data/lib/active_admin/resource/action_items.rb +13 -3
- data/lib/active_admin/resource/belongs_to.rb +6 -2
- data/lib/active_admin/resource/pagination.rb +4 -0
- data/lib/active_admin/resource_collection.rb +3 -1
- data/lib/active_admin/resource_controller/data_access.rb +6 -11
- data/lib/active_admin/resource_controller/decorators.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +8 -2
- data/lib/active_admin/sidebar_section.rb +4 -12
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -2
- data/lib/active_admin/view_helpers.rb +0 -1
- data/lib/active_admin/view_helpers/display_helper.rb +3 -4
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
- data/lib/active_admin/views/components/active_admin_form.rb +3 -3
- data/lib/active_admin/views/components/columns.rb +9 -4
- data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +35 -13
- data/lib/active_admin/views/components/panel.rb +1 -3
- data/lib/active_admin/views/components/sidebar_section.rb +6 -1
- data/lib/active_admin/views/components/status_tag.rb +3 -2
- data/lib/active_admin/views/components/table_for.rb +2 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +4 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
- data/lib/generators/active_admin/page/templates/page.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
- data/spec/rails_helper.rb +6 -2
- data/spec/requests/memory_spec.rb +1 -3
- data/spec/support/active_admin_request_helpers.rb +27 -0
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +7 -0
- data/spec/unit/application_spec.rb +29 -4
- data/spec/unit/batch_actions/resource_spec.rb +5 -0
- data/spec/unit/belongs_to_spec.rb +14 -0
- data/spec/unit/comments_spec.rb +24 -2
- data/spec/unit/controller_filters_spec.rb +25 -28
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/humanized_spec.rb +56 -0
- data/spec/unit/filters/resource_spec.rb +1 -1
- data/spec/unit/form_builder_spec.rb +71 -11
- data/spec/unit/generators/install_spec.rb +3 -2
- data/spec/unit/pretty_format_spec.rb +15 -1
- data/spec/unit/resource_collection_spec.rb +17 -0
- data/spec/unit/resource_controller_spec.rb +2 -2
- data/spec/unit/resource_registration_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +53 -2
- data/spec/unit/view_factory_spec.rb +0 -2
- data/spec/unit/view_helpers/display_name_spec.rb +6 -4
- data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
- data/spec/unit/views/components/columns_spec.rb +17 -0
- data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
- data/spec/unit/views/components/panel_spec.rb +1 -5
- data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
- data/spec/unit/views/components/status_tag_spec.rb +15 -1
- data/spec/unit/views/components/table_for_spec.rb +45 -0
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -4
- metadata +29 -30
- data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
- data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
- data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
- data/lib/active_admin/iconic.rb +0 -53
- data/lib/active_admin/iconic/icons.rb +0 -142
- data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
- data/lib/active_admin/views/components/action_list_popover.rb +0 -29
- data/lib/active_admin/views/components/popover.rb +0 -27
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
- data/spec/support/integration_example_group.rb +0 -31
- data/spec/unit/event_spec.rb +0 -47
- data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
- data/spec/unit/views/components/popover_spec.rb +0 -33
data/docs/14-gotchas.md
CHANGED
@@ -54,8 +54,8 @@ end
|
|
54
54
|
## CSS
|
55
55
|
|
56
56
|
In order to avoid the override of your application style with the Active Admin one, you can do one of this things:
|
57
|
-
* You can properly move the generated file `active_admin.
|
58
|
-
* You can remove all `require_tree` comands from your root level css files, where the `active_admin.
|
57
|
+
* You can properly move the generated file `active_admin.scss` from `app/assets/stylesheets` to `vendor/assets/stylesheets`.
|
58
|
+
* You can remove all `require_tree` comands from your root level css files, where the `active_admin.scss` is in the tree.
|
59
59
|
|
60
60
|
## Conflicts
|
61
61
|
|
@@ -30,9 +30,11 @@ end
|
|
30
30
|
Any form field that sends multiple values (such as a HABTM association, or an array attribute)
|
31
31
|
needs to pass an empty array to `permit_params`:
|
32
32
|
|
33
|
+
If your HABTM is `roles`, you should permit `role_ids: []`
|
34
|
+
|
33
35
|
```ruby
|
34
36
|
ActiveAdmin.register Post do
|
35
|
-
permit_params :title, :content, :publisher_id,
|
37
|
+
permit_params :title, :content, :publisher_id, role_ids: []
|
36
38
|
end
|
37
39
|
```
|
38
40
|
|
@@ -336,7 +338,7 @@ ActiveAdmin.register Ticket do
|
|
336
338
|
end
|
337
339
|
```
|
338
340
|
|
339
|
-
Projects will be available as usual and tickets will be
|
341
|
+
Projects will be available as usual and tickets will be available by visiting
|
340
342
|
`/admin/projects/1/tickets` assuming that a Project with the id of 1 exists.
|
341
343
|
Active Admin does not add "Tickets" to the global navigation because the routes
|
342
344
|
can only be generated when there is a project id.
|
@@ -367,7 +369,7 @@ end
|
|
367
369
|
In some cases (like Projects), there are many sub resources and you would
|
368
370
|
actually like the global navigation to switch when the user navigates "into" a
|
369
371
|
project. To accomplish this, Active Admin stores the `belongs_to` resources in a
|
370
|
-
|
372
|
+
separate menu which you can use if you so wish. To use:
|
371
373
|
|
372
374
|
```ruby
|
373
375
|
ActiveAdmin.register Ticket do
|
data/docs/3-index-pages.md
CHANGED
@@ -152,6 +152,13 @@ preserve_default_filters!
|
|
152
152
|
filter :author
|
153
153
|
```
|
154
154
|
|
155
|
+
Or you can also remove a filter and still preserve the default filters:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
preserve_default_filters!
|
159
|
+
remove_filter :id
|
160
|
+
```
|
161
|
+
|
155
162
|
## Index Scopes
|
156
163
|
|
157
164
|
You can define custom scopes for your index page. This will add a tab bar above
|
@@ -55,6 +55,8 @@ index do
|
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
58
|
+
## Defining Actions
|
59
|
+
|
58
60
|
To setup links to View, Edit and Delete a resource, use the `actions` method:
|
59
61
|
|
60
62
|
```ruby
|
@@ -84,6 +86,8 @@ index do
|
|
84
86
|
column :title
|
85
87
|
actions defaults: false do |post|
|
86
88
|
item "View", admin_post_path(post)
|
89
|
+
item "Edit", edit_admin_post_path(post)
|
90
|
+
item "Delete", admin_post_path(post), method: :delete
|
87
91
|
end
|
88
92
|
end
|
89
93
|
```
|
data/docs/6-show-pages.md
CHANGED
data/docs/7-sidebars.md
CHANGED
@@ -39,6 +39,14 @@ sidebar :help, if: proc{ current_admin_user.super_admin? } do
|
|
39
39
|
end
|
40
40
|
```
|
41
41
|
|
42
|
+
You can access your model as resource in the sidebar too:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
sidebar :custom, only: :show do
|
46
|
+
resource.a_method
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
42
50
|
You can also render a partial:
|
43
51
|
|
44
52
|
```ruby
|
@@ -1,5 +1,6 @@
|
|
1
1
|
Feature: Batch Actions
|
2
2
|
|
3
|
+
@javascript
|
3
4
|
Scenario: Use default (destroy) batch action
|
4
5
|
Given 10 posts exist
|
5
6
|
And an index configuration of:
|
@@ -16,10 +17,28 @@ Feature: Batch Actions
|
|
16
17
|
And I follow "Batch Actions"
|
17
18
|
Then I should see the batch action :destroy "Delete Selected"
|
18
19
|
|
19
|
-
Given I
|
20
|
+
Given I click "Delete Selected" and accept confirmation
|
20
21
|
Then I should see a flash with "Successfully destroyed 2 posts"
|
21
22
|
And I should see 8 posts in the table
|
22
23
|
|
24
|
+
Scenario: Use default (destroy) batch action on a decorated resource
|
25
|
+
Given 5 posts exist
|
26
|
+
And an index configuration of:
|
27
|
+
"""
|
28
|
+
ActiveAdmin.register Post do
|
29
|
+
decorate_with PostDecorator
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
When I check the 2nd record
|
33
|
+
And I check the 4th record
|
34
|
+
And I follow "Batch Actions"
|
35
|
+
Then I should see the batch action :destroy "Delete Selected"
|
36
|
+
|
37
|
+
Given I submit the batch action form with "destroy"
|
38
|
+
Then I should see a flash with "Successfully destroyed 2 posts"
|
39
|
+
And I should see 3 posts in the table
|
40
|
+
|
41
|
+
@javascript
|
23
42
|
Scenario: Use default (destroy) batch action on a nested resource
|
24
43
|
Given I am logged in
|
25
44
|
And 5 posts written by "John Doe" exist
|
@@ -41,7 +60,7 @@ Feature: Batch Actions
|
|
41
60
|
And I follow "Batch Actions"
|
42
61
|
Then I should see the batch action :destroy "Delete Selected"
|
43
62
|
|
44
|
-
Given I
|
63
|
+
Given I click "Delete Selected" and accept confirmation
|
45
64
|
Then I should see a flash with "Successfully destroyed 2 posts"
|
46
65
|
And I should see 3 posts in the table
|
47
66
|
|
@@ -43,17 +43,21 @@ Feature: Index Pagination
|
|
43
43
|
When I am on the index page for posts
|
44
44
|
Then I should not see pagination
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
Scenario: Viewing index with pagination_total set to false
|
47
|
+
Given an index configuration of:
|
48
|
+
"""
|
49
|
+
ActiveAdmin.register Post do
|
50
|
+
config.per_page = 10
|
51
|
+
index :pagination_total => false do
|
52
52
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
end
|
54
|
+
"""
|
55
|
+
Given 11 posts exist
|
56
|
+
When I am on the index page for posts
|
57
|
+
Then I should see "Displaying Posts 1 - 10"
|
58
|
+
And I should not see "11 in total"
|
59
|
+
And I should see the pagination "Next" link
|
59
60
|
|
61
|
+
When I follow "Next"
|
62
|
+
Then I should see "Displaying Posts 11 - 11"
|
63
|
+
And I should not see the pagination "Next" link
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Meta Tag
|
2
|
+
|
3
|
+
Add custom meta tags to head of pages.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a configuration of:
|
7
|
+
"""
|
8
|
+
ActiveAdmin.register Post
|
9
|
+
ActiveAdmin.application.meta_tags = { author: 'My Company' }
|
10
|
+
ActiveAdmin.application.meta_tags_for_logged_out_pages = { robots: 'noindex' }
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: Logged out views include custom meta tags
|
14
|
+
Given I am logged out
|
15
|
+
When I am on the login page
|
16
|
+
Then the site should contain a meta tag with name "robots" and content "noindex"
|
17
|
+
|
18
|
+
Scenario: Logged in views include custom meta tags
|
19
|
+
Given I am logged in
|
20
|
+
When I am on the dashboard
|
21
|
+
Then the site should contain a meta tag with name "author" and content "My Company"
|
@@ -12,8 +12,7 @@ Feature: Registering Assets
|
|
12
12
|
|
13
13
|
Scenario: Viewing default asset files
|
14
14
|
When I am on the index page for posts
|
15
|
-
Then I should see the css file "
|
16
|
-
Then I should see the js file "active_admin_vendor.js"
|
15
|
+
Then I should see the css file "active_admin.css"
|
17
16
|
Then I should see the js file "active_admin.js"
|
18
17
|
|
19
18
|
Scenario: Registering a CSS file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: Show - Columns
|
2
|
+
|
3
|
+
Columns in show page
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a post with the title "Hello World" written by "Jane Doe" exists
|
7
|
+
|
8
|
+
Scenario:
|
9
|
+
Given a show configuration of:
|
10
|
+
"""
|
11
|
+
ActiveAdmin.register Post do
|
12
|
+
|
13
|
+
show do
|
14
|
+
columns do
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
Then I should see a columns container
|
21
|
+
And I should see 0 column
|
22
|
+
|
23
|
+
Scenario:
|
24
|
+
Given a show configuration of:
|
25
|
+
"""
|
26
|
+
ActiveAdmin.register Post do
|
27
|
+
|
28
|
+
show do
|
29
|
+
columns do
|
30
|
+
column do
|
31
|
+
end
|
32
|
+
column do
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
Then I should see a columns container
|
40
|
+
And I should see 2 columns
|
@@ -3,7 +3,7 @@ Feature: Show - Default Content
|
|
3
3
|
Viewing the show page for a resource
|
4
4
|
|
5
5
|
Background:
|
6
|
-
Given a post with the title "Hello World" written by "Jane Doe" exists
|
6
|
+
Given a unstarred post with the title "Hello World" written by "Jane Doe" exists
|
7
7
|
|
8
8
|
Scenario: Viewing the default show page
|
9
9
|
Given a show configuration of:
|
@@ -14,6 +14,7 @@ Feature: Show - Default Content
|
|
14
14
|
And I should see the attribute "Body" with "Empty"
|
15
15
|
And I should see the attribute "Created At" with a nicely formatted datetime
|
16
16
|
And I should see the attribute "Author" with "Jane Doe"
|
17
|
+
And I should see the attribute "Starred" with "false"
|
17
18
|
And I should see an action item button "Delete Post"
|
18
19
|
And I should see an action item button "Edit Post"
|
19
20
|
|
@@ -3,13 +3,13 @@ Then /^I should see the css file "([^"]*)"$/ do |path|
|
|
3
3
|
end
|
4
4
|
|
5
5
|
Then /^I should see the css file "([^"]*)" of media "([^"]*)"$/ do |path, media|
|
6
|
-
expect(page).to have_xpath("//link[contains(@href,
|
6
|
+
expect(page).to have_xpath("//link[contains(@href, '#{path}') and contains(@media, '#{media}')]", visible: false)
|
7
7
|
end
|
8
8
|
|
9
9
|
Then /^I should see the js file "([^"]*)"$/ do |path|
|
10
|
-
expect(page).to have_xpath("//script[contains(@src,
|
10
|
+
expect(page).to have_xpath("//script[contains(@src, '#{path}')]", visible: false)
|
11
11
|
end
|
12
12
|
|
13
13
|
Then /^I should see the favicon "([^"]*)"$/ do |path|
|
14
|
-
expect(page).to have_xpath("//link[contains(@href, path)]", visible: false)
|
14
|
+
expect(page).to have_xpath("//link[contains(@href, '#{path}')]", visible: false)
|
15
15
|
end
|
@@ -7,11 +7,11 @@ Then /^I (should|should not) be asked to confirm "([^"]*)" for "([^"]*)"$/ do |m
|
|
7
7
|
end
|
8
8
|
|
9
9
|
Then /^I (should|should not) see the batch action :([^\s]*) "([^"]*)"$/ do |maybe, sym, title|
|
10
|
-
selector = ".batch_actions_selector a.batch_action
|
10
|
+
selector = ".batch_actions_selector a.batch_action"
|
11
11
|
selector << "[href='#'][data-action='#{sym}']" if maybe == 'should'
|
12
12
|
|
13
13
|
verb = maybe == 'should' ? :to : :to_not
|
14
|
-
expect(page).send verb, have_css(selector)
|
14
|
+
expect(page).send verb, have_css(selector, text: title)
|
15
15
|
end
|
16
16
|
|
17
17
|
Then /^the (\d+)(?:st|nd|rd|th) batch action should be "([^"]*)"$/ do |index, title|
|
@@ -57,6 +57,15 @@ Given /^I submit the batch action form with "([^"]*)"$/ do |action|
|
|
57
57
|
page.driver.submit form['method'], form['action'], params
|
58
58
|
end
|
59
59
|
|
60
|
+
When /^I click "(.*?)" and accept confirmation$/ do |link|
|
61
|
+
# Use this implementation instead if poltergeist ever implements it
|
62
|
+
# page.driver.accept_modal(:confirm) { click_link(link) }
|
63
|
+
|
64
|
+
click_link(link)
|
65
|
+
expect(page).to have_content("Are you sure you want to delete these posts?")
|
66
|
+
click_button("OK")
|
67
|
+
end
|
68
|
+
|
60
69
|
Then /^I should not see checkboxes in the table$/ do
|
61
70
|
expect(page).to_not have_css '.paginated_collection table input[type=checkbox]'
|
62
71
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module ActiveAdminReloading
|
2
2
|
def load_aa_config(config_content)
|
3
|
-
|
3
|
+
ActiveSupport::Notifications.publish ActiveAdmin::Application::BeforeLoadEvent, ActiveAdmin.application
|
4
4
|
eval(config_content)
|
5
|
-
|
5
|
+
ActiveSupport::Notifications.publish ActiveAdmin::Application::AfterLoadEvent, ActiveAdmin.application
|
6
6
|
Rails.application.reload_routes!
|
7
7
|
ActiveAdmin.application.namespaces.each &:reset_menu!
|
8
8
|
end
|
@@ -3,14 +3,15 @@ def create_user(name, type = 'User')
|
|
3
3
|
user = type.camelize.constantize.where(first_name: first_name, last_name: last_name).first_or_create(username: name.tr(' ', '').underscore)
|
4
4
|
end
|
5
5
|
|
6
|
-
Given /^(a|\d+)( published)? posts?(?: with the title "([^"]*)")?(?: and body "([^"]*)")?(?: written by "([^"]*)")?(?: in category "([^"]*)")? exists?$/ do |count, published, title, body, user, category_name|
|
6
|
+
Given /^(a|\d+)( published)?( unstarred|starred)? posts?(?: with the title "([^"]*)")?(?: and body "([^"]*)")?(?: written by "([^"]*)")?(?: in category "([^"]*)")? exists?$/ do |count, published, starred, title, body, user, category_name|
|
7
7
|
count = count == 'a' ? 1 : count.to_i
|
8
8
|
published = Time.now if published
|
9
|
+
starred = starred == " starred" if starred
|
9
10
|
author = create_user(user) if user
|
10
11
|
category = Category.where(name: category_name).first_or_create if category_name
|
11
12
|
title ||= "Hello World %i"
|
12
13
|
count.times do |i|
|
13
|
-
Post.create! title: title % i, body: body, author: author, published_at: published, custom_category_id: category.try(:id)
|
14
|
+
Post.create! title: title % i, body: body, author: author, published_at: published, custom_category_id: category.try(:id), starred: starred
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
@@ -5,3 +5,11 @@ end
|
|
5
5
|
Then /^I should see pagination with (\d+) pages$/ do |count|
|
6
6
|
expect(page).to have_css '.pagination span.page', count: count
|
7
7
|
end
|
8
|
+
|
9
|
+
Then /^I should see the pagination "Next" link/ do
|
10
|
+
expect(page).to have_css "a", text: "Next"
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^I should not see the pagination "Next" link/ do
|
14
|
+
expect(page).to_not have_css "a", text: "Next"
|
15
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
Then /^I should see (\d+) ([\w]*) in the table$/ do |count, resource_type|
|
2
|
-
expect(
|
2
|
+
expect(page).to \
|
3
|
+
have_css("table.index_table tr > td:first-child", count: count.to_i)
|
3
4
|
end
|
4
5
|
|
5
6
|
# TODO: simplify this, if possible?
|
data/lib/active_admin.rb
CHANGED
@@ -6,6 +6,7 @@ require 'ransack_ext'
|
|
6
6
|
require 'bourbon'
|
7
7
|
require 'kaminari'
|
8
8
|
require 'formtastic'
|
9
|
+
require 'formtastic_i18n'
|
9
10
|
require 'sass-rails'
|
10
11
|
require 'inherited_resources'
|
11
12
|
require 'jquery-rails'
|
@@ -35,7 +36,6 @@ module ActiveAdmin
|
|
35
36
|
autoload :Event, 'active_admin/event'
|
36
37
|
autoload :FormBuilder, 'active_admin/form_builder'
|
37
38
|
autoload :Inputs, 'active_admin/inputs'
|
38
|
-
autoload :Iconic, 'active_admin/iconic'
|
39
39
|
autoload :Menu, 'active_admin/menu'
|
40
40
|
autoload :MenuCollection, 'active_admin/menu_collection'
|
41
41
|
autoload :MenuItem, 'active_admin/menu_item'
|
@@ -92,7 +92,7 @@ module ActiveAdmin
|
|
92
92
|
#
|
93
93
|
# @param [Block] block A block to call each time (before) AA loads resources
|
94
94
|
def before_load(&block)
|
95
|
-
|
95
|
+
ActiveSupport::Notifications.subscribe ActiveAdmin::Application::BeforeLoadEvent, &ActiveAdmin::Event.wrap_block_for_active_support_notifications(block)
|
96
96
|
end
|
97
97
|
|
98
98
|
# A callback is triggered each time (after) Active Admin loads the configuration files. This
|
@@ -110,7 +110,7 @@ module ActiveAdmin
|
|
110
110
|
#
|
111
111
|
# @param [Block] block A block to call each time (after) AA loads resources
|
112
112
|
def after_load(&block)
|
113
|
-
|
113
|
+
ActiveSupport::Notifications.subscribe ActiveAdmin::Application::AfterLoadEvent, &ActiveAdmin::Event.wrap_block_for_active_support_notifications(block)
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
@@ -28,6 +28,9 @@ module ActiveAdmin
|
|
28
28
|
# The default number of resources to display on index pages
|
29
29
|
inheritable_setting :default_per_page, 30
|
30
30
|
|
31
|
+
# The max number of resources to display on index pages and batch exports
|
32
|
+
inheritable_setting :max_per_page, 10_000
|
33
|
+
|
31
34
|
# The title which gets displayed in the main layout
|
32
35
|
inheritable_setting :site_title, ""
|
33
36
|
|
@@ -40,6 +43,12 @@ module ActiveAdmin
|
|
40
43
|
# Set a favicon
|
41
44
|
inheritable_setting :favicon, false
|
42
45
|
|
46
|
+
# Additional meta tags to place in head of logged in pages.
|
47
|
+
inheritable_setting :meta_tags, {}
|
48
|
+
|
49
|
+
# Additional meta tags to place in head of logged out pages.
|
50
|
+
inheritable_setting :meta_tags_for_logged_out_pages, { robots: "noindex, nofollow" }
|
51
|
+
|
43
52
|
# The view factory to use to generate all the view classes. Take
|
44
53
|
# a look at ActiveAdmin::ViewFactory
|
45
54
|
inheritable_setting :view_factory, ActiveAdmin::ViewFactory.new
|
@@ -88,6 +97,9 @@ module ActiveAdmin
|
|
88
97
|
# A regex to detect unsupported browser, set to false to disable
|
89
98
|
inheritable_setting :unsupported_browser_matcher, /MSIE [1-8]\.0/
|
90
99
|
|
100
|
+
# Whether to display 'Current Filters' on search screen
|
101
|
+
inheritable_setting :current_filters, true
|
102
|
+
|
91
103
|
# Request parameters that are permitted by default
|
92
104
|
inheritable_setting :permitted_params, [
|
93
105
|
:utf8, :_method, :authenticity_token, :commit, :id
|
@@ -96,6 +108,9 @@ module ActiveAdmin
|
|
96
108
|
# Set flash message keys that shouldn't show in ActiveAdmin
|
97
109
|
inheritable_setting :flash_keys_to_except, ['timedout']
|
98
110
|
|
111
|
+
# Set default localize format for Date/Time values
|
112
|
+
inheritable_setting :localize_format, :long
|
113
|
+
|
99
114
|
# Active Admin makes educated guesses when displaying objects, this is
|
100
115
|
# the list of methods it tries calling in order
|
101
116
|
setting :display_name_methods, [ :display_name,
|
@@ -146,7 +161,7 @@ module ActiveAdmin
|
|
146
161
|
|
147
162
|
namespace = namespaces[name] ||= begin
|
148
163
|
namespace = Namespace.new(self, name)
|
149
|
-
|
164
|
+
ActiveSupport::Notifications.publish ActiveAdmin::Namespace::RegisterEvent, namespace
|
150
165
|
namespace
|
151
166
|
end
|
152
167
|
|
@@ -182,10 +197,10 @@ module ActiveAdmin
|
|
182
197
|
# To reload everything simply call `ActiveAdmin.unload!`
|
183
198
|
def load!
|
184
199
|
unless loaded?
|
185
|
-
|
186
|
-
files.each{ |file| load file }
|
187
|
-
namespace(default_namespace)
|
188
|
-
|
200
|
+
ActiveSupport::Notifications.publish BeforeLoadEvent, self # before_load hook
|
201
|
+
files.each{ |file| load file } # load files
|
202
|
+
namespace(default_namespace) # init AA resources
|
203
|
+
ActiveSupport::Notifications.publish AfterLoadEvent, self # after_load hook
|
189
204
|
@@loaded = true
|
190
205
|
end
|
191
206
|
end
|
@@ -213,7 +228,8 @@ module ActiveAdmin
|
|
213
228
|
# Example usage:
|
214
229
|
# ActiveAdmin.before_filter :authenticate_admin!
|
215
230
|
#
|
216
|
-
|
231
|
+
AbstractController::Callbacks::ClassMethods.public_instance_methods.
|
232
|
+
select { |m| m.match(/(filter|action)/) }.each do |name|
|
217
233
|
define_method name do |*args, &block|
|
218
234
|
controllers_for_filters.each do |controller|
|
219
235
|
controller.public_send name, *args, &block
|
@@ -246,20 +262,54 @@ module ActiveAdmin
|
|
246
262
|
Rails.application.config.eager_load_paths -= load_paths
|
247
263
|
end
|
248
264
|
|
249
|
-
#
|
250
|
-
#
|
265
|
+
# Hook into the Rails code reloading mechanism so that things are reloaded
|
266
|
+
# properly in development mode.
|
251
267
|
#
|
252
|
-
# If files
|
253
|
-
#
|
268
|
+
# If any of the app files (e.g. models) has changed, we need to reload all
|
269
|
+
# the admin files. If the admin files themselves has changed, we need to
|
270
|
+
# regenerate the routes as well.
|
254
271
|
def attach_reloader
|
255
|
-
|
256
|
-
ActiveAdmin
|
257
|
-
|
272
|
+
Rails.application.config.after_initialize do |app|
|
273
|
+
unload_active_admin = -> { ActiveAdmin.application.unload! }
|
274
|
+
|
275
|
+
if app.config.reload_classes_only_on_change
|
276
|
+
# Rails is about to unload all the app files (e.g. models), so we
|
277
|
+
# should first unload the classes generated by Active Admin, otherwise
|
278
|
+
# they will contain references to the stale (unloaded) classes.
|
279
|
+
ActionDispatch::Reloader.to_prepare(prepend: true, &unload_active_admin)
|
280
|
+
else
|
281
|
+
# If the user has configured the app to always reload app files after
|
282
|
+
# each request, so we should unload the generated classes too.
|
283
|
+
ActionDispatch::Reloader.to_cleanup(&unload_active_admin)
|
284
|
+
end
|
285
|
+
|
286
|
+
admin_dirs = {}
|
287
|
+
|
288
|
+
load_paths.each do |path|
|
289
|
+
admin_dirs[path] = [:rb]
|
290
|
+
end
|
291
|
+
|
292
|
+
routes_reloader = app.config.file_watcher.new([], admin_dirs) do
|
293
|
+
app.reload_routes!
|
294
|
+
end
|
295
|
+
|
296
|
+
app.reloaders << routes_reloader
|
258
297
|
|
259
|
-
Rails.application.config.after_initialize do
|
260
298
|
ActionDispatch::Reloader.to_prepare do
|
261
|
-
|
262
|
-
|
299
|
+
# Rails might have reloaded the routes for other reasons (e.g.
|
300
|
+
# routes.rb has changed), in which case Active Admin would have been
|
301
|
+
# loaded via the `ActiveAdmin.routes` call in `routes.rb`.
|
302
|
+
#
|
303
|
+
# Otherwise, we should check if any of the admin files are changed
|
304
|
+
# and force the routes to reload if necessary. This would again causes
|
305
|
+
# Active Admin to load via `ActiveAdmin.routes`.
|
306
|
+
#
|
307
|
+
# Finally, if Active Admin is still not loaded at this point, then we
|
308
|
+
# would need to load it manually.
|
309
|
+
unless ActiveAdmin.application.loaded?
|
310
|
+
routes_reloader.execute_if_updated
|
311
|
+
ActiveAdmin.application.load!
|
312
|
+
end
|
263
313
|
end
|
264
314
|
end
|
265
315
|
end
|