active_scaffold 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +9 -0
- data/app/assets/javascripts/active_scaffold.js.erb +5 -2
- data/app/assets/javascripts/jquery/active_scaffold.js +4 -6
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +16 -14
- data/app/assets/javascripts/prototype/active_scaffold.js +0 -5
- data/app/assets/stylesheets/active_scaffold.css.scss +1 -1
- data/app/assets/stylesheets/active_scaffold_jquery_ui.css.erb +7 -0
- data/lib/active_scaffold.rb +1 -1
- data/lib/active_scaffold/actions/update.rb +2 -1
- data/lib/active_scaffold/attribute_params.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker.rb +1 -1
- data/lib/active_scaffold/config/core.rb +0 -2
- data/lib/active_scaffold/config/nested.rb +6 -3
- data/lib/active_scaffold/constraints.rb +2 -2
- data/lib/active_scaffold/data_structures/action_columns.rb +68 -72
- data/lib/active_scaffold/data_structures/column.rb +7 -3
- data/lib/active_scaffold/data_structures/sorting.rb +2 -1
- data/lib/active_scaffold/finder.rb +2 -14
- data/lib/active_scaffold/helpers/form_column_helpers.rb +1 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/pagination_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/view_helpers.rb +7 -5
- data/lib/active_scaffold/tableless.rb +2 -2
- data/lib/active_scaffold/version.rb +1 -1
- data/test/bridges/bridge_test.rb +22 -33
- data/test/bridges/date_picker_test.rb +29 -0
- data/test/bridges/paperclip_test.rb +10 -11
- data/test/bridges/tiny_mce_test.rb +7 -7
- data/test/{bridges/company.rb → company.rb} +14 -13
- data/test/config/base_test.rb +14 -12
- data/test/config/core_test.rb +59 -53
- data/test/config/create_test.rb +56 -54
- data/test/config/delete_test.rb +31 -29
- data/test/config/field_search_test.rb +45 -43
- data/test/config/list_test.rb +119 -117
- data/test/config/nested_test.rb +50 -58
- data/test/config/search_test.rb +58 -56
- data/test/config/show_test.rb +42 -40
- data/test/config/subform_test.rb +15 -13
- data/test/config/update_test.rb +40 -38
- data/test/const_mocker.rb +14 -18
- data/test/data_structures/action_columns_test.rb +3 -3
- data/test/data_structures/action_link_test.rb +1 -1
- data/test/data_structures/action_links_test.rb +3 -3
- data/test/data_structures/actions_test.rb +2 -2
- data/test/data_structures/association_column_test.rb +5 -6
- data/test/data_structures/column_test.rb +8 -4
- data/test/data_structures/columns_test.rb +2 -3
- data/test/data_structures/error_message_test.rb +2 -2
- data/test/data_structures/set_test.rb +2 -3
- data/test/data_structures/sorting_test.rb +1 -2
- data/test/data_structures/standard_column_test.rb +2 -3
- data/test/data_structures/validation_reflection_test.rb +51 -0
- data/test/data_structures/virtual_column_test.rb +1 -1
- data/test/extensions/active_record_test.rb +2 -3
- data/test/extensions/array_test.rb +2 -2
- data/test/helpers/form_column_helpers_test.rb +6 -6
- data/test/helpers/list_column_helpers_test.rb +4 -1
- data/test/helpers/pagination_helpers_test.rb +7 -3
- data/test/misc/active_record_permissions_test.rb +1 -1
- data/test/misc/attribute_params_test.rb +3 -4
- data/test/misc/configurable_test.rb +2 -2
- data/test/misc/constraints_test.rb +29 -29
- data/test/misc/finder_test.rb +13 -10
- data/test/misc/lang_test.rb +1 -1
- data/test/mock_app/Rakefile +7 -0
- data/test/mock_app/config.ru +4 -0
- data/test/mock_app/config/application.rb +11 -0
- data/test/mock_app/config/boot.rb +6 -109
- data/test/mock_app/config/database.yml +2 -2
- data/test/mock_app/config/environment.rb +4 -42
- data/test/mock_app/config/environments/development.rb +21 -13
- data/test/mock_app/config/environments/production.rb +41 -20
- data/test/mock_app/config/environments/test.rb +27 -22
- data/test/mock_app/config/initializers/backtrace_silencers.rb +2 -2
- data/test/mock_app/config/initializers/inflections.rb +1 -1
- data/test/mock_app/config/initializers/secret_token.rb +7 -0
- data/test/mock_app/config/initializers/session_store.rb +2 -9
- data/test/mock_app/config/initializers/wrap_parameters.rb +14 -0
- data/test/mock_app/config/routes.rb +2 -42
- data/test/model_stub.rb +2 -3
- data/test/test_helper.rb +13 -11
- data/vendor/assets/stylesheets/jquery-ui-theme.css.erb +47 -0
- data/vendor/assets/stylesheets/jquery-ui.css +2 -36
- metadata +92 -103
- data/test/bridges/active_scaffold_dependent_protect_test.rb +0 -34
- data/test/bridges/unobtrusive_date_picker_test.rb +0 -49
- data/test/bridges/validation_reflection_test.rb +0 -57
- data/test/mock_app/config/initializers/new_rails_defaults.rb +0 -19
data/test/config/nested_test.rb
CHANGED
@@ -1,62 +1,54 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def test_default_options
|
9
|
-
assert !@config.nested.shallow_delete
|
10
|
-
assert_equal 'Add Existing ModelStub', @config.nested.label
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_label
|
14
|
-
label = 'nested monkeys'
|
15
|
-
@config.nested.label = label
|
16
|
-
assert_equal label, @config.nested.label
|
17
|
-
I18n.backend.store_translations :en, :active_scaffold => {:create_model => 'Add new %{model}'}
|
18
|
-
@config.nested.label = :create_model
|
19
|
-
assert_equal 'Add new ModelStub', @config.nested.label
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_shallow_delete
|
23
|
-
@config.nested.shallow_delete = true
|
24
|
-
assert @config.nested.shallow_delete
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_add_link_deprecation
|
28
|
-
ActiveSupport::Deprecation.silence { @config.nested.add_link :custom_link, [:assoc_1, :assoc_2] }
|
29
|
-
link = @config.action_links['nested']
|
30
|
-
assert_equal 'Custom Link', link.label
|
31
|
-
assert_equal 'nested', link.action
|
32
|
-
assert_equal :after, link.position
|
33
|
-
assert !link.page?
|
34
|
-
assert !link.popup?
|
35
|
-
assert !link.confirm?
|
36
|
-
assert link.inline?
|
37
|
-
assert_equal :assoc_1, link.parameters[:associations]
|
38
|
-
assert_equal 'assoc_1', link.html_options[:class]
|
39
|
-
assert_equal :get, link.method
|
40
|
-
assert_equal :member, link.type
|
41
|
-
assert_equal :read, link.crud_type
|
42
|
-
assert_equal :nested_authorized?, link.security_method
|
43
|
-
end
|
3
|
+
module Config
|
4
|
+
class NestedTest < Test::Unit::TestCase
|
5
|
+
class ModelStubsController < ActionController::Base
|
6
|
+
active_scaffold
|
7
|
+
end
|
44
8
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
9
|
+
def setup
|
10
|
+
@config = ActiveScaffold::Config::Core.new(:model_stub)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_default_options
|
14
|
+
assert @config.nested.shallow_delete
|
15
|
+
assert_equal 'Add Existing Model stub', @config.nested.label
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_label
|
19
|
+
label = 'nested monkeys'
|
20
|
+
@config.nested.label = label
|
21
|
+
assert_equal label, @config.nested.label
|
22
|
+
I18n.backend.store_translations :en, :active_scaffold => {:create_model => 'Add new %{model}'}
|
23
|
+
@config.nested.label = :create_model
|
24
|
+
assert_equal 'Add new Model stub', @config.nested.label
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_shallow_delete
|
28
|
+
@config.nested.shallow_delete = true
|
29
|
+
assert @config.nested.shallow_delete
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_add_link
|
33
|
+
assert_raise(ArgumentError) { @config.nested.add_link :assoc_1 }
|
34
|
+
config = @config
|
35
|
+
ModelStubsController.class_eval do
|
36
|
+
config.configure { nested.add_link :other_models }
|
37
|
+
end
|
38
|
+
link = @config.action_links['index']
|
39
|
+
assert_equal 'ModelStubs', link.label
|
40
|
+
assert_equal 'index', link.action
|
41
|
+
assert_equal :after, link.position
|
42
|
+
assert !link.page?
|
43
|
+
assert !link.popup?
|
44
|
+
assert !link.confirm?
|
45
|
+
assert link.inline?
|
46
|
+
assert link.refresh_on_close
|
47
|
+
assert_equal :other_models, link.parameters[:association]
|
48
|
+
assert_equal :get, link.method
|
49
|
+
assert_equal :member, link.type
|
50
|
+
assert_equal :read, link.crud_type
|
51
|
+
assert_equal :nested_authorized?, link.security_method
|
52
|
+
end
|
61
53
|
end
|
62
54
|
end
|
data/test/config/search_test.rb
CHANGED
@@ -1,60 +1,62 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
3
|
+
module Config
|
4
|
+
class SearchTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
@default_link = @config.search.link
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
@config.search.link = @default_link
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_default_options
|
15
|
+
assert_equal :full, @config.search.text_search
|
16
|
+
assert !@config.search.live?
|
17
|
+
assert_equal ' ', @config.search.split_terms
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_text_search
|
21
|
+
@config.search.text_search = :start
|
22
|
+
assert_equal :start, @config.search.text_search
|
23
|
+
@config.search.text_search = :end
|
24
|
+
assert_equal :end, @config.search.text_search
|
25
|
+
@config.search.text_search = false
|
26
|
+
assert !@config.search.text_search
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_live
|
30
|
+
@config.search.live = true
|
31
|
+
assert @config.search.live?
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_split_terms
|
35
|
+
@config.search.split_terms = nil
|
36
|
+
assert @config.search.split_terms.nil?
|
37
|
+
@config.search.split_terms = ','
|
38
|
+
assert_equal ',', @config.search.split_terms
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
41
|
+
def test_link_defaults
|
42
|
+
link = @config.search.link
|
43
|
+
assert !link.page?
|
44
|
+
assert !link.popup?
|
45
|
+
assert !link.confirm?
|
46
|
+
assert_equal "show_search", link.action
|
47
|
+
assert_equal "Search", link.label
|
48
|
+
assert link.inline?
|
49
|
+
blank = {}
|
50
|
+
assert_equal blank, link.html_options
|
51
|
+
assert_equal :get, link.method
|
52
|
+
assert_equal :collection, link.type
|
53
|
+
assert_equal :read, link.crud_type
|
54
|
+
assert_equal :search_authorized?, link.security_method
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_setting_link
|
58
|
+
@config.search.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
|
59
|
+
assert_not_equal(@default_link, @config.search.link)
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
data/test/config/show_test.rb
CHANGED
@@ -1,43 +1,45 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
3
|
+
module Config
|
4
|
+
class ShowTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
@default_link = @config.show.link
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
@config.show.link = @default_link
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_link_defaults
|
15
|
+
link = @config.show.link
|
16
|
+
assert !link.page?
|
17
|
+
assert !link.popup?
|
18
|
+
assert !link.confirm?
|
19
|
+
assert_equal "show", link.action
|
20
|
+
assert_equal "Show", link.label
|
21
|
+
assert link.inline?
|
22
|
+
blank = {}
|
23
|
+
assert_equal blank, link.html_options
|
24
|
+
assert_equal :get, link.method
|
25
|
+
assert_equal :member, link.type
|
26
|
+
assert_equal :read, link.crud_type
|
27
|
+
assert_equal :show_authorized?, link.security_method
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_setting_link
|
31
|
+
@config.show.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
|
32
|
+
assert_not_equal(@default_link, @config.show.link)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_label
|
36
|
+
label = 'show monkeys'
|
37
|
+
@config.show.label = label
|
38
|
+
assert_equal label, @config.show.label
|
39
|
+
I18n.backend.store_translations :en, :active_scaffold => {:view_model => 'View %{model}'}
|
40
|
+
@config.show.label = :view_model
|
41
|
+
assert_equal 'View Model stub', @config.show.label
|
42
|
+
assert_equal 'View record', @config.show.label('record')
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
data/test/config/subform_test.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Config
|
4
|
+
class SubformTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
def test_defaults
|
10
|
+
assert_equal :horizontal, @config.subform.layout
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_setting_layout
|
14
|
+
layout = :vertical
|
15
|
+
@config.subform.layout = layout
|
16
|
+
assert_equal layout, @config.subform.layout
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
data/test/config/update_test.rb
CHANGED
@@ -1,40 +1,42 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Config
|
4
|
+
class UpdateTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
end
|
8
|
+
|
9
|
+
def test__params_for_columns__returns_all_params
|
10
|
+
@config._load_action_columns
|
11
|
+
@config.columns[:a].params.add :keep_a, :a_temp
|
12
|
+
assert @config.columns[:a].params.include?(:keep_a)
|
13
|
+
assert @config.columns[:a].params.include?(:a_temp)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_default_options
|
17
|
+
assert !@config.update.persistent
|
18
|
+
assert !@config.update.nested_links
|
19
|
+
assert_equal 'Model stub', @config.update.label
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_persistent
|
23
|
+
@config.update.persistent = true
|
24
|
+
assert @config.update.persistent
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_nested_links
|
28
|
+
@config.update.nested_links = true
|
29
|
+
assert @config.update.nested_links
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_label
|
33
|
+
label = 'update new monkeys'
|
34
|
+
@config.update.label = label
|
35
|
+
assert_equal label, @config.update.label
|
36
|
+
I18n.backend.store_translations :en, :active_scaffold => {:change_model => 'Change %{model}'}
|
37
|
+
@config.update.label = :change_model
|
38
|
+
assert_equal 'Change Model stub', @config.update.label
|
39
|
+
assert_equal 'Change record', @config.update.label('record')
|
40
|
+
end
|
6
41
|
end
|
7
|
-
|
8
|
-
def test__params_for_columns__returns_all_params
|
9
|
-
@config._load_action_columns
|
10
|
-
@config.columns[:a].params.add :keep_a, :a_temp
|
11
|
-
assert @config.columns[:a].params.include?(:keep_a)
|
12
|
-
assert @config.columns[:a].params.include?(:a_temp)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_default_options
|
16
|
-
assert !@config.update.persistent
|
17
|
-
assert !@config.update.nested_links
|
18
|
-
assert_equal 'Update ModelStub', @config.update.label
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_persistent
|
22
|
-
@config.update.persistent = true
|
23
|
-
assert @config.update.persistent
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_nested_links
|
27
|
-
@config.update.nested_links = true
|
28
|
-
assert @config.update.nested_links
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_label
|
32
|
-
label = 'update new monkeys'
|
33
|
-
@config.update.label = label
|
34
|
-
assert_equal label, @config.update.label
|
35
|
-
I18n.backend.store_translations :en, :active_scaffold => {:change_model => 'Change %{model}'}
|
36
|
-
@config.update.label = :change_model
|
37
|
-
assert_equal 'Change ModelStub', @config.update.label
|
38
|
-
assert_equal 'Change record', @config.update.label('record')
|
39
|
-
end
|
40
|
-
end
|
42
|
+
end
|
data/test/const_mocker.rb
CHANGED
@@ -1,34 +1,30 @@
|
|
1
1
|
class ConstMocker
|
2
|
-
def initialize(
|
3
|
-
@
|
4
|
-
@
|
5
|
-
@
|
6
|
-
|
7
|
-
}
|
2
|
+
def initialize(const_name, parent = Object)
|
3
|
+
@parent = parent
|
4
|
+
@const_name = const_name
|
5
|
+
@const_state = nil
|
6
|
+
@const_state = @parent.const_defined?(@const_name) ? @parent.const_get(@const_name) : nil
|
8
7
|
end
|
9
8
|
|
10
9
|
def remove
|
11
|
-
@
|
12
|
-
Object.send :remove_const, const_name if Object.const_defined?(const_name)
|
13
|
-
}
|
10
|
+
@parent.send :remove_const, @const_name if @parent.const_defined?(@const_name)
|
14
11
|
end
|
15
12
|
|
16
13
|
def declare
|
17
|
-
@
|
18
|
-
Object.class_eval "class #{const_name}; end;" unless Object.const_defined?(const_name)
|
19
|
-
}
|
14
|
+
@parent.const_set @const_name, Class.new
|
20
15
|
end
|
21
16
|
|
22
17
|
def restore
|
23
18
|
remove
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
@parent.const_set @const_name, @const_state if @const_state
|
20
|
+
end
|
21
|
+
|
22
|
+
def const
|
23
|
+
@parent.const_get @const_name if @parent.const_defined?(@const_name)
|
28
24
|
end
|
29
25
|
|
30
|
-
def self.mock(
|
31
|
-
cm = new(
|
26
|
+
def self.mock(const_name, parent = Object, &block)
|
27
|
+
cm = new(const_name, parent)
|
32
28
|
yield(cm)
|
33
29
|
cm.restore
|
34
30
|
true
|