activeadmin 1.0.0.pre2 → 1.0.0.pre3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +7 -4
  3. data/.travis.yml +17 -15
  4. data/CHANGELOG.md +5 -1
  5. data/CODE_OF_CONDUCT.md +22 -0
  6. data/Gemfile +26 -12
  7. data/README.md +24 -4
  8. data/activeadmin.gemspec +1 -0
  9. data/app/assets/javascripts/active_admin/base.js.coffee +1 -1
  10. data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +7 -0
  11. data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +10 -0
  12. data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +15 -0
  13. data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +3 -0
  14. data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +1 -1
  15. data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +1 -1
  16. data/app/assets/stylesheets/active_admin/_forms.scss +1 -1
  17. data/config/locales/ar.yml +47 -43
  18. data/config/locales/de.yml +2 -1
  19. data/config/locales/en.yml +2 -1
  20. data/config/locales/es-MX.yml +3 -3
  21. data/config/locales/es.yml +5 -4
  22. data/config/locales/fr.yml +2 -1
  23. data/config/locales/hu.yml +1 -1
  24. data/config/locales/id.yml +2 -1
  25. data/config/locales/it.yml +19 -0
  26. data/config/locales/ja.yml +2 -1
  27. data/config/locales/ko.yml +2 -1
  28. data/config/locales/nb.yml +6 -1
  29. data/config/locales/nl.yml +1 -1
  30. data/config/locales/pt-BR.yml +5 -1
  31. data/config/locales/ru.yml +4 -3
  32. data/config/locales/sv-SE.yml +3 -2
  33. data/config/locales/tr.yml +83 -44
  34. data/config/locales/uk.yml +13 -12
  35. data/config/locales/zh-CN.yml +2 -1
  36. data/config/locales/zh-TW.yml +10 -1
  37. data/cucumber.yml +1 -1
  38. data/docs/0-installation.md +24 -10
  39. data/docs/1-general-configuration.md +22 -0
  40. data/docs/12-arbre-components.md +1 -1
  41. data/docs/13-authorization-adapter.md +1 -1
  42. data/docs/14-gotchas.md +11 -3
  43. data/docs/2-resource-customization.md +16 -3
  44. data/docs/3-index-pages.md +1 -1
  45. data/docs/3-index-pages/index-as-table.md +13 -1
  46. data/docs/4-csv-format.md +19 -0
  47. data/docs/5-forms.md +14 -2
  48. data/docs/6-show-pages.md +1 -1
  49. data/features/decorators.feature +2 -0
  50. data/features/development_reloading.feature +1 -1
  51. data/features/edit_page.feature +4 -4
  52. data/features/index/batch_actions.feature +13 -0
  53. data/features/index/page_title.feature +2 -1
  54. data/features/new_page.feature +4 -4
  55. data/features/renamed_resource.feature +1 -1
  56. data/features/show/default_content.feature +1 -1
  57. data/features/show/page_title.feature +2 -1
  58. data/features/step_definitions/attribute_steps.rb +2 -2
  59. data/features/step_definitions/factory_steps.rb +2 -2
  60. data/features/step_definitions/filter_steps.rb +2 -2
  61. data/features/step_definitions/format_steps.rb +1 -1
  62. data/features/sti_resource.feature +2 -2
  63. data/features/strong_parameters.feature +3 -3
  64. data/features/support/env.rb +21 -4
  65. data/lib/active_admin/application.rb +11 -4
  66. data/lib/active_admin/authorization_adapter.rb +1 -1
  67. data/lib/active_admin/base_controller.rb +12 -2
  68. data/lib/active_admin/base_controller/authorization.rb +4 -7
  69. data/lib/active_admin/base_controller/menu.rb +5 -1
  70. data/lib/active_admin/batch_actions/controller.rb +0 -1
  71. data/lib/active_admin/batch_actions/resource_extension.rb +3 -2
  72. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -0
  73. data/lib/active_admin/csv_builder.rb +18 -15
  74. data/lib/active_admin/dependency.rb +74 -1
  75. data/lib/active_admin/error.rb +1 -1
  76. data/lib/active_admin/filters/active.rb +4 -3
  77. data/lib/active_admin/filters/resource_extension.rb +7 -3
  78. data/lib/active_admin/generators/boilerplate.rb +8 -0
  79. data/lib/active_admin/inputs/filters/base.rb +3 -1
  80. data/lib/active_admin/inputs/filters/base/search_method_select.rb +3 -3
  81. data/lib/active_admin/inputs/filters/date_range_input.rb +2 -2
  82. data/lib/active_admin/inputs/filters/select_input.rb +3 -2
  83. data/lib/active_admin/orm/active_record/comments.rb +13 -8
  84. data/lib/active_admin/page_controller.rb +5 -1
  85. data/lib/active_admin/reloader.rb +25 -0
  86. data/lib/active_admin/resource/menu.rb +1 -1
  87. data/lib/active_admin/resource_controller/data_access.rb +33 -20
  88. data/lib/active_admin/resource_controller/decorators.rb +2 -2
  89. data/lib/active_admin/resource_controller/streaming.rb +7 -1
  90. data/lib/active_admin/resource_dsl.rb +15 -9
  91. data/lib/active_admin/router.rb +1 -1
  92. data/lib/active_admin/scope.rb +2 -3
  93. data/lib/active_admin/version.rb +1 -1
  94. data/lib/active_admin/view_helpers/display_helper.rb +31 -0
  95. data/lib/active_admin/view_helpers/fields_for.rb +3 -2
  96. data/lib/active_admin/views/components/attributes_table.rb +5 -23
  97. data/lib/active_admin/views/components/index_list.rb +1 -1
  98. data/lib/active_admin/views/components/paginated_collection.rb +3 -3
  99. data/lib/active_admin/views/components/site_title.rb +1 -1
  100. data/lib/active_admin/views/components/table_for.rb +8 -27
  101. data/lib/active_admin/views/index_as_grid.rb +2 -2
  102. data/lib/active_admin/views/index_as_table.rb +24 -2
  103. data/lib/active_admin/views/pages/base.rb +1 -1
  104. data/lib/active_admin/views/pages/form.rb +6 -2
  105. data/lib/active_admin/views/title_bar.rb +1 -1
  106. data/lib/generators/active_admin/assets/templates/active_admin.scss +1 -1
  107. data/lib/generators/active_admin/install/install_generator.rb +1 -1
  108. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +14 -4
  109. data/lib/generators/active_admin/resource/templates/admin.rb +8 -2
  110. data/lib/ransack_ext.rb +8 -0
  111. data/script/local +15 -6
  112. data/spec/rails_helper.rb +12 -1
  113. data/spec/requests/javascript_spec.rb +15 -13
  114. data/spec/requests/stylesheets_spec.rb +1 -1
  115. data/spec/support/detect_rails_version.rb +1 -1
  116. data/spec/support/rails_template.rb +117 -104
  117. data/spec/support/rails_template_with_data.rb +5 -9
  118. data/spec/support/templates/admin/stores.rb +1 -1
  119. data/spec/unit/action_builder_spec.rb +58 -56
  120. data/spec/unit/authorization/authorization_adapter_spec.rb +5 -5
  121. data/spec/unit/authorization/index_overriding_spec.rb +2 -1
  122. data/spec/unit/auto_link_spec.rb +1 -1
  123. data/spec/unit/batch_actions/resource_spec.rb +2 -2
  124. data/spec/unit/batch_actions/settings_spec.rb +13 -13
  125. data/spec/unit/comments_spec.rb +5 -5
  126. data/spec/unit/csv_builder_spec.rb +59 -0
  127. data/spec/unit/dsl_spec.rb +1 -1
  128. data/spec/unit/filters/filter_form_builder_spec.rb +5 -4
  129. data/spec/unit/filters/resource_spec.rb +7 -0
  130. data/spec/unit/form_builder_spec.rb +4 -1
  131. data/spec/unit/generators/install_spec.rb +4 -4
  132. data/spec/unit/helpers/collection_spec.rb +4 -4
  133. data/spec/unit/menu_collection_spec.rb +3 -3
  134. data/spec/unit/namespace/register_page_spec.rb +17 -18
  135. data/spec/unit/namespace/register_resource_spec.rb +20 -21
  136. data/spec/unit/namespace_spec.rb +4 -4
  137. data/spec/unit/pundit_adapter_spec.rb +3 -3
  138. data/spec/unit/resource/action_items_spec.rb +1 -1
  139. data/spec/unit/resource/naming_spec.rb +1 -1
  140. data/spec/unit/resource/routes_spec.rb +6 -2
  141. data/spec/unit/resource/scopes_spec.rb +2 -2
  142. data/spec/unit/resource_controller/decorators_spec.rb +11 -0
  143. data/spec/unit/resource_controller/sidebars_spec.rb +17 -24
  144. data/spec/unit/resource_spec.rb +14 -12
  145. data/spec/unit/routing_spec.rb +19 -14
  146. data/spec/unit/scope_spec.rb +28 -33
  147. data/spec/unit/view_helpers/display_helper_spec.rb +165 -0
  148. data/spec/unit/view_helpers/download_format_links_helper_spec.rb +9 -9
  149. data/spec/unit/views/components/attributes_table_spec.rb +1 -1
  150. data/spec/unit/views/components/blank_slate_spec.rb +3 -3
  151. data/spec/unit/views/components/index_table_for_spec.rb +82 -1
  152. data/spec/unit/views/components/paginated_collection_spec.rb +0 -1
  153. data/spec/unit/views/components/table_for_spec.rb +13 -8
  154. data/spec/unit/views/components/unsupported_browser_spec.rb +2 -8
  155. data/spec/unit/views/index_as_blog_spec.rb +76 -0
  156. data/spec/unit/views/pages/form_spec.rb +9 -0
  157. data/tasks/test.rake +13 -5
  158. metadata +27 -10
  159. data/app/assets/javascripts/active_admin/application.js.coffee +0 -37
  160. data/spec/support/templates/cucumber.rb +0 -24
  161. data/spec/support/templates/cucumber_with_reloading.rb +0 -5
  162. data/spec/unit/view_helpers/display_name_spec.rb +0 -71
