activeadmin 1.0.0.pre2 → 1.0.0.pre3

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.

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
@@ -97,7 +97,7 @@ describe ActiveAdmin::DSL do
97
97
  dsl.run_registration_block do
98
98
  sidebar :help
99
99
  end
100
- expect(dsl.config.sidebar_sections.map(&:name)).to match_array %w{filters search_status email help}
100
+ expect(dsl.config.sidebar_sections.map(&:name)).to match_array ['filters', 'Search status:', 'email', 'help']
101
101
  end
102
102
 
103
103
  end
@@ -143,8 +143,9 @@ describe ActiveAdmin::Filters::ViewHelper do
143
143
 
144
144
  it "should remove original ordering to prevent PostgreSQL error" do
145
145
  expect(scope.object.klass).to receive(:reorder).with('title asc') {
146
- m = double uniq: double(pluck: ['A Title'])
147
- expect(m.uniq).to receive(:pluck).with :title
146
+ distinct = ActiveAdmin::Dependency.rails >= 4 ? :distinct : :uniq
147
+ m = double distinct => double(pluck: ['A Title'])
148
+ expect(m.send(distinct)).to receive(:pluck).with :title
148
149
  m
149
150
  }
150
151
  body
@@ -156,13 +157,13 @@ describe ActiveAdmin::Filters::ViewHelper do
156
157
  let(:body) { Capybara.string(filter :created_at) }
157
158
 
158
159
  it "should generate a date greater than" do
159
- expect(body).to have_selector("input.datepicker[name='q[created_at_gteq]']")
160
+ expect(body).to have_selector("input.datepicker[name='q[created_at_gteq_date]']")
160
161
  end
161
162
  it "should generate a seperator" do
162
163
  expect(body).to have_selector("span.seperator")
163
164
  end
164
165
  it "should generate a date less than" do
165
- expect(body).to have_selector("input.datepicker[name='q[created_at_lteq]']")
166
+ expect(body).to have_selector("input.datepicker[name='q[created_at_lteq_date]']")
166
167
  end
167
168
  end
168
169
 
@@ -32,6 +32,13 @@ describe ActiveAdmin::Filters::ResourceExtension do
32
32
  expect(resource.filters).to be_empty
33
33
  end
34
34
 
35
+ it "should return the defaults without associations if default association filters are disabled on the namespace" do
36
+ resource.namespace.include_default_association_filters = false
37
+ expect(resource.filters.keys).to match_array([
38
+ :body, :created_at, :custom_searcher, :position, :published_at, :starred, :title, :updated_at
39
+ ])
40
+ end
41
+
35
42
  describe "removing a filter" do
36
43
  it "should work" do
37
44
  expect(resource.filters.keys).to include :author
@@ -563,8 +563,11 @@ describe ActiveAdmin::FormBuilder do
563
563
  describe "with allow destroy" do
564
564
  context "with an existing post" do
565
565
  let :body do
566
+ s = self
566
567
  build_form({url: '/categories'}, Category.new) do |f|
567
- allow(f.object.posts.build).to receive(:new_record?).and_return(false)
568
+ s.instance_exec do
569
+ allow(f.object.posts.build).to receive(:new_record?).and_return(false)
570
+ end
568
571
  f.has_many :posts, allow_destroy: true do |p|
569
572
  p.input :title
570
573
  end
@@ -5,19 +5,19 @@ describe "AA installation" do
5
5
 
6
6
  it "active_admin.scss" do
7
7
  path = Rails.root + "app/assets/stylesheets/active_admin.scss"
8
- expect(File.exists? path).to be_truthy
8
+ expect(File.exists? path).to eq true
9
9
  end
10
10
 
11
11
  it "active_admin.js.coffee" do
12
- expect(File.exists?(Rails.root + "app/assets/javascripts/active_admin.js.coffee")).to be_truthy
12
+ expect(File.exists?(Rails.root + "app/assets/javascripts/active_admin.js.coffee")).to eq true
13
13
  end
14
14
 
15
15
  it "the dashboard" do
16
- expect(File.exists?(Rails.root + "app/admin/dashboard.rb")).to be_truthy
16
+ expect(File.exists?(Rails.root + "app/admin/dashboard.rb")).to eq true
17
17
  end
18
18
 
19
19
  it "the initializer" do
20
- expect(File.exists?(Rails.root + "config/initializers/active_admin.rb")).to be_truthy
20
+ expect(File.exists?(Rails.root + "config/initializers/active_admin.rb")).to eq true
21
21
  end
22
22
 
23
23
  end
@@ -45,21 +45,21 @@ describe ActiveAdmin::Helpers::Collection do
45
45
 
46
46
  describe "#collection_is_empty?" do
47
47
  it "should return true when the collection is empty" do
