active_scaffold 3.4.17 → 3.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +12 -1
  3. data/README.md +8 -4
  4. data/app/assets/javascripts/jquery/active_scaffold.js +82 -67
  5. data/app/assets/stylesheets/active_scaffold.scss +1 -1
  6. data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
  7. data/app/assets/stylesheets/blue-theme.css +1 -1
  8. data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -3
  9. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +3 -3
  10. data/app/views/active_scaffold_overrides/_show_columns.html.erb +1 -1
  11. data/lib/active_scaffold.rb +16 -16
  12. data/lib/active_scaffold/actions/common_search.rb +13 -11
  13. data/lib/active_scaffold/actions/core.rb +85 -78
  14. data/lib/active_scaffold/actions/create.rb +29 -28
  15. data/lib/active_scaffold/actions/delete.rb +17 -17
  16. data/lib/active_scaffold/actions/field_search.rb +18 -19
  17. data/lib/active_scaffold/actions/list.rb +30 -22
  18. data/lib/active_scaffold/actions/mark.rb +1 -1
  19. data/lib/active_scaffold/actions/nested.rb +78 -65
  20. data/lib/active_scaffold/actions/search.rb +13 -10
  21. data/lib/active_scaffold/actions/show.rb +10 -6
  22. data/lib/active_scaffold/actions/subform.rb +1 -2
  23. data/lib/active_scaffold/actions/update.rb +39 -31
  24. data/lib/active_scaffold/active_record_permissions.rb +14 -15
  25. data/lib/active_scaffold/attribute_params.rb +42 -43
  26. data/lib/active_scaffold/bridges.rb +22 -12
  27. data/lib/active_scaffold/bridges/ancestry.rb +1 -1
  28. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +6 -6
  29. data/lib/active_scaffold/bridges/bitfields.rb +1 -1
  30. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -13
  31. data/lib/active_scaffold/bridges/calendar_date_select.rb +5 -5
  32. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +17 -20
  33. data/lib/active_scaffold/bridges/cancan.rb +1 -1
  34. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +8 -9
  35. data/lib/active_scaffold/bridges/carrierwave.rb +4 -4
  36. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +9 -8
  37. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +11 -10
  38. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +7 -6
  39. data/lib/active_scaffold/bridges/chosen.rb +1 -1
  40. data/lib/active_scaffold/bridges/chosen/helpers.rb +4 -4
  41. data/lib/active_scaffold/bridges/country_helper.rb +1 -1
  42. data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +259 -260
  43. data/lib/active_scaffold/bridges/date_picker.rb +2 -2
  44. data/lib/active_scaffold/bridges/date_picker/ext.rb +9 -11
  45. data/lib/active_scaffold/bridges/date_picker/helper.rb +61 -67
  46. data/lib/active_scaffold/bridges/dragonfly.rb +4 -4
  47. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +9 -8
  48. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +11 -10
  49. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +6 -5
  50. data/lib/active_scaffold/bridges/file_column.rb +5 -5
  51. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +20 -23
  52. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +20 -23
  53. data/lib/active_scaffold/bridges/file_column/form_ui.rb +13 -14
  54. data/lib/active_scaffold/bridges/file_column/list_ui.rb +7 -8
  55. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +18 -22
  56. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +5 -4
  57. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +2 -10
  58. data/lib/active_scaffold/bridges/paper_trail.rb +7 -5
  59. data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +4 -3
  60. data/lib/active_scaffold/bridges/paperclip.rb +5 -5
  61. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +11 -10
  62. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +6 -5
  63. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +10 -9
  64. data/lib/active_scaffold/bridges/record_select.rb +1 -1
  65. data/lib/active_scaffold/bridges/record_select/helpers.rb +28 -28
  66. data/lib/active_scaffold/bridges/semantic_attributes.rb +1 -1
  67. data/lib/active_scaffold/bridges/semantic_attributes/column.rb +1 -1
  68. data/lib/active_scaffold/bridges/shared/date_bridge.rb +58 -52
  69. data/lib/active_scaffold/bridges/tiny_mce.rb +2 -2
  70. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -3
  71. data/lib/active_scaffold/config/base.rb +9 -10
  72. data/lib/active_scaffold/config/core.rb +24 -29
  73. data/lib/active_scaffold/config/create.rb +0 -1
  74. data/lib/active_scaffold/config/field_search.rb +8 -10
  75. data/lib/active_scaffold/config/form.rb +5 -5
  76. data/lib/active_scaffold/config/list.rb +21 -20
  77. data/lib/active_scaffold/config/mark.rb +3 -3
  78. data/lib/active_scaffold/config/nested.rb +11 -10
  79. data/lib/active_scaffold/config/search.rb +2 -3
  80. data/lib/active_scaffold/config/show.rb +1 -1
  81. data/lib/active_scaffold/config/update.rb +1 -2
  82. data/lib/active_scaffold/configurable.rb +9 -11
  83. data/lib/active_scaffold/constraints.rb +9 -8
  84. data/lib/active_scaffold/core.rb +72 -84
  85. data/lib/active_scaffold/data_structures/action_columns.rb +26 -25
  86. data/lib/active_scaffold/data_structures/action_link.rb +43 -43
  87. data/lib/active_scaffold/data_structures/action_links.rb +17 -15
  88. data/lib/active_scaffold/data_structures/actions.rb +5 -5
  89. data/lib/active_scaffold/data_structures/bridge.rb +6 -3
  90. data/lib/active_scaffold/data_structures/column.rb +110 -89
  91. data/lib/active_scaffold/data_structures/columns.rb +3 -3
  92. data/lib/active_scaffold/data_structures/error_message.rb +4 -6
  93. data/lib/active_scaffold/data_structures/nested_info.rb +43 -48
  94. data/lib/active_scaffold/data_structures/set.rb +7 -8
  95. data/lib/active_scaffold/data_structures/sorting.rb +38 -33
  96. data/lib/active_scaffold/delayed_setup.rb +5 -6
  97. data/lib/active_scaffold/engine.rb +4 -4
  98. data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -4
  99. data/lib/active_scaffold/extensions/action_controller_rescueing.rb +1 -1
  100. data/lib/active_scaffold/extensions/action_view_rendering.rb +5 -6
  101. data/lib/active_scaffold/extensions/left_outer_joins.rb +11 -11
  102. data/lib/active_scaffold/extensions/localize.rb +1 -1
  103. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +1 -1
  104. data/lib/active_scaffold/extensions/paginator_extensions.rb +2 -5
  105. data/lib/active_scaffold/extensions/reverse_associations.rb +13 -13
  106. data/lib/active_scaffold/extensions/routing_mapper.rb +9 -9
  107. data/lib/active_scaffold/extensions/unsaved_associated.rb +9 -9
  108. data/lib/active_scaffold/finder.rb +90 -93
  109. data/lib/active_scaffold/helpers/association_helpers.rb +5 -5
  110. data/lib/active_scaffold/helpers/controller_helpers.rb +22 -19
  111. data/lib/active_scaffold/helpers/form_column_helpers.rb +115 -105
  112. data/lib/active_scaffold/helpers/human_condition_helpers.rb +62 -35
  113. data/lib/active_scaffold/helpers/id_helpers.rb +6 -6
  114. data/lib/active_scaffold/helpers/list_column_helpers.rb +89 -94
  115. data/lib/active_scaffold/helpers/pagination_helpers.rb +9 -9
  116. data/lib/active_scaffold/helpers/search_column_helpers.rb +47 -44
  117. data/lib/active_scaffold/helpers/show_column_helpers.rb +2 -2
  118. data/lib/active_scaffold/helpers/view_helpers.rb +86 -91
  119. data/lib/active_scaffold/marked_model.rb +10 -10
  120. data/lib/active_scaffold/paginator.rb +30 -34
  121. data/lib/active_scaffold/responds_to_parent.rb +27 -28
  122. data/lib/active_scaffold/tableless.rb +20 -15
  123. data/lib/active_scaffold/version.rb +1 -1
  124. data/lib/generators/active_scaffold/active_scaffold_generator.rb +8 -8
  125. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +9 -9
  126. data/shoulda_macros/macros.rb +27 -22
  127. data/test/bridges/bridge_test.rb +38 -29
  128. data/test/bridges/date_picker_test.rb +1 -1
  129. data/test/bridges/paper_trail_test.rb +17 -0
  130. data/test/bridges/paperclip_test.rb +3 -2
  131. data/test/bridges/tiny_mce_test.rb +5 -2
  132. data/test/company.rb +25 -30
  133. data/test/config/base_test.rb +1 -1
  134. data/test/config/core_test.rb +9 -9
  135. data/test/config/create_test.rb +14 -8
  136. data/test/config/delete_test.rb +4 -4
  137. data/test/config/field_search_test.rb +6 -6
  138. data/test/config/list_test.rb +16 -16
  139. data/test/config/nested_test.rb +4 -4
  140. data/test/config/search_test.rb +8 -8
  141. data/test/config/show_test.rb +6 -6
  142. data/test/config/subform_test.rb +1 -1
  143. data/test/config/update_test.rb +5 -5
  144. data/test/const_mocker.rb +4 -4
  145. data/test/data_structures/action_columns_test.rb +4 -5
  146. data/test/data_structures/action_link_test.rb +1 -0
  147. data/test/data_structures/action_links_test.rb +5 -5
  148. data/test/data_structures/column_test.rb +9 -9
  149. data/test/data_structures/columns_test.rb +2 -2
  150. data/test/data_structures/error_message_test.rb +4 -5
  151. data/test/data_structures/set_test.rb +1 -2
  152. data/test/data_structures/sorting_test.rb +10 -10
  153. data/test/data_structures/validation_reflection_test.rb +8 -0
  154. data/test/extensions/routing_mapper_test.rb +2 -2
  155. data/test/helpers/list_column_helpers_test.rb +3 -2
  156. data/test/helpers/pagination_helpers_test.rb +5 -4
  157. data/test/helpers/search_column_helpers_test.rb +1 -1
  158. data/test/misc/active_record_permissions_test.rb +63 -50
  159. data/test/misc/attribute_params_test.rb +28 -26
  160. data/test/misc/calculation_test.rb +10 -3
  161. data/test/misc/configurable_test.rb +12 -13
  162. data/test/misc/constraints_test.rb +6 -6
  163. data/test/misc/convert_numbers_format_test.rb +7 -6
  164. data/test/misc/finder_test.rb +17 -12
  165. data/test/misc/lang_test.rb +3 -4
  166. data/test/misc/tableless_test.rb +2 -3
  167. data/test/mock_app/app/controllers/addresses_controller.rb +1 -1
  168. data/test/mock_app/app/controllers/buildings_controller.rb +1 -1
  169. data/test/mock_app/app/controllers/cars_controller.rb +1 -1
  170. data/test/mock_app/app/controllers/contacts_controller.rb +1 -1
  171. data/test/mock_app/app/controllers/people_controller.rb +1 -1
  172. data/test/mock_app/app/models/file_model.rb +2 -2
  173. data/test/mock_app/app/models/person.rb +1 -1
  174. data/test/mock_app/config/application.rb +3 -3
  175. data/test/mock_app/config/boot.rb +1 -1
  176. data/test/mock_app/config/environment.rb +1 -0
  177. data/test/mock_app/config/environments/development.rb +0 -1
  178. data/test/mock_app/config/environments/production.rb +1 -1
  179. data/test/mock_app/db/schema.rb +14 -15
  180. data/test/model_stub.rb +13 -16
  181. data/test/run_all.rb +5 -7
  182. data/test/test_helper.rb +12 -9
  183. metadata +19 -3
