active_scaffold 3.0.26 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/CHANGELOG +1 -1
  2. data/{frontends/default → app/assets}/images/add.gif +0 -0
  3. data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
  4. data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
  5. data/{frontends/default → app/assets}/images/close.gif +0 -0
  6. data/{frontends/default → app/assets}/images/close_touch.png +0 -0
  7. data/{frontends/default → app/assets}/images/config.png +0 -0
  8. data/{frontends/default → app/assets}/images/cross.png +0 -0
  9. data/{frontends/default → app/assets}/images/gears.png +0 -0
  10. data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
  11. data/{frontends/default → app/assets}/images/indicator.gif +0 -0
  12. data/{frontends/default → app/assets}/images/magnifier.png +0 -0
  13. data/app/assets/javascripts/active_scaffold.js.erb +16 -0
  14. data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +16 -28
  15. data/app/assets/javascripts/jquery/active_scaffold.js~ +1036 -0
  16. data/{lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js → app/assets/javascripts/jquery/date_picker_bridge.js.erb} +3 -1
  17. data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +0 -0
  18. data/app/assets/javascripts/prototype/active_scaffold.js +1033 -0
  19. data/{frontends/default/javascripts/prototype/active_scaffold.js → app/assets/javascripts/prototype/active_scaffold.js~} +1 -0
  20. data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
  21. data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
  22. data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
  23. data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
  24. data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +29 -24
  25. data/{lib/active_scaffold/locale → config/locales}/de.yml +3 -0
  26. data/{lib/active_scaffold/locale → config/locales}/en.yml +3 -0
  27. data/{lib/active_scaffold/locale → config/locales}/es.yml +5 -0
  28. data/{lib/active_scaffold/locale → config/locales}/fr.yml +3 -0
  29. data/{lib/active_scaffold/locale → config/locales}/hu.yml +13 -2
  30. data/{lib/active_scaffold/locale → config/locales}/ja.yml +9 -0
  31. data/{lib/active_scaffold/locale → config/locales}/ru.yml +3 -0
  32. data/frontends/default/views/_form.html.erb +1 -1
  33. data/frontends/default/views/_form_association.html.erb +1 -5
  34. data/frontends/default/views/_horizontal_subform.html.erb +7 -4
  35. data/frontends/default/views/_horizontal_subform.html.erb~ +2 -5
  36. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  37. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  38. data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
  39. data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
  40. data/frontends/default/views/_list_actions.html.erb +1 -1
  41. data/frontends/default/views/_list_messages.html.erb +1 -3
  42. data/frontends/default/views/_render_field.js.erb +20 -0
  43. data/frontends/default/views/_row.html.erb +3 -9
  44. data/frontends/default/views/_show.html.erb +2 -2
  45. data/frontends/default/views/add_existing.js.erb +20 -0
  46. data/frontends/default/views/destroy.js.erb +24 -0
  47. data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
  48. data/frontends/default/views/form_messages.js.erb +1 -0
  49. data/frontends/default/views/list.js.erb +1 -0
  50. data/frontends/default/views/mark.js.rjs +6 -0
  51. data/frontends/default/views/on_action_update.js.erb +13 -0
  52. data/frontends/default/views/{on_create.js.erb~ → on_create.js.erb} +0 -0
  53. data/frontends/default/views/on_mark_all.js.erb +12 -0
  54. data/frontends/default/views/{on_update.js.erb~ → on_update.js.erb} +0 -0
  55. data/frontends/default/views/render_field.js.erb +1 -0
  56. data/frontends/default/views/search.html.erb +1 -1
  57. data/frontends/default/views/{update_column.js.erb~ → update_column.js.erb} +3 -3
  58. data/frontends/default/views/update_row.js.erb +1 -0
  59. data/lib/active_scaffold.rb +22 -46
  60. data/lib/active_scaffold/actions/core.rb +14 -6
  61. data/lib/active_scaffold/actions/core.rb~ +3 -3
  62. data/lib/active_scaffold/actions/create.rb +2 -5
  63. data/lib/active_scaffold/actions/create.rb~ +3 -2
  64. data/lib/active_scaffold/actions/delete.rb +1 -0
  65. data/lib/active_scaffold/actions/field_search.rb +1 -1
  66. data/lib/active_scaffold/actions/list.rb +10 -6
  67. data/lib/active_scaffold/actions/list.rb~ +3 -3
  68. data/lib/active_scaffold/actions/mark.rb +8 -8
  69. data/lib/active_scaffold/actions/nested.rb +2 -9
  70. data/lib/active_scaffold/actions/nested.rb~ +5 -7
  71. data/lib/active_scaffold/actions/search.rb +2 -1
  72. data/lib/active_scaffold/actions/subform.rb +1 -5
  73. data/lib/active_scaffold/actions/update.rb +1 -4
  74. data/lib/active_scaffold/actions/update.rb~ +5 -5
  75. data/lib/active_scaffold/attribute_params.rb +15 -26
  76. data/lib/active_scaffold/attribute_params.rb~ +1 -2
  77. data/lib/active_scaffold/bridges.rb +61 -0
  78. data/lib/active_scaffold/bridges/ancestry.rb +5 -0
  79. data/lib/active_scaffold/bridges/ancestry/{lib/ancestry_bridge.rb → ancestry_bridge.rb} +3 -3
  80. data/lib/active_scaffold/bridges/{calendar_date_select/bridge.rb → calendar_date_select.rb} +13 -5
  81. data/lib/active_scaffold/bridges/calendar_date_select/{lib/as_cds_bridge.rb → as_cds_bridge.rb} +4 -20
  82. data/lib/active_scaffold/bridges/cancan.rb +15 -0
  83. data/lib/active_scaffold/bridges/cancan/{lib/cancan_bridge.rb → cancan_bridge.rb} +2 -2
  84. data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
  85. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
  86. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
  87. data/lib/active_scaffold/bridges/carrierwave/{lib/form_ui.rb → form_ui.rb} +0 -0
  88. data/lib/active_scaffold/bridges/carrierwave/{lib/list_ui.rb → list_ui.rb} +1 -1
  89. data/lib/active_scaffold/bridges/country_helper.rb +9 -0
  90. data/lib/active_scaffold/bridges/country_helper/{lib/country_helper_bridge.rb → country_helper_bridge.rb} +5 -5
  91. data/lib/active_scaffold/bridges/date_picker.rb +23 -0
  92. data/lib/active_scaffold/bridges/date_picker/ext.rb +54 -0
  93. data/lib/active_scaffold/bridges/date_picker/helper.rb +188 -0
  94. data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
  95. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
  96. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
  97. data/lib/active_scaffold/bridges/dragonfly/{lib/form_ui.rb → form_ui.rb} +0 -0
  98. data/lib/active_scaffold/bridges/dragonfly/{lib/list_ui.rb → list_ui.rb} +2 -2
  99. data/lib/active_scaffold/bridges/file_column.rb +11 -0
  100. data/lib/active_scaffold/bridges/file_column/{lib/as_file_column_bridge.rb → as_file_column_bridge.rb} +2 -2
  101. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
  102. data/lib/active_scaffold/bridges/file_column/{lib/form_ui.rb → form_ui.rb} +2 -2
  103. data/lib/active_scaffold/bridges/file_column/{lib/list_ui.rb → list_ui.rb} +0 -0
  104. data/lib/active_scaffold/bridges/paperclip.rb +12 -0
  105. data/lib/active_scaffold/bridges/paperclip/{lib/form_ui.rb → form_ui.rb} +0 -0
  106. data/lib/active_scaffold/bridges/paperclip/{lib/list_ui.rb → list_ui.rb} +3 -3
  107. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
  108. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
  109. data/lib/active_scaffold/bridges/record_select.rb +11 -0
  110. data/lib/active_scaffold/bridges/record_select/{lib/record_select_bridge.rb → helpers.rb} +5 -16
  111. data/lib/active_scaffold/bridges/record_select/helpers.rb~ +9 -14
  112. data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
  113. data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb} +3 -3
  114. data/lib/active_scaffold/bridges/tiny_mce.rb +5 -0
  115. data/lib/active_scaffold/bridges/tiny_mce/{lib/tiny_mce_bridge.rb → helpers.rb} +16 -8
  116. data/lib/active_scaffold/config/base.rb +9 -1
  117. data/lib/active_scaffold/config/core.rb +1 -1
  118. data/lib/active_scaffold/config/create.rb +3 -10
  119. data/lib/active_scaffold/config/delete.rb +1 -2
  120. data/lib/active_scaffold/config/field_search.rb +1 -2
  121. data/lib/active_scaffold/config/form.rb +2 -6
  122. data/lib/active_scaffold/config/list.rb +8 -2
  123. data/lib/active_scaffold/config/nested.rb +2 -6
  124. data/lib/active_scaffold/config/search.rb +6 -2
  125. data/lib/active_scaffold/config/show.rb +1 -4
  126. data/lib/active_scaffold/config/subform.rb +1 -1
  127. data/lib/active_scaffold/config/update.rb +1 -6
  128. data/lib/active_scaffold/data_structures/action_columns.rb +3 -0
  129. data/lib/active_scaffold/data_structures/action_link.rb +14 -10
  130. data/lib/active_scaffold/data_structures/bridge.rb +22 -0
  131. data/lib/active_scaffold/data_structures/column.rb +36 -4
  132. data/lib/active_scaffold/data_structures/nested_info.rb +4 -4
  133. data/lib/active_scaffold/data_structures/set.rb +1 -6
  134. data/lib/active_scaffold/data_structures/sorting.rb +2 -2
  135. data/lib/active_scaffold/engine.rb +4 -0
  136. data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
  137. data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
  138. data/lib/active_scaffold/extensions/action_view_rendering.rb +90 -93
  139. data/lib/active_scaffold/extensions/action_view_rendering.rb~ +1 -13
  140. data/lib/active_scaffold/extensions/active_association_reflection.rb +16 -7
  141. data/lib/active_scaffold/extensions/cache_association.rb +16 -0
  142. data/lib/active_scaffold/extensions/reverse_associations.rb +15 -13
  143. data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
  144. data/lib/active_scaffold/finder.rb +40 -23
  145. data/lib/active_scaffold/finder.rb~ +3 -11
  146. data/lib/active_scaffold/helpers/association_helpers.rb +1 -1
  147. data/lib/active_scaffold/helpers/controller_helpers.rb +9 -1
  148. data/lib/active_scaffold/helpers/controller_helpers.rb~ +12 -5
  149. data/lib/active_scaffold/helpers/form_column_helpers.rb +20 -21
  150. data/lib/active_scaffold/helpers/form_column_helpers.rb~ +2 -1
  151. data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
  152. data/lib/active_scaffold/helpers/list_column_helpers.rb +14 -24
  153. data/lib/active_scaffold/helpers/list_column_helpers.rb~ +15 -20
  154. data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -1
  155. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
  156. data/lib/active_scaffold/helpers/view_helpers.rb +14 -40
  157. data/lib/active_scaffold/helpers/view_helpers.rb~ +3 -3
  158. data/lib/active_scaffold/version.rb +2 -2
  159. data/lib/active_scaffold_env.rb +0 -2
  160. data/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
  161. data/test/bridges/bridge_test.rb +43 -0
  162. data/test/bridges/company.rb +81 -0
  163. data/test/bridges/paperclip_test.rb +68 -0
  164. data/test/bridges/tiny_mce_test.rb +27 -0
  165. data/test/bridges/unobtrusive_date_picker_test.rb +49 -0
  166. data/test/bridges/validation_reflection_test.rb +57 -0
  167. data/test/config/base_test.rb +1 -1
  168. data/test/config/core_test.rb +58 -0
  169. data/test/config/create_test.rb +8 -5
  170. data/test/config/delete_test.rb +33 -0
  171. data/test/config/field_search_test.rb +47 -0
  172. data/test/config/list_test.rb +64 -9
  173. data/test/config/nested_test.rb +62 -0
  174. data/test/config/search_test.rb +60 -0
  175. data/test/config/show_test.rb +5 -5
  176. data/test/config/subform_test.rb +17 -0
  177. data/test/config/update_test.rb +27 -4
  178. data/test/helpers/list_column_helpers_test.rb +16 -5
  179. data/test/helpers/pagination_helpers_test.rb +4 -0
  180. data/test/misc/attribute_params_test.rb +37 -1
  181. data/test/misc/finder_test.rb +0 -1
  182. data/test/misc/lang_test.rb +2 -3
  183. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +2 -2
  184. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +13 -7
  185. metadata +137 -154
  186. data/frontends/default/views/_list_with_header.html.erb~ +0 -32
  187. data/frontends/default/views/_render_field.js.rjs +0 -14
  188. data/frontends/default/views/_show.html.erb~ +0 -8
  189. data/frontends/default/views/_update_form.html.erb~ +0 -6
  190. data/frontends/default/views/add_existing.js.erb~ +0 -18
  191. data/frontends/default/views/add_existing.js.rjs +0 -17
  192. data/frontends/default/views/destroy.js.rjs +0 -23
  193. data/frontends/default/views/form_messages.js.rjs +0 -1
  194. data/frontends/default/views/list.js.rjs +0 -1
  195. data/frontends/default/views/on_action_update.js.rjs +0 -10
  196. data/frontends/default/views/on_create.js.rjs +0 -41
  197. data/frontends/default/views/on_mark_all.js.rjs +0 -12
  198. data/frontends/default/views/on_update.js.rjs +0 -28
  199. data/frontends/default/views/render_field.js.rjs +0 -1
  200. data/frontends/default/views/update_column.js.rjs +0 -13
  201. data/frontends/default/views/update_row.js.rjs +0 -1
  202. data/lib/active_scaffold.rb~ +0 -362
  203. data/lib/active_scaffold/bridges/ancestry/bridge.rb +0 -5
  204. data/lib/active_scaffold/bridges/bridge.rb +0 -59
  205. data/lib/active_scaffold/bridges/cancan/bridge.rb +0 -12
  206. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +0 -9
  207. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +0 -33
  208. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +0 -12
  209. data/lib/active_scaffold/bridges/country_helper/bridge.rb +0 -9
  210. data/lib/active_scaffold/bridges/date_picker/bridge.rb +0 -24
  211. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +0 -234
  212. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +0 -9
  213. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +0 -36
  214. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +0 -12
  215. data/lib/active_scaffold/bridges/file_column/bridge.rb +0 -11
  216. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +0 -59
  217. data/lib/active_scaffold/bridges/paperclip/bridge.rb +0 -12
  218. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +0 -38
  219. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +0 -26
  220. data/lib/active_scaffold/bridges/record_select/bridge.rb +0 -5
  221. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +0 -5
  222. data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
  223. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -5
  224. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +0 -8
  225. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +0 -21
  226. data/lib/active_scaffold/config/base.rb~ +0 -70
  227. data/lib/active_scaffold/config/nested.rb~ +0 -41
  228. data/lib/active_scaffold/constraints.rb~ +0 -186
  229. data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
  230. data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -123
  231. data/lib/active_scaffold/extensions/action_view_resolver.rb +0 -7
  232. data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
  233. data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
  234. data/lib/active_scaffold_assets.rb +0 -45
  235. data/lib/generators/active_scaffold_setup/USAGE +0 -10
  236. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +0 -59