@@ -12,7 +12,7 @@ Feature: Development Reloading
12
12
  When "app/admin/posts.rb" contains:
13
13
  """
14
14
  ActiveAdmin.register Post do
15
- if Rails::VERSION::MAJOR == 4
15
+ if Rails::VERSION::MAJOR >= 4
16
16
  permit_params :custom_category_id, :author_id, :title,
17
17
  :body, :position, :published_at, :starred
18
18
  end
@@ -10,7 +10,7 @@ Feature: Edit Page
10
10
  Given a configuration of:
11
11
  """
12
12
  ActiveAdmin.register Post do
13
- if Rails::VERSION::MAJOR == 4
13
+ if Rails::VERSION::MAJOR >= 4
14
14
  permit_params :custom_category_id, :author_id, :title,
15
15
  :body, :position, :published_at, :starred
16
16
  end
@@ -34,7 +34,7 @@ Feature: Edit Page
34
34
  Given a configuration of:
35
35
  """
36
36
  ActiveAdmin.register Post do
37
- permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
37
+ permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
38
38
 
39
39
  form do |f|
40
40
  f.inputs "Your Post" do
@@ -63,7 +63,7 @@ Feature: Edit Page
63
63
  Given a configuration of:
64
64
  """
65
65
  ActiveAdmin.register Post do