@@ -24,13 +24,14 @@ class ActiveSupport::TestCase
24
24
  end
25
25
 
26
26
  def self.should_render_as_form_ui(column_name, form_ui)
27
- should "render column #{column_name} as #{form_ui} form_ui", :before => lambda{
27
+ before_block = lambda do
28
28
  @rendered_columns = []
29
- @controller.view_context_class.any_instance.expects(:"active_scaffold_input_#{form_ui}").at_least_once.with {|column, options|
29
+ @controller.view_context_class.any_instance.expects(:"active_scaffold_input_#{form_ui}").at_least_once.with do |column, _|
30
30
  @rendered_columns << column.name
31
31
  true
32
- }
33
- } do
32
+ end
33
+ end
34
+ should "render column #{column_name} as #{form_ui} form_ui", :before => before_block do
34
35
  assert_equal form_ui, @controller.active_scaffold_config.columns[column_name].form_ui
35
36
  assert @rendered_columns.include?(column_name)
36
37
  end
@@ -38,7 +39,7 @@ class ActiveSupport::TestCase
38
39
 
39
40
  def self.should_render_with_options_for_select(column_name, *options)
40
41
  should "render column #{column_name} with options for select" do
41
- converting_sort = lambda{|a,b| a.to_s <=> b.to_s}
42
+ converting_sort = ->(a, b) { a.to_s <=> b.to_s }
42
43
  assert_equal options.sort(&converting_sort), @controller.active_scaffold_config.columns[column_name].options[:options].sort(&converting_sort)