@@ -0,0 +1,57 @@
1
+ require 'test/unit'
2
+ require File.join(File.dirname(__FILE__), 'company')
3
+ require File.join(File.dirname(__FILE__), '../../lib/bridges/validation_reflection/lib/validation_reflection_bridge')
4
+
5
+ class ColumnWithValidationReflection < ActiveScaffold::DataStructures::Column
6
+ include ActiveScaffold::ValidationReflectionBridge
7
+ end
8
+
9
+ class ValidationReflectionTest < Test::Unit::TestCase
10
+ def test_set_required_for_validates_presence_of
11
+ Company.expects(:reflect_on_validations_for).with(:name).returns([stub(:macro => :validates_presence_of)])
12
+ column = ColumnWithValidationReflection.new(:name, Company)
13
+ assert column.required?
14
+ end
15
+
16
+ def test_set_required_for_validates_inclusion_of
17
+ Company.expects(:reflect_on_validations_for).with(:name).returns([stub(:macro => :validates_inclusion_of, :options => {})])
18
+ column = ColumnWithValidationReflection.new(:name, Company)
19
+ assert column.required?
20
+ end
21
+
22
+ def test_not_set_required_for_validates_inclusion_of_and_allow_nil
23
+ Company.expects(:reflect_on_validations_for).with(:name).returns([stub(:macro => :validates_inclusion_of, :options => {:allow_nil => true})])
24
+ column = ColumnWithValidationReflection.new(:name, Company)
25
+ assert !column.required?
26
+ end
27
+
28
+ def test_not_set_required_for_validates_inclusion_of_and_allow_blank
29
+ Company.expects(:reflect_on_validations_for).with(:name).returns([stub(:macro => :validates_inclusion_of, :options => {:allow_blank => true})])
30
+ column = ColumnWithValidationReflection.new(:name, Company)
31
+ assert !column.required?
32
+ end
33
+
34
+ def test_not_set_required_for_no_validation
35
+ Company.expects(:reflect_on_validations_for).with(:name).returns([])
36
+ column = ColumnWithValidationReflection.new(:name, Company)
37
+ assert !column.required?
38
+ end
39
+
40
+ def test_set_required_for_validates_presence_of_in_association
41
+ Company.stubs(:reflect_on_validations_for).returns([stub(:macro => :validates_presence_of)], [])
42
+ column = ColumnWithValidationReflection.new(:main_company, Company)
43
+ assert column.required?
44
+ end
45
+
46
+ def test_set_required_for_validates_presence_of_in_foreign_key
47
+ Company.stubs(:reflect_on_validations_for).returns([], [stub(:macro => :validates_presence_of)])
48
+ column = ColumnWithValidationReflection.new(:main_company, Company)
49
+ assert column.required?
50
+ end
51
+
52
+ def test_not_set_required_for_no_validation_in_association_neither_foreign_key
53
+ Company.stubs(:reflect_on_validations_for).returns([])
54
+ column = ColumnWithValidationReflection.new(:main_company, Company)
55
+ assert !column.required?
56
+ end
57
+ end
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
2
 
