active_scaffold 3.6.0.pre → 3.6.0.rc1
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.
- checksums.yaml +4 -4
- data/{CHANGELOG → CHANGELOG.rdoc} +39 -0
- data/app/assets/javascripts/active_scaffold.js.erb +0 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +35 -4
- data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
- data/app/assets/stylesheets/active_scaffold_layout.css +52 -29
- data/app/views/active_scaffold_overrides/_list_header.html.erb +5 -7
- data/app/views/active_scaffold_overrides/_list_record.html.erb +4 -5
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/fr.yml +2 -1
- data/config/locales/hu.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/lib/active_scaffold.rb +8 -3
- data/lib/active_scaffold/actions/common_search.rb +11 -8
- data/lib/active_scaffold/actions/core.rb +79 -51
- data/lib/active_scaffold/actions/create.rb +27 -27
- data/lib/active_scaffold/actions/delete.rb +1 -1
- data/lib/active_scaffold/actions/field_search.rb +52 -42
- data/lib/active_scaffold/actions/list.rb +106 -23
- data/lib/active_scaffold/actions/nested.rb +59 -42
- data/lib/active_scaffold/actions/show.rb +3 -3
- data/lib/active_scaffold/actions/subform.rb +9 -16
- data/lib/active_scaffold/actions/update.rb +95 -77
- data/lib/active_scaffold/attribute_params.rb +93 -68
- data/lib/active_scaffold/bridges/active_storage.rb +6 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +33 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +54 -0
- data/lib/active_scaffold/bridges/active_storage/form_ui.rb +22 -0
- data/lib/active_scaffold/bridges/active_storage/list_ui.rb +36 -0
- data/lib/active_scaffold/bridges/bitfields.rb +1 -0
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +6 -0
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker/helper.rb +46 -41
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +3 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/record_select/helpers.rb +3 -7
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +19 -18
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +20 -3
- data/lib/active_scaffold/config/base.rb +58 -34
- data/lib/active_scaffold/config/core.rb +31 -12
- data/lib/active_scaffold/config/delete.rb +12 -1
- data/lib/active_scaffold/config/list.rb +17 -7
- data/lib/active_scaffold/config/mark.rb +1 -1
- data/lib/active_scaffold/configurable.rb +5 -3
- data/lib/active_scaffold/constraints.rb +21 -19
- data/lib/active_scaffold/core.rb +35 -26
- data/lib/active_scaffold/data_structures/action_columns.rb +1 -1
- data/lib/active_scaffold/data_structures/action_link.rb +34 -16
- data/lib/active_scaffold/data_structures/action_links.rb +9 -11
- data/lib/active_scaffold/data_structures/association/abstract.rb +35 -13
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
- data/lib/active_scaffold/data_structures/association/active_record.rb +5 -1
- data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
- data/lib/active_scaffold/data_structures/column.rb +49 -58
- data/lib/active_scaffold/data_structures/columns.rb +3 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +20 -18
- data/lib/active_scaffold/data_structures/sorting.rb +5 -0
- data/lib/active_scaffold/delayed_setup.rb +16 -6
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +34 -14
- data/lib/active_scaffold/extensions/cow_proxy.rb +50 -2
- data/lib/active_scaffold/extensions/localize.rb +3 -1
- data/lib/active_scaffold/extensions/routing_mapper.rb +2 -2
- data/lib/active_scaffold/extensions/to_label.rb +3 -2
- data/lib/active_scaffold/finder.rb +81 -46
- data/lib/active_scaffold/helpers/action_link_helpers.rb +47 -21
- data/lib/active_scaffold/helpers/association_helpers.rb +13 -11
- data/lib/active_scaffold/helpers/controller_helpers.rb +14 -11
- data/lib/active_scaffold/helpers/form_column_helpers.rb +133 -99
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +4 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +76 -49
- data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/search_column_helpers.rb +25 -30
- data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
- data/lib/active_scaffold/helpers/view_helpers.rb +31 -22
- data/lib/active_scaffold/orm_checks.rb +2 -2
- data/lib/active_scaffold/paginator.rb +1 -3
- data/lib/active_scaffold/registry.rb +11 -0
- data/lib/active_scaffold/responds_to_parent.rb +6 -5
- data/lib/active_scaffold/tableless.rb +6 -8
- data/lib/active_scaffold/version.rb +1 -1
- data/shoulda_macros/macros.rb +3 -1
- data/test/bridges/paperclip_test.rb +1 -1
- data/test/company.rb +2 -2
- data/test/data_structures/action_columns_test.rb +2 -2
- data/test/data_structures/column_test.rb +3 -6
- data/test/data_structures/columns_test.rb +2 -2
- data/test/extensions/active_record_test.rb +4 -4
- data/test/extensions/routing_mapper_test.rb +2 -2
- data/test/helpers/list_column_helpers_test.rb +3 -1
- data/test/misc/active_record_permissions_test.rb +2 -2
- data/test/misc/attribute_params_test.rb +4 -0
- data/test/misc/configurable_test.rb +10 -10
- data/test/misc/convert_numbers_format_test.rb +4 -0
- data/test/mock_app/app/assets/config/manifest.js +0 -0
- data/test/mock_app/app/controllers/cars_controller.rb +1 -0
- data/test/mock_app/app/controllers/people_controller.rb +3 -1
- data/test/mock_app/config/application.rb +1 -0
- data/test/mock_app/config/routes.rb +4 -1
- data/test/mock_app/db/schema.rb +2 -0
- data/test/performance/list_cars_performance_test.rb +34 -0
- data/test/performance/list_people_performance_test.rb +31 -0
- data/test/performance_test_help.rb +3 -0
- data/test/test_helper.rb +2 -1
- metadata +22 -12
- data/app/assets/javascripts/prototype/rico_corner.js +0 -370
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -5
@@ -43,7 +43,7 @@ module ActiveScaffold
|
|
43
43
|
elsif mongoid? klass
|
44
44
|
klass.fields
|
45
45
|
else
|
46
|
-
|
46
|
+
{}
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -71,7 +71,7 @@ module ActiveScaffold
|
|
71
71
|
if active_record? klass
|
72
72
|
klass.type_for_attribute column_name.to_s
|
73
73
|
elsif mongoid? klass
|
74
|
-
klass.fields[column_name.to_s]
|
74
|
+
klass.fields[column_name.to_s]&.type
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -21,9 +21,7 @@ class Paginator
|
|
21
21
|
def initialize(count, per_page, &select)
|
22
22
|
@count = count
|
23
23
|
@per_page = per_page
|
24
|
-
unless select
|
25
|
-
raise MissingSelectError, 'Must provide block to select data for each page'
|
26
|
-
end
|
24
|
+
raise MissingSelectError, 'Must provide block to select data for each page' unless select
|
27
25
|
@select = select
|
28
26
|
end
|
29
27
|
|
@@ -15,6 +15,17 @@ module ActiveScaffold
|
|
15
15
|
@unauthorized_columns ||= Hash.new { |h, k| h[k] = [] }
|
16
16
|
end
|
17
17
|
|
18
|
+
def cache(kind, key = nil, &block)
|
19
|
+
unless key
|
20
|
+
key = kind
|
21
|
+
kind = :cache
|
22
|
+
end
|
23
|
+
@cache ||= {}
|
24
|
+
cache = @cache[kind] ||= {}
|
25
|
+
return cache[key] if cache.include? key
|
26
|
+
cache[key] ||= yield
|
27
|
+
end
|
28
|
+
|
18
29
|
def self.instance
|
19
30
|
RequestStore.store[@per_thread_registry_key] ||= new
|
20
31
|
end
|
@@ -9,11 +9,12 @@ module ActiveScaffold
|
|
9
9
|
return unless performed?
|
10
10
|
|
11
11
|
# Either pull out a redirect or the request body
|
12
|
-
script =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
script =
|
13
|
+
if response.headers['Location']
|
14
|
+
"document.location.href = '#{self.class.helpers.escape_javascript response.headers.delete('Location').to_s}'"
|
15
|
+
else
|
16
|
+
response.body || ''
|
17
|
+
end
|
17
18
|
response.status = 200 if (300...400).cover? response.status
|
18
19
|
|
19
20
|
# Eval in parent scope and replace document location of this frame
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class ActiveScaffold::Tableless < ActiveRecord::Base
|
1
|
+
class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
|
2
2
|
class AssociationScope < ActiveRecord::Associations::AssociationScope
|
3
3
|
INSTANCE = create
|
4
4
|
def self.scope(association, connection)
|
@@ -82,7 +82,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base
|
|
82
82
|
end
|
83
83
|
|
84
84
|
module TablelessCollectionAssociation
|
85
|
-
def get_records
|
85
|
+
def get_records # rubocop:disable Naming/AccessorMethodName
|
86
86
|
klass < ActiveScaffold::Tableless ? scope.to_a : super
|
87
87
|
end
|
88
88
|
end
|
@@ -94,7 +94,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base
|
|
94
94
|
end
|
95
95
|
|
96
96
|
module TablelessSingularAssociation
|
97
|
-
def get_records
|
97
|
+
def get_records # rubocop:disable Naming/AccessorMethodName
|
98
98
|
klass < ActiveScaffold::Tableless ? scope.limit(1).to_a : super
|
99
99
|
end
|
100
100
|
end
|
@@ -199,8 +199,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base
|
|
199
199
|
end
|
200
200
|
if Rails.version < '5.0' # 4.2.x
|
201
201
|
def self.initialize_find_by_cache
|
202
|
-
# rubocop:disable Rails/DynamicFindBy
|
203
|
-
self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) }
|
202
|
+
self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) } # rubocop:disable Rails/DynamicFindBy
|
204
203
|
end
|
205
204
|
elsif Rails.version < '5.2' # 5.0 and 5.1
|
206
205
|
def self.initialize_find_by_cache
|
@@ -242,11 +241,10 @@ class ActiveScaffold::Tableless < ActiveRecord::Base
|
|
242
241
|
end
|
243
242
|
|
244
243
|
def self.execute_simple_calculation(relation, operation, column_name, distinct)
|
245
|
-
|
246
|
-
find_all(relation).size
|
247
|
-
else
|
244
|
+
unless operation == 'count' && [relation.klass.primary_key, :all].include?(column_name)
|
248
245
|
raise "self.execute_simple_calculation must be implemented in a Tableless model to support #{operation} #{column_name}#{' distinct' if distinct} columns"
|
249
246
|
end
|
247
|
+
find_all(relation).size
|
250
248
|
end
|
251
249
|
|
252
250
|
def destroy
|
data/shoulda_macros/macros.rb
CHANGED
@@ -127,7 +127,9 @@ class ActiveSupport::TestCase
|
|
127
127
|
script = script.gsub('\n', '\\\\\\n')
|
128
128
|
.gsub(/['"]/, '\\\\\\\\\&')
|
129
129
|
.gsub('</script>', '</scr"+"ipt>')
|
130
|
-
|
130
|
+
pre_regex = Regexp.quote("with(window.parent) { setTimeout(function() { window.eval('")
|
131
|
+
post_regex = Regexp.quote("'); if (typeof(loc) !== 'undefined') loc.replace('about:blank'); }, 1) };")
|
132
|
+
assert_select 'script[type=text/javascript]', Regexp.new('.*' + pre_regex + script + post_regex + '.*')
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
@@ -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
|
19
|
+
refute(config.columns.any? { |column| column.form_ui == :paperclip })
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_initialization
|
data/test/company.rb
CHANGED
@@ -53,11 +53,11 @@ class Company < ActiveRecord::Base
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def self.has_many(association_id, options = {})
|
56
|
+
def self.has_many(association_id, options = {}) # rubocop:disable Naming/PredicateName
|
57
57
|
create_reflection(:has_many, association_id, nil, options, self)
|
58
58
|
end
|
59
59
|
|
60
|
-
def self.has_one(association_id, options = {})
|
60
|
+
def self.has_one(association_id, options = {}) # rubocop:disable Naming/PredicateName
|
61
61
|
create_reflection(:has_one, association_id, nil, options, self)
|
62
62
|
end
|
63
63
|
|
@@ -71,12 +71,12 @@ class ActionColumnsTest < MiniTest::Test
|
|
71
71
|
# first, use @columns.add directly
|
72
72
|
@c2 = ActiveScaffold::DataStructures::ActionColumns.new
|
73
73
|
@columns.add @c2
|
74
|
-
assert
|
74
|
+
assert(@columns.any? { |c| c == @c2 })
|
75
75
|
|
76
76
|
# then use the shortcut
|
77
77
|
@columns.add_subgroup 'foo' do
|
78
78
|
end
|
79
|
-
assert
|
79
|
+
assert(@columns.any? { |c| c.respond_to?(:label) && c.label == 'foo' })
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_block_config
|
@@ -16,9 +16,6 @@ class ColumnTest < MiniTest::Test
|
|
16
16
|
def test_basic_properties
|
17
17
|
# test that it was set during initialization
|
18
18
|
assert_equal @column.name, :a
|
19
|
-
# test that we can change it
|
20
|
-
@column.name = :b
|
21
|
-
assert_equal @column.name, :b
|
22
19
|
|
23
20
|
# label
|
24
21
|
@column.label = 'foo'
|
@@ -74,7 +71,7 @@ class ColumnTest < MiniTest::Test
|
|
74
71
|
# comparison with different object of same type
|
75
72
|
column2 = ActiveScaffold::DataStructures::Column.new(:fake, ModelStub)
|
76
73
|
refute_equal @column, column2
|
77
|
-
column2
|
74
|
+
column2 = ActiveScaffold::DataStructures::Column.new(:a, ModelStub)
|
78
75
|
assert_equal @column, column2
|
79
76
|
|
80
77
|
# special comparisons
|
@@ -152,12 +149,12 @@ class ColumnTest < MiniTest::Test
|
|
152
149
|
def test_config_block
|
153
150
|
@column.configure do |config|
|
154
151
|
# we can use the config object
|
155
|
-
config.
|
152
|
+
config.form_ui = :select
|
156
153
|
# or not
|
157
154
|
self.label = 'hello'
|
158
155
|
end
|
159
156
|
|
160
|
-
assert_equal
|
157
|
+
assert_equal :select, @column.form_ui
|
161
158
|
assert_equal 'hello', @column.label
|
162
159
|
end
|
163
160
|
|
@@ -41,8 +41,8 @@ class ColumnsTest < MiniTest::Test
|
|
41
41
|
|
42
42
|
# test the collection finders
|
43
43
|
found = @columns.find_by_names(:a, :b)
|
44
|
-
assert
|
45
|
-
assert
|
44
|
+
assert(found.any? { |c| c.name == :a })
|
45
|
+
assert(found.any? { |c| c.name == :b })
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_each
|
@@ -14,7 +14,7 @@ class ActiveRecordTest < MiniTest::Test
|
|
14
14
|
'to_s'
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
RequestStore.clear!
|
18
18
|
assert_equal 'to_s', @record.to_label
|
19
19
|
|
20
20
|
class << @record
|
@@ -22,7 +22,7 @@ class ActiveRecordTest < MiniTest::Test
|
|
22
22
|
'title'
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
RequestStore.clear!
|
26
26
|
assert_equal 'title', @record.to_label
|
27
27
|
|
28
28
|
class << @record
|
@@ -30,7 +30,7 @@ class ActiveRecordTest < MiniTest::Test
|
|
30
30
|
'label'
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
RequestStore.clear!
|
34
34
|
assert_equal 'label', @record.to_label
|
35
35
|
|
36
36
|
class << @record
|
@@ -38,7 +38,7 @@ class ActiveRecordTest < MiniTest::Test
|
|
38
38
|
'name'
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
RequestStore.clear!
|
42
42
|
assert_equal 'name', @record.to_label
|
43
43
|
end
|
44
44
|
end
|
@@ -54,8 +54,8 @@ class RoutingMapperTest < ActionController::TestCase
|
|
54
54
|
assert_routing 'cars/1/edit', controller: 'cars', action: 'edit', id: '1'
|
55
55
|
assert_routing({method: :patch, path: 'cars/1'}, {controller: 'cars', action: 'update', id: '1'})
|
56
56
|
|
57
|
-
assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars' }
|
58
|
-
assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars/1
|
57
|
+
assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars', method: :post }
|
58
|
+
assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars/1' }
|
59
59
|
assert_raises(ActionController::RoutingError) { @routes.recognize_path '/cars/1/destroy', method: :delete }
|
60
60
|
end
|
61
61
|
|
@@ -34,8 +34,10 @@ class ListColumnHelpersTest < ActionView::TestCase
|
|
34
34
|
value.each { |v| v.stubs(:to_label).returns(v) }
|
35
35
|
assert_equal '1, 2, 3, … (4)', format_association_value(value, @association_column, value.size)
|
36
36
|
@config.list.stubs(:association_join_text => ',<br/>')
|
37
|
+
remove_instance_variable :@_association_join_text
|
37
38
|
assert_equal '1,<br/>2,<br/>3,<br/>… (4)', format_association_value(value, @association_column, value.size)
|
38
|
-
@config.list.stubs(:association_join_text => ',<br/>'.html_safe)
|
39
|
+
@config.list.stubs(:association_join_text => ',<br/>'.html_safe) # rubocop:disable Rails/OutputSafety
|
40
|
+
remove_instance_variable :@_association_join_text
|
39
41
|
assert_equal '1,<br/>2,<br/>3,<br/>… (4)', format_association_value(value, @association_column, value.size)
|
40
42
|
end
|
41
43
|
|
@@ -91,7 +91,7 @@ class ActiveRecordPermissionsTest < MiniTest::Test
|
|
91
91
|
# symbols are: is (a)bsent, returns (f)alse, returns (t)rue, or n/a (_)
|
92
92
|
def test_method_combinations_with_default_true
|
93
93
|
old_permission = nil
|
94
|
-
ActiveScaffold.
|
94
|
+
ActiveScaffold.defaults do |config|
|
95
95
|
old_permission = config.security.default_permission
|
96
96
|
config.security.default_permission = true
|
97
97
|
end
|
@@ -134,7 +134,7 @@ class ActiveRecordPermissionsTest < MiniTest::Test
|
|
134
134
|
miss(@model.authorized_for?(:crud_type => :read, :column => :b1), 'ttf')
|
135
135
|
pass(@model.authorized_for?(:crud_type => :read, :column => :a1), 'ttt')
|
136
136
|
|
137
|
-
ActiveScaffold.
|
137
|
+
ActiveScaffold.defaults do |config|
|
138
138
|
config.security.default_permission = old_permission
|
139
139
|
end
|
140
140
|
end
|
@@ -46,6 +46,7 @@ class AttributeParamsTest < MiniTest::Test
|
|
46
46
|
assert_nil model.last_name
|
47
47
|
assert_equal buildings.map(&:id), model.building_ids
|
48
48
|
assert_equal buildings.map(&:id), model.buildings.map(&:id)
|
49
|
+
assert_equal model, model.buildings[0].owner
|
49
50
|
assert model.save
|
50
51
|
assert_equal 2, model.reload.buildings_count
|
51
52
|
|
@@ -134,6 +135,7 @@ class AttributeParamsTest < MiniTest::Test
|
|
134
135
|
assert_equal 'Name', model.first_name
|
135
136
|
assert model.floor.present?
|
136
137
|
assert_equal floor.id, model.floor.id
|
138
|
+
assert_equal model, model.floor.tenant
|
137
139
|
assert_nil floor.reload.tenant_id, 'tenant_id should not be saved yet'
|
138
140
|
assert model.save
|
139
141
|
assert_equal model.id, floor.reload.tenant_id, 'tenant_id should be saved'
|
@@ -224,6 +226,7 @@ class AttributeParamsTest < MiniTest::Test
|
|
224
226
|
assert_equal 3, model.floors.size
|
225
227
|
assert_equal floor.id, model.floors.first.id
|
226
228
|
assert_equal [nil, *people.map(&:id)], model.floors.map(&:tenant_id)
|
229
|
+
assert_equal model, model.floors[0].building
|
227
230
|
assert model.save
|
228
231
|
assert_equal [1, 1], people.map(&:reload).map(&:floors_count)
|
229
232
|
assert_equal 3, model.reload.floors_count
|
@@ -299,6 +302,7 @@ class AttributeParamsTest < MiniTest::Test
|
|
299
302
|
assert_equal 'First', model.first_name
|
300
303
|
assert model.car.present?
|
301
304
|
assert model.car.new_record?
|
305
|
+
assert_equal model, model.car.person
|
302
306
|
assert model.save
|
303
307
|
assert model.car.persisted?
|
304
308
|
|
@@ -41,17 +41,17 @@ class ConfigurableTest < MiniTest::Test
|
|
41
41
|
## test normal block behaviors
|
42
42
|
##
|
43
43
|
# functions
|
44
|
-
assert_equal hello, configurable_class.configure { hello }
|
44
|
+
assert_equal hello, (configurable_class.configure { hello })
|
45
45
|
# variables
|
46
|
-
assert_equal configurable_class, configurable_class.configure { configurable_class }
|
46
|
+
assert_equal configurable_class, (configurable_class.configure { configurable_class })
|
47
47
|
# constants
|
48
|
-
assert_equal ConfigurableTest::HELLO, configurable_class.configure { ConfigurableTest::HELLO }
|
48
|
+
assert_equal ConfigurableTest::HELLO, (configurable_class.configure { ConfigurableTest::HELLO })
|
49
49
|
|
50
50
|
##
|
51
51
|
## test extra "localized" block behavior
|
52
52
|
##
|
53
53
|
# functions
|
54
|
-
assert_equal configurable_class.foo, configurable_class.configure { foo }
|
54
|
+
assert_equal configurable_class.foo, (configurable_class.configure { foo })
|
55
55
|
# constants - not working
|
56
56
|
# assert_equal configurable_class.FOO, configurable_class.configure {FOO}
|
57
57
|
end
|
@@ -73,25 +73,25 @@ class ConfigurableTest < MiniTest::Test
|
|
73
73
|
## test normal block behaviors
|
74
74
|
##
|
75
75
|
# functions
|
76
|
-
assert_equal hello, ExtendedClass.configure { hello }
|
76
|
+
assert_equal hello, (ExtendedClass.configure { hello })
|
77
77
|
# variables
|
78
|
-
assert_equal ExtendedClass, ExtendedClass.configure { ExtendedClass }
|
78
|
+
assert_equal ExtendedClass, (ExtendedClass.configure { ExtendedClass })
|
79
79
|
# constants
|
80
|
-
assert_equal ConfigurableTest::HELLO, ExtendedClass.configure { ConfigurableTest::HELLO }
|
80
|
+
assert_equal ConfigurableTest::HELLO, (ExtendedClass.configure { ConfigurableTest::HELLO })
|
81
81
|
|
82
82
|
##
|
83
83
|
## test extra "localized" block behavior
|
84
84
|
##
|
85
85
|
# functions
|
86
|
-
assert_equal ExtendedClass.foo, ExtendedClass.configure { foo }
|
86
|
+
assert_equal ExtendedClass.foo, (ExtendedClass.configure { foo })
|
87
87
|
# constants - not working
|
88
88
|
# assert_equal ExtendedClass.FOO, ExtendedClass.configure {FOO}
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_arity
|
92
92
|
# this is the main style
|
93
|
-
assert_equal 'foo', ExtendedClass.configure { 'foo' }
|
93
|
+
assert_equal 'foo', (ExtendedClass.configure { 'foo' })
|
94
94
|
# but we want to let people accept the configurable class as the first argument, too
|
95
|
-
assert_equal 'bar', ExtendedClass.configure { |a| a.foo } # rubocop:disable Style/SymbolProc
|
95
|
+
assert_equal 'bar', (ExtendedClass.configure { |a| a.foo }) # rubocop:disable Style/SymbolProc
|
96
96
|
end
|
97
97
|
end
|
File without changes
|
@@ -9,5 +9,6 @@ module RailsApp
|
|
9
9
|
config.filter_parameters << :password
|
10
10
|
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
|
11
11
|
config.i18n.enforce_available_locales = false if config.i18n.respond_to? :enforce_available_locales
|
12
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3.respond_to? :represent_boolean_as_integer
|
12
13
|
end
|
13
14
|
end
|
@@ -6,9 +6,12 @@ Rails.application.routes.draw do
|
|
6
6
|
resources :buildings, except: :index do
|
7
7
|
concerns :active_scaffold, except: %i[mark add_existing new_existing destroy_existing]
|
8
8
|
end
|
9
|
-
resources :cars, only: %i[edit update] do
|
9
|
+
resources :cars, only: %i[index edit update] do
|
10
10
|
concerns :active_scaffold, association: false, except: [:mark]
|
11
11
|
end
|
12
|
+
resources :people do
|
13
|
+
concerns :active_scaffold, except: %i[mark]
|
14
|
+
end
|
12
15
|
|
13
16
|
match ':controller(/:action(/:id))', :via => :any
|
14
17
|
end
|
data/test/mock_app/db/schema.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'performance_test_help'
|
3
|
+
|
4
|
+
class ListCarsPerformanceTest < ActionDispatch::PerformanceTest
|
5
|
+
self.profile_options =
|
6
|
+
if ENV['BENCHMARK_TESTS']
|
7
|
+
{metrics: [:wall_time]}
|
8
|
+
else
|
9
|
+
{metrics: %i[process_time], formats: %i[flat graph_html call_stack]}
|
10
|
+
end
|
11
|
+
def setup
|
12
|
+
owners = Array.new(4) { |i| Person.create first_name: "Name#{i}" } << nil
|
13
|
+
500.times { |i| Car.create(brand: 'Skoda', model: 'Fabia', person: owners[i % 5]) }
|
14
|
+
CarsController.class_eval do
|
15
|
+
before_action :setup
|
16
|
+
|
17
|
+
def setup
|
18
|
+
active_scaffold_config.list.pagination = false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_list
|
24
|
+
get '/cars'
|
25
|
+
end
|
26
|
+
|
27
|
+
# def test_list2
|
28
|
+
# get '/cars?t=2'
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# def test_list3
|
32
|
+
# get '/cars?t=3'
|
33
|
+
# end
|
34
|
+
end
|