active_scaffold 3.5.4 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/{CHANGELOG → CHANGELOG.rdoc} +72 -0
  3. data/README.md +20 -8
  4. data/app/assets/javascripts/active_scaffold.js.erb +0 -1
  5. data/app/assets/javascripts/jquery/active_scaffold.js +98 -7
  6. data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
  7. data/app/assets/stylesheets/active_scaffold_layout.css +52 -29
  8. data/app/views/active_scaffold_overrides/_base_form.html.erb +2 -2
  9. data/app/views/active_scaffold_overrides/_form.html.erb +1 -1
  10. data/app/views/active_scaffold_overrides/_form_association.html.erb +2 -1
  11. data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +3 -2
  12. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +9 -7
  13. data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +4 -4
  14. data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +2 -1
  15. data/app/views/active_scaffold_overrides/_list.html.erb +2 -1
  16. data/app/views/active_scaffold_overrides/_list_header.html.erb +5 -7
  17. data/app/views/active_scaffold_overrides/_list_messages.html.erb +1 -0
  18. data/app/views/active_scaffold_overrides/_list_record.html.erb +4 -5
  19. data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
  20. data/app/views/active_scaffold_overrides/_messages.html.erb +1 -0
  21. data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
  22. data/app/views/active_scaffold_overrides/_render_field.js.erb +2 -1
  23. data/app/views/active_scaffold_overrides/_show_association_horizontal.html.erb +2 -1
  24. data/app/views/active_scaffold_overrides/_show_columns.html.erb +2 -2
  25. data/app/views/active_scaffold_overrides/_show_horizontal_record.html.erb +4 -4
  26. data/app/views/active_scaffold_overrides/_update_calculations.js.erb +1 -1
  27. data/app/views/active_scaffold_overrides/_update_column.js.erb +2 -2
  28. data/app/views/active_scaffold_overrides/_vertical_subform.html.erb +2 -2
  29. data/app/views/active_scaffold_overrides/action_confirmation.html.erb +2 -2
  30. data/app/views/active_scaffold_overrides/delete.html.erb +2 -2
  31. data/app/views/active_scaffold_overrides/on_action_update.js.erb +16 -6
  32. data/app/views/active_scaffold_overrides/on_update.js.erb +1 -1
  33. data/app/views/active_scaffold_overrides/row.js.erb +1 -1
  34. data/app/views/active_scaffold_overrides/update_column.js.erb +2 -2
  35. data/config/locales/de.yml +2 -1
  36. data/config/locales/en.yml +1 -0
  37. data/config/locales/es.yml +1 -0
  38. data/config/locales/fr.yml +2 -1
  39. data/config/locales/hu.yml +1 -0
  40. data/config/locales/ja.yml +1 -0
  41. data/config/locales/ru.yml +1 -0
  42. data/lib/active_scaffold.rb +19 -16
  43. data/lib/active_scaffold/actions/common_search.rb +11 -8
  44. data/lib/active_scaffold/actions/core.rb +91 -70
  45. data/lib/active_scaffold/actions/create.rb +28 -28
  46. data/lib/active_scaffold/actions/delete.rb +3 -3
  47. data/lib/active_scaffold/actions/field_search.rb +53 -43
  48. data/lib/active_scaffold/actions/list.rb +111 -27
  49. data/lib/active_scaffold/actions/nested.rb +65 -48
  50. data/lib/active_scaffold/actions/search.rb +1 -1
  51. data/lib/active_scaffold/actions/show.rb +4 -4
  52. data/lib/active_scaffold/actions/subform.rb +23 -22
  53. data/lib/active_scaffold/actions/update.rb +96 -77
  54. data/lib/active_scaffold/active_record_permissions.rb +2 -11
  55. data/lib/active_scaffold/attribute_params.rb +102 -94
  56. data/lib/active_scaffold/bridges.rb +8 -8
  57. data/lib/active_scaffold/bridges/active_storage.rb +6 -0
  58. data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +34 -0
  59. data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +54 -0
  60. data/lib/active_scaffold/bridges/active_storage/form_ui.rb +22 -0
  61. data/lib/active_scaffold/bridges/active_storage/list_ui.rb +36 -0
  62. data/lib/active_scaffold/bridges/bitfields.rb +2 -1
  63. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
  64. data/lib/active_scaffold/bridges/bitfields/list_ui.rb +19 -0
  65. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +1 -1
  66. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +9 -12
  67. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +1 -1
  68. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
  69. data/lib/active_scaffold/bridges/chosen/helpers.rb +7 -6
  70. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -13
  71. data/lib/active_scaffold/bridges/date_picker/helper.rb +49 -44
  72. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
  73. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
  74. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +3 -3
  75. data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
  76. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +10 -7
  77. data/lib/active_scaffold/bridges/paper_trail.rb +1 -1
  78. data/lib/active_scaffold/bridges/paper_trail/actions.rb +3 -1
  79. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
  80. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +1 -1
  81. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
  82. data/lib/active_scaffold/bridges/record_select/helpers.rb +15 -17
  83. data/lib/active_scaffold/bridges/shared/date_bridge.rb +20 -19
  84. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
  85. data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +21 -4
  86. data/lib/active_scaffold/config/base.rb +133 -41
  87. data/lib/active_scaffold/config/core.rb +146 -18
  88. data/lib/active_scaffold/config/delete.rb +14 -1
  89. data/lib/active_scaffold/config/field_search.rb +7 -1
  90. data/lib/active_scaffold/config/form.rb +10 -1
  91. data/lib/active_scaffold/config/list.rb +39 -13
  92. data/lib/active_scaffold/config/mark.rb +4 -2
  93. data/lib/active_scaffold/config/nested.rb +16 -17
  94. data/lib/active_scaffold/config/search.rb +9 -0
  95. data/lib/active_scaffold/config/show.rb +4 -0
  96. data/lib/active_scaffold/config/update.rb +4 -0
  97. data/lib/active_scaffold/configurable.rb +14 -7
  98. data/lib/active_scaffold/constraints.rb +22 -20
  99. data/lib/active_scaffold/core.rb +67 -28
  100. data/lib/active_scaffold/data_structures/action_columns.rb +50 -59
  101. data/lib/active_scaffold/data_structures/action_link.rb +50 -20
  102. data/lib/active_scaffold/data_structures/action_links.rb +15 -13
  103. data/lib/active_scaffold/data_structures/association/abstract.rb +38 -15
  104. data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
  105. data/lib/active_scaffold/data_structures/association/active_record.rb +6 -2
  106. data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
  107. data/lib/active_scaffold/data_structures/column.rb +75 -66
  108. data/lib/active_scaffold/data_structures/columns.rb +3 -2
  109. data/lib/active_scaffold/data_structures/nested_info.rb +33 -19
  110. data/lib/active_scaffold/data_structures/set.rb +8 -0
  111. data/lib/active_scaffold/data_structures/sorting.rb +10 -2
  112. data/lib/active_scaffold/delayed_setup.rb +16 -5
  113. data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -2
  114. data/lib/active_scaffold/extensions/action_view_rendering.rb +93 -32
  115. data/lib/active_scaffold/extensions/cow_proxy.rb +95 -0
  116. data/lib/active_scaffold/extensions/ice_nine.rb +36 -0
  117. data/lib/active_scaffold/extensions/left_outer_joins.rb +8 -33
  118. data/lib/active_scaffold/extensions/localize.rb +3 -1
  119. data/lib/active_scaffold/extensions/routing_mapper.rb +6 -45
  120. data/lib/active_scaffold/extensions/to_label.rb +3 -2
  121. data/lib/active_scaffold/extensions/unsaved_record.rb +2 -4
  122. data/lib/active_scaffold/finder.rb +110 -77
  123. data/lib/active_scaffold/helpers/action_link_helpers.rb +62 -36
  124. data/lib/active_scaffold/helpers/association_helpers.rb +18 -16
  125. data/lib/active_scaffold/helpers/controller_helpers.rb +34 -10
  126. data/lib/active_scaffold/helpers/form_column_helpers.rb +196 -124
  127. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  128. data/lib/active_scaffold/helpers/id_helpers.rb +6 -2
  129. data/lib/active_scaffold/helpers/list_column_helpers.rb +90 -57
  130. data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
  131. data/lib/active_scaffold/helpers/search_column_helpers.rb +29 -34
  132. data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
  133. data/lib/active_scaffold/helpers/view_helpers.rb +39 -36
  134. data/lib/active_scaffold/marked_model.rb +2 -2
  135. data/lib/active_scaffold/orm_checks.rb +3 -7
  136. data/lib/active_scaffold/paginator.rb +7 -7
  137. data/lib/active_scaffold/registry.rb +33 -0
  138. data/lib/active_scaffold/responds_to_parent.rb +8 -11
  139. data/lib/active_scaffold/tableless.rb +82 -66
  140. data/lib/active_scaffold/version.rb +2 -2
  141. data/lib/generators/active_scaffold/controller_generator.rb +2 -2
  142. data/lib/generators/active_scaffold/install_generator.rb +52 -4
  143. data/lib/generators/active_scaffold/resource_generator.rb +2 -2
  144. data/shoulda_macros/macros.rb +3 -1
  145. data/test/bridges/date_picker_test.rb +1 -2
  146. data/test/bridges/paperclip_test.rb +6 -6
  147. data/test/class_with_finder.rb +2 -2
  148. data/test/company.rb +4 -4
  149. data/test/config/create_test.rb +4 -2
  150. data/test/config/nested_test.rb +1 -1
  151. data/test/config/show_test.rb +1 -1
  152. data/test/config/update_test.rb +7 -6
  153. data/test/data_structures/action_columns_test.rb +2 -2
  154. data/test/data_structures/action_links_test.rb +1 -1
  155. data/test/data_structures/column_test.rb +3 -6
  156. data/test/data_structures/columns_test.rb +2 -2
  157. data/test/data_structures/sorting_test.rb +7 -0
  158. data/test/extensions/action_view_rendering_test.rb +20 -0
  159. data/test/extensions/active_record_test.rb +4 -4
  160. data/test/extensions/routing_mapper_test.rb +2 -2
  161. data/test/helpers/list_column_helpers_test.rb +3 -1
  162. data/test/misc/active_record_permissions_test.rb +3 -11
  163. data/test/misc/attribute_params_test.rb +12 -8
  164. data/test/misc/calculation_test.rb +1 -1
  165. data/test/misc/configurable_test.rb +10 -10
  166. data/test/misc/constraints_test.rb +2 -2
  167. data/test/misc/convert_numbers_format_test.rb +7 -3
  168. data/test/misc/lang_test.rb +1 -1
  169. data/test/misc/parse_datetime_test.rb +3 -4
  170. data/test/misc/tableless_test.rb +14 -0
  171. data/test/mock_app/Rakefile +1 -1
  172. data/test/mock_app/app/assets/config/manifest.js +0 -0
  173. data/test/mock_app/app/controllers/cars_controller.rb +1 -0
  174. data/test/mock_app/app/controllers/people_controller.rb +5 -1
  175. data/test/mock_app/app/controllers/roles_controller.rb +4 -0
  176. data/test/mock_app/app/views/active_scaffold_overrides/_form.html.erb +2 -0
  177. data/test/mock_app/app/views/active_scaffold_overrides/list.html.erb +2 -0
  178. data/test/mock_app/app/views/people/_first_name_form_column.html.erb +2 -0
  179. data/test/mock_app/app/views/people/_form.html.erb +2 -0
  180. data/test/mock_app/app/views/people/list.html.erb +2 -0
  181. data/test/mock_app/config/application.rb +2 -1
  182. data/test/mock_app/config/boot.rb +1 -1
  183. data/test/mock_app/config/environment.rb +2 -2
  184. data/test/mock_app/config/routes.rb +4 -1
  185. data/test/mock_app/db/schema.rb +2 -0
  186. data/test/performance/list_cars_performance_test.rb +34 -0
  187. data/test/performance/list_people_performance_test.rb +31 -0
  188. data/test/performance_test_help.rb +3 -0
  189. data/test/test_helper.rb +12 -4
  190. metadata +69 -18
  191. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  192. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -7