3
3
  class Config::BaseTest < Test::Unit::TestCase
4
4
  def setup
5
- @base = ActiveScaffold::Config::Base.new
5
+ @base = ActiveScaffold::Config::Base.new(ActiveScaffold::Config::Core.new(:model_stub))
6
6
  end
7
7
 
8
8
  def test_formats
@@ -0,0 +1,58 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
+
3
+ class Config::CoreTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = ActiveScaffold::Config::Core.new :model_stub
6
+ end
7
+
8
+ def test_default_options
9
+ assert !@config.add_sti_create_links?
10
+ assert !@config.sti_children
11
+ assert_equal [:create, :list, :search, :update, :delete, :show, :nested, :subform], @config.actions.to_a
12
+ assert_equal :default, @config.frontend
13
+ assert_equal :default, @config.theme
14
+ assert_equal 'ModelStub', @config.label(:count => 1)
15
+ assert_equal 'ModelStubs', @config.label
16
+ end
17
+
18
+ def test_add_sti_children
19
+ @config.sti_create_links = true
20
+ assert !@config.add_sti_create_links?
21
+ @config.sti_children = [:a]
22
+ assert @config.add_sti_create_links?
23
+ end
24
+
25
+ def test_sti_children
26
+ @config.sti_children = [:a]
27
+ assert_equal [:a], @config.sti_children
28
+ end
29
+
30
+ def test_actions
31
+ assert @config.actions.include?(:create)
32
+ @config.actions = [:list]
33
+ assert !@config.actions.include?(:create)
34
+ assert_equal [:list], @config.actions.to_a
35
+ end
36
+
37
+ def test_form_ui_in_sti
38
+ @config.columns << :type
39
+
40
+ @config.sti_children = [:model_stub]
41
+ @config._configure_sti
42
+ assert_equal :select, @config.columns[:type].form_ui
43
+ assert_equal [['Modelstub', 'ModelStub']], @config.columns[:type].options[:options]
44
+
45
+ @config.columns[:type].form_ui = nil
46
+ @config.sti_create_links = true
47
+ @config._configure_sti
48
+ assert_equal :hidden, @config.columns[:type].form_ui
49
+ end
50
+
51
+ def test_sti_children_links
52
+ @config.sti_children = [:model_stub]
53
+ @config.sti_create_links = true
54
+ @config.action_links.add @config.create.link
55
+ @config._add_sti_create_links
56
+ assert_equal 'Create Modelstub', @config.action_links[:new].label
57
+ end
58
+ end
@@ -12,8 +12,8 @@ class Config::CreateTest < Test::Unit::TestCase
12
12
 