43
44
  end
44
45
  end
@@ -58,26 +59,28 @@ class ActiveSupport::TestCase
58
59
  end
59
60
 
60
61
  def self.should_render_as_form_hidden(column_name)
61
- should "render column #{column_name} as form hidden", :before => lambda{
62
+ before_block = lambda do
62
63
  @rendered_columns = []
63
- @controller.view_context_class.any_instance.expects(:"hidden_field").at_least_once.with {|object, method, options|
64
+ @controller.view_context_class.any_instance.expects(:"hidden_field").at_least_once.with do |_, method, _|
64
65
  @rendered_columns << method
65
66
  true
66
- }
67
- } do
68
- assert_template :partial => "_form_hidden_attribute"
67
+ end
68
+ end
69
+ should "render column #{column_name} as form hidden", :before => before_block do
70
+ assert_template :partial => '_form_hidden_attribute'
69
71
  assert @rendered_columns.include?(column_name)
70
72
  end
71
73
  end
72
74
 
73
75
  def self.should_render_as_list_ui(column_name, list_ui)
74
- should "render column #{column_name} as #{list_ui} list_ui", :before => lambda{
76
+ before_block = lambda do
75
77
  @rendered_columns = []
76
- @controller.view_context_class.any_instance.expects(:"active_scaffold_column_#{list_ui}").at_least_once.with {|column, options|
78
+ @controller.view_context_class.any_instance.expects(:"active_scaffold_column_#{list_ui}").at_least_once.with do |column, _|
77
79
  @rendered_columns << column.name
78
80
  true
79
- }
80
- } do
81
+ end
82
+ end
83
+ should "render column #{column_name} as #{list_ui} list_ui", :before => before_block do
81
84
  assert_equal list_ui, @controller.active_scaffold_config.columns[column_name].list_ui