@@ -54,8 +54,8 @@ class RoutingMapperTest < ActionController::TestCase
54
54
  assert_routing 'cars/1/edit', controller: 'cars', action: 'edit', id: '1'
55
55
  assert_routing({method: :patch, path: 'cars/1'}, {controller: 'cars', action: 'update', id: '1'})
56
56
 
57
- assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars' }
58
- assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars/1/list' }
57
+ assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars', method: :post }
58
+ assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars/1' }
59
59
  assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars/1/destroy', method: :delete }
60
60
  end
61
61
 
@@ -34,8 +34,10 @@ class ListColumnHelpersTest < ActionView::TestCase
34
34
  value.each { |v| v.stubs(:to_label).returns(v) }
35
35
  assert_equal '1, 2, 3, … (4)', format_association_value(value, @association_column, value.size)
36
36
  @config.list.stubs(:association_join_text => ',<br/>')
37
+ remove_instance_variable :@_association_join_text
37
38
  assert_equal '1,&lt;br/&gt;2,&lt;br/&gt;3,&lt;br/&gt;… (4)', format_association_value(value, @association_column, value.size)
38
- @config.list.stubs(:association_join_text => ',<br/>'.html_safe)
39
+ @config.list.stubs(:association_join_text => ',<br/>'.html_safe) # rubocop:disable Rails/OutputSafety
40
+ remove_instance_variable :@_association_join_text
39
41
  assert_equal '1,<br/>2,<br/>3,<br/>… (4)', format_association_value(value, @association_column, value.size)