13
13
  def test_default_options
14
14
  assert !@config.create.persistent
15
- assert !@config.create.edit_after_create
16
- assert_equal 'Create Modelstub', @config.create.label
15
+ assert @config.create.action_after_create.nil?
16
+ assert_equal 'Create ModelStub', @config.create.label
17
17
  end
18
18
 
19
19
  def test_link_defaults
@@ -41,6 +41,9 @@ class Config::CreateTest < Test::Unit::TestCase
41
41
  label = 'create new monkeys'
42
42
  @config.create.label = label
43
43
  assert_equal label, @config.create.label
44
+ I18n.backend.store_translations :en, :active_scaffold => {:create_new_model => 'Create new %{model}'}
45
+ @config.create.label = :create_new_model
46
+ assert_equal 'Create new ModelStub', @config.create.label
44
47
  end
45
48
 
46
49
  def test_persistent
@@ -48,8 +51,8 @@ class Config::CreateTest < Test::Unit::TestCase
48
51
  assert @config.create.persistent
49
52
  end
50
53
 
51
- def test_edit_after_create
52
- @config.create.edit_after_create = true
53
- assert @config.create.edit_after_create
54
+ def test_action_after_create
55
+ @config.create.action_after_create = :edit
56
+ assert_equal :edit, @config.create.action_after_create
54
57
  end
