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.

Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -16
  3. data/CHANGELOG.md +18 -1013
  4. data/Gemfile +18 -11
  5. data/LICENSE +0 -5
  6. data/README.md +0 -2
  7. data/activeadmin.gemspec +3 -1
  8. data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
  9. data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
  10. data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
  11. data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
  12. data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
  13. data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
  14. data/app/assets/stylesheets/active_admin/_base.scss +1 -4
  15. data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
  16. data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
  17. data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
  18. data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
  19. data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
  20. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
  21. data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
  22. data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
  23. data/config/locales/ar.yml +14 -2
  24. data/config/locales/de-CH.yml +2 -0
  25. data/config/locales/de.yml +15 -0
  26. data/config/locales/en.yml +10 -2
  27. data/config/locales/es.yml +26 -4
  28. data/config/locales/fr.yml +5 -0
  29. data/config/locales/id.yml +135 -0
  30. data/config/locales/ja.yml +21 -3
  31. data/config/locales/ko.yml +66 -36
  32. data/config/locales/nl.yml +14 -1
  33. data/config/locales/pt-BR.yml +11 -0
  34. data/config/locales/ru.yml +15 -1
  35. data/config/locales/sv-SE.yml +45 -5
  36. data/config/locales/uk.yml +16 -4
  37. data/config/locales/zh-CN.yml +5 -0
  38. data/config/locales/zh-TW.yml +32 -1
  39. data/docs/0-installation.md +7 -1
  40. data/docs/1-general-configuration.md +9 -0
  41. data/docs/10-custom-pages.md +10 -0
  42. data/docs/12-arbre-components.md +1 -1
  43. data/docs/14-gotchas.md +2 -2
  44. data/docs/2-resource-customization.md +5 -3
  45. data/docs/3-index-pages.md +7 -0
  46. data/docs/3-index-pages/index-as-table.md +4 -0
  47. data/docs/6-show-pages.md +1 -1
  48. data/docs/7-sidebars.md +8 -0
  49. data/features/index/batch_actions.feature +21 -2
  50. data/features/index/pagination.feature +16 -12
  51. data/features/meta_tags.feature +21 -0
  52. data/features/registering_assets.feature +1 -2
  53. data/features/show/columns.feature +40 -0
  54. data/features/show/default_content.feature +2 -1
  55. data/features/step_definitions/asset_steps.rb +3 -3
  56. data/features/step_definitions/batch_action_steps.rb +11 -2
  57. data/features/step_definitions/column_steps.rb +8 -0
  58. data/features/step_definitions/configuration_steps.rb +2 -2
  59. data/features/step_definitions/factory_steps.rb +3 -2
  60. data/features/step_definitions/meta_tag_steps.rb +3 -0
  61. data/features/step_definitions/pagination_steps.rb +8 -0
  62. data/features/step_definitions/table_steps.rb +2 -1
  63. data/lib/active_admin.rb +3 -3
  64. data/lib/active_admin/application.rb +66 -16
  65. data/lib/active_admin/batch_actions.rb +0 -1
  66. data/lib/active_admin/batch_actions/controller.rb +2 -2
  67. data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
  68. data/lib/active_admin/callbacks.rb +1 -1
  69. data/lib/active_admin/csv_builder.rb +2 -2
  70. data/lib/active_admin/dependency.rb +18 -16
  71. data/lib/active_admin/devise.rb +1 -1
  72. data/lib/active_admin/dsl.rb +1 -1
  73. data/lib/active_admin/event.rb +8 -17
  74. data/lib/active_admin/filters/active.rb +29 -0
  75. data/lib/active_admin/filters/forms.rb +6 -1
  76. data/lib/active_admin/filters/humanized.rb +68 -0
  77. data/lib/active_admin/filters/resource_extension.rb +48 -1
  78. data/lib/active_admin/form_builder.rb +4 -4
  79. data/lib/active_admin/generators/boilerplate.rb +37 -0
  80. data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
  81. data/lib/active_admin/inputs.rb +1 -0
  82. data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
  83. data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
  84. data/lib/active_admin/menu.rb +1 -0
  85. data/lib/active_admin/menu_item.rb +1 -1
  86. data/lib/active_admin/namespace.rb +5 -5
  87. data/lib/active_admin/orm/active_record/comments.rb +10 -1
  88. data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
  89. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
  90. data/lib/active_admin/resource.rb +9 -3
  91. data/lib/active_admin/resource/action_items.rb +13 -3
  92. data/lib/active_admin/resource/belongs_to.rb +6 -2
  93. data/lib/active_admin/resource/pagination.rb +4 -0
  94. data/lib/active_admin/resource_collection.rb +3 -1
  95. data/lib/active_admin/resource_controller/data_access.rb +6 -11
  96. data/lib/active_admin/resource_controller/decorators.rb +1 -1
  97. data/lib/active_admin/resource_dsl.rb +8 -2
  98. data/lib/active_admin/sidebar_section.rb +4 -12
  99. data/lib/active_admin/version.rb +1 -1
  100. data/lib/active_admin/view_factory.rb +1 -2
  101. data/lib/active_admin/view_helpers.rb +0 -1
  102. data/lib/active_admin/view_helpers/display_helper.rb +3 -4
  103. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
  104. data/lib/active_admin/views/components/active_admin_form.rb +3 -3
  105. data/lib/active_admin/views/components/columns.rb +9 -4
  106. data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
  107. data/lib/active_admin/views/components/paginated_collection.rb +35 -13
  108. data/lib/active_admin/views/components/panel.rb +1 -3
  109. data/lib/active_admin/views/components/sidebar_section.rb +6 -1
  110. data/lib/active_admin/views/components/status_tag.rb +3 -2
  111. data/lib/active_admin/views/components/table_for.rb +2 -1
  112. data/lib/active_admin/views/index_as_table.rb +2 -2
  113. data/lib/active_admin/views/pages/base.rb +4 -0
  114. data/lib/active_admin/views/pages/show.rb +1 -1
  115. data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
  116. data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
  117. data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
  118. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
  119. data/lib/generators/active_admin/page/templates/page.rb +1 -1
  120. data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
  121. data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
  122. data/spec/rails_helper.rb +6 -2
  123. data/spec/requests/memory_spec.rb +1 -3
  124. data/spec/support/active_admin_request_helpers.rb +27 -0
  125. data/spec/support/detect_rails_version.rb +1 -1
  126. data/spec/support/rails_template.rb +7 -0
  127. data/spec/unit/application_spec.rb +29 -4
  128. data/spec/unit/batch_actions/resource_spec.rb +5 -0
  129. data/spec/unit/belongs_to_spec.rb +14 -0
  130. data/spec/unit/comments_spec.rb +24 -2
  131. data/spec/unit/controller_filters_spec.rb +25 -28
  132. data/spec/unit/dsl_spec.rb +1 -1
  133. data/spec/unit/filters/humanized_spec.rb +56 -0
  134. data/spec/unit/filters/resource_spec.rb +1 -1
  135. data/spec/unit/form_builder_spec.rb +71 -11
  136. data/spec/unit/generators/install_spec.rb +3 -2
  137. data/spec/unit/pretty_format_spec.rb +15 -1
  138. data/spec/unit/resource_collection_spec.rb +17 -0
  139. data/spec/unit/resource_controller_spec.rb +2 -2
  140. data/spec/unit/resource_registration_spec.rb +3 -3
  141. data/spec/unit/resource_spec.rb +53 -2
  142. data/spec/unit/view_factory_spec.rb +0 -2
  143. data/spec/unit/view_helpers/display_name_spec.rb +6 -4
  144. data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
  145. data/spec/unit/views/components/columns_spec.rb +17 -0
  146. data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
  147. data/spec/unit/views/components/panel_spec.rb +1 -5
  148. data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
  149. data/spec/unit/views/components/status_tag_spec.rb +15 -1
  150. data/spec/unit/views/components/table_for_spec.rb +45 -0
  151. data/tasks/parallel_tests.rake +1 -1
  152. data/tasks/test.rake +4 -4
  153. metadata +29 -30
  154. data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
  155. data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
  156. data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
  157. data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
  158. data/lib/active_admin/iconic.rb +0 -53
  159. data/lib/active_admin/iconic/icons.rb +0 -142
  160. data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
  161. data/lib/active_admin/views/components/action_list_popover.rb +0 -29
  162. data/lib/active_admin/views/components/popover.rb +0 -27
  163. data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
  164. data/spec/support/integration_example_group.rb +0 -31
  165. data/spec/unit/event_spec.rb +0 -47
  166. data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
  167. data/spec/unit/views/components/popover_spec.rb +0 -33