40
42
  end
41
43
 
@@ -91,7 +91,7 @@ class ActiveRecordPermissionsTest < MiniTest::Test
91
91
  # symbols are: is (a)bsent, returns (f)alse, returns (t)rue, or n/a (_)
92
92
  def test_method_combinations_with_default_true
93
93
  old_permission = nil
94
- ActiveScaffold.set_defaults do |config|
94
+ ActiveScaffold.defaults do |config|
95
95
  old_permission = config.security.default_permission
96
96
  config.security.default_permission = true
97
97
  end
@@ -134,17 +134,13 @@ class ActiveRecordPermissionsTest < MiniTest::Test
134
134
  miss(@model.authorized_for?(:crud_type => :read, :column => :b1), 'ttf')
135
135
  pass(@model.authorized_for?(:crud_type => :read, :column => :a1), 'ttt')
136
136
 
137
- ActiveScaffold.set_defaults do |config|
137
+ ActiveScaffold.defaults do |config|
138
138
  config.security.default_permission = old_permission
139
139
  end
140
140
  end
141
141
 
142
142
  def test_method_combinations_with_default_false
143
- old_permission = nil
144
- ActiveScaffold.set_defaults do |config|
145
- old_permission = config.security.default_permission
146
- config.security.default_permission = false
147
- end
143
+ ActiveScaffold::Config::Core.security.stubs(default_permission: false)
148
144
 
