active_scaffold 3.6.20 → 3.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +47 -0
- data/README.md +29 -16
- data/app/assets/javascripts/jquery/active_scaffold.js +106 -68
- data/app/assets/javascripts/jquery/active_scaffold_chosen.js +6 -5
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +18 -4
- data/app/assets/stylesheets/active_scaffold_layout.css +13 -2
- data/app/views/active_scaffold_overrides/_base_form.html.erb +5 -1
- data/app/views/active_scaffold_overrides/_field_search.html.erb +1 -0
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +2 -1
- data/app/views/active_scaffold_overrides/_render_field.js.erb +24 -13
- data/config/locales/de.yml +6 -3
- data/config/locales/en.yml +3 -0
- data/config/locales/es.yml +3 -0
- data/config/locales/fr.yml +9 -6
- data/config/locales/hu.yml +20 -17
- data/config/locales/ja.yml +83 -80
- data/config/locales/ru.yml +17 -14
- data/lib/active_scaffold/actions/common_search.rb +2 -2
- data/lib/active_scaffold/actions/core.rb +30 -10
- data/lib/active_scaffold/actions/field_search.rb +9 -6
- data/lib/active_scaffold/actions/nested.rb +7 -7
- data/lib/active_scaffold/actions/update.rb +3 -3
- data/lib/active_scaffold/attribute_params.rb +22 -70
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +0 -3
- data/lib/active_scaffold/bridges/active_storage/form_ui.rb +6 -6
- data/lib/active_scaffold/bridges/active_storage/list_ui.rb +7 -7
- data/lib/active_scaffold/bridges/active_storage.rb +3 -0
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +2 -2
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +2 -2
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +12 -14
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +2 -2
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/chosen/helpers.rb +10 -10
- data/lib/active_scaffold/bridges/country_select/country_select_bridge_helper.rb +7 -7
- data/lib/active_scaffold/bridges/date_picker/ext.rb +20 -9
- data/lib/active_scaffold/bridges/date_picker/helper.rb +9 -9
- data/lib/active_scaffold/bridges/date_picker.rb +2 -0
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +3 -3
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +5 -5
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +3 -3
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +1 -1
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +4 -1
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +3 -3
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/record_select/helpers.rb +17 -17
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +6 -6
- data/lib/active_scaffold/bridges/tiny_mce.rb +1 -1
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +6 -11
- data/lib/active_scaffold/bridges.rb +0 -3
- data/lib/active_scaffold/config/core.rb +1 -1
- data/lib/active_scaffold/config/field_search.rb +9 -1
- data/lib/active_scaffold/config/form.rb +9 -1
- data/lib/active_scaffold/constraints.rb +22 -7
- data/lib/active_scaffold/core.rb +6 -10
- data/lib/active_scaffold/data_structures/action_columns.rb +0 -25
- data/lib/active_scaffold/data_structures/action_links.rb +1 -1
- data/lib/active_scaffold/data_structures/association/abstract.rb +8 -0
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +8 -0
- data/lib/active_scaffold/data_structures/association/active_record.rb +1 -13
- data/lib/active_scaffold/data_structures/association/mongoid.rb +21 -8
- data/lib/active_scaffold/data_structures/column.rb +139 -28
- data/lib/active_scaffold/data_structures/columns.rb +12 -12
- data/lib/active_scaffold/data_structures/nested_info.rb +12 -0
- data/lib/active_scaffold/data_structures/sorting.rb +1 -1
- data/lib/active_scaffold/engine.rb +15 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +13 -5
- data/lib/active_scaffold/extensions/cow_proxy.rb +1 -1
- data/lib/active_scaffold/extensions/routing_mapper.rb +1 -0
- data/lib/active_scaffold/extensions/unsaved_record.rb +9 -3
- data/lib/active_scaffold/finder.rb +147 -28
- data/lib/active_scaffold/helpers/action_link_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb +9 -4
- data/lib/active_scaffold/helpers/form_column_helpers.rb +153 -107
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +48 -14
- data/lib/active_scaffold/helpers/list_column_helpers.rb +37 -20
- data/lib/active_scaffold/helpers/search_column_helpers.rb +137 -55
- data/lib/active_scaffold/helpers/show_column_helpers.rb +6 -6
- data/lib/active_scaffold/helpers/view_helpers.rb +1 -1
- data/lib/active_scaffold/orm_checks.rb +21 -1
- data/lib/active_scaffold/registry.rb +10 -15
- data/lib/active_scaffold/tableless.rb +10 -79
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/active_scaffold.rb +3 -9
- data/lib/generators/active_scaffold/install_generator.rb +2 -2
- data/test/bridges/bridge_test.rb +1 -1
- data/test/bridges/date_picker_test.rb +3 -2
- data/test/bridges/paperclip_test.rb +18 -14
- data/test/bridges/tiny_mce_test.rb +5 -3
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +1 -1
- data/test/config/create_test.rb +1 -1
- data/test/config/delete_test.rb +1 -1
- data/test/config/field_search_test.rb +1 -1
- data/test/config/list_test.rb +1 -1
- data/test/config/nested_test.rb +1 -1
- data/test/config/search_test.rb +1 -1
- data/test/config/show_test.rb +1 -1
- data/test/config/subform_test.rb +1 -1
- data/test/config/update_test.rb +1 -1
- data/test/data_structures/action_columns_test.rb +1 -1
- data/test/data_structures/action_link_test.rb +1 -1
- data/test/data_structures/action_links_test.rb +1 -1
- data/test/data_structures/actions_test.rb +1 -1
- data/test/data_structures/association_column_test.rb +1 -1
- data/test/data_structures/column_test.rb +1 -1
- data/test/data_structures/columns_test.rb +1 -1
- data/test/data_structures/set_test.rb +1 -1
- data/test/data_structures/sorting_test.rb +1 -1
- data/test/data_structures/standard_column_test.rb +1 -1
- data/test/data_structures/validation_reflection_test.rb +1 -1
- data/test/data_structures/virtual_column_test.rb +1 -1
- data/test/extensions/active_record_test.rb +1 -1
- data/test/helpers/form_column_helpers_test.rb +7 -5
- data/test/helpers/pagination_helpers_test.rb +1 -1
- data/test/helpers/search_column_helpers_test.rb +2 -1
- data/test/misc/active_record_permissions_test.rb +1 -1
- data/test/misc/attribute_params_test.rb +1 -1
- data/test/misc/calculation_test.rb +1 -1
- data/test/misc/configurable_test.rb +1 -1
- data/test/misc/constraints_test.rb +2 -1
- data/test/misc/convert_numbers_format_test.rb +1 -1
- data/test/misc/finder_test.rb +39 -1
- data/test/misc/lang_test.rb +1 -1
- data/test/misc/parse_datetime_test.rb +1 -1
- data/test/misc/tableless_test.rb +1 -1
- data/test/test_helper.rb +4 -4
- metadata +5 -17
- data/config/brakeman.ignore +0 -26
- data/config/brakeman.yml +0 -3
- data/config/i18n-tasks.yml +0 -121
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -221
- data/lib/active_scaffold/delayed_setup.rb +0 -41
- data/lib/active_scaffold/extensions/left_outer_joins.rb +0 -43
@@ -4,24 +4,6 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
4
4
|
def self.scope(association, connection)
|
5
5
|
INSTANCE.scope association, connection
|
6
6
|
end
|
7
|
-
|
8
|
-
if Rails.version < '5.0.0'
|
9
|
-
def column_for(table_name, column_name, alias_tracker = nil)
|
10
|
-
klass = alias_tracker ? alias_tracker.connection.klass : self.klass
|
11
|
-
if table_name == klass.table_name
|
12
|
-
klass.columns_hash[column_name]
|
13
|
-
elsif alias_tracker && (klass = alias_tracker.instance_variable_get(:@assoc_klass))
|
14
|
-
klass.columns_hash[column_name]
|
15
|
-
else # rails < 4.1
|
16
|
-
association.klass.columns_hash[column_name]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_constraints(scope, owner, assoc_klass, refl, tracker)
|
21
|
-
tracker.instance_variable_set(:@assoc_klass, assoc_klass)
|
22
|
-
super
|
23
|
-
end
|
24
|
-
end
|
25
7
|
end
|
26
8
|
|
27
9
|
class Connection < ActiveRecord::ConnectionAdapters::AbstractAdapter
|
@@ -43,33 +25,15 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
43
25
|
end
|
44
26
|
|
45
27
|
class Column < ActiveRecord::ConnectionAdapters::Column
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
super(name, default, metadata, null)
|
50
|
-
end
|
51
|
-
else
|
52
|
-
def initialize(name, default, sql_type = nil, null = true)
|
53
|
-
cast_type = ActiveRecord::Base.connection.send :lookup_cast_type, sql_type
|
54
|
-
super(name, default, cast_type, sql_type, null)
|
55
|
-
end
|
28
|
+
def initialize(name, default, sql_type = nil, null = true, **)
|
29
|
+
metadata = ActiveRecord::Base.connection.send :fetch_type_metadata, sql_type
|
30
|
+
super(name, default, metadata, null)
|
56
31
|
end
|
57
32
|
end
|
58
33
|
|
59
34
|
module Tableless
|
60
|
-
|
61
|
-
|
62
|
-
klass < ActiveScaffold::Tableless ? true : super
|
63
|
-
end
|
64
|
-
|
65
|
-
def association_scope
|
66
|
-
@association_scope ||= AssociationScope.scope(self, klass.connection) if klass < ActiveScaffold::Tableless
|
67
|
-
super
|
68
|
-
end
|
69
|
-
else
|
70
|
-
def skip_statement_cache?(scope)
|
71
|
-
klass < ActiveScaffold::Tableless ? true : super
|
72
|
-
end
|
35
|
+
def skip_statement_cache?(scope)
|
36
|
+
klass < ActiveScaffold::Tableless ? true : super
|
73
37
|
end
|
74
38
|
|
75
39
|
def target_scope
|
@@ -186,18 +150,11 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
186
150
|
private
|
187
151
|
|
188
152
|
def relation
|
189
|
-
|
190
|
-
if Rails.version < '5.2.0'
|
191
|
-
args << arel_table
|
192
|
-
args << predicate_builder if Rails.version >= '5.0.0'
|
193
|
-
end
|
194
|
-
ActiveScaffold::Tableless::Relation.new(*args)
|
153
|
+
ActiveScaffold::Tableless::Relation.new(self)
|
195
154
|
end
|
196
155
|
|
197
|
-
|
198
|
-
|
199
|
-
StatementCache.new(key, self, &block)
|
200
|
-
end
|
156
|
+
def cached_find_by_statement(key, &block)
|
157
|
+
StatementCache.new(key, self, &block)
|
201
158
|
end
|
202
159
|
end
|
203
160
|
|
@@ -207,34 +164,8 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
207
164
|
@model = model
|
208
165
|
end
|
209
166
|
|
210
|
-
|
211
|
-
|
212
|
-
model.where(@key => values)
|
213
|
-
end
|
214
|
-
else
|
215
|
-
def execute(values, connection)
|
216
|
-
@model.where(@key => values)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
if Rails.version < '5.0' # 4.2.x
|
221
|
-
def self.columns_hash
|
222
|
-
if self < ActiveScaffold::Tableless
|
223
|
-
@columns_hash ||= Hash[columns.map { |c| [c.name, c] }]
|
224
|
-
else
|
225
|
-
super
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def self.initialize_find_by_cache
|
230
|
-
self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) } # rubocop:disable Rails/DynamicFindBy
|
231
|
-
end
|
232
|
-
elsif Rails.version < '5.2' # 5.0 and 5.1
|
233
|
-
def self.initialize_find_by_cache
|
234
|
-
@find_by_statement_cache = {
|
235
|
-
true => Hash.new { |h, k| h[k] = StatementCache.new(k) },
|
236
|
-
false => Hash.new { |h, k| h[k] = StatementCache.new(k) }
|
237
|
-
}
|
167
|
+
def execute(values, connection)
|
168
|
+
@model.where(@key => values)
|
238
169
|
end
|
239
170
|
end
|
240
171
|
|
data/lib/active_scaffold.rb
CHANGED
@@ -3,9 +3,9 @@ module ActiveScaffold
|
|
3
3
|
autoload :AttributeParams, 'active_scaffold/attribute_params'
|
4
4
|
autoload :Bridges, 'active_scaffold/bridges'
|
5
5
|
autoload :Configurable, 'active_scaffold/configurable'
|
6
|
+
autoload :ConnectionAdapters, 'active_scaffold/extensions/connection_adapter.rb'
|
6
7
|
autoload :Constraints, 'active_scaffold/constraints'
|
7
8
|
autoload :Core, 'active_scaffold/core'
|
8
|
-
autoload :DelayedSetup, 'active_scaffold/delayed_setup'
|
9
9
|
autoload :Finder, 'active_scaffold/finder'
|
10
10
|
autoload :MarkedModel, 'active_scaffold/marked_model'
|
11
11
|
autoload :OrmChecks, 'active_scaffold/orm_checks'
|
@@ -45,7 +45,6 @@ module ActiveScaffold
|
|
45
45
|
class ActionNotAllowed < RuntimeError; end
|
46
46
|
class ReverseAssociationRequired < RuntimeError; end
|
47
47
|
|
48
|
-
mattr_accessor :delayed_setup, instance_writer: false
|
49
48
|
mattr_accessor :stylesheets, instance_writer: false
|
50
49
|
self.stylesheets = []
|
51
50
|
mattr_accessor :javascripts, instance_writer: false
|
@@ -80,15 +79,12 @@ module ActiveScaffold
|
|
80
79
|
@@exclude_bridges ||= []
|
81
80
|
end
|
82
81
|
|
82
|
+
mattr_accessor :nested_subforms, instance_writer: false
|
83
|
+
|
83
84
|
def self.root
|
84
85
|
File.dirname(__FILE__) + '/..'
|
85
86
|
end
|
86
87
|
|
87
|
-
def self.set_defaults(&block) # rubocop:disable Naming/AccessorMethodName
|
88
|
-
ActiveSupport::Deprecation.warn 'use ActiveScaffold.defaults'
|
89
|
-
defaults(&block)
|
90
|
-
end
|
91
|
-
|
92
88
|
def self.defaults(&block)
|
93
89
|
ActiveScaffold::Config::Core.configure(&block)
|
94
90
|
end
|
@@ -97,5 +93,3 @@ require 'active_scaffold/engine'
|
|
97
93
|
require 'ice_nine'
|
98
94
|
require 'ice_nine/core_ext/object'
|
99
95
|
require 'request_store'
|
100
|
-
# TODO: clean up extensions. some could be organized for autoloading, and others could be removed entirely.
|
101
|
-
Dir["#{File.dirname __FILE__}/active_scaffold/extensions/*.rb"].each { |file| require file }
|
@@ -37,7 +37,7 @@ module ActiveScaffold
|
|
37
37
|
file = 'app/assets/stylesheets/application.css'
|
38
38
|
return unless File.exist?(file)
|
39
39
|
original_css = File.binread(file)
|
40
|
-
if original_css
|
40
|
+
if original_css.match?(/require active_scaffold$/)
|
41
41
|
say_status('skipped', 'insert into app/assets/stylesheets/application.css', :yellow)
|
42
42
|
else
|
43
43
|
insert_into_file 'app/assets/stylesheets/application.css', before: %r{[ ]*\*/} do
|
@@ -68,7 +68,7 @@ module ActiveScaffold
|
|
68
68
|
say_status('create', file)
|
69
69
|
end
|
70
70
|
insert_into_file 'app/views/layouts/application.html.erb', after: /javascript_pack_tag 'application'.*\n/ do
|
71
|
-
" <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>\n"
|
71
|
+
" <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload', 'data-turbo-track': 'reload' %>\n"
|
72
72
|
end
|
73
73
|
append_to_file 'config/initializers/assets.rb' do
|
74
74
|
"Rails.application.config.assets.precompile += %w( application.js )\n"
|
data/test/bridges/bridge_test.rb
CHANGED
@@ -24,7 +24,8 @@ class DatePickerTest < ActionView::TestCase
|
|
24
24
|
def test_form_ui
|
25
25
|
config = ActiveScaffold::Config::Core.new(:company)
|
26
26
|
@record = Company.new
|
27
|
-
|
28
|
-
assert active_scaffold_input_date_picker(config.columns[:
|
27
|
+
opts = {object: @record}
|
28
|
+
assert active_scaffold_input_date_picker(config.columns[:date], opts.merge(id: 'record_date', name: 'record[date]'))
|
29
|
+
assert active_scaffold_input_date_picker(config.columns[:datetime], opts.merge(id: 'record_date', name: 'record[datetime]'))
|
29
30
|
end
|
30
31
|
end
|
@@ -58,24 +58,28 @@ class PaperclipTest < ActionView::TestCase
|
|
58
58
|
with_js_framework :jquery do
|
59
59
|
config = PaperclipCore.new(:company)
|
60
60
|
@record = Company.new
|
61
|
+
opts = {name: 'record[logo]', id: 'record_logo', object: @record}
|
61
62
|
|
62
63
|
@record.stubs(:logo).returns(stub(:file? => true, :original_filename => 'file', :url => '/system/file', :styles => Company.attachment_definitions[:logo]))
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
'</div></div>'
|
74
|
-
].join
|
75
|
-
assert_dom_equal template, active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo', :object => @record)
|
64
|
+
click_js = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show(); return false;"
|
65
|
+
change_js = "jQuery(this).parents('div.paperclip_controls').find('input.remove_file').val('false'); return false;"
|
66
|
+
@document = Nokogiri::HTML::Document.parse(active_scaffold_input_paperclip(config.columns[:logo], opts))
|
67
|
+
assert_select 'div.paperclip_controls input[type=file]' do |match|
|
68
|
+
assert_equal match[0]['onchange'], change_js
|
69
|
+
end
|
70
|
+
assert_select 'div.paperclip_controls a[href="#"][onclick]' do |match|
|
71
|
+
assert_equal match[0]['onclick'], click_js
|
72
|
+
end
|
73
|
+
assert_select 'div.paperclip_controls input.remove_file[type=hidden][value=false]'
|
76
74
|
|
77
75
|
@record.stubs(:logo).returns(stub(:file? => false))
|
78
|
-
assert_dom_equal '<input name="record[logo]" class="text-input" autocomplete="off" type="file" id="record_logo" />', active_scaffold_input_paperclip(config.columns[:logo],
|
76
|
+
assert_dom_equal '<input name="record[logo]" class="text-input" autocomplete="off" type="file" id="record_logo" />', active_scaffold_input_paperclip(config.columns[:logo], opts)
|
79
77
|
end
|
80
78
|
end
|
79
|
+
|
80
|
+
protected
|
81
|
+
|
82
|
+
def document_root_element
|
83
|
+
@document.root
|
84
|
+
end
|
81
85
|
end
|
@@ -28,23 +28,25 @@ class TinyMceTest < ActionView::TestCase
|
|
28
28
|
def test_includes
|
29
29
|
ActiveScaffold::Bridges::TinyMce.expects(:install?).returns(true)
|
30
30
|
with_js_framework :jquery do
|
31
|
-
assert ActiveScaffold::Bridges.all_javascripts.include?('tinymce
|
31
|
+
assert ActiveScaffold::Bridges.all_javascripts.include?('tinymce')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_form_ui
|
36
36
|
config = ActiveScaffold::Config::Core.new(:company)
|
37
37
|
record = Company.new
|
38
|
+
opts = {name: 'record[name]', id: 'record_name', class: 'name-input', object: record}
|
38
39
|
|
39
|
-
assert_dom_equal %(<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\" data-tinymce=\"{"theme":"modern"}\">\n</textarea>), active_scaffold_input_text_editor(config.columns[:name],
|
40
|
+
assert_dom_equal %(<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\" data-tinymce=\"{"theme":"modern"}\">\n</textarea>), active_scaffold_input_text_editor(config.columns[:name], opts)
|
40
41
|
end
|
41
42
|
|
42
43
|
def test_form_ui_alternate
|
43
44
|
config = ActiveScaffold::Config::Core.new(:company)
|
44
45
|
record = Company.new
|
45
46
|
config.columns[:name].options[:tinymce_config] = :alternate
|
47
|
+
opts = {name: 'record[name]', id: 'record_name', class: 'name-input', object: record}
|
46
48
|
|
47
|
-
assert_dom_equal %(<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\" data-tinymce=\"{"theme":"alternate","toolbar":"undo redo | format"}\">\n</textarea>), active_scaffold_input_tinymce(config.columns[:name],
|
49
|
+
assert_dom_equal %(<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\" data-tinymce=\"{"theme":"alternate","toolbar":"undo redo | format"}\">\n</textarea>), active_scaffold_input_tinymce(config.columns[:name], opts)
|
48
50
|
end
|
49
51
|
|
50
52
|
protected
|
data/test/config/base_test.rb
CHANGED
data/test/config/core_test.rb
CHANGED
data/test/config/create_test.rb
CHANGED
data/test/config/delete_test.rb
CHANGED
data/test/config/list_test.rb
CHANGED
data/test/config/nested_test.rb
CHANGED
data/test/config/search_test.rb
CHANGED
data/test/config/show_test.rb
CHANGED
data/test/config/subform_test.rb
CHANGED
data/test/config/update_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
# require 'test/model_stub'
|
3
3
|
# require File.join(File.dirname(__FILE__), '../../lib/active_scaffold/data_structures/set.rb')
|
4
4
|
|
5
|
-
class ActionColumnsTest <
|
5
|
+
class ActionColumnsTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@columns = ActiveScaffold::DataStructures::ActionColumns.new(%i[a b])
|
8
8
|
@columns.action = stub(core: stub(model_id: 'model_stub'), user_settings_key: :"model_stub_active_scaffold/config/test")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class SortingTest <
|
3
|
+
class SortingTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
@columns = ActiveScaffold::DataStructures::Columns.new(ModelStub, :a, :b, :c, :d, :id)
|
6
6
|
@sorting = ActiveScaffold::DataStructures::Sorting.new(@columns, ModelStub)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class ValidationReflectionTest <
|
3
|
+
class ValidationReflectionTest < Minitest::Test
|
4
4
|
def test_set_required_for_validates_presence_of
|
5
5
|
column = ActiveScaffold::DataStructures::Column.new(:name, Company)
|
6
6
|
refute column.required?
|
@@ -9,23 +9,25 @@ class FormColumnHelpersTest < ActionView::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_choices_for_select_form_ui_for_simple_column
|
12
|
+
opts = {object: @record}
|
12
13
|
@column.options[:options] = %i[value_1 value_2 value_3]
|
13
|
-
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">Value 1</option>\n<option value=\"value_2\">Value 2</option>\n<option value=\"value_3\">Value 3</option></select>", active_scaffold_input_select(@column,
|
14
|
+
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">Value 1</option>\n<option value=\"value_2\">Value 2</option>\n<option value=\"value_3\">Value 3</option></select>", active_scaffold_input_select(@column, opts.dup)
|
14
15
|
|
15
16
|
@column.options[:options] = %w[value_1 value_2 value_3]
|
16
|
-
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">value_1</option>\n<option value=\"value_2\">value_2</option>\n<option value=\"value_3\">value_3</option></select>", active_scaffold_input_select(@column,
|
17
|
+
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">value_1</option>\n<option value=\"value_2\">value_2</option>\n<option value=\"value_3\">value_3</option></select>", active_scaffold_input_select(@column, opts.dup)
|
17
18
|
|
18
19
|
@column.options[:options] = [%w[text_1 value_1], %w[text_2 value_2], %w[text_3 value_3]]
|
19
|
-
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">text_1</option>\n<option value=\"value_2\">text_2</option>\n<option value=\"value_3\">text_3</option></select>", active_scaffold_input_select(@column,
|
20
|
+
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">text_1</option>\n<option value=\"value_2\">text_2</option>\n<option value=\"value_3\">text_3</option></select>", active_scaffold_input_select(@column, opts.dup)
|
20
21
|
|
21
22
|
@column.options[:options] = [%i[text_1 value_1], %i[text_2 value_2], %i[text_3 value_3]]
|
22
|
-
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">Text 1</option>\n<option value=\"value_2\">Text 2</option>\n<option value=\"value_3\">Text 3</option></select>", active_scaffold_input_select(@column,
|
23
|
+
assert_dom_equal "<select name=\"record[a]\" id=\"record_a\"><option value=\"value_1\">Text 1</option>\n<option value=\"value_2\">Text 2</option>\n<option value=\"value_3\">Text 3</option></select>", active_scaffold_input_select(@column, opts.dup)
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_options_for_select_form_ui_for_simple_column
|
27
|
+
opts = {object: @record}
|
26
28
|
@column.options = {:include_blank => 'None', :selected => 'value_2', :disabled => %w[value_1 value_3]}
|
27
29
|
@column.options[:options] = %w[value_1 value_2 value_3]
|
28
30
|
@column.options[:html_options] = {:class => 'big'}
|
29
|
-
assert_dom_equal "<select name=\"record[a]\" class=\"big\" id=\"record_a\"><option value=\"\">None</option>\n<option disabled=\"disabled\" value=\"value_1\">value_1</option>\n<option selected=\"selected\" value=\"value_2\">value_2</option>\n<option disabled=\"disabled\" value=\"value_3\">value_3</option></select>", active_scaffold_input_select(@column,
|
31
|
+
assert_dom_equal "<select name=\"record[a]\" class=\"big\" id=\"record_a\"><option value=\"\">None</option>\n<option disabled=\"disabled\" value=\"value_1\">value_1</option>\n<option selected=\"selected\" value=\"value_2\">value_2</option>\n<option disabled=\"disabled\" value=\"value_3\">value_3</option></select>", active_scaffold_input_select(@column, opts)
|
30
32
|
end
|
31
33
|
end
|
@@ -9,6 +9,7 @@ class SearchColumnHelpersTest < ActionView::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_choices_for_boolean_search_ui
|
12
|
-
|
12
|
+
opts = {object: @record, name: 'search[adult]', value: '0'}
|
13
|
+
assert_dom_equal "<select name=\"search[adult]\"><option value=\"\">- select -</option>\n<option value=\"true\">True</option>\n<option value=\"false\" selected=\"selected\">False</option></select>", active_scaffold_search_boolean(@column, opts)
|
13
14
|
end
|
14
15
|
end
|
@@ -17,6 +17,7 @@ module ModelStubs
|
|
17
17
|
@table_name || to_s.split('::').last.underscore.pluralize
|
18
18
|
end
|
19
19
|
self.store_full_sti_class = false
|
20
|
+
def self.load_schema; end
|
20
21
|
end
|
21
22
|
|
22
23
|
##
|
@@ -121,7 +122,7 @@ class ConstraintsTestObject
|
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
|
-
class ConstraintsTest <
|
125
|
+
class ConstraintsTest < Minitest::Test
|
125
126
|
def setup
|
126
127
|
@test_object = ConstraintsTestObject.new
|
127
128
|
end
|