48
- expect(collection_is_empty?(Post.where(title: "Non existing post"))).to be_truthy
48
+ expect(collection_is_empty?(Post.where(title: "Non existing post"))).to eq true
49
49
  end
50
50
 
51
51
  it "should return false when the collection is not empty" do
52
- expect(collection_is_empty?(Post.where(title: "A post"))).to be_falsey
52
+ expect(collection_is_empty?(Post.where(title: "A post"))).to eq false
53
53
  end
54
54
 
55
55
  it "should take the defined collection by default" do
56
56
  def collection; Post.where(nil); end
57
57
 
58
- expect(collection_is_empty?).to be_falsey
58
+ expect(collection_is_empty?).to eq false
59
59
 
60
60
  def collection; Post.where(title: "Non existing post"); end
61
61
 
62
- expect(collection_is_empty?).to be_truthy
62
+ expect(collection_is_empty?).to eq true
63
63
  end
64
64
  end
65
65
  end
@@ -44,7 +44,7 @@ describe ActiveAdmin::MenuCollection do
44
44
  m.add :default, label: "Hello World"
45
45
  end
46
46
 
47
- expect(menus.fetch(:default)["Hello World"]).to_not be_nil
47
+ expect(menus.fetch(:default)["Hello World"]).to_not eq nil
48
48
  end
49
49
 
50
50
  it "re-runs the callbacks when the menu is cleared" do
@@ -52,9 +52,9 @@ describe ActiveAdmin::MenuCollection do
52
52
  m.add :default, label: "Hello World"
53
53
  end
54
54
 
55
- expect(menus.fetch(:default)["Hello World"]).to_not be_nil
55
+ expect(menus.fetch(:default)["Hello World"]).to_not eq nil
56
56
  menus.clear!
57
- expect(menus.fetch(:default)["Hello World"]).to_not be_nil
57
+ expect(menus.fetch(:default)["Hello World"]).to_not eq nil
58
58
  end
59
59
 
60
60
  end
@@ -1,9 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe ActiveAdmin::Namespace, "registering a page" do
4
-
5
4
  let(:application){ ActiveAdmin::Application.new }
6
-
7
5
  let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
8
6
  let(:menu){ namespace.fetch_menu(:default) }
9
7
 
@@ -17,23 +15,21 @@ describe ActiveAdmin::Namespace, "registering a page" do
17
15
  end
18
16
 
19
17
  it "should create a new controller in the default namespace" do
20
- expect(defined?(Admin::StatusController)).to be_truthy
18
+ expect(defined?(Admin::StatusController)).to eq 'constant'
21
19
  end
22
20
 
23
21
  it "should create a menu item" do
24
22
  expect(menu["Status"]).to be_an_instance_of(ActiveAdmin::MenuItem)
25
23
  end
26
- end # context "with no configuration"
24
+ end
27
25
 
28
26
  context "with a block configuration" do
29
27
  it "should be evaluated in the dsl" do
30
- expect {
31
- namespace.register_page "Status" do
32
- raise "Hello World"
33
- end
34
- }.to raise_error
28
+ expect{ |block|
29
+ namespace.register_page "Status", &block
30
+ }.to yield_control
35
31
  end
36
- end # context "with a block configuration"
32
+ end
37
33
 
38
34
  describe "adding to the menu" do
39
35
  describe "adding as a top level item" do
@@ -42,9 +38,9 @@ describe ActiveAdmin::Namespace, "registering a page" do
42
38
  end
43
39
 
44
40
  it "should add a new menu item" do
45
- expect(menu['Status']).to_not be_nil
41
+ expect(menu['Status']).to_not eq nil
46
42
  end
47
- end # describe "adding as a top level item"
43
+ end
48
44
 
49
45
  describe "adding as a child" do
50
46
  before do
@@ -52,13 +48,15 @@ describe ActiveAdmin::Namespace, "registering a page" do
52
48
  menu parent: 'Extra'
53
49
  end
54
50
  end
51
+
55
52
  it "should generate the parent menu item" do
56
- expect( menu['Extra']).to_not be_nil
53
+ expect( menu['Extra']).to_not eq nil
57
54
  end
55
+
58
56
  it "should generate its own child item" do
59
- expect(menu['Extra']['Status']).to_not be_nil
57
+ expect(menu['Extra']['Status']).to_not eq nil
60
58
  end
61
- end # describe "adding as a child"
59
+ end
62
60
 
63
61
  describe "disabling the menu" do
64
62
  before do
@@ -66,9 +64,10 @@ describe ActiveAdmin::Namespace, "registering a page" do
66
64
  menu false
67
65
  end
68
66
  end
67
+
69
68
  it "should not create a menu item" do
70
- expect(menu["Status"]).to be_nil
69
+ expect(menu["Status"]).to eq nil
71
70
  end