82
85
  assert @rendered_columns.include?(column_name)
83
86
  end
@@ -98,15 +101,16 @@ class ActiveSupport::TestCase
98
101
  end
99
102
 
100
103
  def self.should_render_as_inplace_edit(column_name)
101
- should "render column #{column_name} as inplace edit", :before => lambda{
104
+ before_block = lambda do
102
105
  @column = @controller.active_scaffold_config.columns[column_name]
103
106
  @rendered_columns = []
104
107
  method = @column.list_ui == :checkbox ? :format_column_checkbox : :active_scaffold_inplace_edit
105
- @controller.view_context_class.any_instance.expects(method).at_least_once.with {|model, column, options|
108
+ @controller.view_context_class.any_instance.expects(method).at_least_once.with do |_, column, _|
106
109
  @rendered_columns << column.name
107
110
  true
108
- }
109
- } do
111
+ end
112
+ end
113
+ should "render column #{column_name} as inplace edit", :before => before_block do
110
114
  assert @column.inplace_edit
111
115
  assert @rendered_columns.include?(column_name)
112
116
  end
@@ -120,17 +124,18 @@ class ActiveSupport::TestCase
120
124
  should "respond to parent #{description}" do
121
125
  script = block ? instance_eval(&block) : /.*/
122
126
  script = script.is_a?(Regexp) ? script.source : Regexp.quote(script)