149
145
  miss(@model.authorized_for?(:column => :a3), '_a_')
150
146
  miss(@model.authorized_for?(:column => :a2), '_f_')
@@ -183,10 +179,6 @@ class ActiveRecordPermissionsTest < MiniTest::Test
183
179
  pass(@model.authorized_for?(:crud_type => :read, :column => :c1), 'tta')
184
180
  miss(@model.authorized_for?(:crud_type => :read, :column => :b1), 'ttf')
185
181
  pass(@model.authorized_for?(:crud_type => :read, :column => :a1), 'ttt')
186
-
187
- ActiveScaffold.set_defaults do |config|
188
- config.security.default_permission = old_permission
189
- end
190
182
  end
191
183
 
192
184
  private
@@ -46,6 +46,7 @@ class AttributeParamsTest < MiniTest::Test
46
46
  assert_nil model.last_name
47
47
  assert_equal buildings.map(&:id), model.building_ids
48
48
  assert_equal buildings.map(&:id), model.buildings.map(&:id)
49
+ assert_equal model, model.buildings[0].owner
49
50
  assert model.save
50
51
  assert_equal 2, model.reload.buildings_count
51
52
 
@@ -134,6 +135,7 @@ class AttributeParamsTest < MiniTest::Test
134
135
  assert_equal 'Name', model.first_name