55
58
  end
@@ -0,0 +1,33 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
+
3
+ class Config::DeleteTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = ActiveScaffold::Config::Core.new :model_stub
6
+ @default_link = @config.delete.link
7
+ end
8
+
9
+ def teardown
10
+ @config.delete.link = @default_link
11
+ end
12
+
13
+ def test_link_defaults
14
+ link = @config.delete.link
15
+ assert !link.page?
16
+ assert !link.popup?
17
+ assert link.confirm?
18
+ assert_equal "delete", link.action
19
+ assert_equal "Delete", link.label
20
+ assert link.inline?
21
+ blank = {}
22
+ assert_equal blank, link.html_options
23
+ assert_equal :delete, link.method
24
+ assert_equal :member, link.type
25
+ assert_equal :delete, link.crud_type
26
+ assert_equal :delete_authorized?, link.security_method
27
+ end
28
+
29
+ def test_setting_link
30
+ @config.delete.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
31
+ assert_not_equal(@default_link, @config.delete.link)
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
+
3
+ class Config::FieldSearchTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = ActiveScaffold::Config::Core.new :model_stub
6
+ @config.actions.swap :search, :field_search
7
+ @default_link = @config.field_search.link
8
+ end
9
+
10
+ def teardown
11
+ @config.field_search.link = @default_link
12
+ end
13
+
14
+ def test_default_options
15
+ assert_equal :full, @config.field_search.text_search
16
+ end
17
+
18
+ def test_text_search
19
+ @config.field_search.text_search = :start
20
+ assert_equal :start, @config.field_search.text_search
21
+ @config.field_search.text_search = :end
22
+ assert_equal :end, @config.field_search.text_search
23
+ @config.field_search.text_search = false
24
+ assert !@config.field_search.text_search
25
+ end
26
+
27
+ def test_link_defaults
28
+ link = @config.field_search.link
29
+ assert !link.page?
30
+ assert !link.popup?
31
+ assert !link.confirm?
32
+ assert_equal "show_search", link.action
33
+ assert_equal "Search", link.label
34
+ assert link.inline?
35
+ blank = {}
36
+ assert_equal blank, link.html_options
37
+ assert_equal :get, link.method
38
+ assert_equal :collection, link.type
39
+ assert_equal :read, link.crud_type
40
+ assert_equal :search_authorized?, link.security_method
41
+ end
42
+
43
+ def test_setting_link
44
+ @config.field_search.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
45
+ assert_not_equal(@default_link, @config.field_search.link)
46
+ end
47
+ end
@@ -5,15 +5,41 @@ class Config::ListTest < Test::Unit::TestCase
5
5
  @config = ActiveScaffold::Config::Core.new :model_stub
