dry_crud 7.1.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/crud_controller.rb +5 -7
  4. data/app/controllers/dry_crud/generic_model.rb +4 -8
  5. data/app/controllers/dry_crud/nestable.rb +1 -4
  6. data/app/controllers/dry_crud/rememberable.rb +1 -4
  7. data/app/controllers/dry_crud/render_callbacks.rb +2 -10
  8. data/app/controllers/dry_crud/searchable.rb +3 -10
  9. data/app/controllers/dry_crud/sortable.rb +3 -10
  10. data/app/controllers/list_controller.rb +0 -2
  11. data/app/helpers/actions_helper.rb +8 -10
  12. data/app/helpers/dry_crud/form/builder.rb +23 -26
  13. data/app/helpers/dry_crud/form/control.rb +7 -11
  14. data/app/helpers/dry_crud/table/actions.rb +8 -13
  15. data/app/helpers/dry_crud/table/builder.rb +3 -6
  16. data/app/helpers/dry_crud/table/col.rb +1 -4
  17. data/app/helpers/dry_crud/table/sorting.rb +3 -6
  18. data/app/helpers/form_helper.rb +5 -7
  19. data/app/helpers/format_helper.rb +11 -13
  20. data/app/helpers/i18n_helper.rb +8 -10
  21. data/app/helpers/table_helper.rb +2 -4
  22. data/app/helpers/utility_helper.rb +9 -11
  23. data/app/views/layouts/application.html.erb +1 -1
  24. data/app/views/layouts/application.html.haml +1 -1
  25. data/lib/dry_crud/engine.rb +1 -3
  26. data/lib/dry_crud.rb +1 -1
  27. data/lib/generators/dry_crud/dry_crud_generator.rb +17 -17
  28. data/lib/generators/dry_crud/dry_crud_generator_base.rb +8 -8
  29. data/lib/generators/dry_crud/file_generator.rb +6 -6
  30. data/lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb +1 -1
  31. data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +119 -119
  32. data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb +54 -59
  33. data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/table/builder_spec.rb +23 -25
  34. data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +10 -13
  35. data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +88 -92
  36. data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +33 -34
  37. data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +57 -59
  38. data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +18 -21
  39. data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +62 -62
  40. data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +8 -10
  41. data/lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb +63 -65
  42. data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +20 -22
  43. data/lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb +74 -74
  44. data/lib/generators/dry_crud/templates/test/helpers/dry_crud/table/builder_test.rb +21 -21
  45. data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +13 -15
  46. data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +68 -70
  47. data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +26 -28
  48. data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +25 -27
  49. data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +15 -17
  50. data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +13 -15
  51. data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +9 -13
  52. data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +7 -11
  53. data/lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb +13 -15
  54. data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +2 -4
  55. metadata +5 -5
@@ -1,9 +1,8 @@
1
- require 'test_helper'
2
- require 'support/crud_test_model'
1
+ require "test_helper"
2
+ require "support/crud_test_model"
3
3
 
4
4
  # Test FormatHelper
5
5
  class FormatHelperTest < ActionView::TestCase
6
-
7
6
  include UtilityHelper
8
7
  include I18nHelper
9
8
  include CrudTestHelper
@@ -19,167 +18,166 @@ class FormatHelperTest < ActionView::TestCase
19
18
  "#{f(obj.size)} chars"
20
19
  end
21
20
 
22
- test 'labeled text as block' do
23
- result = labeled('label') { 'value' }
21
+ test "labeled text as block" do
22
+ result = labeled("label") { "value" }
24
23
 
25
24
  assert result.html_safe?
26
- assert_dom_equal '<dt>label</dt> ' \
25
+ assert_dom_equal "<dt>label</dt> " \
27
26
  "<dd class='value'>value</dd>",
28
27
  result.squish
29
28
  end
30
29
 
31
- test 'labeled text empty' do
32
- result = labeled('label', '')
30
+ test "labeled text empty" do
31
+ result = labeled("label", "")
33
32
 
34
33
  assert result.html_safe?