135
136
  assert model.floor.present?
136
137
  assert_equal floor.id, model.floor.id
138
+ assert_equal model, model.floor.tenant
137
139
  assert_nil floor.reload.tenant_id, 'tenant_id should not be saved yet'
138
140
  assert model.save
139
141
  assert_equal model.id, floor.reload.tenant_id, 'tenant_id should be saved'
@@ -224,6 +226,7 @@ class AttributeParamsTest < MiniTest::Test
224
226
  assert_equal 3, model.floors.size
225
227
  assert_equal floor.id, model.floors.first.id
226
228
  assert_equal [nil, *people.map(&:id)], model.floors.map(&:tenant_id)
229
+ assert_equal model, model.floors[0].building
227
230
  assert model.save
228
231
  assert_equal [1, 1], people.map(&:reload).map(&:floors_count)
229
232
  assert_equal 3, model.reload.floors_count
@@ -299,6 +302,7 @@ class AttributeParamsTest < MiniTest::Test
299
302
  assert_equal 'First', model.first_name
300
303
  assert model.car.present?
301
304
  assert model.car.new_record?
305
+ assert_equal model, model.car.person
302
306
  assert model.save
303
307
  assert model.car.persisted?
304
308
 
@@ -417,15 +421,15 @@ class AttributeParamsTest < MiniTest::Test
417
421
  record = record.class.find(record.id) if record.persisted?
418
422
  new_record = @controller.update_record_from_params(record, build_action_columns(record, action, columns), params)
419
423
  yield if block_given?
420
- Thread.current[:constraint_columns] = nil
424
+ ActiveScaffold::Registry.constraint_columns.clear
421
425
  end
422
426
  new_record
423
427
  end
424
428
 
425
429
  def build_action_columns(record, action, *columns)
426
- controller = ActiveScaffold::Core.active_scaffold_controller_for record.class
427
- controller.active_scaffold_config.send(action).columns = columns
428
- controller.active_scaffold_config.send(action).columns
430
+ config = @controller.active_scaffold_config_for record.class
431
+ config.send(action).columns = columns
432
+ config.send(action).columns
429
433
  end
430
434
  end
431
435
 
@@ -447,11 +451,11 @@ class Controller
447
451
  @flash ||= ActionDispatch::Flash::FlashHash.new
448
452
  end
449
453
 
450
- def params_hash?(v)
451
- v.is_a? Hash
454
+ def params_hash?(value)
455
+ value.is_a? Hash
452
456
  end
453
457
 
454
- def params_hash(v)
455
- v
458
+ def params_hash(value)
459
+ value
456
460
  end
457
461
  end
@@ -4,7 +4,7 @@ require 'class_with_finder'
4
4
  class CalculationTest < MiniTest::Test
5
5
  def setup
6
6
  @buildings = []
7
- @buildings << Building.create { |b| b.create_owner(:first_name => 'foo') }
7
+ @buildings << Building.create { |b| b.build_owner(:first_name => 'foo') }
8
8
  @buildings << Building.create(:name => 'foo bar')
9
9
  @buildings << Building.create
10
10
 
@@ -41,17 +41,17 @@ class ConfigurableTest < MiniTest::Test
41
41
  ## test normal block behaviors
42
42
  ##
43
43
  # functions
