dry_crud 5.0.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/sample.scss +8 -11
- data/app/controllers/crud_controller.rb +63 -45
- data/app/controllers/dry_crud/generic_model.rb +0 -2
- data/app/controllers/dry_crud/nestable.rb +0 -2
- data/app/controllers/dry_crud/rememberable.rb +1 -3
- data/app/controllers/dry_crud/render_callbacks.rb +0 -2
- data/app/controllers/dry_crud/searchable.rb +0 -2
- data/app/controllers/dry_crud/sortable.rb +1 -3
- data/app/controllers/list_controller.rb +0 -2
- data/app/helpers/actions_helper.rb +1 -3
- data/app/helpers/dry_crud/form/builder.rb +7 -8
- data/app/helpers/dry_crud/form/control.rb +3 -5
- data/app/helpers/dry_crud/table/actions.rb +10 -12
- data/app/helpers/dry_crud/table/builder.rb +4 -6
- data/app/helpers/dry_crud/table/col.rb +0 -2
- data/app/helpers/dry_crud/table/sorting.rb +4 -6
- data/app/helpers/form_helper.rb +1 -3
- data/app/helpers/format_helper.rb +4 -5
- data/app/helpers/i18n_helper.rb +0 -2
- data/app/helpers/table_helper.rb +0 -2
- data/app/helpers/utility_helper.rb +1 -2
- data/app/views/layouts/_nav.html.erb +4 -4
- data/app/views/layouts/_nav.html.haml +4 -4
- data/app/views/layouts/application.html.erb +3 -23
- data/app/views/layouts/application.html.haml +3 -21
- data/app/views/list/_search.html.erb +4 -4
- data/app/views/list/_search.html.haml +2 -2
- data/config/locales/crud.it.yml +64 -0
- data/lib/dry_crud.rb +1 -0
- data/lib/dry_crud/engine.rb +9 -3
- data/lib/generators/dry_crud/dry_crud_generator.rb +3 -5
- data/lib/generators/dry_crud/dry_crud_generator_base.rb +5 -4
- data/lib/generators/dry_crud/file_generator.rb +11 -5
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +48 -23
- data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb +6 -8
- data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/table/builder_spec.rb +1 -2
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +0 -1
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +23 -7
- data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +43 -11
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +8 -6
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +8 -8
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +32 -35
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +1 -3
- data/lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb +38 -17
- data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +0 -1
- data/lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb +6 -6
- data/lib/generators/dry_crud/templates/test/helpers/dry_crud/table/builder_test.rb +1 -2
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +1 -2
- data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +13 -3
- data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +28 -11
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +5 -5
- data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +11 -18
- data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +5 -7
- data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +17 -16
- data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +4 -4
- data/lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb +11 -6
- data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +1 -3
- metadata +14 -12
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
require 'support/crud_test_model'
|
4
3
|
|
@@ -27,7 +26,8 @@ module DryCrud
|
|
27
26
|
assert_equal form.with_addon(
|
28
27
|
form.string_field(:name,
|
29
28
|
required: 'required'),
|
30
|
-
'*'
|
29
|
+
'*'
|
30
|
+
),
|
31
31
|
form.input_field(:name)
|
32
32
|
assert form.string_field(:name).html_safe?
|
33
33
|
end
|
@@ -97,15 +97,15 @@ module DryCrud
|
|
97
97
|
|
98
98
|
test 'labeld_input_field adds required mark' do
|
99
99
|
result = form.labeled_input_field(:name)
|
100
|
-
assert result.include?('input-group-
|
100
|
+
assert result.include?('input-group-append')
|
101
101
|
result = form.labeled_input_field(:remarks)
|
102
|
-
|
102
|
+
assert_not result.include?('input-group-append')
|
103
103
|
end
|
104
104
|
|
105
105
|
test 'labeld_input_field adds help text' do
|
106
106
|
result = form.labeled_input_field(:name, help: 'Some Help')
|
107
107
|
assert result.include?(form.help_block('Some Help'))
|
108
|
-
assert result.include?('input-group-
|
108
|
+
assert result.include?('input-group-append')
|
109
109
|
end
|
110
110
|
|
111
111
|
test 'belongs_to_field has all options by default' do
|
@@ -242,7 +242,7 @@ module DryCrud
|
|
242
242
|
end
|
243
243
|
|
244
244
|
test 'respond to still works' do
|
245
|
-
|
245
|
+
assert_not form.respond_to?(:blalba)
|
246
246
|
assert form.respond_to?(:text_field)
|
247
247
|
assert form.respond_to?(:labeled_text_field)
|
248
248
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
|
4
3
|
module DryCrud
|
@@ -13,7 +12,7 @@ module DryCrud
|
|
13
12
|
attr_reader :table, :entries
|
14
13
|
|
15
14
|
def setup
|
16
|
-
@entries = %w
|
15
|
+
@entries = %w[foo bahr]
|
17
16
|
@table = DryCrud::Table::Builder.new(entries, self)
|
18
17
|
end
|
19
18
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
require 'support/crud_test_model'
|
4
3
|
require 'support/crud_test_helper'
|
@@ -73,7 +72,7 @@ class FormHelperTest < ActionView::TestCase
|
|
73
72
|
test 'standard form with errors' do
|
74
73
|
e = crud_test_models('AAAAA')
|
75
74
|
e.name = nil
|
76
|
-
|
75
|
+
assert_not e.valid?
|
77
76
|
|
78
77
|
f = with_test_routing do
|
79
78
|
capture do
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
require 'support/crud_test_model'
|
4
3
|
|
@@ -63,7 +62,7 @@ class FormatHelperTest < ActionView::TestCase
|
|
63
62
|
test 'format Strings' do
|
64
63
|
assert_equal 'blah blah', f('blah blah')
|
65
64
|
assert_equal '<injection>', f('<injection>')
|
66
|
-
|
65
|
+
assert_not f('<injection>').html_safe?
|
67
66
|
end
|
68
67
|
|
69
68
|
unless ENV['NON_LOCALIZED'] # localization dependent tests
|
@@ -159,6 +158,17 @@ class FormatHelperTest < ActionView::TestCase
|
|
159
158
|
assert_equal 'AAAAA', format_attr(m, :companion)
|
160
159
|
end
|
161
160
|
|
161
|
+
test 'format has one without content' do
|
162
|
+
m = crud_test_models(:FFFFF)
|
163
|
+
assert_equal t('global.associations.no_entry'),
|
164
|
+
format_attr(m, :comrad)
|
165
|
+
end
|
166
|
+
|
167
|
+
test 'format has one with content' do
|
168
|
+
m = crud_test_models(:AAAAA)
|
169
|
+
assert_equal 'BBBBB', format_attr(m, :comrad)
|
170
|
+
end
|
171
|
+
|
162
172
|
test 'format has_many column with content' do
|
163
173
|
m = crud_test_models(:CCCCC)
|
164
174
|
assert_equal '<ul><li>AAAAA</li><li>BBBBB</li></ul>',
|
@@ -169,7 +179,7 @@ class FormatHelperTest < ActionView::TestCase
|
|
169
179
|
assert_equal 'Camel Case', captionize(:camel_case)
|
170
180
|
assert_equal 'All Upper Case', captionize('all upper case')
|
171
181
|
assert_equal 'With Object', captionize('With object', Object.new)
|
172
|
-
|
182
|
+
assert_not captionize('bad <title>').html_safe?
|
173
183
|
end
|
174
184
|
|
175
185
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
require 'support/crud_test_model'
|
4
3
|
require 'support/crud_test_models_controller'
|
@@ -14,37 +13,44 @@ class I18nHelperTest < ActionView::TestCase
|
|
14
13
|
|
15
14
|
I18n.backend.store_translations(
|
16
15
|
I18n.locale,
|
17
|
-
global: { test_key: 'global' }
|
16
|
+
global: { test_key: 'global' }
|
17
|
+
)
|
18
18
|
assert_equal 'global', ti(:test_key)
|
19
19
|
|
20
20
|
I18n.backend.store_translations(
|
21
21
|
I18n.locale,
|
22
|
-
list: { global: { test_key: 'list global' } }
|
22
|
+
list: { global: { test_key: 'list global' } }
|
23
|
+
)
|
23
24
|
assert_equal 'list global', ti(:test_key)
|
24
25
|
|
25
26
|
I18n.backend.store_translations(
|
26
27
|
I18n.locale,
|
27
|
-
list: { index: { test_key: 'list index' } }
|
28
|
+
list: { index: { test_key: 'list index' } }
|
29
|
+
)
|
28
30
|
assert_equal 'list index', ti(:test_key)
|
29
31
|
|
30
32
|
I18n.backend.store_translations(
|
31
33
|
I18n.locale,
|
32
|
-
crud: { global: { test_key: 'crud global' } }
|
34
|
+
crud: { global: { test_key: 'crud global' } }
|
35
|
+
)
|
33
36
|
assert_equal 'crud global', ti(:test_key)
|
34
37
|
|
35
38
|
I18n.backend.store_translations(
|
36
39
|
I18n.locale,
|
37
|
-
crud: { index: { test_key: 'crud index' } }
|
40
|
+
crud: { index: { test_key: 'crud index' } }
|
41
|
+
)
|
38
42
|
assert_equal 'crud index', ti(:test_key)
|
39
43
|
|
40
44
|
I18n.backend.store_translations(
|
41
45
|
I18n.locale,
|
42
|
-
crud_test_models: { global: { test_key: 'test global' } }
|
46
|
+
crud_test_models: { global: { test_key: 'test global' } }
|
47
|
+
)
|
43
48
|
assert_equal 'test global', ti(:test_key)
|
44
49
|
|
45
50
|
I18n.backend.store_translations(
|
46
51
|
I18n.locale,
|
47
|
-
crud_test_models: { index: { test_key: 'test index' } }
|
52
|
+
crud_test_models: { index: { test_key: 'test index' } }
|
53
|
+
)
|
48
54
|
assert_equal 'test index', ti(:test_key)
|
49
55
|
end
|
50
56
|
|
@@ -53,7 +59,8 @@ class I18nHelperTest < ActionView::TestCase
|
|
53
59
|
|
54
60
|
I18n.backend.store_translations(
|
55
61
|
I18n.locale,
|
56
|
-
global: { associations: { test_key: 'global' } }
|
62
|
+
global: { associations: { test_key: 'global' } }
|
63
|
+
)
|
57
64
|
assert_equal 'global', ta(:test_key, assoc)
|
58
65
|
|
59
66
|
I18n.backend.store_translations(
|
@@ -61,7 +68,11 @@ class I18nHelperTest < ActionView::TestCase
|
|
61
68
|
activerecord: {
|
62
69
|
associations: {
|
63
70
|
crud_test_model: {
|
64
|
-
test_key: 'model'
|
71
|
+
test_key: 'model'
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
)
|
65
76
|
assert_equal 'model', ta(:test_key, assoc)
|
66
77
|
|
67
78
|
I18n.backend.store_translations(
|
@@ -71,7 +82,13 @@ class I18nHelperTest < ActionView::TestCase
|
|
71
82
|
models: {
|
72
83
|
crud_test_model: {
|
73
84
|
companion: {
|
74
|
-
test_key: 'companion'
|
85
|
+
test_key: 'companion'
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
)
|
75
92
|
assert_equal 'companion', ta(:test_key, assoc)
|
76
93
|
|
77
94
|
assert_equal 'global', ta(:test_key)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
require 'support/custom_assertions'
|
4
3
|
require 'support/crud_test_model'
|
@@ -38,7 +37,7 @@ class TableHelperTest < ActionView::TestCase
|
|
38
37
|
end
|
39
38
|
|
40
39
|
test 'non empty table renders table' do
|
41
|
-
result = plain_table_or_message(%w
|
40
|
+
result = plain_table_or_message(%w[foo bar]) do |t|
|
42
41
|
t.attrs :size, :upcase
|
43
42
|
end
|
44
43
|
assert result.html_safe?
|
@@ -47,11 +46,12 @@ class TableHelperTest < ActionView::TestCase
|
|
47
46
|
|
48
47
|
test 'table with attrs' do
|
49
48
|
expected = DryCrud::Table::Builder.table(
|
50
|
-
%w
|
51
|
-
class: 'table table-striped table-hover'
|
49
|
+
%w[foo bar], self,
|
50
|
+
class: 'table table-striped table-hover'
|
51
|
+
) do |t|
|
52
52
|
t.attrs :size, :upcase
|
53
53
|
end
|
54
|
-
actual = plain_table(%w
|
54
|
+
actual = plain_table(%w[foo bar], :size, :upcase)
|
55
55
|
assert actual.html_safe?
|
56
56
|
assert_equal expected, actual
|
57
57
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'test_helper'
|
3
2
|
require 'support/crud_test_model'
|
4
3
|
|
@@ -7,18 +6,21 @@ class UtilityHelperTest < ActionView::TestCase
|
|
7
6
|
|
8
7
|
include CrudTestHelper
|
9
8
|
|
9
|
+
setup :reset_db, :setup_db, :create_test_data
|
10
|
+
teardown :reset_db
|
11
|
+
|
10
12
|
test 'content_tag_nested escapes safe correctly' do
|
11
|
-
html = content_tag_nested(:div, %w
|
13
|
+
html = content_tag_nested(:div, %w[a b]) { |e| content_tag(:span, e) }
|
12
14
|
assert_equal '<div><span>a</span><span>b</span></div>', html
|
13
15
|
end
|
14
16
|
|
15
17
|
test 'content_tag_nested escapes unsafe correctly' do
|
16
|
-
html = content_tag_nested(:div, %w
|
18
|
+
html = content_tag_nested(:div, %w[a b]) { |e| "<#{e}>" }
|
17
19
|
assert_equal '<div><a><b></div>', html
|
18
20
|
end
|
19
21
|
|
20
22
|
test 'content_tag_nested without block' do
|
21
|
-
html = content_tag_nested(:div, %w
|
23
|
+
html = content_tag_nested(:div, %w[a b])
|
22
24
|
assert_equal '<div>ab</div>', html
|
23
25
|
end
|
24
26
|
|
@@ -28,30 +30,23 @@ class UtilityHelperTest < ActionView::TestCase
|
|
28
30
|
end
|
29
31
|
|
30
32
|
test 'safe_join with block' do
|
31
|
-
html = safe_join(%w
|
33
|
+
html = safe_join(%w[a b]) { |e| content_tag(:span, e) }
|
32
34
|
assert_equal '<span>a</span><span>b</span>', html
|
33
35
|
end
|
34
36
|
|
35
37
|
test 'default attributes do not include id and password' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:income, :birthdate, :gets_up_at, :last_seen, :human,
|
40
|
-
:remarks, :created_at, :updated_at],
|
38
|
+
assert_equal %i[name email whatever children companion_id rating
|
39
|
+
income birthdate gets_up_at last_seen human
|
40
|
+
remarks created_at updated_at],
|
41
41
|
default_crud_attrs
|
42
|
-
reset_db
|
43
42
|
end
|
44
43
|
|
45
44
|
test 'column types' do
|
46
|
-
reset_db
|
47
|
-
setup_db
|
48
|
-
create_test_data
|
49
|
-
|
50
45
|
m = crud_test_models(:AAAAA)
|
51
46
|
assert_equal :string, column_type(m, :name)
|
52
47
|
assert_equal :integer, column_type(m, :children)
|
53
48
|
assert_equal :integer, column_type(m, :companion_id)
|
54
|
-
|
49
|
+
assert_nil column_type(m, :companion)
|
55
50
|
assert_equal :float, column_type(m, :rating)
|
56
51
|
assert_equal :decimal, column_type(m, :income)
|
57
52
|
assert_equal :date, column_type(m, :birthdate)
|
@@ -59,8 +54,6 @@ class UtilityHelperTest < ActionView::TestCase
|
|
59
54
|
assert_equal :datetime, column_type(m, :last_seen)
|
60
55
|
assert_equal :boolean, column_type(m, :human)
|
61
56
|
assert_equal :text, column_type(m, :remarks)
|
62
|
-
|
63
|
-
reset_db
|
64
57
|
end
|
65
58
|
|
66
59
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
# A module to include into your functional tests for your crud controller
|
4
2
|
# subclasses. Simply implement the two methods #test_entry and
|
5
3
|
# #test_entry_attrs to test the basic crud functionality. Override the test
|
6
4
|
# methods if you changed the behaviour in your subclass controller.
|
7
|
-
module CrudControllerTestHelper
|
5
|
+
module CrudControllerTestHelper # rubocop:disable Metrics/ModuleLength
|
8
6
|
|
9
7
|
def test_index # :nodoc:
|
10
8
|
get :index, params: test_params
|
@@ -19,7 +17,7 @@ module CrudControllerTestHelper
|
|
19
17
|
assert @response.body.starts_with?('[{'), @response.body
|
20
18
|
end
|
21
19
|
|
22
|
-
def test_index_search # :nodoc:
|
20
|
+
def test_index_search # rubocop:disable Metrics/AbcSize :nodoc:
|
23
21
|
field = @controller.search_columns.first
|
24
22
|
val = field && test_entry[field].to_s
|
25
23
|
return if val.blank? # does not support search or no value in this field
|
@@ -78,7 +76,7 @@ module CrudControllerTestHelper
|
|
78
76
|
post :create, params: test_params(model_identifier => new_entry_attrs)
|
79
77
|
end
|
80
78
|
assert_redirected_to_show entry
|
81
|
-
|
79
|
+
assert_not entry.new_record?
|
82
80
|
assert_attrs_equal(new_entry_attrs)
|
83
81
|
end
|
84
82
|
|
@@ -177,12 +175,12 @@ module CrudControllerTestHelper
|
|
177
175
|
|
178
176
|
# Test object used in several tests.
|
179
177
|
def test_entry
|
180
|
-
raise 'Implement
|
178
|
+
raise 'Implement the method "test_entry" in your test class'
|
181
179
|
end
|
182
180
|
|
183
181
|
# Attribute hash used in several tests.
|
184
182
|
def test_entry_attrs
|
185
|
-
raise 'Implement
|
183
|
+
raise 'Implement the method "test_entry_attrs" in your test class'
|
186
184
|
end
|
187
185
|
|
188
186
|
# Attribute hash used in edit/update tests.
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
#:nodoc:
|
4
2
|
REGEXP_ROWS = /<tr.+?<\/tr>/m #:nodoc:
|
5
3
|
REGEXP_HEADERS = /<th.+?<\/th>/m #:nodoc:
|
@@ -57,8 +55,8 @@ module CrudTestHelper
|
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
|
-
def create_crud_test_models(
|
61
|
-
|
58
|
+
def create_crud_test_models(connection)
|
59
|
+
connection.create_table :crud_test_models, force: true do |t|
|
62
60
|
t.string :name, null: false, limit: 50
|
63
61
|
t.string :email
|
64
62
|
t.string :password
|
@@ -77,16 +75,16 @@ module CrudTestHelper
|
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
80
|
-
def create_other_crud_test_models(
|
81
|
-
|
78
|
+
def create_other_crud_test_models(connection)
|
79
|
+
connection.create_table :other_crud_test_models, force: true do |t|
|
82
80
|
t.string :name, null: false, limit: 50
|
83
81
|
t.integer :more_id
|
84
82
|
end
|
85
83
|
end
|
86
84
|
|
87
|
-
def create_crud_test_models_other_crud_test_models(
|
88
|
-
|
89
|
-
|
85
|
+
def create_crud_test_models_other_crud_test_models(connection)
|
86
|
+
connection.create_table :crud_test_models_other_crud_test_models,
|
87
|
+
force: true do |t|
|
90
88
|
t.belongs_to :crud_test_model, index: { name: 'parent' }
|
91
89
|
t.belongs_to :other_crud_test_model, index: { name: 'other' }
|
92
90
|
end
|
@@ -95,9 +93,9 @@ module CrudTestHelper
|
|
95
93
|
# Removes the crud_test_models table from the database.
|
96
94
|
def reset_db
|
97
95
|
c = ActiveRecord::Base.connection
|
98
|
-
[
|
99
|
-
|
100
|
-
|
96
|
+
%i[crud_test_models
|
97
|
+
other_crud_test_models
|
98
|
+
crud_test_models_other_crud_test_models].each do |table|
|
101
99
|
c.drop_table(table) if c.data_source_exists?(table)
|
102
100
|
end
|
103
101
|
end
|
@@ -110,10 +108,11 @@ module CrudTestHelper
|
|
110
108
|
|
111
109
|
# Fixture-style accessor method to get CrudTestModel instances by name
|
112
110
|
def crud_test_models(name)
|
113
|
-
CrudTestModel.
|
111
|
+
CrudTestModel.find_by(name: name.to_s)
|
114
112
|
end
|
115
113
|
|
116
114
|
def with_test_routing
|
115
|
+
@routes ||= nil
|
117
116
|
with_routing do |set|
|
118
117
|
set.draw { resources :crud_test_models }
|
119
118
|
# used to define a controller in these tests
|
@@ -136,7 +135,7 @@ module CrudTestHelper
|
|
136
135
|
@routes.draw { resources :crud_test_models }
|
137
136
|
end
|
138
137
|
|
139
|
-
def create(index, companion)
|
138
|
+
def create(index, companion) # rubocop:disable Metrics/AbcSize
|
140
139
|
c = str(index)
|
141
140
|
m = CrudTestModel.new(
|
142
141
|
name: c,
|
@@ -150,7 +149,8 @@ module CrudTestHelper
|
|
150
149
|
"1#{index}:2#{index}",
|
151
150
|
human: index.even?,
|
152
151
|
remarks: "#{c} #{str(index + 1)} #{str(index + 2)}\n" *
|
153
|
-
(index % 3 + 1)
|
152
|
+
(index % 3 + 1)
|
153
|
+
)
|
154
154
|
m.companion = companion
|
155
155
|
m.save!
|
156
156
|
m
|
@@ -172,7 +172,8 @@ module CrudTestHelper
|
|
172
172
|
def without_transaction
|
173
173
|
c = ActiveRecord::Base.connection
|
174
174
|
start_transaction = false
|
175
|
-
if c.adapter_name.downcase.include?('mysql') &&
|
175
|
+
if c.adapter_name.downcase.include?('mysql') &&
|
176
|
+
c.open_transactions.positive?
|
176
177
|
# in transactional tests, we may simply rollback
|
177
178
|
c.execute('ROLLBACK')
|
178
179
|
start_transaction = true
|