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/create_test.rb
CHANGED
@@ -1,58 +1,60 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
module Config
|
4
|
+
class CreateTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
@default_link = @config.create.link
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
@config.create.link = @default_link
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_default_options
|
15
|
+
assert !@config.create.persistent
|
16
|
+
assert @config.create.action_after_create.nil?
|
17
|
+
assert_equal 'Create Model stub', @config.create.label
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
20
|
+
def test_link_defaults
|
21
|
+
link = @config.create.link
|
22
|
+
assert !link.page?
|
23
|
+
assert !link.popup?
|
24
|
+
assert !link.confirm?
|
25
|
+
assert_equal "new", link.action
|
26
|
+
assert_equal "Create New", link.label
|
27
|
+
assert link.inline?
|
28
|
+
blank = {}
|
29
|
+
assert_equal blank, link.html_options
|
30
|
+
assert_equal :get, link.method
|
31
|
+
assert_equal :collection, link.type
|
32
|
+
assert_equal :create, link.crud_type
|
33
|
+
assert_equal :create_authorized?, link.security_method
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_setting_link
|
37
|
+
@config.create.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
|
38
|
+
assert_not_equal(@default_link, @config.create.link)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_label
|
42
|
+
label = 'create new monkeys'
|
43
|
+
@config.create.label = label
|
44
|
+
assert_equal label, @config.create.label
|
45
|
+
I18n.backend.store_translations :en, :active_scaffold => {:create_new_model => 'Create new %{model}'}
|
46
|
+
@config.create.label = :create_new_model
|
47
|
+
assert_equal 'Create new Model stub', @config.create.label
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_persistent
|
51
|
+
@config.create.persistent = true
|
52
|
+
assert @config.create.persistent
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_action_after_create
|
56
|
+
@config.create.action_after_create = :edit
|
57
|
+
assert_equal :edit, @config.create.action_after_create
|
58
|
+
end
|
57
59
|
end
|
58
60
|
end
|
data/test/config/delete_test.rb
CHANGED
@@ -1,33 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module Config
|
4
|
+
class DeleteTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
@default_link = @config.delete.link
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
@config.delete.link = @default_link
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
14
|
+
def test_link_defaults
|
15
|
+
link = @config.delete.link
|
16
|
+
assert !link.page?
|
17
|
+
assert !link.popup?
|
18
|
+
assert link.confirm?
|
19
|
+
assert_equal "destroy", link.action
|
20
|
+
assert_equal "Delete", link.label
|
21
|
+
assert link.inline?
|
22
|
+
blank = {}
|
23
|
+
assert_equal blank, link.html_options
|
24
|
+
assert_equal :delete, link.method
|
25
|
+
assert_equal :member, link.type
|
26
|
+
assert_equal :delete, link.crud_type
|
27
|
+
assert_equal :delete_authorized?, link.security_method
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_setting_link
|
31
|
+
@config.delete.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
|
32
|
+
assert_not_equal(@default_link, @config.delete.link)
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
@@ -1,47 +1,49 @@
|
|
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
|
-
|
3
|
+
module Config
|
4
|
+
class FieldSearchTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = ActiveScaffold::Config::Core.new :model_stub
|
7
|
+
@config.actions.swap :search, :field_search
|
8
|
+
@default_link = @config.field_search.link
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
@config.field_search.link = @default_link
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_default_options
|
16
|
+
assert_equal :full, @config.field_search.text_search
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_text_search
|
20
|
+
@config.field_search.text_search = :start
|
21
|
+
assert_equal :start, @config.field_search.text_search
|
22
|
+
@config.field_search.text_search = :end
|
23
|
+
assert_equal :end, @config.field_search.text_search
|
24
|
+
@config.field_search.text_search = false
|
25
|
+
assert !@config.field_search.text_search
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
28
|
+
def test_link_defaults
|
29
|
+
link = @config.field_search.link
|
30
|
+
assert !link.page?
|
31
|
+
assert !link.popup?
|
32
|
+
assert !link.confirm?
|
33
|
+
assert_equal "show_search", link.action
|
34
|
+
assert_equal "Search", link.label
|
35
|
+
assert link.inline?
|
36
|
+
blank = {}
|
37
|
+
assert_equal blank, link.html_options
|
38
|
+
assert_equal :get, link.method
|
39
|
+
assert_equal :collection, link.type
|
40
|
+
assert_equal :read, link.crud_type
|
41
|
+
assert_equal :search_authorized?, link.security_method
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_setting_link
|
45
|
+
@config.field_search.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
|
46
|
+
assert_not_equal(@default_link, @config.field_search.link)
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
data/test/config/list_test.rb
CHANGED
@@ -1,123 +1,125 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Config
|
4
|
+
class ListTest < 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_label
|
10
|
+
I18n.backend.store_translations :en, :active_scaffold => {:resource => {:one => 'Resource', :other => 'Resources'}}
|
11
|
+
@config.list.label = :resource
|
12
|
+
assert_equal 'Resources', @config.list.label
|
13
|
+
label = 'monkeys'
|
14
|
+
@config.list.label = label
|
15
|
+
assert_equal label, @config.list.label
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def test_empty_field_text
|
35
|
-
@config.list.empty_field_text = '(missing)'
|
36
|
-
assert_equal '(missing)', @config.list.empty_field_text
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_association_join_text
|
40
|
-
@config.list.association_join_text = '<br/>'
|
41
|
-
assert_equal '<br/>', @config.list.association_join_text
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_no_entries
|
45
|
-
@config.list.no_entries_message = 'No items'
|
46
|
-
assert_equal 'No items', @config.list.no_entries_message
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_filtered_message
|
50
|
-
@config.list.filtered_message = 'filtered items'
|
51
|
-
assert_equal 'filtered items', @config.list.filtered_message
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_pagination
|
55
|
-
@config.list.pagination = :infinite
|
56
|
-
assert_equal :infinite, @config.list.pagination
|
57
|
-
@config.list.pagination = false
|
58
|
-
assert !@config.list.pagination
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_sorting
|
62
|
-
@config.list.sorting = {:a => :desc}
|
63
|
-
assert @config.list.sorting.sorts_on?(:a)
|
64
|
-
assert_equal 'DESC', @config.list.sorting.direction_of(:a)
|
65
|
-
assert !@config.list.sorting.sorts_on?(:id)
|
18
|
+
def test_default_options
|
19
|
+
assert_equal 15, @config.list.per_page
|
20
|
+
assert_equal 2, @config.list.page_links_inner_window
|
21
|
+
assert_equal '-', @config.list.empty_field_text
|
22
|
+
assert_equal ', ', @config.list.association_join_text
|
23
|
+
assert_equal true, @config.list.pagination
|
24
|
+
assert_equal 'search', @config.list.search_partial
|
25
|
+
assert_equal :no_entries, @config.list.no_entries_message
|
26
|
+
assert_equal :filtered, @config.list.filtered_message
|
27
|
+
assert !@config.list.always_show_create
|
28
|
+
assert !@config.list.always_show_search
|
29
|
+
assert @config.list.count_includes.nil?
|
30
|
+
assert_equal 'ModelStubs', @config.list.label
|
31
|
+
assert @config.list.sorting.sorts_on?(:id)
|
32
|
+
assert_equal 'ASC', @config.list.sorting.direction_of(:id)
|
33
|
+
end
|
66
34
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
35
|
+
def test_empty_field_text
|
36
|
+
@config.list.empty_field_text = '(missing)'
|
37
|
+
assert_equal '(missing)', @config.list.empty_field_text
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_association_join_text
|
41
|
+
@config.list.association_join_text = '<br/>'
|
42
|
+
assert_equal '<br/>', @config.list.association_join_text
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_no_entries
|
46
|
+
@config.list.no_entries_message = 'No items'
|
47
|
+
assert_equal 'No items', @config.list.no_entries_message
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_filtered_message
|
51
|
+
@config.list.filtered_message = 'filtered items'
|
52
|
+
assert_equal 'filtered items', @config.list.filtered_message
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_pagination
|
56
|
+
@config.list.pagination = :infinite
|
57
|
+
assert_equal :infinite, @config.list.pagination
|
58
|
+
@config.list.pagination = false
|
59
|
+
assert !@config.list.pagination
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_sorting
|
63
|
+
@config.list.sorting = {:a => :desc}
|
64
|
+
assert @config.list.sorting.sorts_on?(:a)
|
65
|
+
assert_equal 'DESC', @config.list.sorting.direction_of(:a)
|
66
|
+
assert !@config.list.sorting.sorts_on?(:id)
|
67
|
+
|
68
|
+
@config.list.sorting = [{:a => :asc}, {:b => :desc}]
|
69
|
+
assert @config.list.sorting.sorts_on?(:a)
|
70
|
+
assert_equal 'ASC', @config.list.sorting.direction_of(:a)
|
71
|
+
assert @config.list.sorting.sorts_on?(:b)
|
72
|
+
assert_equal 'DESC', @config.list.sorting.direction_of(:b)
|
73
|
+
assert !@config.list.sorting.sorts_on?(:id)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_per_page
|
77
|
+
per_page = 35
|
78
|
+
@config.list.per_page = per_page
|
79
|
+
assert_equal per_page, @config.list.per_page
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_page_links_window
|
83
|
+
page_links_window = 3
|
84
|
+
@config.list.page_links_inner_window = page_links_window
|
85
|
+
assert_equal page_links_window, @config.list.page_links_inner_window
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_always_show_create
|
89
|
+
always_show_create = true
|
90
|
+
@config.list.always_show_create = always_show_create
|
91
|
+
assert_equal always_show_create, @config.list.always_show_create
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_always_show_create_when_create_is_not_enabled
|
95
|
+
always_show_create = true
|
96
|
+
@config.list.always_show_create = always_show_create
|
97
|
+
@config.actions.exclude :create
|
98
|
+
assert_equal false, @config.list.always_show_create
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_always_show_search
|
102
|
+
@config.list.always_show_search = true
|
103
|
+
assert @config.list.always_show_search
|
104
|
+
assert_equal 'search', @config.list.search_partial
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_always_show_search_when_search_is_not_enabled
|
108
|
+
@config.list.always_show_search = true
|
109
|
+
@config.actions.exclude :search
|
110
|
+
assert_equal false, @config.list.always_show_search
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_always_show_search_when_field_search
|
114
|
+
@config.list.always_show_search = true
|
115
|
+
@config.actions.swap :search, :field_search
|
116
|
+
assert @config.list.always_show_search
|
117
|
+
assert_equal 'field_search', @config.list.search_partial
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_count_includes
|
121
|
+
@config.list.count_includes = [:assoc_1, :assoc_2]
|
122
|
+
assert_equal [:assoc_1, :assoc_2], @config.list.count_includes
|
123
|
+
end
|
122
124
|
end
|
123
125
|
end
|