66
- permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
66
+ permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
67
67
 
68
68
  form :html => {} do |f|
69
69
  f.inputs "Your Post" do
@@ -102,7 +102,7 @@ Feature: Edit Page
102
102
  Given a configuration of:
103
103
  """
104
104
  ActiveAdmin.register Post do
105
- permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
105
+ permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
106
106
 
107
107
  form :partial => "form"
108
108
  end
@@ -64,6 +64,19 @@ Feature: Batch Actions
64
64
  Then I should see a flash with "Successfully destroyed 2 posts"
65
65
  And I should see 3 posts in the table
66
66
 
67
+ Scenario: Disable display of batch action button if all nested buttons hide
68
+ Given 1 post exist
69
+ And an index configuration of:
70
+ """
71
+ ActiveAdmin.register Post do
72
+ batch_action :destroy, false
73
+ batch_action(:flag, if: proc { false } ) do
74
+ render text: 42
75
+ end
76
+ end
77
+ """
78
+ Then I should not see the batch action selector
79
+
67
80
  Scenario: Using a custom batch action
68
81
  Given 10 posts exist
69
82
  And an index configuration of:
@@ -34,7 +34,8 @@ Feature: Index - Page Title
34
34
  """
35
35
  ActiveAdmin.register Post do