35
- assert_dom_equal '<dt>label</dt> ' \
34
+ assert_dom_equal "<dt>label</dt> " \
36
35
  "<dd class='value'>#{EMPTY_STRING}</dd>",
37
36
  result.squish
38
37
  end
39
38
 
40
- test 'labeled text as content' do
41
- result = labeled('label', 'value <unsafe>')
39
+ test "labeled text as content" do
40
+ result = labeled("label", "value <unsafe>")
42
41
 
43
42
  assert result.html_safe?
44
- assert_dom_equal '<dt>label</dt> ' \
43
+ assert_dom_equal "<dt>label</dt> " \
45
44
  "<dd class='value'>value &lt;unsafe&gt;</dd>",
46
45
  result.squish
47
46
  end
48
47
 
49
- test 'labeled attr' do
50
- result = labeled_attr('foo', :size)
48
+ test "labeled attr" do
49
+ result = labeled_attr("foo", :size)
51
50
  assert result.html_safe?
52
- assert_dom_equal '<dt>Size</dt> ' \
51
+ assert_dom_equal "<dt>Size</dt> " \
53
52
  "<dd class='value'>3 chars</dd>",
54
53
  result.squish
55
54
  end
56
55
 
57
- test 'format nil' do
56
+ test "format nil" do
58
57
  assert EMPTY_STRING.html_safe?
59
58
  assert_equal EMPTY_STRING, f(nil)
60
59
  end
61
60
 
62
- test 'format Strings' do
63
- assert_equal 'blah blah', f('blah blah')
64
- assert_equal '<injection>', f('<injection>')
65
- assert_not f('<injection>').html_safe?
61
+ test "format Strings" do
62
+ assert_equal "blah blah", f("blah blah")
63
+ assert_equal "<injection>", f("<injection>")
64
+ assert_not f("<injection>").html_safe?
66
65
  end
67
66
 
68
- unless ENV['NON_LOCALIZED'] # localization dependent tests
69
- test 'format Floats' do
70
- assert_equal '1.000', f(1.0)
71
- assert_equal '1.200', f(1.2)
72
- assert_equal '3.142', f(3.14159)
67
+ unless ENV["NON_LOCALIZED"] # localization dependent tests
68
+ test "format Floats" do
69
+ assert_equal "1.000", f(1.0)
70
+ assert_equal "1.200", f(1.2)
71
+ assert_equal "3.142", f(3.14159)
73
72
  end
74
73
 
75
- test 'format Booleans' do
76
- assert_equal 'yes', f(true)
77
- assert_equal 'no', f(false)
74
+ test "format Booleans" do
75
+ assert_equal "yes", f(true)
76
+ assert_equal "no", f(false)
78
77
  end
79
78
 
80
- test 'format attr with fallthrough to f' do
81
- assert_equal '12.234', format_attr('12.23424', :to_f)
79
+ test "format attr with fallthrough to f" do
80
+ assert_equal "12.234", format_attr("12.23424", :to_f)
82
81
  end
83
82
  end
84
83
 
85
- test 'format attr with custom format_string_size method' do
86
- assert_equal '4 chars', format_attr('abcd', :size)
84
+ test "format attr with custom format_string_size method" do
85
+ assert_equal "4 chars", format_attr("abcd", :size)
87
86
  end
88
87
 
89
- test 'format attr with custom format_size method' do
90
- assert_equal '2 items', format_attr([1, 2], :size)
88
+ test "format attr with custom format_size method" do
89
+ assert_equal "2 items", format_attr([ 1, 2 ], :size)
91
90
  end
92
91
 
93
- test 'format integer column' do
92
+ test "format integer column" do
94
93
  m = crud_test_models(:AAAAA)
95
- assert_equal '9', format_type(m, :children)
94
+ assert_equal "9", format_type(m, :children)
96
95
 
97
96
  m.children = 10_000
98
- assert_equal '10,000', format_type(m, :children)
97
+ assert_equal "10,000", format_type(m, :children)
99
98
  end
100
99
 
101
- unless ENV['NON_LOCALIZED'] # localization dependent tests
102
- test 'format float column' do
100
+ unless ENV["NON_LOCALIZED"] # localization dependent tests
101
+ test "format float column" do
103
102
  m = crud_test_models(:AAAAA)