123
- script = script.gsub('\n', '\\\\\\n').
124
- gsub(/['"]/, '\\\\\\\\\&').
125
- gsub('</script>','</scr"+"ipt>')
127
+ script = script.gsub('\n', '\\\\\\n')
128
+ .gsub(/['"]/, '\\\\\\\\\&')
129
+ .gsub('</script>', '</scr"+"ipt>')
126
130
  assert_select 'script[type=text/javascript]', Regexp.new('.*' + Regexp.quote("with(window.parent) { setTimeout(function() { window.eval('") + script + Regexp.quote("'); if (typeof(loc) !== 'undefined') loc.replace('about:blank'); }, 1) };") + '.*')
127
131
  end
128
132
  end
129
133
 
130
134
  private
135
+
131
136
  def column_names(action)
132
137
  columns = []
133
- @controller.active_scaffold_config.send(action).columns.each(:flatten => true) {|col| columns << col.name}
138
+ @controller.active_scaffold_config.send(action).columns.each(:flatten => true) { |col| columns << col.name }
134
139
  columns
135
140
  end
136
141
  end
@@ -4,76 +4,85 @@ class BridgeTest < MiniTest::Test
4
4
  def setup
5
5
  @const_store = {}
6
6
  end
7
-
7
+
8
8
  def teardown
9
9
  end
10
-
10
+
11
11
  def test__shouldnt_throw_errors
12
12
  ActiveScaffold::Bridges.run_all
13
13
  end
14
-
14
+
15
15
  def test__cds_bridge
16
16
  js, ActiveScaffold.js_framework = ActiveScaffold.js_framework, :prototype
17
- ConstMocker.mock("CalendarDateSelect") do |cm|
17
+ ConstMocker.mock('CalendarDateSelect') do |cm|
18
18
  cm.remove
19
- assert(! bridge_will_be_installed("CalendarDateSelect"))
19
+ assert(!bridge_will_be_installed('CalendarDateSelect'))
20
20
  cm.declare
21
- assert(bridge_will_be_installed("CalendarDateSelect"))
21
+ assert(bridge_will_be_installed('CalendarDateSelect'))
22
22
  end
23
23
  ActiveScaffold.js_framework = js
24
24
  end
25
-
25
+
26
26
  def test__file_column_bridge
27
- ConstMocker.mock("FileColumn") do |cm|
28
- cm.remove
29
- assert(! bridge_will_be_installed("FileColumn"))
27
+ ConstMocker.mock('FileColumn') do |cm|
28
+ cm.remove
29
+ assert(!bridge_will_be_installed('FileColumn'))
30
30
  cm.declare
31
- assert(bridge_will_be_installed("FileColumn"))
31
+ assert(bridge_will_be_installed('FileColumn'))
32
32
  end
33
33
  end
34
-
34
+
35
35
  def test__paperclip_bridge
36
- ConstMocker.mock("Paperclip") do |cm|
36
+ ConstMocker.mock('Paperclip') do |cm|
37
37
  cm.remove
38
- assert(! bridge_will_be_installed("Paperclip"))
38
+ assert(!bridge_will_be_installed('Paperclip'))
39
39
  cm.declare
40
- assert(bridge_will_be_installed("Paperclip"))
40
+ assert(bridge_will_be_installed('Paperclip'))
41
41
  end
42
42
  end
43
-
43
+
44
44
  def test__date_picker_bridge
45
- ConstMocker.mock("Jquery") do |jquery|
45
+ ConstMocker.mock('Jquery') do |jquery|
46
46
  jquery.declare
47
- ConstMocker.mock("Rails", jquery.const) do |rails|
47
+ ConstMocker.mock('Rails', jquery.const) do |rails|
48
48
  rails.declare
49
- ConstMocker.mock("Ui", jquery.const) do |cm|
49
+ ConstMocker.mock('Ui', jquery.const) do |cm|
50
50
  cm.remove
51
- assert(! bridge_will_be_installed("DatePicker"))
51
+ assert(!bridge_will_be_installed('DatePicker'))
52
52
  cm.declare
53
- assert(bridge_will_be_installed("DatePicker"))
53
+ assert(bridge_will_be_installed('DatePicker'))
54
54
  end
55
55
  end
56
56
  end
57
57
  end
58
-
58
+
59
59
  def test__semantic_attributes_bridge
60
- ConstMocker.mock("SemanticAttributes") do |cm|
60
+ ConstMocker.mock('SemanticAttributes') do |cm|
61
61
  cm.remove
62
- assert(! bridge_will_be_installed("SemanticAttributes"))
62
+ assert(!bridge_will_be_installed('SemanticAttributes'))
63
63
  cm.declare
64
- assert(bridge_will_be_installed("SemanticAttributes"))
64
+ assert(bridge_will_be_installed('SemanticAttributes'))
65
65
  end
66
66
  end
67
67
 
68
- protected
68
+ def test__paper_trail_bridge
69
+ ConstMocker.mock('PaperTrail') do |cm|
70
+ cm.remove
71
+ assert(!bridge_will_be_installed('PaperTrail'))
72
+ cm.declare
73
+ assert(bridge_will_be_installed('PaperTrail'))
74
+ end
75
+ end
76
+
77
+ protected
69
78
 
70
79
  def find_bridge(name)
71
80
  ActiveScaffold::Bridges[name.to_s.underscore.to_sym]
72
81
  end
73
-
82
+
74
83
  def bridge_will_be_installed(name)
75
- assert bridge=find_bridge(name), "No bridge found matching #{name}"
76
-
84
+ assert bridge = find_bridge(name), "No bridge found matching #{name}"
85
+
77
86
  bridge.install?
78
87
  end
79
88
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
  require File.join(File.dirname(__FILE__), '../../lib/active_scaffold/bridges/date_picker/ext')
3
- #require File.join(File.dirname(__FILE__), '../../lib/active_scaffold/bridges/date_picker/helper')
3
+ # require File.join(File.dirname(__FILE__), '../../lib/active_scaffold/bridges/date_picker/helper')
4
4
 
5
5
  class DatePickerTest < ActionView::TestCase
6
6
  include ActiveScaffold::Helpers::ViewHelpers
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+ ActiveScaffold::Bridges::PaperTrail.prepare
3
+
4
+ class PaperTrailTest < ActionController::TestCase
5
+ tests AddressesController
6
+
7
+ def test_deleted_route
8
+ with_routing do |map|
9
+ map.draw do
10
+ resources :addresses do
11
+ as_routes
12
+ end
13
+ end
14
+ assert_routing '/addresses/deleted', :controller => 'addresses', :action => 'deleted'
15
+ end
16
+ end
17
+ end
@@ -16,7 +16,7 @@ class PaperclipTest < ActionView::TestCase
16
16
  config = PaperclipCore.new(:company)
17
17
  refute config.create.multipart?
18
18
  refute config.update.multipart?
19
- refute config.columns.any? {|column| column.form_ui == :paperclip}
19
+ refute config.columns.any? { |column| column.form_ui == :paperclip }
20
20
  end
21
21
 
22
22
  def test_initialization
@@ -40,7 +40,7 @@ class PaperclipTest < ActionView::TestCase
40
40
 
41
41
  company.expects(:logo).returns(stub(:dirty? => false))
42
42
  company.expects(:logo=)
43
- company.delete_logo = 'true'
43
+ company.delete_logo = 'true' # rubocop:disable Lint/UselessSetterCall
44
44
  end
45
45
 
46
46
  def test_list_ui
@@ -65,5 +65,6 @@ class PaperclipTest < ActionView::TestCase
65
65
 
66
66
  @record.stubs(:logo).returns(stub(:file? => false))
67
67
  assert_dom_equal '<input name="record[logo]" class="text-input" autocomplete="off" type="file" id="record_logo" />', active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo', :object => @record)
68
+ ActiveScaffold.js_framework = js
68
69
  end
69
70
  end
@@ -7,20 +7,23 @@ class TinyMceTest < ActionView::TestCase
7
7
  def test_includes
8
8
  ActiveScaffold::Bridges::TinyMce.expects(:install?).returns(true)
9
9
  ActiveScaffold.js_framework = :jquery
10
- assert ActiveScaffold::Bridges.all_javascripts.include?("tinymce-jquery")
10
+ assert ActiveScaffold::Bridges.all_javascripts.include?('tinymce-jquery')
11
11
  end
12
12
 
13
13
  def test_form_ui
14
14
  config = ActiveScaffold::Config::Core.new(:company)
15
15
  @record = Company.new
16
- self.expects(:request).returns(stub(:xhr? => true))
16
+ expects(:request).returns(stub(:xhr? => true))
17
17
 
18
18
  assert_dom_equal %{<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\">\n</textarea>\n<script#{' type="text/javascript"' if Rails::VERSION::MAJOR < 4}>\n//<![CDATA[\ntinyMCE.settings = {\"theme\":\"simple\"};tinyMCE.execCommand('mceAddControl', false, 'record_name');\n//]]>\n</script>}, active_scaffold_input_text_editor(config.columns[:name], :name => 'record[name]', :id => 'record_name', :class => 'name-input', :object => @record)
19
19
  end
20
20
 
21
21
  protected
22
+
22
23
  def include_tiny_mce_if_needed; end
24
+
23
25
  def tiny_mce_js; end
26
+
24
27
  def using_tiny_mce?
25
28
  true
26
29
  end
@@ -1,13 +1,13 @@
1
1
  class Company < ActiveRecord::Base
2
2
  def initialize(with_or_without = nil)
3
- @with_companies = with_or_without == :with_companies
4
- @with_company = with_or_without == :with_company
5
- @with_main_company = with_or_without == :with_main_company
3
+ @companies = with_or_without == :with_companies
4
+ @company = with_or_without == :with_company
5
+ @main_company = with_or_without == :with_main_company
6
6
  @attributes = {}
7
7
  @attributes_cache = {}
8
8
  @raw_attributes = {}
9
9
  end
10
-
10
+
11
11
  def self.columns_hash
12
12
  {
13
13
  'name' => ColumnMock.new('name', nil, 'varchar(255)'),
@@ -16,28 +16,28 @@ class Company < ActiveRecord::Base
16
16
  'logo_file_name' => ColumnMock.new('logo_file_name', nil, 'varchar(255)'),
17
17
  'logo_content_type' => ColumnMock.new('logo_content_type', nil, 'varchar(255)'),
18
18
  'logo_file_size' => ColumnMock.new('logo_file_size', nil, 'int(11)'),
19
- 'logo_updated_at' => ColumnMock.new('logo_updated_at', nil, 'datetime'),
19
+ 'logo_updated_at' => ColumnMock.new('logo_updated_at', nil, 'datetime')
20
20
  }
21
21
  end
22
22
 
23
23
  def self.columns
24
- self.columns_hash.values
24
+ columns_hash.values
25
25
  end
26
-
26
+
27
27
  def self.class_name
28
- self.name
28
+ name
29
29
  end
30
-
30
+
31
31
  def self.table_name
32
32
  'companies'
33
33
  end
34
-
34
+
35
35
  def self.attachment_definitions
36
36
  {:logo => {}}
37
37
  end
38
-
38
+
39
39
  # not the real signature of the method, but forgive me
40
- def self.before_destroy(s=nil)
40
+ def self.before_destroy(s = nil)
41
41
  @@before = s
42
42
  end
43
43
 
@@ -52,40 +52,35 @@ class Company < ActiveRecord::Base
52
52
  ActiveRecord::Reflection.create *args
53
53
  end
54
54
  end
55
-
55
+
56
56
  def self.has_many(association_id, options = {})
57
- reflection = create_reflection(:has_many, association_id, nil, options, self)
57
+ create_reflection(:has_many, association_id, nil, options, self)
58
58
  end
59
59
  def self.has_one(association_id, options = {})
60
- reflection = create_reflection(:has_one, association_id, nil, options, self)
60
+ create_reflection(:has_one, association_id, nil, options, self)
61
61
  end
62
62
  def self.belongs_to(association_id, options = {})
63
- reflection = create_reflection(:belongs_to, association_id, nil, options, self)
63
+ create_reflection(:belongs_to, association_id, nil, options, self)
64
64
  end
65
65
  has_many :companies
66
66
  has_one :company
67
67
  belongs_to :main_company, :class_name => 'Company'
68
-
68
+
69
69
  def companies
70
- if @with_companies
70
+ if @companies
71
71
  [nil]
72
72
  else
73
73
  []
74
74
  end
75
75
  end
76
-
77
- def company
78
- @with_company
79
- end
80
-
81
- def main_company
82
- @with_main_company
83
- end
84
-
85
- def name
86
- end
76
+
77
+ attr_reader :company
78
+ attr_reader :main_company
79
+
80
+ def name; end
81
+
87
82
  def name_before_type_cast
88
- self.name.to_s
83
+ name.to_s
89
84
  end
90
85
 
91
86
  def date
@@ -5,7 +5,7 @@ module Config
5
5
  def setup
6
6
  @base = ActiveScaffold::Config::Base.new(ActiveScaffold::Config::Core.new(:model_stub))
7
7
  end
8
-
8
+
9
9
  def test_formats
10
10
  assert_equal [], @base.formats
11
11
  @base.formats << :pdf
@@ -9,7 +9,7 @@ module Config
9
9
  @config = ActiveScaffold::Config::Core.new :model_stub
10
10
  ModelStubsController.instance_variable_set :@active_scaffold_config, @config
11
11
  end
12
-
12
+
13
13
  def test_default_options
14
14
  refute @config.add_sti_create_links?
15
15
  refute @config.sti_children
@@ -19,48 +19,48 @@ module Config
19
19
  assert_equal 'Model stub', @config.label(:count => 1)
20
20
  assert_equal 'ModelStubs', @config.label
21
21
  end
22
-
22
+
23
23
  def test_add_sti_children
24
24
  @config.sti_create_links = true
25
25
  refute @config.add_sti_create_links?
26
26
  @config.sti_children = [:a]
27
27
  assert @config.add_sti_create_links?
28
28
  end
29
-
29
+
30
30
  def test_sti_children
31
31
  @config.sti_children = [:a]
32
32
  assert_equal [:a], @config.sti_children
33
33
  end
34
-
34
+
35
35
  def test_actions
36
36
  assert @config.actions.include?(:create)
37
37
  @config.actions = [:list]
38
38
  refute @config.actions.include?(:create)
39
39
  assert_equal [:list], @config.actions.to_a
40
40
  end
41
-
41
+
42
42
  def test_form_ui_in_sti
43
43
  @config.columns << :type
44
-
44
+
45
45
  @config.sti_create_links = false
46
46
  @config.sti_children = [:model_stub]
47
47
  @config._configure_sti
48
48
  assert_equal :select, @config.columns[:type].form_ui
49
49
  assert_equal [['Model stub', 'ModelStub']], @config.columns[:type].options[:options]
50
-
50
+
51
51
  @config.columns[:type].form_ui = nil
52
52
  @config.sti_create_links = true
53
53
  @config._configure_sti
54
54
  assert_equal :hidden, @config.columns[:type].form_ui
55
55
  end
56
-
56
+
57
57
  def test_sti_children_links
58
58
  @config.sti_children = [:model_stub]
59
59
  @config.sti_create_links = true
60
60
  @config.action_links.add @config.create.link
61
61
  ModelStubsController.send(:_add_sti_create_links)
62
62
  assert_equal 'Create Model stub', @config.action_links[:new].label
63
- assert_equal 'config/core_test/model_stubs', @config.action_links[:new].parameters[:parent_sti]
63
+ assert_equal 'rb_config/core_test/model_stubs', @config.action_links[:new].parameters[:parent_sti]
64
64
  end
65
65
  end
66
66
  end