6
6
  end
7
7
 
8
+ def test_label
9
+ I18n.backend.store_translations :en, :active_scaffold => {:resource => {:one => 'Resource', :other => 'Resources'}}
10
+ @config.list.label = :resource
11
+ assert_equal 'Resources', @config.list.label
12
+ label = 'monkeys'
13
+ @config.list.label = label
14
+ assert_equal label, @config.list.label
15
+ end
16
+
8
17
  def test_default_options
9
18
  assert_equal 15, @config.list.per_page
19
+ assert_equal 2, @config.list.page_links_window
10
20
  assert_equal '-', @config.list.empty_field_text
11
- assert @config.actions.include?(:search)
21
+ assert_equal ', ', @config.list.association_join_text
22
+ assert_equal true, @config.list.pagination
12
23
  assert_equal 'search', @config.list.search_partial
13
24
  assert_equal :no_entries, @config.list.no_entries_message
14
25
  assert_equal :filtered, @config.list.filtered_message
15
26
  assert !@config.list.always_show_create
16
27
  assert !@config.list.always_show_search
28
+ assert !@config.list.mark_records
29
+ assert @config.list.count_includes.nil?
30
+ assert_equal 'ModelStubs', @config.list.label
31
+ assert @config.list.sorting.sorts_on?(:id)
32
+ assert_equal 'ASC', @config.list.sorting.direction_of(:id)
33
+ end
34
+
35
+ def test_empty_field_text
36
+ @config.list.empty_field_text = '(missing)'
37
+ assert_equal '(missing)', @config.list.empty_field_text
38
+ end
39
+
40
+ def test_association_join_text
41
+ @config.list.association_join_text = '<br/>'
42
+ assert_equal '<br/>', @config.list.association_join_text
17
43
  end