104
- assert_equal '1.100', format_type(m, :rating)
103
+ assert_equal "1.100", format_type(m, :rating)
105
104
 
106
105
  m.rating = 3.145001 # you never know with these floats..
107
- assert_equal '3.145', format_type(m, :rating)
106
+ assert_equal "3.145", format_type(m, :rating)
108
107
  end
109
108
 
110
- test 'format decimal column' do
109
+ test "format decimal column" do
111
110
  m = crud_test_models(:AAAAA)
112
- assert_equal '10,000,000.1111', format_type(m, :income)
111
+ assert_equal "10,000,000.1111", format_type(m, :income)
113
112
  end
114
113
 
115
- test 'format date column' do
114
+ test "format date column" do
116
115
  m = crud_test_models(:AAAAA)
117
- assert_equal '1910-01-01', format_type(m, :birthdate)
116
+ assert_equal "1910-01-01", format_type(m, :birthdate)
118
117
  end
119
118
 
120
- test 'format datetime column' do
119
+ test "format datetime column" do
121
120
  m = crud_test_models(:AAAAA)
122
- assert_equal '2010-01-01 11:21', format_type(m, :last_seen)
121
+ assert_equal "2010-01-01 11:21", format_type(m, :last_seen)
123
122
  end
124
123
  end
125
124
 
126
- test 'format time column' do
125
+ test "format time column" do
127
126
  m = crud_test_models(:AAAAA)
128
- assert_equal '01:01', format_type(m, :gets_up_at)
127
+ assert_equal "01:01", format_type(m, :gets_up_at)
129
128
  end
130
129
 
131
- test 'format text column' do
130
+ test "format text column" do
132
131
  m = crud_test_models(:AAAAA)
133
132
  assert_equal "<p>AAAAA BBBBB CCCCC\n<br />AAAAA BBBBB CCCCC\n</p>",
134
133
  format_type(m, :remarks)
135
134
  assert format_type(m, :remarks).html_safe?
136
135
  end
137
136
 
138
- test 'format boolean false column' do
137
+ test "format boolean false column" do
139
138
  m = crud_test_models(:AAAAA)
140
139
  m.human = false
141
- assert_equal 'no', format_type(m, :human)
140
+ assert_equal "no", format_type(m, :human)
142
141
  end
143
142
 
144
- test 'format boolean true column' do
143
+ test "format boolean true column" do
145
144
  m = crud_test_models(:AAAAA)
146
145
  m.human = true
147
- assert_equal 'yes', format_type(m, :human)
146
+ assert_equal "yes", format_type(m, :human)
148
147
  end
149
148
 
150
- test 'format belongs to column without content' do
149
+ test "format belongs to column without content" do
151
150
  m = crud_test_models(:AAAAA)
152
- assert_equal t('global.associations.no_entry'),
151
+ assert_equal t("global.associations.no_entry"),
153
152
  format_attr(m, :companion)
154
153
  end
155
154
 
156
- test 'format belongs to column with content' do
155
+ test "format belongs to column with content" do
157
156
  m = crud_test_models(:BBBBB)
158
- assert_equal 'AAAAA', format_attr(m, :companion)
157
+ assert_equal "AAAAA", format_attr(m, :companion)
159
158
  end
160
159
 
161
- test 'format has one without content' do
160
+ test "format has one without content" do
162
161
  m = crud_test_models(:FFFFF)
163
- assert_equal t('global.associations.no_entry'),
162
+ assert_equal t("global.associations.no_entry"),
164
163
  format_attr(m, :comrad)
165
164
  end
166
165
 
167
- test 'format has one with content' do
166
+ test "format has one with content" do
168
167
  m = crud_test_models(:AAAAA)
169
- assert_equal 'BBBBB', format_attr(m, :comrad)
168
+ assert_equal "BBBBB", format_attr(m, :comrad)
170
169
  end
171
170
 
172
- test 'format has_many column with content' do
171
+ test "format has_many column with content" do
173
172
  m = crud_test_models(:CCCCC)