44
- assert_equal hello, configurable_class.configure { hello }
44
+ assert_equal hello, (configurable_class.configure { hello })
45
45
  # variables
46
- assert_equal configurable_class, configurable_class.configure { configurable_class }
46
+ assert_equal configurable_class, (configurable_class.configure { configurable_class })
47
47
  # constants
48
- assert_equal ConfigurableTest::HELLO, configurable_class.configure { ConfigurableTest::HELLO }
48
+ assert_equal ConfigurableTest::HELLO, (configurable_class.configure { ConfigurableTest::HELLO })
49
49
 
50
50
  ##
51
51
  ## test extra "localized" block behavior
52
52
  ##
53
53
  # functions
54
- assert_equal configurable_class.foo, configurable_class.configure { foo }
54
+ assert_equal configurable_class.foo, (configurable_class.configure { foo })
55
55
  # constants - not working
56
56
  # assert_equal configurable_class.FOO, configurable_class.configure {FOO}
57
57
  end
@@ -73,25 +73,25 @@ class ConfigurableTest < MiniTest::Test
73
73
  ## test normal block behaviors
74
74
  ##
75
75
  # functions
76
- assert_equal hello, ExtendedClass.configure { hello }
76
+ assert_equal hello, (ExtendedClass.configure { hello })
77
77
  # variables
78
- assert_equal ExtendedClass, ExtendedClass.configure { ExtendedClass }
78
+ assert_equal ExtendedClass, (ExtendedClass.configure { ExtendedClass })
79
79
  # constants
80
- assert_equal ConfigurableTest::HELLO, ExtendedClass.configure { ConfigurableTest::HELLO }
80
+ assert_equal ConfigurableTest::HELLO, (ExtendedClass.configure { ConfigurableTest::HELLO })
81
81
 
82
82
  ##
83
83
  ## test extra "localized" block behavior
84
84
  ##
85
85
  # functions
86
- assert_equal ExtendedClass.foo, ExtendedClass.configure { foo }
86
+ assert_equal ExtendedClass.foo, (ExtendedClass.configure { foo })
87
87
  # constants - not working
88
88
  # assert_equal ExtendedClass.FOO, ExtendedClass.configure {FOO}
89
89
  end
90
90
 
91
91
  def test_arity
92
92
  # this is the main style
93
- assert_equal 'foo', ExtendedClass.configure { 'foo' }
93
+ assert_equal 'foo', (ExtendedClass.configure { 'foo' })
94
94
  # but we want to let people accept the configurable class as the first argument, too
95
- assert_equal 'bar', ExtendedClass.configure { |a| a.foo } # rubocop:disable Style/SymbolProc
95
+ assert_equal 'bar', (ExtendedClass.configure { |a| a.foo }) # rubocop:disable Style/SymbolProc
96
96
  end
97
97
  end
@@ -116,8 +116,8 @@ class ConstraintsTestObject
116
116
  @params = {}
117
117
  end
118
118
 
119
- def params_hash?(v)
120
- v.is_a? Hash
119
+ def params_hash?(value)
120
+ value.is_a? Hash
121
121
  end
122
122
  end
123
123
 
@@ -26,6 +26,7 @@ class ConvertNumbersFormatTest < MiniTest::Test
26
26
  include ActiveScaffoldConfigMock
27
27
  include ActiveScaffold::AttributeParams
28
28
  include ActiveScaffold::Finder
29
+ include ActiveScaffold::Helpers::ControllerHelpers
29
30
 
30
31
  def setup
31
32
  NumberModel.load_schema! if Rails.version >= '5.0'
@@ -46,7 +47,6 @@ class ConvertNumbersFormatTest < MiniTest::Test
46
47
 
47
48
  @config = config_for('number_model')
48
49
  @config.columns[:number].form_ui = nil
49
- @config.create.columns.set_columns @config.columns
50
50
  end
51
51
 
52
52
  def teardown
@@ -161,7 +161,11 @@ class ConvertNumbersFormatTest < MiniTest::Test
161
161
  record.number