18
44
 
19
45
  def test_no_entries
@@ -26,12 +52,44 @@ class Config::ListTest < Test::Unit::TestCase
26
52
  assert_equal 'filtered items', @config.list.filtered_message
27
53
  end
28
54
 
55
+ def test_pagination
56
+ @config.list.pagination = :infinite
57
+ assert_equal :infinite, @config.list.pagination
58
+ @config.list.pagination = false
59
+ assert !@config.list.pagination
60
+ end
61
+
62
+ def test_sorting
63
+ @config.list.sorting = {:a => :desc}
64
+ assert @config.list.sorting.sorts_on?(:a)
65
+ assert_equal 'DESC', @config.list.sorting.direction_of(:a)
66
+ assert !@config.list.sorting.sorts_on?(:id)
67
+
68
+ @config.list.sorting = [{:a => :asc}, {:b => :desc}]
69
+ assert @config.list.sorting.sorts_on?(:a)
70
+ assert_equal 'ASC', @config.list.sorting.direction_of(:a)
71
+ assert @config.list.sorting.sorts_on?(:b)
72
+ assert_equal 'DESC', @config.list.sorting.direction_of(:b)
73
+ assert !@config.list.sorting.sorts_on?(:id)
74
+ end
75
+
76
+ def test_mark_records
77
+ @config.list.mark_records = true
78
+ assert @config.list.mark_records
79
+ end
80
+
29
81
  def test_per_page
30
82
  per_page = 35
31
83
  @config.list.per_page = per_page
32
84
  assert_equal per_page, @config.list.per_page
33
85
  end
34
86
 
87
+ def test_page_links_window
88
+ page_links_window = 3
89
+ @config.list.page_links_window = page_links_window
90
+ assert_equal page_links_window, @config.list.page_links_window
91
+ end
92
+
35
93
  def test_always_show_create
36
94
  always_show_create = true
37
95
  @config.list.always_show_create = always_show_create
@@ -56,13 +114,6 @@ class Config::ListTest < Test::Unit::TestCase
56
114
  @config.actions.exclude :search
57
115
  assert_equal false, @config.list.always_show_search
58
116
  end
59
-
60
- def test_always_show_search_when_field_search
61
- @config.list.always_show_search = true
62
- @config.actions.swap :search, :live_search
63
- assert @config.list.always_show_search
64
- assert_equal 'live_search', @config.list.search_partial
65
- end
66
117
 
67
118
  def test_always_show_search_when_field_search
68
119
  @config.list.always_show_search = true
@@ -70,5 +121,9 @@ class Config::ListTest < Test::Unit::TestCase
70
121
  assert @config.list.always_show_search
71
122
  assert_equal 'field_search', @config.list.search_partial
72
123
  end
73
-
124
+
125
+ def test_count_includes
126
+ @config.list.count_includes = [:assoc_1, :assoc_2]
127
+ assert_equal [:assoc_1, :assoc_2], @config.list.count_includes
128
+ end
74
129
  end