36
36
  controller do
37
- before_filter { @page_title = "List of #{resource_class.model_name.plural}" }
37
+ callback = ActiveAdmin::Dependency.rails >= 4 ? :before_action : :before_filter
38
+ send(callback) { @page_title = "List of #{resource_class.model_name.plural}" }
38
39
  end
39
40
  end
40
41
  """
@@ -9,7 +9,7 @@ Feature: New Page
9
9
  Given a configuration of:
10
10
  """
11
11
  ActiveAdmin.register Post do
12
- if Rails::VERSION::MAJOR == 4
12
+ if Rails::VERSION::MAJOR >= 4
13
13
  permit_params :custom_category_id, :author_id, :title,
14
14
  :body, :position, :published_at, :starred
15
15
  end
@@ -34,7 +34,7 @@ Feature: New Page
34
34
  Given a configuration of:
35
35
  """
36
36
  ActiveAdmin.register Post do
37
- permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
37
+ permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
38
38
 
39
39
  form do |f|
40
40
  f.inputs "Your Post" do
@@ -70,7 +70,7 @@ Feature: New Page
70
70
  Given a configuration of:
71
71
  """
72
72
  ActiveAdmin.register Post do
73
- permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
73
+ permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
74
74
 
75
75
  form :partial => "form"
76
76
  end
@@ -87,7 +87,7 @@ Feature: New Page
87
87
  Given a configuration of:
88
88
  """
89
89
  ActiveAdmin.register Post do
90
- permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
90
+ permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
91
91
 
92
92
  form do |f|
93
93
  f.inputs "Your Post" do
@@ -9,7 +9,7 @@ Feature: Renamed Resource
9
9
  Given a configuration of:
10
10
  """
11
11
  ActiveAdmin.register Blog::Post, as: 'Post' do
12
- if Rails::VERSION::MAJOR == 4
12
+ if Rails::VERSION::MAJOR >= 4
13
13
  permit_params :custom_category_id, :author_id, :title,
14
14
  :body, :position, :published_at, :starred
15
15
  end
@@ -14,7 +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
+ And I should see the attribute "Starred" with "No"
18
18
  And I should see an action item button "Delete Post"
19
19
  And I should see an action item button "Edit Post"
20
20
 
@@ -51,7 +51,8 @@ Feature: Show - Page Title
51
51
  """
52
52
  ActiveAdmin.register Post do
53
53
  controller do
54
- before_filter { @page_title = "List of #{resource_class.model_name.plural}" }
54
+ callback = ActiveAdmin::Dependency.rails >= 4 ? :before_action : :before_filter
55
+ send(callback) { @page_title = "List of #{resource_class.model_name.plural}" }
55
56
  end
56
57
  end
57
58
  """
@@ -1,6 +1,6 @@
1
1
  Then /^I should see the attribute "([^"]*)" with "([^"]*)"$/ do |title, value|
2
2
  elems = all ".attributes_table th:contains('#{title}') ~ td:contains('#{value}')"
3
- expect(elems.first).to_not be_nil, 'attribute missing'
3
+ expect(elems.first).to_not eq(nil), 'attribute missing'
4
4
  end
5
5
 
6
6
  Then /^I should see the attribute "([^"]*)" with a nicely formatted datetime$/ do |title|
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  Then /^the attribute "([^"]*)" should be empty$/ do |title|
12
12
  elems = all ".attributes_table th:contains('#{title}') ~ td > span.empty"
13
- expect(elems.first).to_not be_nil, 'attribute not empty'
13
+ expect(elems.first).to_not eq(nil), 'attribute not empty'
14
14
  end
15
15
 
16
16
  Then /^I should not see the attribute "([^"]*)"$/ do |title|
@@ -5,9 +5,9 @@ end
5
5
 