162
162
  end
163
163
 
164
- def params_hash?(v)
165
- v.is_a? Hash
164
+ def params_hash?(value)
165
+ value.is_a? Hash
166
+ end
167
+
168
+ def params_hash(value)
169
+ value
166
170
  end
167
171
  end
@@ -4,7 +4,7 @@ class LocalizationTest < MiniTest::Test
4
4
  def test_localization
5
5
  assert_equal 'Dutch', as_(:dutch)
6
6
  assert_equal 'dutch', as_('dutch')
7
- I18n.backend.store_translations :en, :active_scaffold => {:create_model => 'Create %{model}'}
7
+ I18n.backend.store_translations :en, :active_scaffold => {:create_model => 'Create %<model>s'}
8
8
  assert_equal 'Create Test', as_(:create_model, :model => 'Test')
9
9
  end
10
10
  end
@@ -44,7 +44,6 @@ class ParseDatetimeTest < MiniTest::Test
44
44
  I18n.backend.store_translations :es, spanish
45
45
 
46
46
  @config = config_for('date_time_model')
47
- @config.create.columns.set_columns @config.columns
48
47
  end
49
48
 
50
49
  def teardown
@@ -125,7 +124,7 @@ class ParseDatetimeTest < MiniTest::Test
125
124
  end
126
125
 
127
126
  def test_condition_for_datetime_with_zone
128
- assert_equal DateTime.new(2017, 4, 8, 16, 30, 0, '+0300'), condition_value('2017-04-08 16:30 +0300')
127
+ assert_equal ActiveSupport::TimeZone[3].local(2017, 4, 8, 16, 30, 0), condition_value('2017-04-08 16:30 +0300')
129
128
  end
130
129
 
131
130
  def test_condition_for_spanish_date
@@ -154,7 +153,7 @@ class ParseDatetimeTest < MiniTest::Test
154
153
  self.class.condition_value_for_datetime(@config.columns[:run_at], value, conversion || :to_time)
155
154
  end
156
155
 
157
- def params_hash?(v)
158
- v.is_a? Hash
156
+ def params_hash?(value)
157
+ value.is_a? Hash
159
158
  end
160
159
  end
@@ -25,10 +25,24 @@ class TablelessTest < MiniTest::Test
25
25
 
26
26
  def test_find_with_association
27
27
  assert Person.new.files.empty?
28
+ @person = Person.new
29
+ @person.save(validate: false)
30
+ assert @person.files.empty?
31
+ assert_equal [], @person.files.to_a
32
+ end
33
+
34
+ def test_tableless_assoc_with_dependent
35
+ @person = Person.new
36
+ @person.save(validate: false)
37
+ assert @person.destroy
28
38
  end
29
39
 
30
40
  def test_find_with_through_association
31
41
  assert Building.new.files.empty?
42
+ @building = Building.new
43
+ @building.save(validate: false)
44
+ assert @building.files.empty?
45
+ assert_equal [], @building.files.to_a
32
46
  end
33
47
 
34
48
  def test_new
@@ -1,7 +1,7 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require File.expand_path('config/application', __dir__)
5
5
  require 'rake'
6
6
 
7
7
  RailsApp::Application.load_tasks
File without changes
@@ -1,4 +1,5 @@
1
1
  class CarsController < ApplicationController
2
2
  active_scaffold do
3
+ columns[:model].inplace_edit = true
3
4
  end
4
5
  end
@@ -1,4 +1,8 @@
1
1
  class PeopleController < ApplicationController
2
- active_scaffold do
2
+ active_scaffold do |conf|
3
+ conf.columns.exclude :files
4
+ conf.columns[:buildings].includes = nil
5
+ conf.columns[:buildings].associated_limit = 0
6
+ conf.create.columns.exclude :address
3
7
  end
4
8
  end