@@ -0,0 +1,62 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
+
3
+ class Config::NestedTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = ActiveScaffold::Config::Core.new :model_stub
6
+ end
7
+
8
+ def test_default_options
9
+ assert !@config.nested.shallow_delete
10
+ assert_equal 'Add Existing ModelStub', @config.nested.label
11
+ end
12
+
13
+ def test_label
14
+ label = 'nested monkeys'
15
+ @config.nested.label = label
16
+ assert_equal label, @config.nested.label
17
+ I18n.backend.store_translations :en, :active_scaffold => {:create_model => 'Add new %{model}'}
18
+ @config.nested.label = :create_model
19
+ assert_equal 'Add new ModelStub', @config.nested.label
20
+ end
21
+
22
+ def test_shallow_delete
23
+ @config.nested.shallow_delete = true
24
+ assert @config.nested.shallow_delete
25
+ end
26
+
27
+ def test_add_link_deprecation
28
+ ActiveSupport::Deprecation.silence { @config.nested.add_link :custom_link, [:assoc_1, :assoc_2] }
29
+ link = @config.action_links['nested']
30
+ assert_equal 'Custom Link', link.label
31
+ assert_equal 'nested', link.action
32
+ assert_equal :after, link.position
33
+ assert !link.page?
34
+ assert !link.popup?
35
+ assert !link.confirm?
36
+ assert link.inline?
37
+ assert_equal :assoc_1, link.parameters[:associations]
38
+ assert_equal 'assoc_1', link.html_options[:class]
39
+ assert_equal :get, link.method
40
+ assert_equal :member, link.type
41
+ assert_equal :read, link.crud_type
42
+ assert_equal :nested_authorized?, link.security_method
43
+ end
44
+
45
+ def test_add_link
46
+ @config.nested.add_link :custom_link, :assoc_1
47
+ link = @config.action_links['nested']
48
+ assert_equal 'Custom Link', link.label
49
+ assert_equal 'nested', link.action
50
+ assert_equal :after, link.position
51
+ assert !link.page?
52
+ assert !link.popup?
53
+ assert !link.confirm?
54
+ assert link.inline?
55
+ assert_equal :assoc_1, link.parameters[:associations]
56
+ assert_equal 'assoc_1', link.html_options[:class]
57
+ assert_equal :get, link.method
58
+ assert_equal :member, link.type
59
+ assert_equal :read, link.crud_type
60
+ assert_equal :nested_authorized?, link.security_method
61
+ end
62
+ end
@@ -0,0 +1,60 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
+
3
+ class Config::SearchTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = ActiveScaffold::Config::Core.new :model_stub
6
+ @default_link = @config.search.link
7
+ end
8
+
9
+ def teardown
10
+ @config.search.link = @default_link
11
+ end
12
+
13
+ def test_default_options
14
+ assert_equal :full, @config.search.text_search
15
+ assert !@config.search.live?
16
+ assert_equal ' ', @config.search.split_terms
17
+ end
18
+
19
+ def test_text_search
20
+ @config.search.text_search = :start
21
+ assert_equal :start, @config.search.text_search
22
+ @config.search.text_search = :end
23
+ assert_equal :end, @config.search.text_search
24
+ @config.search.text_search = false
25
+ assert !@config.search.text_search
26
+ end
27
+
28
+ def test_live
29
+ @config.search.live = true
30
+ assert @config.search.live?
31
+ end
32
+
33
+ def test_split_terms
34
+ @config.search.split_terms = nil
35
+ assert @config.search.split_terms.nil?
36
+ @config.search.split_terms = ','
37
+ assert_equal ',', @config.search.split_terms
38
+ end
39
+
40
+ def test_link_defaults
41
+ link = @config.search.link
42
+ assert !link.page?
43
+ assert !link.popup?
44
+ assert !link.confirm?
45
+ assert_equal "show_search", link.action
46
+ assert_equal "Search", link.label
47
+ assert link.inline?
48
+ blank = {}
49
+ assert_equal blank, link.html_options
50
+ assert_equal :get, link.method
51
+ assert_equal :collection, link.type
52
+ assert_equal :read, link.crud_type
53
+ assert_equal :search_authorized?, link.security_method
54
+ end
55
+
56
+ def test_setting_link
57
+ @config.search.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
58
+ assert_not_equal(@default_link, @config.search.link)
59
+ end
60
+ end