72
- end # describe "disabling the menu"
73
- end # describe "adding to the menu"
71
+ end
72
+ end
74
73
  end
@@ -4,41 +4,40 @@ require 'rails_helper'
4
4
  # Specifically, the dashboard is already defined.
5
5
 
6
6
  describe ActiveAdmin::Namespace, "registering a resource" do
7
-
8
7
  let(:application){ ActiveAdmin::Application.new }
9
-
10
8
  let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
11
-
12
9
  let(:menu){ namespace.fetch_menu(:default) }
13
10
 
14
11
  context "with no configuration" do
15
12
  before do
16
13
  namespace.register Category
17
14
  end
15
+
18
16
  it "should store the namespaced registered configuration" do
19
17
  expect(namespace.resources.keys).to include('Category')
20
18
  end
19
+
21
20
  it "should create a new controller in the default namespace" do
22
- expect(defined?(Admin::CategoriesController)).to be_truthy
21
+ expect(defined?(Admin::CategoriesController)).to eq 'constant'
23
22
  end
23
+
24
24
  skip "should not create the dashboard controller" do
25
- defined?(Admin::DashboardController).to_not be_truthy
25
+ defined?(Admin::DashboardController).to_not eq 'constant'
26
26
  end
27
+
27
28
  it "should create a menu item" do
28
29
  expect(menu["Categories"]).to be_a ActiveAdmin::MenuItem
29
30
  expect(menu["Categories"].instance_variable_get(:@url)).to be_a Proc
30
31
  end
31
- end # context "with no configuration"
32
+ end
32
33
 
33
34
  context "with a block configuration" do
34
35
  it "should be evaluated in the dsl" do
35
- expect {
36
- namespace.register Category do
37
- raise "Hello World"
38
- end
39
- }.to raise_error
36
+ expect{ |block|
37
+ namespace.register Category, &block
38
+ }.to yield_control
40
39
  end
41
- end # context "with a block configuration"
40
+ end
42
41
 
43
42
  context "with a resource that's namespaced" do
44
43
  before do
@@ -50,7 +49,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
50
49
  expect(namespace.resources.keys).to include('Mock::Resource')
51
50
  end
52
51
  it "should create a new controller in the default namespace" do
53
- expect(defined?(Admin::MockResourcesController)).to be_truthy
52
+ expect(defined?(Admin::MockResourcesController)).to eq 'constant'
54
53
  end
55
54
  it "should create a menu item" do
56
55
  expect(menu["Mock Resources"]).to be_an_instance_of(ActiveAdmin::MenuItem)
@@ -89,7 +88,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
89
88
  namespace.register Category
90
89
  end
91
90
  it "should add a new menu item" do
92
- expect(menu['Categories']).to_not be_nil
91
+ expect(menu['Categories']).to_not eq nil
93
92
  end
94
93
  end # describe "adding as a top level item"
95
94
 
@@ -100,10 +99,10 @@ describe ActiveAdmin::Namespace, "registering a resource" do
100
99
  end
101
100
  end
102
101
  it "should generate the parent menu item" do
103
- expect(menu['Blog']).to_not be_nil
102
+ expect(menu['Blog']).to_not eq nil
104
103
  end
105
104
  it "should generate its own child item" do
106
- expect(menu['Blog']['Categories']).to_not be_nil
105
+ expect(menu['Blog']['Categories']).to_not eq nil
107
106
  end
108
107
  end # describe "adding as a child"
109
108
 
@@ -114,7 +113,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
114
113
  end
115
114
  end
116
115
  it "should not create a menu item" do
117
- expect(menu["Categories"]).to be_nil
116
+ expect(menu["Categories"]).to eq nil
118
117
  end
119
118
  end # describe "disabling the menu"
120
119
 
@@ -126,7 +125,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
126
125
  end
127
126
  end
128
127
  it "should not show up in the menu" do
129
- expect(menu["Posts"]).to be_nil
128
+ expect(menu["Posts"]).to eq nil
130
129
  end
131
130
  end
132
131
  context "when optional" do
@@ -136,7 +135,7 @@ describe ActiveAdmin::Namespace, "registering a resource" do
136
135
  end
137
136
  end
138
137
  it "should show up in the menu" do
139
- expect(menu["Posts"]).to_not be_nil
138
+ expect(menu["Posts"]).to_not eq nil
140
139
  end
141
140
  end
142
141
  end
@@ -147,14 +146,14 @@ describe ActiveAdmin::Namespace, "registering a resource" do
147
146
  it "should be namespaced" do
148
147
  namespace = ActiveAdmin::Namespace.new(application, :one)
149
148
  namespace.register Category
150
- expect(defined?(One::CategoriesController)).to be_truthy
149
+ expect(defined?(One::CategoriesController)).to eq 'constant'
151
150
  end
152
151
  end
153
152
  context "when not namespaced" do