174
- assert_equal '<ul><li>AAAAA</li><li>BBBBB</li></ul>',
173
+ assert_equal "<ul><li>AAAAA</li><li>BBBBB</li></ul>",
175
174
  format_attr(m, :others)
176
175
  end
177
176
 
178
- test 'captionize' do
179
- assert_equal 'Camel Case', captionize(:camel_case)
180
- assert_equal 'All Upper Case', captionize('all upper case')
181
- assert_equal 'With Object', captionize('With object', Object.new)
182
- assert_not captionize('bad <title>').html_safe?
177
+ test "captionize" do
178
+ assert_equal "Camel Case", captionize(:camel_case)
179
+ assert_equal "All Upper Case", captionize("all upper case")
180
+ assert_equal "With Object", captionize("With object", Object.new)
181
+ assert_not captionize("bad <title>").html_safe?
183
182
  end
184
-
185
183
  end
@@ -1,79 +1,78 @@
1
- require 'test_helper'
2
- require 'support/crud_test_model'
3
- require 'support/crud_test_models_controller'
1
+ require "test_helper"
2
+ require "support/crud_test_model"
3
+ require "support/crud_test_models_controller"
4
4
 
5
5
  # Test I18nHelper
6
6
  class I18nHelperTest < ActionView::TestCase
7
-
8
7
  include CrudTestHelper
9
8
 
10
- test 'translate inheritable lookup' do
9
+ test "translate inheritable lookup" do
11
10
  # current controller is :crud_test_models, action is :index
12
11
  @controller = CrudTestModelsController.new
13
12
 
14
13
  I18n.backend.store_translations(
15
14
  I18n.locale,
16
- global: { test_key: 'global' }
15
+ global: { test_key: "global" }
17
16
  )
18
- assert_equal 'global', ti(:test_key)
17
+ assert_equal "global", ti(:test_key)
19
18
 
20
19
  I18n.backend.store_translations(
21
20
  I18n.locale,
22
- list: { global: { test_key: 'list global' } }
21
+ list: { global: { test_key: "list global" } }
23
22
  )
24
- assert_equal 'list global', ti(:test_key)
23
+ assert_equal "list global", ti(:test_key)
25
24
 
26
25
  I18n.backend.store_translations(
27
26
  I18n.locale,
28
- list: { index: { test_key: 'list index' } }
27
+ list: { index: { test_key: "list index" } }
29
28
  )
30
- assert_equal 'list index', ti(:test_key)
29
+ assert_equal "list index", ti(:test_key)
31
30
 
32
31
  I18n.backend.store_translations(
33
32
  I18n.locale,
34
- crud: { global: { test_key: 'crud global' } }
33
+ crud: { global: { test_key: "crud global" } }
35
34
  )
36
- assert_equal 'crud global', ti(:test_key)
35
+ assert_equal "crud global", ti(:test_key)
37
36
 
38
37
  I18n.backend.store_translations(
39
38
  I18n.locale,
40
- crud: { index: { test_key: 'crud index' } }
39
+ crud: { index: { test_key: "crud index" } }
41
40
  )
42
- assert_equal 'crud index', ti(:test_key)
41
+ assert_equal "crud index", ti(:test_key)
43
42
 
44
43
  I18n.backend.store_translations(
45
44
  I18n.locale,
46
- crud_test_models: { global: { test_key: 'test global' } }
45
+ crud_test_models: { global: { test_key: "test global" } }
47
46
  )
48
- assert_equal 'test global', ti(:test_key)
47
+ assert_equal "test global", ti(:test_key)
49
48
 
50
49
  I18n.backend.store_translations(
51
50
  I18n.locale,
52
- crud_test_models: { index: { test_key: 'test index' } }
51
+ crud_test_models: { index: { test_key: "test index" } }
53
52
  )
54
- assert_equal 'test index', ti(:test_key)
53
+ assert_equal "test index", ti(:test_key)
55
54
  end
56
55
 
57
- test 'translate association lookup' do
56
+ test "translate association lookup" do
58
57
  assoc = CrudTestModel.reflect_on_association(:companion)