@@ -0,0 +1,4 @@
1
+ class RolesController < ApplicationController
2
+ active_scaffold do
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ <div id="app_form"></div>
2
+ <%= render :super %>
@@ -0,0 +1,2 @@
1
+ <div id="app"></div>
2
+ <%= render :super %>
@@ -0,0 +1,2 @@
1
+ <span id="first_name_field"></span>
2
+ <%= form_attribute(column, record, scope, only_value, col_class) %>
@@ -0,0 +1,2 @@
1
+ <div id="controller_form"></div>
2
+ <%= render :super %>
@@ -0,0 +1,2 @@
1
+ <div id="controller"></div>
2
+ <%= render :super %>
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require File.expand_path('boot', __dir__)
2
2
 
3
3
  require 'rails/all'
4
4
  require 'rails/test_unit/railtie'
@@ -9,5 +9,6 @@ module RailsApp
9
9
  config.filter_parameters << :password
10
10
  config.action_mailer.default_url_options = {:host => 'localhost:3000'}
11
11
  config.i18n.enforce_available_locales = false if config.i18n.respond_to? :enforce_available_locales
12
+ config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3.respond_to? :represent_boolean_as_integer
12
13
  end
13
14
  end
@@ -1,5 +1,5 @@
1
1
  begin
2
- require File.expand_path('../../../../.bundle/environment', __FILE__)
2
+ require File.expand_path('../../../.bundle/environment', __dir__)
3
3
  rescue LoadError
4
4
  require 'rubygems'
5
5
  require 'bundler'
@@ -1,6 +1,6 @@
1
1
  # Load the rails application
2
- require File.expand_path('../application', __FILE__)
2
+ require File.expand_path('application', __dir__)
3
3
 
4
4
  # Initialize the rails application
5
- RailsApp::Application.config.root = File.expand_path('../..', __FILE__)
5
+ RailsApp::Application.config.root = File.expand_path('..', __dir__)
6
6
  RailsApp::Application.initialize!
@@ -6,9 +6,12 @@ Rails.application.routes.draw do
6
6
  resources :buildings, except: :index do
7
7
  concerns :active_scaffold, except: %i[mark add_existing new_existing destroy_existing]
8
8
  end
9
- resources :cars, only: %i[edit update] do
9
+ resources :cars, only: %i[index edit update] do
10
10
  concerns :active_scaffold, association: false, except: [:mark]
11
11
  end
12
+ resources :people do
13
+ concerns :active_scaffold, except: %i[mark]
14
+ end
12
15
 
13
16
  match ':controller(/:action(/:id))', :via => :any
14
17
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Metrics/BlockLength
1
2
  ActiveRecord::Schema.define do
2
3
  create_table 'addresses' do |t|
3
4
  t.integer 'addressable_id'
@@ -64,3 +65,4 @@ ActiveRecord::Schema.define do
64
65
  t.integer 'role_id'
65
66
  end
66
67
  end
68
+ # rubocop:enable Metrics/BlockLength
@@ -0,0 +1,34 @@
1
+ require 'test_helper'
2
+ require 'performance_test_help'
3
+
4
+ class ListCarsPerformanceTest < ActionDispatch::PerformanceTest
5
+ self.profile_options =
6
+ if ENV['BENCHMARK_TESTS']
7
+ {metrics: [:wall_time]}
8
+ else
9
+ {metrics: %i[process_time], formats: %i[flat graph_html call_stack]}
10
+ end
11
+ def setup
12
+ owners = Array.new(4) { |i| Person.create first_name: "Name#{i}" } << nil
13
+ 500.times { |i| Car.create(brand: 'Skoda', model: 'Fabia', person: owners[i % 5]) }
14
+ CarsController.class_eval do
15
+ before_action :setup
16
+
17
+ def setup
18
+ active_scaffold_config.list.pagination = false
19
+ end
20
+ end
21
+ end
22
+
23
+ def test_list
24
+ get '/cars'
25
+ end
26
+
27
+ # def test_list2
28
+ # get '/cars?t=2'
29
+ # end
30
+ #
31
+ # def test_list3
32
+ # get '/cars?t=3'
33
+ # end
34
+ end