154
153
  it "should not be namespaced" do
155
154
  namespace = ActiveAdmin::Namespace.new(application, :two)
156
155
  namespace.register Category
157
- expect(defined?(Two::CategoriesController)).to be_truthy
156
+ expect(defined?(Two::CategoriesController)).to eq 'constant'
158
157
  end
159
158
  end
160
159
  end # describe "dashboard controller name"
@@ -66,7 +66,7 @@ describe ActiveAdmin::Namespace do
66
66
  menu.add label: "menu item"
67
67
  end
68
68
 
69
- expect(namespace.fetch_menu(:default)["menu item"]).to_not be_nil
69
+ expect(namespace.fetch_menu(:default)["menu item"]).to_not eq nil
70
70
  end
71
71
 
72
72
  it "should set a block on a custom menu" do
@@ -74,7 +74,7 @@ describe ActiveAdmin::Namespace do
74
74
  menu.add label: "menu item"
75
75
  end
76
76
 
77
- expect(namespace.fetch_menu(:test)["menu item"]).to_not be_nil
77
+ expect(namespace.fetch_menu(:test)["menu item"]).to_not eq nil
78
78
  end
79
79
  end
80
80
 
@@ -89,12 +89,12 @@ describe ActiveAdmin::Namespace do
89
89
  end
90
90
 
91
91
  it "should have a logout button to the far left" do
92
- expect(menu["Logout"]).to_not be_nil
92
+ expect(menu["Logout"]).to_not eq nil
93
93
  expect(menu["Logout"].priority).to eq 1
94
94
  end
95
95
 
96
96
  it "should have a static link with a target of :blank" do
97
- expect(menu["ActiveAdmin.info"]).to_not be_nil
97
+ expect(menu["ActiveAdmin.info"]).to_not eq nil
98
98
  expect(menu["ActiveAdmin.info"].html_options).to include(target: :blank)
99
99
  end
100
100
 
@@ -64,9 +64,9 @@ describe ActiveAdmin::PunditAdapter do
64
64
 
65
65
  it "works well with method_missing" do
66
66
  allow(auth).to receive(:retrieve_policy).and_return(DefaultPolicy.new(double, double))
67
- expect(auth.authorized?(:foo_no)).to be_falsey
68
- expect(auth.authorized?(:foo_yes)).to be_truthy
69
- expect(auth.authorized?(:bar_yes)).to be_falsey
67
+ expect(auth.authorized?(:foo_no)).to eq false
68
+ expect(auth.authorized?(:foo_yes)).to eq true
69
+ expect(auth.authorized?(:bar_yes)).to eq false
70
70
  end
71
71
 
72
72
  context 'when Pundit is unable to find policy scope' do
@@ -25,7 +25,7 @@ describe ActiveAdmin::Resource::ActionItems do
25
25
  end
26
26
 
27
27
  it "should store the block in the action item" do
28
- expect(resource.action_items.first.block).to_not be_nil
28
+ expect(resource.action_items.first.block).to_not eq nil
29
29
  end
30
30
 
31
31
  end
@@ -110,7 +110,7 @@ module ActiveAdmin
110
110
 
111
111
  [:==, :===, :eql?].each do |method|
112
112
  it "are equivalent when compared with #{method}" do
113
- expect(resource_name.public_send(method, duplicate_resource_name)).to be_truthy
113
+ expect(resource_name.public_send(method, duplicate_resource_name)).to eq true
114
114
  end
115
115
  end
116
116
 
@@ -2,7 +2,11 @@ require 'rails_helper'
2
2
 
3
3
  module ActiveAdmin
4
4
  describe Resource::Routes do
5
- before { load_defaults! }
5
+
6
+ after :all do
7
+ load_defaults!
8
+ reload_routes!
9
+ end
6
10
 
7
11
  describe "route names" do
8
12
  context "when in the admin namespace" do
@@ -25,7 +29,7 @@ module ActiveAdmin
25
29
  context "when in the root namespace" do
26
30
  let!(:config) { ActiveAdmin.register Category, namespace: false }
27
31
  it "should have a nil route_prefix" do
28
- expect(config.route_prefix).to be_nil
32
+ expect(config.route_prefix).to eq nil
29
33
  end
30
34
 
31
35
  it "should generate a correct route" do
@@ -40,9 +40,9 @@ module ActiveAdmin
40
40
 
41
41
  it "should update a scope with the same id" do
42
42
  config.scope :published
43
- expect(config.scopes.first.scope_block).to be_nil
43
+ expect(config.scopes.first.scope_block).to eq nil
44
44
  config.scope(:published){ }
45
- expect(config.scopes.first.scope_block).to_not be_nil
45
+ expect(config.scopes.first.scope_block).to_not eq nil
46
46
  end
47
47
 
48
48
  end