59
58
 
60
59
  I18n.backend.store_translations(
61
60
  I18n.locale,
62
- global: { associations: { test_key: 'global' } }
61
+ global: { associations: { test_key: "global" } }
63
62
  )
64
- assert_equal 'global', ta(:test_key, assoc)
63
+ assert_equal "global", ta(:test_key, assoc)
65
64
 
66
65
  I18n.backend.store_translations(
67
66
  I18n.locale,
68
67
  activerecord: {
69
68
  associations: {
70
69
  crud_test_model: {
71
- test_key: 'model'
70
+ test_key: "model"
72
71
  }
73
72
  }
74
73
  }
75
74
  )
76
- assert_equal 'model', ta(:test_key, assoc)
75
+ assert_equal "model", ta(:test_key, assoc)
77
76
 
78
77
  I18n.backend.store_translations(
79
78
  I18n.locale,
@@ -82,16 +81,15 @@ class I18nHelperTest < ActionView::TestCase
82
81
  models: {
83
82
  crud_test_model: {
84
83
  companion: {
85
- test_key: 'companion'
84
+ test_key: "companion"
86
85
  }
87
86
  }
88
87
  }
89
88
  }
90
89
  }
91
90
  )
92
- assert_equal 'companion', ta(:test_key, assoc)
91
+ assert_equal "companion", ta(:test_key, assoc)
93
92
 
94
- assert_equal 'global', ta(:test_key)
93
+ assert_equal "global", ta(:test_key)
95
94
  end
96
-
97
95
  end
@@ -1,10 +1,9 @@
1
- require 'test_helper'
2
- require 'support/custom_assertions'
3
- require 'support/crud_test_model'
1
+ require "test_helper"
2
+ require "support/custom_assertions"
3
+ require "support/crud_test_model"
4
4
 
5
5
  # Test TableHelper
6
6
  class TableHelperTest < ActionView::TestCase
7
-
8
7
  include UtilityHelper
9
8
  include FormatHelper
10
9
  include I18nHelper
@@ -30,13 +29,13 @@ class TableHelperTest < ActionView::TestCase
30
29
  @params = {}
31
30
  end
32
31
 
33
- test 'empty table renders message' do
32
+ test "empty table renders message" do
34
33
  result = plain_table_or_message([])
35
34
  assert result.html_safe?