@@ -3,8 +3,9 @@ require 'rails_helper'
3
3
  describe "AA installation" do
4
4
  context "should create" do
5
5
 
6
- it "active_admin.css.scss" do
7
- expect(File.exists?(Rails.root + "app/assets/stylesheets/active_admin.css.scss")).to be_truthy
6
+ it "active_admin.scss" do
7
+ path = Rails.root + "app/assets/stylesheets/active_admin.scss"
8
+ expect(File.exists? path).to be_truthy
8
9
  end
9
10
 
10
11
  it "active_admin.js.coffee" do
@@ -7,7 +7,7 @@ describe "#pretty_format" do
7
7
  mock_action_view.send *args, &block
8
8
  end
9
9
 
10
- {String: 'hello', Fixnum: 23, Float: 5.67, Bignum: 10**30,
10
+ {String: 'hello', Fixnum: 23, Float: 5.67, Bignum: 10**30, Symbol: :foo,
11
11
  'Arbre::Element' => Arbre::Element.new.br(:foo)
12
12
  }.each do |klass, obj|
13
13
  it "should call `to_s` on #{klass}s" do
@@ -29,6 +29,20 @@ describe "#pretty_format" do
29
29
  expect(pretty_format(t)).to eq "February 28, 1985 20:15"
30
30
  end
31
31
 
32
+ context "apply custom localize format" do
33
+ before do
34
+ ActiveAdmin.application.localize_format = :short
35
+ end
36
+ after do
37
+ ActiveAdmin.application = nil
38
+ end
39
+ it "should actually do the formatting" do
40
+ t = Time.utc(1985, "feb", 28, 20, 15, 1)
41
+
42
+ expect(pretty_format(t)).to eq "28 Feb 20:15"
43
+ end
44
+ end
45
+
32
46
  context "with non-English locale" do
33
47
  before(:all) do
34
48
  @previous_locale = I18n.locale.to_s
@@ -151,6 +151,23 @@ describe ActiveAdmin::ResourceCollection do
151
151
  expect(collection[name]).to eq renamed_resource
152
152
  end
153
153
  end
154
+
155
+ context "with a resource and a renamed resource added in disorder" do
156
+ let(:resource) { ActiveAdmin::Resource.new namespace, resource_class }
157
+ let(:renamed_resource) do
158
+ ActiveAdmin::Resource.new namespace, resource_class, as: name
159
+ end
160
+ let(:name) { "Administrators" }
161
+
162
+ before do
163
+ collection.add renamed_resource
164
+ collection.add resource
165
+ end
166
+
167
+ it "should find a resource by class when there are two resources with that class" do
168
+ expect(collection[resource_class]).to eq resource
169
+ end
170
+ end
154
171
  end
155
172
 
156
173
  skip "specs for subclasses of Page and Resource"
@@ -157,7 +157,7 @@ end
157
157
 
158
158
  describe Admin::PostsController, type: "controller" do
159
159
 
160
- describe 'retreiving the resource' do
160
+ describe 'retrieving the resource' do
161
161
  let(:controller){ Admin::PostsController.new }
162
162
  let(:post) { Post.new title: "An incledibly unique Post Title" }
163
163
 
@@ -186,7 +186,7 @@ describe Admin::PostsController, type: "controller" do
186
186
  end
187
187
  end
188
188
 
189
- describe 'retreiving the resource collection' do
189
+ describe 'retrieving the resource collection' do
190
190
  let(:controller){ Admin::PostsController.new }
191
191
  let(:config) { controller.class.active_admin_config }
192
192
  before do
@@ -13,7 +13,7 @@ describe "Registering an object to administer" do
13
13
  end
14
14
 
15
15
  it "should dispatch a Resource::RegisterEvent" do
16
- expect(ActiveAdmin::Event).to receive(:dispatch).with(ActiveAdmin::Resource::RegisterEvent, an_instance_of(ActiveAdmin::Resource))
16
+ expect(ActiveSupport::Notifications).to receive(:publish).with(ActiveAdmin::Resource::RegisterEvent, an_instance_of(ActiveAdmin::Resource))
17
17
  application.register Category
18
18
  end
19
19
  end
@@ -28,8 +28,8 @@ describe "Registering an object to administer" do
28
28
  end
29
29
 
30
30
  it "should generate a Namespace::RegisterEvent and a Resource::RegisterEvent" do
31
- expect(ActiveAdmin::Event).to receive(:dispatch).with(ActiveAdmin::Namespace::RegisterEvent, an_instance_of(ActiveAdmin::Namespace))
32
- expect(ActiveAdmin::Event).to receive(:dispatch).with(ActiveAdmin::Resource::RegisterEvent, an_instance_of(ActiveAdmin::Resource))
31
+ expect(ActiveSupport::Notifications).to receive(:publish).with(ActiveAdmin::Namespace::RegisterEvent, an_instance_of(ActiveAdmin::Namespace))
32
+ expect(ActiveSupport::Notifications).to receive(:publish).with(ActiveAdmin::Resource::RegisterEvent, an_instance_of(ActiveAdmin::Resource))
33
33
  application.register Category, namespace: :not_yet_created
34
34
  end
35
35
  end
@@ -232,7 +232,11 @@ module ActiveAdmin
232
232
  let(:resource) { namespace.register(Post) }
233
233
  let(:post) { double }
234
234
  before do
235
- allow(Post).to receive(:find_by_id).with('12345') { post }
235
+ if Rails::VERSION::MAJOR >= 4
236
+ allow(Post).to receive(:find_by).with("id" => "12345") { post }
237
+ else
238
+ allow(Post).to receive(:find_by_id).with("12345") { post }
239
+ end
236
240
  end
237
241
 
238
242
  it 'can find the resource' do
@@ -250,7 +254,13 @@ module ActiveAdmin
250
254
  let(:different_post) { double }
251
255
  before do
252
256
  allow(Post).to receive(:primary_key).and_return 'something_else'
253
- allow(Post).to receive(:find_by_something_else).with('55555') { different_post }
257
+ if Rails::VERSION::MAJOR >= 4
258
+ allow(Post).to receive(:find_by).
259
+ with("something_else" => "55555") { different_post }
260
+ else
261
+ allow(Post).to receive(:find_by_something_else).
262
+ with("55555") { different_post }
263
+ end
254
264
  end
255
265
 
256
266
  it 'can find the post by the custom primary key' do
@@ -274,5 +284,46 @@ module ActiveAdmin
274
284
  end
275
285
  end
276
286
  end
287
+
288
+ describe "delegation" do
289
+ let(:controller) {
290
+ Class.new do
291
+ def method_missing(name, *args, &block)
292
+ "called #{name}"
293
+ end
294
+ end.new
295
+ }
296
+ let(:resource) { ActiveAdmin::ResourceDSL.new(double, double) }
297
+
298
+ before do
299
+ expect(resource).to receive(:controller).and_return(controller)
300
+ end
301
+
302
+ context "filters" do
303
+ [
304
+ :before_filter, :skip_before_filter,
305
+ :after_filter, :skip_after_filter,
306
+ :around_filter, :skip_filter
307
+ ].each do |filter|
308
+ it "delegates #{filter}" do
309
+ expect(resource.send(filter)).to eq "called #{filter}"
310
+ end
311
+ end
312
+ end
313
+
314
+ if Rails::VERSION::MAJOR == 4
315
+ context "actions" do
316
+ [
317
+ :before_action, :skip_before_action,
318
+ :after_action, :skip_after_action,
319
+ :around_action, :skip_action
320
+ ].each do |action|
321
+ it "delegates #{action}" do
322
+ expect(resource.send(action)).to eq "called #{action}"
323
+ end
324
+ end
325
+ end
326
+ end
327
+ end
277
328
  end
278
329
  end
@@ -14,8 +14,6 @@ describe ActiveAdmin::ViewFactory do
14
14
  it_should_have_view :action_items, ActiveAdmin::Views::ActionItems
15
15
  it_should_have_view :header, ActiveAdmin::Views::Header
16
16
  it_should_have_view :blank_slate, ActiveAdmin::Views::BlankSlate
17
- it_should_have_view :action_list_popover, ActiveAdmin::Views::ActionListPopover
18
-
19
17
  it_should_have_view :layout, ActiveAdmin::Views::Pages::Layout
20
18
 
21
19
  end
@@ -31,10 +31,12 @@ describe "display_name" do
31
31
  expect(display_name subject).to eq 'foo@bar.baz'
32
32
  end
33
33
 
34
- [nil, false].each do |type|
35
- it "should return nil when the passed object is #{type.inspect}" do
36
- expect(display_name type).to eq nil
37
- end
34
+ it "should return `nil` when the passed object is `nil`" do
35
+ expect(display_name nil).to eq nil
36
+ end
37
+
38
+ it "should return 'false' when the passed objct is `false`" do
39
+ expect(display_name false).to eq "false"
38
40
  end
39
41
 
40
42
  it "should default to `to_s`" do
@@ -1,25 +1,21 @@
1
1
  require 'rails_helper'
2
- require 'active_admin/batch_actions/views/batch_action_popover'
2
+ require 'active_admin/batch_actions/views/batch_action_selector'
3
3
 
4
- describe ActiveAdmin::BatchActions::BatchActionPopover do
4
+ describe ActiveAdmin::BatchActions::BatchActionSelector do
5
5
 
6
- let(:the_popover) do
6
+ let(:dropdown) do
7
7
  render_arbre_component do
8
- batch_action_popover do
9
- action ActiveAdmin::BatchAction.new( :action_1, "Action 1" )
10
- action ActiveAdmin::BatchAction.new( :action_2, "Action 2" )
11
- action ActiveAdmin::BatchAction.new( :action_3, "Action 3" )
12
- end
8
+ batch_action_selector [
9
+ ActiveAdmin::BatchAction.new(:action_1, "Action 1"),
10
+ ActiveAdmin::BatchAction.new(:action_2, "Action 2"),
11
+ ActiveAdmin::BatchAction.new(:action_3, "Action 3")
12
+ ]
13
13
  end
14
14
  end
15
15
 
16
- it "should have an id" do
17
- expect(the_popover.id).to eq "batch_actions_popover"
18
- end
19
-
20
16
  describe "the action list" do
21
17
  subject do
22
- the_popover.find_by_class("popover_contents").first
18
+ dropdown.find_by_class("dropdown_menu_list").first
23
19
  end
24
20
 
25
21
  describe '#tag_name' do
@@ -2,6 +2,23 @@ require 'rails_helper'
2
2
 
3
3
  describe ActiveAdmin::Views::Columns do
4
4
 
5
+ describe "Rendering zero columns" do
6
+ let(:cols) do
7
+ render_arbre_component do
8
+ columns do
9
+ end
10
+ end
11
+ end
12
+
13
+ it "should have the class .columns" do
14
+ expect(cols.class_list).to include("columns")
15
+ end
16
+
17
+ it "should have one column" do
18
+ expect(cols.children.first.class_list).not_to include("column")
19
+ end
20
+ end
21
+
5
22
  describe "Rendering one column" do
6
23
  let(:cols) do
7
24
  render_arbre_component do
@@ -65,6 +65,19 @@ describe ActiveAdmin::Views::PaginatedCollection do
65
65
  end
66
66
  end
67
67
 
68
+ context "when specifying :params option" do
69
+ let(:collection) do
70
+ posts = 10.times.map{ Post.new }
71
+ Kaminari.paginate_array(posts).page(1).per(5)
72
+ end
73
+
74
+ let(:pagination) { paginated_collection(collection, param_name: :post_page, params: { anchor: 'here' }) }
75
+
76
+ it "should pass it through to Kaminari" do
77
+ expect(pagination.children.last.content).to match(/\/admin\/posts\?post_page=2#here/)
78
+ end
79
+ end
80
+
68
81
  context "when specifying download_links: false option" do
69
82
  let(:collection) do
70
83
  posts = 10.times.map{ Post.new }
@@ -198,9 +211,10 @@ describe ActiveAdmin::Views::PaginatedCollection do
198
211
  end
199
212
 
200
213
  describe "set to false" do
201
- let(:pagination) { paginated_collection(collection, pagination_total: false) }
202
-
203
214
  it "should not show the total item counts" do
215
+ expect(collection).not_to receive(:num_pages)
216
+ expect(collection).not_to receive(:total_pages)
217
+ pagination = paginated_collection(collection, pagination_total: false)
204
218
  info = pagination.find_by_class('pagination_information').first.content.gsub(' ',' ')
205
219
  expect(info).to eq "Displaying posts <b>1 - 30</b>"
206
220
  end
@@ -3,7 +3,7 @@ require 'rails_helper'
3
3
  describe ActiveAdmin::Views::Panel do
4
4
  let(:arbre_panel) do
5
5
  render_arbre_component do
6
- panel "My Title", icon: :arrow_down do
6
+ panel "My Title" do
7
7
  header_action link_to("My Link", "https://www.github.com/activeadmin/activeadmin")
8
8
  span("Hello World")
9
9
  end
@@ -30,10 +30,6 @@ describe ActiveAdmin::Views::Panel do
30
30
  expect(panel_html).to have_css 'div.panel_contents > span', text: "Hello World"
31
31
  end
32
32
 
33
- it "should set the icon" do
34
- expect(panel_html).to have_css "h3 > span.icon"
35
- end
36
-
37
33
  context "with html-safe title" do
38
34
  let(:arbre_panel) do
39
35
  title_with_html = %q[Title with <abbr>HTML</abbr>].html_safe
@@ -44,4 +44,25 @@ describe ActiveAdmin::Views::SidebarSection do
44
44
  end
45
45
  end
46
46
 
47
+ context "with attributes_table for resource" do
48
+ let(:post) { Post.create!(title: "Testing.") }
49
+ let(:section) do
50
+ ActiveAdmin::SidebarSection.new("Summary", options) do
51
+ attributes_table do
52
+ row :title
53
+ end
54
+ end
55
+ end
56
+ let(:assigns) { { resource: post, section: section } }
57
+ let(:html) do
58
+ render_arbre_component assigns do
59
+ sidebar_section(assigns[:section])
60
+ end
61
+ end
62
+
63
+ it "should have table" do
64
+ expect(html.find_by_tag("th").first.content).to eq "Title"
65
+ expect(html.find_by_tag("td").first.content).to eq "Testing."
66
+ end
67
+ end
47
68
  end
@@ -89,7 +89,7 @@ describe ActiveAdmin::Views::StatusTag do
89
89
  end
90
90
  end
91
91
 
92
- context "when status is false" do
92
+ context "when status is 'false'" do
93
93
  subject { status_tag('false') }
94
94
 
95
95
  describe '#class_list' do
@@ -103,6 +103,20 @@ describe ActiveAdmin::Views::StatusTag do
103
103
  end
104
104
  end
105
105
 
106
+ context "when status is false" do
107
+ subject { status_tag(false) }
108
+
109
+ describe '#class_list' do
110
+ subject { super().class_list }
111
+ it { is_expected.to include('status_tag') }
112
+ end
113
+
114
+ describe '#content' do
115
+ subject { super().content }
116
+ it { is_expected.to eq('No') }
117
+ end
118
+ end
119
+
106
120
  context "when status is nil" do
107
121
  subject { status_tag(nil) }
108
122
 
@@ -301,6 +301,51 @@ describe ActiveAdmin::Views::TableFor do
301
301
  end
302
302
  end
303
303
 
304
+ context "when i18n option is specified" do
305
+ before(:each) do
306
+ I18n.backend.store_translations :en,
307
+ activerecord: { attributes: { post: { title: "Name" } } }
308
+ end
309
+
310
+ let(:table) do
311
+ render_arbre_component assigns, helpers do
312
+ table_for(collection, i18n: Post) do
313
+ column :title
314
+ end
315
+ end
316
+ end
317
+
318
+ it "should use localized column key" do
319
+ expect(table.find_by_tag("th").first.content).to eq "Name"
320
+ end
321
+ end
322
+
323
+ context "when i18n option is not specified" do
324
+ before(:each) do
325
+ I18n.backend.store_translations :en,
326
+ activerecord: { attributes: { post: { title: "Name" } } }
327
+ end
328
+
329
+ let(:collection) do
330
+ Post.create([
331
+ { title: "First Post", starred: true },
332
+ { title: "Second Post" },
333
+ ])
334
+ Post.where(starred: true)
335
+ end
336
+
337
+ let(:table) do
338
+ render_arbre_component assigns, helpers do
339
+ table_for(collection) do
340
+ column :title
341
+ end
342
+ end
343
+ end
344
+
345
+ it "should predict localized key based on AR collection klass" do
346
+ expect(table.find_by_tag("th").first.content).to eq "Name"
347
+ end
348
+ end
304
349
  end
305
350
 
306
351
  describe "column sorting" do
@@ -49,7 +49,7 @@ namespace :parallel do
49
49
 
50
50
  namespace :spec do
51
51
 
52
- %w(unit integration).each do |type|
52
+ %w(unit request).each do |type|
53
53
  desc "Run the #{type} specs in parallel"
54
54
  task type => :setup_parallel_tests do
55
55
  run_in_parallel "parallel_rspec spec/#{type}"
@@ -11,7 +11,7 @@ task :setup, :parallel do |t, args|
11
11
  end
12
12
 
13
13
  desc "Run the full suite using 1 core"
14
- task test: ['spec:unit', 'spec:integration', 'cucumber', 'cucumber:class_reloading']
14
+ task test: ['spec:unit', 'spec:request', 'cucumber', 'cucumber:class_reloading']
15
15
 
16
16
  require 'coveralls/rake/task'
17
17
  Coveralls::RakeTask.new
@@ -56,9 +56,9 @@ namespace :spec do
56
56
  t.pattern = "spec/unit/**/*_spec.rb"
57
57
  end
58
58
 
59
- desc "Run the integration specs"
60
- RSpec::Core::RakeTask.new(:integration) do |t|
61
- t.pattern = "spec/integration/**/*_spec.rb"
59
+ desc "Run the request specs"
60
+ RSpec::Core::RakeTask.new(:request) do |t|
61
+ t.pattern = "spec/requests/**/*_spec.rb"
62
62
  end
63
63
 
64
64
  end