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