6
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
- published = Time.now if published
8
+ published = Time.now if published
9
9
  starred = starred == " starred" if starred
10
- author = create_user(user) if user
10
+ author = create_user(user) if user
11
11
  category = Category.where(name: category_name).first_or_create if category_name
12
12
  title ||= "Hello World %i"
13
13
  count.times do |i|
@@ -25,14 +25,14 @@ end
25
25
  Then(/^I should( not)? have parameter "([^"]*)"( with value "([^"]*)")?$/) do |negative, key, compare_val, value|
26
26
  query = URI(page.current_url).query
27
27
  if query.nil?
28
- expect(negative).to be_truthy
28
+ expect(negative).to eq true
29
29
  else
30
30
  params = Rack::Utils.parse_query query
31
31
  if compare_val
32
32
  expect(params[key]).to_not eq value if negative
33
33
  expect(params[key]).to eq value unless negative
34
34
  else
35
- expect(params[key]).to be_nil if negative
35
+ expect(params[key]).to eq nil if negative
36
36
  expect(params[key]).to be_present unless negative
37
37
  end
38
38
  end
@@ -24,7 +24,7 @@ Then /^I should download a CSV file with "([^"]*)" separator for "([^"]*)" conta
24
24
  expected_row.each_with_index do |expected_cell, col_index|
25
25
  cell = csv.try(:[], row_index).try(:[], col_index)
26
26
  if expected_cell.blank?
27
- expect(cell).to be_nil
27
+ expect(cell).to eq nil
28
28
  else
29
29
  expect(cell || '').to match /#{expected_cell}/
30
30
  end
@@ -7,10 +7,10 @@ Feature: STI Resource
7
7
  And a configuration of:
8
8
  """
9
9
  ActiveAdmin.register Publisher do
10
- permit_params :first_name, :last_name, :username, :age if Rails::VERSION::MAJOR == 4
10
+ permit_params :first_name, :last_name, :username, :age if Rails::VERSION::MAJOR >= 4
11
11
  end
12
12
  ActiveAdmin.register User do
13
- permit_params :first_name, :last_name, :username, :age if Rails::VERSION::MAJOR == 4
13
+ permit_params :first_name, :last_name, :username, :age if Rails::VERSION::MAJOR >= 4
14
14
  end
15
15
  """
16
16
 
@@ -32,7 +32,7 @@ Feature: Strong Params
32
32
  Then I should see "Post was successfully updated."
33
33
  And I should see the attribute "Title" with "Hello World from update"
34
34
  And I should see the attribute "Author" with "John Doe"
35
- And I should see the attribute "Starred" with "true"
35
+ And I should see the attribute "Starred" with "Yes"
36
36
 
37
37
  Scenario: Dynamic permitted parameters
38
38
  Given a configuration of:
@@ -53,7 +53,7 @@ Feature: Strong Params
53
53
  Then I should see "Post was successfully updated."
54
54
  And I should see the attribute "Title" with "Hello World from update"
55
55
  And I should see the attribute "Author" with "John Doe"
56
- And I should see the attribute "Starred" with "true"
56
+ And I should see the attribute "Starred" with "Yes"
57
57
 
58
58
  Scenario: Should not update parameters that are not declared as permitted
59
59
  Given a configuration of:
@@ -70,4 +70,4 @@ Feature: Strong Params
70
70
  Then I should see "Post was successfully updated."
71
71
  And I should see the attribute "Title" with "Hello World from update"
72
72
  And I should see the attribute "Author" with "John Doe"
73
- And the attribute "Starred" should be empty
73
+ And I should see the attribute "Starred" with "No"
@@ -4,7 +4,7 @@
4
4
  # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
5
  # files.
6
6
 
7
- ENV["RAILS_ENV"] ||= "cucumber"
7
+ ENV['RAILS_ENV'] = 'test'
8
8
 
9
9
  require File.expand_path('../../../spec/spec_helper', __FILE__)
10
10
 
@@ -58,6 +58,9 @@ Capybara.javascript_driver = :poltergeist
58
58
  # steps to use the XPath syntax.
59
59
  Capybara.default_selector = :css
60
60
 
61
+ # Make input type=hidden visible
62
+ Capybara.ignore_hidden_elements = false
63
+
61
64
  # If you set this to false, any error raised from within your app will bubble
62
65
  # up to your step definition and out to cucumber unless you catch it somewhere
63
66
  # on the way. You can make Rails rescue errors and render error pages on a
@@ -81,7 +84,12 @@ ActionController::Base.allow_rescue = false
81
84
  # after each scenario, which can lead to hard-to-debug failures in
82
85
  # subsequent scenarios. If you do this, we recommend you create a Before
83
86
  # block that will explicitly put your database in a known state.
84
- Cucumber::Rails::World.use_transactional_fixtures = false
87
+ if ActiveAdmin::Dependency.rails5?
88
+ Cucumber::Rails::World.use_transactional_tests = true
89
+ else
90
+ Cucumber::Rails::World.use_transactional_fixtures = true
91
+ end
92
+
85
93
  # How to clean your database when transactions are turned off. See
86
94
  # http://github.com/bmabey/database_cleaner for more info.
87
95
  if defined?(ActiveRecord::Base)
@@ -89,7 +97,8 @@ if defined?(ActiveRecord::Base)
89
97
  require 'database_cleaner'
90
98
  require 'database_cleaner/cucumber'
91
99
  DatabaseCleaner.strategy = :truncation
92
- rescue LoadError => ignore_if_database_cleaner_not_present
100
+ rescue LoadError
101
+ # ignore if database_cleaner isn't present
93
102
  end
94
103
  end
95
104
 
@@ -106,7 +115,6 @@ After do
106
115
  end
107
116
 
108
117
  Before do
109
-
110
118
  begin
111
119
  # We are caching classes, but need to manually clear references to
112
120
  # the controllers. If they aren't clear, the router stores references
@@ -121,6 +129,15 @@ Before do
121
129
  end
122
130
  end
123
131
 
132
+ # Force deprecations to raise an exception.
133
+ # This would set `behavior = :raise`, but that wasn't added until Rails 4.
134
+ ActiveSupport::Deprecation.behavior = -> message, callstack do
135
+ e = StandardError.new message
136
+ e.set_backtrace callstack.map(&:to_s)
137
+ puts e # sometimes Cucumber otherwise won't show the error message
138
+ raise e
139
+ end
140
+
124
141
  # improve the performance of the specs suite by not logging anything
125
142
  # see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
126
143
  Rails.logger.level = 4
@@ -1,4 +1,5 @@
1
1
  require 'active_admin/router'
2
+ require 'active_admin/reloader'
2
3
  require 'active_admin/helpers/settings'
3
4
 
4
5
  module ActiveAdmin
@@ -109,7 +110,10 @@ module ActiveAdmin
109
110
  inheritable_setting :flash_keys_to_except, ['timedout']
110
111
 
111
112
  # Set default localize format for Date/Time values
112
- inheritable_setting :localize_format, :long
113
+ setting :localize_format, :long
114
+
115
+ # Include association filters by default
116
+ inheritable_setting :include_default_association_filters, true
113
117
 
114
118
  # Active Admin makes educated guesses when displaying objects, this is
115
119
  # the list of methods it tries calling in order
@@ -122,6 +126,9 @@ module ActiveAdmin
122
126
  :email,
123
127
  :to_s ]
124
128
 
129
+ # To make debugging easier, by default don't stream in development
130
+ setting :disable_streaming_in, ['development']
131
+
125
132
  # == Deprecated Settings
126
133
 
127
134
  def allow_comments=(*)
@@ -276,11 +283,11 @@ module ActiveAdmin
276
283
  # Rails is about to unload all the app files (e.g. models), so we
277
284
  # should first unload the classes generated by Active Admin, otherwise
278
285
  # they will contain references to the stale (unloaded) classes.
279
- ActionDispatch::Reloader.to_prepare(prepend: true, &unload_active_admin)
286
+ Reloader.to_prepare(prepend: true, &unload_active_admin)
280
287
  else
281
288
  # If the user has configured the app to always reload app files after
282
289
  # each request, so we should unload the generated classes too.
283
- ActionDispatch::Reloader.to_cleanup(&unload_active_admin)
290
+ Reloader.to_complete(&unload_active_admin)
284
291
  end
285
292
 
286
293
  admin_dirs = {}
@@ -295,7 +302,7 @@ module ActiveAdmin
295
302
 
296
303
  app.reloaders << routes_reloader
297
304
 
298
- ActionDispatch::Reloader.to_prepare do
305
+ Reloader.to_prepare do
299
306
  # Rails might have reloaded the routes for other reasons (e.g.
300
307
  # routes.rb has changed), in which case Active Admin would have been
301
308
  # loaded via the `ActiveAdmin.routes` call in `routes.rb`.
@@ -47,7 +47,7 @@ module ActiveAdmin
47
47
  # the class of the subject also. For example, Active Admin uses the class
48
48
  # of the resource to decide if the resource should be displayed in the
49
49
  # global navigation. To deal with this nicely in a case statement, take
50
- # a look at `#normalized(klasss)`
50
+ # a look at `#normalized(klass)`
51
51
  #
52
52
  # @return [Boolean]
53
53
  def authorized?(action, subject = nil)
@@ -10,8 +10,13 @@ module ActiveAdmin
10
10
 
11
11
  layout :determine_active_admin_layout
12
12
 
13
- before_filter :only_render_implemented_actions
14
- before_filter :authenticate_active_admin_user
13
+ if ActiveAdmin::Dependency.rails >= 4
14
+ before_action :only_render_implemented_actions
15
+ before_action :authenticate_active_admin_user
16
+ else
17
+ before_filter :only_render_implemented_actions
18
+ before_filter :authenticate_active_admin_user
19
+ end
15
20
 
16
21
  class << self
17
22
  # Ensure that this method is available for the DSL
@@ -73,5 +78,10 @@ module ActiveAdmin
73
78
  ACTIVE_ADMIN_ACTIONS.include?(params[:action].to_sym) ? false : 'active_admin'
74
79
  end
75
80
 
81
+ def active_admin_root
82
+ controller, action = active_admin_namespace.root_to.split '#'
83
+ {controller: controller, action: action}
84
+ end
85
+
76
86
  end
77
87
  end
@@ -113,19 +113,16 @@ module ActiveAdmin
113
113
  redirect_backwards_or_to_root
114
114
  end
115
115
 
116
- format.csv { render text: error, status: :unauthorized }
116
+ body = ActiveAdmin::Dependency.rails.render_key
117
+
118
+ format.csv { render body => error, status: :unauthorized }
117
119
  format.json { render json: { error: error }, status: :unauthorized }
118
120
  format.xml { render xml: "<error>#{error}</error>", status: :unauthorized }
119
121
  end
120
122
  end
121
123
 
122
124
  def redirect_backwards_or_to_root
123
- if request.headers.key? "HTTP_REFERER"
124
- redirect_to :back
125
- else
126
- controller, action = active_admin_namespace.root_to.split '#'
127
- redirect_to controller: controller, action: action
128
- end
125
+ ActiveAdmin::Dependency.rails.redirect_back self, active_admin_root
129
126
  end
130
127
 
131
128
  end
@@ -4,7 +4,11 @@ module ActiveAdmin
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- before_filter :set_current_tab
7
+ if ActiveAdmin::Dependency.rails >= 4
8
+ before_action :set_current_tab
9
+ else
10
+ before_filter :set_current_tab
11
+ end
8
12
  helper_method :current_menu
9
13
  end
10
14
 
@@ -30,7 +30,6 @@ module ActiveAdmin
30
30
  :filtering,
31
31
  :scoping,
32
32
  :includes,
33
- :collection_decorator
34
33
  ].freeze
35
34
 
36
35
  def batch_action_collection(only = COLLECTION_APPLIES)
@@ -54,8 +54,9 @@ module ActiveAdmin
54
54
  # Path to the batch action itself
55
55
  def batch_action_path(params = {})
56
56
  path = [route_collection_path(params), "batch_action"].join("/")
57
- query = params.slice(:q, :scope).to_param
58
- [path, query].reject(&:blank?).join("?")
57
+ query = params.slice(:q, :scope)
58
+ query = query.permit!.to_h if query.respond_to? :permit!
59
+ [path, query.to_param].reject(&:blank?).join("?")
59
60
  end
60
61
 
61
62
  private