36
35
  assert_match(/<div class=["']table["']>.*<\/div>/, result)
37
36
  end
38
37
 
39
- test 'non empty table renders table' do
38
+ test "non empty table renders table" do
40
39
  result = plain_table_or_message(%w[foo bar]) do |t|
41
40
  t.attrs :size, :upcase
42
41
  end
@@ -44,10 +43,10 @@ class TableHelperTest < ActionView::TestCase
44
43
  assert_match(/^<table.*<\/table>$/, result)
45
44
  end
46
45
 
47
- test 'table with attrs' do
46
+ test "table with attrs" do
48
47
  expected = DryCrud::Table::Builder.table(
49
48
  %w[foo bar], self,
50
- class: 'table table-striped table-hover'
49
+ class: "table table-striped table-hover"
51
50
  ) do |t|
52
51
  t.attrs :size, :upcase
53
52
  end
@@ -56,7 +55,7 @@ class TableHelperTest < ActionView::TestCase
56
55
  assert_equal expected, actual
57
56
  end
58
57
 
59
- test 'standard list table' do
58
+ test "standard list table" do
60
59
  @entries = CrudTestModel.all
61
60
 
62
61
  table = with_test_routing do
@@ -67,7 +66,7 @@ class TableHelperTest < ActionView::TestCase
67
66
  assert_count 14, REGEXP_SORT_HEADERS, table
68
67
  end
69
68
 
70
- test 'custom list table with attributes' do
69
+ test "custom list table with attributes" do
71
70
  @entries = CrudTestModel.all
72
71
 
73
72
  table = with_test_routing do
@@ -78,13 +77,13 @@ class TableHelperTest < ActionView::TestCase
78
77
  assert_count 3, REGEXP_SORT_HEADERS, table
79
78
  end
80
79
 
81
- test 'custom list table with block' do
80
+ test "custom list table with block" do
82
81
  @entries = CrudTestModel.all
83
82
 
84
83
  table = with_test_routing do
85
84
  list_table do |t|
86
85
  t.attrs :name, :children, :companion_id
87
- t.col('head') { |e| tag.span(e.income.to_s) }
86
+ t.col("head") { |e| tag.span(e.income.to_s) }
88
87
  end
89
88
  end
90
89
 
@@ -94,12 +93,12 @@ class TableHelperTest < ActionView::TestCase
94
93
  assert_count 6, /<span>.+?<\/span>/, table
95
94
  end
96
95
 
97
- test 'custom list table with attributes and block' do
96
+ test "custom list table with attributes and block" do
98
97
  @entries = CrudTestModel.all
99
98
 
100
99
  table = with_test_routing do
101
100
  list_table :name, :children, :companion_id do |t|
102
- t.col('head') { |e| tag.span(e.income.to_s) }
101
+ t.col("head") { |e| tag.span(e.income.to_s) }
103
102
  end
104
103
  end
105
104
 
@@ -109,8 +108,8 @@ class TableHelperTest < ActionView::TestCase
109
108
  assert_count 6, /<span>.+?<\/span>/, table
110
109
  end
111
110
 
112
- test 'standard list table with ascending sort params' do
113
- @params = { sort: 'children', sort_dir: 'asc' }
111
+ test "standard list table with ascending sort params" do
112
+ @params = { sort: "children", sort_dir: "asc" }
114
113
  @entries = CrudTestModel.all
115
114
 
116
115
  table = with_test_routing do
@@ -123,8 +122,8 @@ class TableHelperTest < ActionView::TestCase
123
122
  assert_count 1, sort_header_desc, table
124
123
  end
125
124
 
126
- test 'standard list table with descending sort params' do
127
- @params = { sort: 'children', sort_dir: 'desc' }
125
+ test "standard list table with descending sort params" do
126
+ @params = { sort: "children", sort_dir: "desc" }
128
127
  @entries = CrudTestModel.all
129
128
 
130
129
  table = with_test_routing do
@@ -137,8 +136,8 @@ class TableHelperTest < ActionView::TestCase
137
136
  assert_count 1, sort_header_asc, table
138
137
  end
139
138
 
140
- test 'list table with custom column sort params' do
141
- @params = { sort: 'chatty', sort_dir: 'asc' }
139
+ test "list table with custom column sort params" do
140
+ @params = { sort: "chatty", sort_dir: "asc" }
142
141
  @entries = CrudTestModel.all
143
142
 
144
143
  table = with_test_routing do
@@ -151,7 +150,7 @@ class TableHelperTest < ActionView::TestCase
151
150
  assert_count 1, sort_header_desc, table
152
151
  end
153
152
 
154
- test 'standard crud table' do
153
+ test "standard crud table" do
155
154
  @entries = CrudTestModel.all
156
155
 
157
156
  table = with_test_routing do
@@ -163,7 +162,7 @@ class TableHelperTest < ActionView::TestCase
163
162
  assert_count 12, REGEXP_ACTION_CELL, table # edit, delete links
164
163
  end
165
164
 
166
- test 'custom crud table with attributes' do
165
+ test "custom crud table with attributes" do
167
166
  @entries = CrudTestModel.all
168
167
 
169
168
  table = with_test_routing do
@@ -175,13 +174,13 @@ class TableHelperTest < ActionView::TestCase
175
174
  assert_count 12, REGEXP_ACTION_CELL, table # edit, delete links
176
175
  end
177
176
 
178
- test 'custom crud table with block' do
177
+ test "custom crud table with block" do
179
178
  @entries = CrudTestModel.all
180
179
 
181
180
  table = with_test_routing do
182
181
  crud_table do |t|
183
182
  t.attrs :name, :children, :companion_id
184
- t.col('head') { |e| tag.span(e.income.to_s) }
183
+ t.col("head") { |e| tag.span(e.income.to_s) }
185
184
  end
186
185
  end
187
186
 
@@ -191,12 +190,12 @@ class TableHelperTest < ActionView::TestCase
191
190
  assert_count 12, REGEXP_ACTION_CELL, table # edit, delete links
192
191
  end
193
192
 
194
- test 'custom crud table with attributes and block' do
193
+ test "custom crud table with attributes and block" do
195
194
  @entries = CrudTestModel.all
196
195
 
197
196
  table = with_test_routing do
198
197
  crud_table :name, :children, :companion_id do |t|
199
- t.col('head') { |e| tag.span(e.income.to_s) }
198
+ t.col("head") { |e| tag.span(e.income.to_s) }
200
199
  end
201
200
  end
202
201
 
@@ -210,5 +209,4 @@ class TableHelperTest < ActionView::TestCase
210
209
  def entry
211
210
  @entry ||= CrudTestModel.first
212
211
  end
213
-
214
212
  end
@@ -1,47 +1,46 @@
1
- require 'test_helper'
2
- require 'support/crud_test_model'
1
+ require "test_helper"
2
+ require "support/crud_test_model"
3
3
 
4
4
  # Test UtilityHelper
5
5
  class UtilityHelperTest < ActionView::TestCase
6
-
7
6
  include CrudTestHelper
8
7
 
9
8
  setup :reset_db, :setup_db, :create_test_data
10
9
  teardown :reset_db
11
10
 
12
- test 'content_tag_nested escapes safe correctly' do
11
+ test "content_tag_nested escapes safe correctly" do
13
12
  html = content_tag_nested(:div, %w[a b]) { |e| tag.span(e) }
14
- assert_equal '<div><span>a</span><span>b</span></div>', html
13
+ assert_equal "<div><span>a</span><span>b</span></div>", html
15
14
  end
16
15
 
17
- test 'content_tag_nested escapes unsafe correctly' do
16
+ test "content_tag_nested escapes unsafe correctly" do
18
17
  html = content_tag_nested(:div, %w[a b]) { |e| "<#{e}>" }
19
- assert_equal '<div>&lt;a&gt;&lt;b&gt;</div>', html
18
+ assert_equal "<div>&lt;a&gt;&lt;b&gt;</div>", html
20
19
  end
21
20
 
22
- test 'content_tag_nested without block' do
21
+ test "content_tag_nested without block" do
23
22
  html = content_tag_nested(:div, %w[a b])
24
- assert_equal '<div>ab</div>', html
23
+ assert_equal "<div>ab</div>", html
25
24
  end
26
25
 
27
- test 'safe_join without block' do
28
- html = safe_join(['<a>', '<b>'.html_safe])
29
- assert_equal '&lt;a&gt;<b>', html
26
+ test "safe_join without block" do
27
+ html = safe_join([ "<a>", "<b>".html_safe ])
28
+ assert_equal "&lt;a&gt;<b>", html
30
29
  end
31
30
 
32
- test 'safe_join with block' do
31
+ test "safe_join with block" do
33
32
  html = safe_join(%w[a b]) { |e| tag.span(e) }
34
- assert_equal '<span>a</span><span>b</span>', html
33
+ assert_equal "<span>a</span><span>b</span>", html
35
34
  end
36
35
 
37
- test 'default attributes do not include id and password' do
36
+ test "default attributes do not include id and password" do
38
37
  assert_equal %i[name email whatever children companion_id rating
39
38
  income birthdate gets_up_at last_seen human
40
39
  remarks created_at updated_at],
41
40
  default_crud_attrs
42
41
  end
43
42
 
44
- test 'column types' do
43
+ test "column types" do
45
44
  m = crud_test_models(:AAAAA)
46
45
  assert_equal :string, column_type(m, :name)
47
46
  assert_equal :integer, column_type(m, :children)
@@ -55,5 +54,4 @@ class UtilityHelperTest < ActionView::TestCase
55
54
  assert_equal :boolean, column_type(m, :human)
56
55
  assert_equal :text, column_type(m, :remarks)
57
56
  end
58
-
59
57
  end