cells 2.3.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -3
- data/MIT-LICENSE +22 -0
- data/README.rdoc +2 -2
- data/Rakefile +22 -25
- data/generators/cell/templates/cell.rb +1 -1
- data/generators/cells_install/USAGE +3 -0
- data/generators/cells_install/cells_install_generator.rb +12 -0
- data/generators/cells_install/templates/initializer.rb +9 -0
- data/lib/cell.rb +9 -0
- data/lib/cells.rb +68 -0
- data/lib/cells/cell.rb +15 -0
- data/lib/cells/cell/base.rb +461 -0
- data/lib/cells/cell/caching.rb +163 -0
- data/lib/cells/cell/view.rb +56 -0
- data/lib/cells/helpers.rb +7 -0
- data/lib/cells/helpers/capture_helper.rb +51 -0
- data/lib/cells/rails.rb +17 -0
- data/lib/cells/rails/action_controller.rb +37 -0
- data/lib/cells/rails/action_view.rb +37 -0
- data/lib/cells/version.rb +5 -0
- data/rails/init.rb +30 -0
- data/test/{cells → app/cells}/cells_test_one_cell.rb +2 -2
- data/test/{cells → app/cells}/cells_test_two_cell.rb +2 -0
- data/test/{cells → app/cells}/really_module/nested_cell.rb +1 -1
- data/test/app/cells/simple_cell.rb +7 -0
- data/test/{cells → app/cells}/test_cell.rb +3 -7
- data/test/app/controllers/cells_test_controller.rb +44 -0
- data/test/app/helpers/application_helper.rb +7 -0
- data/test/{helpers → app/helpers}/helper_using_cell_helper.rb +3 -1
- data/test/bugs_test.rb +10 -13
- data/test/caching_test.rb +169 -165
- data/test/capture_helper_test.rb +59 -0
- data/test/cells_test.rb +160 -158
- data/test/helper_test.rb +83 -104
- data/test/rails_test.rb +35 -0
- data/test/render_test.rb +163 -106
- data/test/support/assertions_helper.rb +60 -0
- data/test/test_helper.rb +67 -0
- metadata +35 -25
- data/README +0 -150
- data/VERSION +0 -1
- data/init.rb +0 -59
- data/lib/cell/base.rb +0 -454
- data/lib/cell/caching.rb +0 -151
- data/lib/cell/view.rb +0 -55
- data/lib/cells_helper.rb +0 -49
- data/lib/rails_extensions.rb +0 -75
- data/test/capture_test.rb +0 -56
- data/test/cell_view_test.rb +0 -9
- data/test/cells/simple_cell.rb +0 -5
- data/test/rails_extensions_test.rb +0 -25
- data/test/testing_helper.rb +0 -67
data/test/helper_test.rb
CHANGED
@@ -1,87 +1,129 @@
|
|
1
|
-
|
2
|
-
require File.dirname(__FILE__)
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module CellsTestHelper
|
5
|
+
def a_mysterious_helper_method
|
6
|
+
'mysterious'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module AnotherHelper
|
11
|
+
def senseless_helper_method
|
12
|
+
'senseless'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class HelperUsingCell < ::Cell::Base
|
17
|
+
helper CellsTestHelper
|
18
|
+
helper_method :my_helper_method
|
19
|
+
|
20
|
+
def state_with_helper_invocation
|
21
|
+
render
|
22
|
+
end
|
23
|
+
|
24
|
+
def state_with_automatic_helper_invocation
|
25
|
+
render
|
26
|
+
end
|
27
|
+
|
28
|
+
def state_with_helper_method_invocation
|
29
|
+
render
|
30
|
+
end
|
31
|
+
|
32
|
+
def state_using_application_helper
|
33
|
+
render
|
34
|
+
end
|
6
35
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
36
|
+
protected
|
37
|
+
|
38
|
+
def my_helper_method
|
39
|
+
'helped by a method'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class TwoHelpersIncludingCell < HelperUsingCell
|
44
|
+
helper AnotherHelper
|
45
|
+
|
46
|
+
def state_using_another_helper
|
47
|
+
render
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class HelperUsingSubCell < HelperUsingCell
|
52
|
+
end
|
53
|
+
|
54
|
+
class HelperTest < ActionController::TestCase
|
11
55
|
def test_helper
|
12
56
|
cell = HelperUsingCell.new(@controller)
|
13
57
|
|
14
|
-
|
15
|
-
assert_selekt
|
58
|
+
c = cell.render_state(:state_with_helper_invocation)
|
59
|
+
assert_selekt c, 'p#stateWithHelperInvocation', 'mysterious'
|
16
60
|
end
|
17
|
-
|
18
|
-
#ActiveSupport::Dependencies.load_paths <<
|
61
|
+
|
62
|
+
# ActiveSupport::Dependencies.load_paths << File.join(File.dirname(__FILE__), 'helpers')
|
19
63
|
# test if the HelperUsingCellHelper is automatically included:
|
20
|
-
|
64
|
+
|
21
65
|
## FIXME: currently loading should happen in render_view_for_state, since
|
22
66
|
# there seems to be no automatic mechanism.
|
23
67
|
def dont_test_auto_helper
|
24
|
-
#ActionController::Base.helpers_dir =
|
25
|
-
|
26
|
-
Cell::Base.helpers_dir = RAILS_ROOT + "/vendor/plugins/cells/test/helpers"
|
68
|
+
# ActionController::Base.helpers_dir = File.join(File.dirname(__FILE__), 'helpers')
|
69
|
+
::Cell::Base.helpers_dir = File.join(File.dirname(__FILE__), 'app', 'helpers')
|
27
70
|
setup
|
28
|
-
|
71
|
+
|
29
72
|
cell = HelperUsingCell.new(@controller)
|
73
|
+
c = cell.render_state(:state_with_automatic_helper_invocation)
|
30
74
|
|
31
|
-
|
32
|
-
assert_selekt content, "p#stateWithAutomaticHelperInvocation", "automatic"
|
75
|
+
assert_selekt c, 'p#stateWithAutomaticHelperInvocation', 'automatic'
|
33
76
|
end
|
34
77
|
|
35
78
|
def test_helper_method
|
36
79
|
cell = HelperUsingCell.new(@controller)
|
80
|
+
c = cell.render_state(:state_with_helper_method_invocation)
|
37
81
|
|
38
|
-
|
39
|
-
assert_selekt content, "p#stateWithHelperMethodInvocation", "helped by a method"
|
82
|
+
assert_selekt c, 'p#stateWithHelperMethodInvocation', 'helped by a method'
|
40
83
|
end
|
41
84
|
|
42
85
|
def test_helper_with_subclassing
|
43
|
-
|
44
|
-
|
45
|
-
|
86
|
+
cell = HelperUsingSubCell.new(@controller)
|
87
|
+
c = cell.render_state(:state_with_helper_invocation)
|
88
|
+
|
89
|
+
assert_selekt c, 'p#stateWithHelperInvocation', 'mysterious'
|
46
90
|
end
|
47
91
|
|
48
92
|
def test_helper_including_and_cleanup
|
49
93
|
# this cell includes a helper, and uses it:
|
50
94
|
cell = HelperUsingCell.new(@controller)
|
95
|
+
c = cell.render_state(:state_with_helper_invocation)
|
51
96
|
|
52
|
-
|
53
|
-
assert_selekt content, "p#stateWithHelperInvocation", "mysterious"
|
97
|
+
assert_selekt c, 'p#stateWithHelperInvocation', 'mysterious'
|
54
98
|
|
55
99
|
# this cell doesn't include the helper, but uses it anyway, which should
|
56
100
|
# produce an error:
|
57
|
-
|
58
101
|
cell = TestCell.new(@controller)
|
59
102
|
|
60
|
-
#
|
61
|
-
|
103
|
+
# assert_raises (NameError) do
|
104
|
+
assert_raises (::ActionView::TemplateError) do
|
62
105
|
cell.render_state(:state_with_not_included_helper_method)
|
63
106
|
end
|
64
107
|
end
|
65
|
-
|
66
|
-
|
108
|
+
|
67
109
|
def test_helpers_included_on_different_inheritance_levels
|
68
110
|
cell = TwoHelpersIncludingCell.new(@controller)
|
69
|
-
|
70
111
|
c = cell.render_state(:state_with_helper_invocation)
|
71
|
-
|
72
|
-
|
112
|
+
|
113
|
+
assert_selekt c, 'p#stateWithHelperInvocation', 'mysterious'
|
114
|
+
|
73
115
|
c = cell.render_state(:state_using_another_helper)
|
74
|
-
|
116
|
+
|
117
|
+
assert_selekt c, 'p#stateUsingAnotherHelper', 'senseless'
|
75
118
|
end
|
76
|
-
|
77
|
-
|
119
|
+
|
78
120
|
def test_application_helper
|
79
121
|
cell = HelperUsingCell.new(@controller)
|
80
|
-
|
81
122
|
c = cell.render_state(:state_using_application_helper)
|
82
|
-
|
123
|
+
|
124
|
+
assert_selekt c, 'p#stateUsingApplicationHelper', 'global'
|
83
125
|
end
|
84
|
-
|
126
|
+
|
85
127
|
def test_rails_helper_url_for
|
86
128
|
cell = HelperUsingCell.new(@controller)
|
87
129
|
cell.instance_eval do
|
@@ -89,71 +131,8 @@ class CellsHelperTest < ActionController::TestCase
|
|
89
131
|
render :inline => "<%= url_for '/test' %>"
|
90
132
|
end
|
91
133
|
end
|
92
|
-
|
93
134
|
c = cell.render_state(:state_with_url_for)
|
94
|
-
assert_equal "/test", c
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
module ApplicationHelper
|
100
|
-
def application_helper_method
|
101
|
-
"global"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
module CellsTestHelper
|
107
|
-
def a_mysterious_helper_method
|
108
|
-
"mysterious"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
module AnotherHelper
|
114
|
-
def senseless_helper_method
|
115
|
-
"senseless"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
class HelperUsingCell < Cell::Base
|
121
|
-
helper CellsTestHelper
|
122
|
-
|
123
|
-
def state_with_helper_invocation
|
124
|
-
render
|
125
|
-
end
|
126
|
-
|
127
|
-
def state_with_automatic_helper_invocation
|
128
|
-
render
|
129
|
-
end
|
130
|
-
|
131
|
-
def state_with_helper_method_invocation
|
132
|
-
render
|
133
|
-
end
|
134
|
-
|
135
|
-
def state_using_application_helper
|
136
|
-
render
|
137
|
-
end
|
138
|
-
|
139
|
-
protected
|
140
135
|
|
141
|
-
|
142
|
-
"helped by a method"
|
136
|
+
assert_equal '/test', c
|
143
137
|
end
|
144
|
-
|
145
|
-
helper_method :my_helper_method
|
146
|
-
end
|
147
|
-
|
148
|
-
class TwoHelpersIncludingCell < HelperUsingCell
|
149
|
-
|
150
|
-
helper AnotherHelper
|
151
|
-
|
152
|
-
def state_using_another_helper
|
153
|
-
render
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
|
-
class HelperUsingSubCell < HelperUsingCell
|
159
138
|
end
|
data/test/rails_test.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
3
|
+
|
4
|
+
class ACell < ::Cell::Base
|
5
|
+
def existing_view
|
6
|
+
@a = 'a'
|
7
|
+
render
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ActionControllerRenderTest < ActionController::TestCase
|
12
|
+
include Cells::Rails::ActionController
|
13
|
+
|
14
|
+
def test_render_cell
|
15
|
+
assert_equal 'A/existing_view/a', render_cell(:a, :existing_view)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Backward-compability.
|
19
|
+
def test_render_cell_to_string
|
20
|
+
assert_equal render_cell_to_string(:a, :existing_view), render_cell(:a, :existing_view)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ActionControllerRenderTest < ActionController::TestCase
|
25
|
+
include Cells::Rails::ActionView
|
26
|
+
|
27
|
+
def test_render_cell
|
28
|
+
assert_equal 'A/existing_view/a', render_cell(:a, :existing_view)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Backward-compability.
|
32
|
+
def test_render_cell_to_string
|
33
|
+
assert_equal render_cell_to_string(:a, :existing_view), render_cell(:a, :existing_view)
|
34
|
+
end
|
35
|
+
end
|
data/test/render_test.rb
CHANGED
@@ -1,229 +1,286 @@
|
|
1
|
-
|
2
|
-
require File.dirname(__FILE__)
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
3
3
|
|
4
|
-
class ACell < Cell::Base
|
4
|
+
class ACell < ::Cell::Base
|
5
5
|
def existing_view
|
6
|
-
@a =
|
6
|
+
@a = 'a'
|
7
|
+
render
|
7
8
|
end
|
8
|
-
|
9
|
+
|
9
10
|
def not_existing_view
|
10
|
-
@a =
|
11
|
+
@a = 'a'
|
12
|
+
render
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
class BCell < ACell
|
15
17
|
def existing_view
|
16
|
-
@b =
|
18
|
+
@b = 'b'
|
19
|
+
render
|
17
20
|
end
|
18
|
-
|
21
|
+
|
19
22
|
def not_existing_view
|
20
|
-
@b =
|
23
|
+
@b = 'b'
|
24
|
+
render
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
class RenderTest <
|
25
|
-
include
|
26
|
-
|
27
|
-
|
28
|
+
class RenderTest < ActiveSupport::TestCase
|
29
|
+
include Cells::Rails::ActionView
|
30
|
+
|
28
31
|
def test_return_nil_with_locally_existing_view
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
32
|
+
assert_equal 'A/existing_view/a', render_cell(:a, :existing_view)
|
33
|
+
assert_equal 'B/existing_view/b', render_cell(:b, :existing_view)
|
31
34
|
end
|
32
|
-
|
35
|
+
|
33
36
|
def test_return_nil_with_inherited_view
|
34
|
-
BCell.class_eval do
|
35
|
-
def inherited_view
|
37
|
+
BCell.class_eval do
|
38
|
+
def inherited_view
|
39
|
+
@a = 'b'
|
40
|
+
render
|
41
|
+
end
|
36
42
|
end
|
37
|
-
assert_equal
|
43
|
+
assert_equal 'A/inherited_view/b', render_cell(:b, :inherited_view)
|
38
44
|
end
|
39
|
-
|
45
|
+
|
40
46
|
def test_render_with_not_existing_view
|
41
|
-
assert_raises ActionView::MissingTemplate do
|
42
|
-
|
47
|
+
assert_raises ActionView::MissingTemplate do
|
48
|
+
render_cell(:a, :not_existing_view)
|
49
|
+
end
|
50
|
+
assert_raises ActionView::MissingTemplate do
|
51
|
+
render_cell(:b, :not_existing_view)
|
52
|
+
end
|
43
53
|
end
|
44
|
-
|
54
|
+
|
45
55
|
def test_render_without_arguments_with_locally_existing_view
|
46
56
|
ACell.class_eval do
|
47
|
-
def existing_view
|
57
|
+
def existing_view
|
58
|
+
@a = 'a'
|
59
|
+
render
|
60
|
+
end
|
48
61
|
end
|
49
62
|
BCell.class_eval do
|
50
|
-
def existing_view
|
63
|
+
def existing_view
|
64
|
+
@b = 'b'
|
65
|
+
render
|
66
|
+
end
|
51
67
|
end
|
52
|
-
assert_equal
|
53
|
-
assert_equal
|
68
|
+
assert_equal 'A/existing_view/a', render_cell(:a, :existing_view)
|
69
|
+
assert_equal 'B/existing_view/b', render_cell(:b, :existing_view)
|
54
70
|
end
|
55
|
-
|
71
|
+
|
56
72
|
def test_render_passing_view_with_locally_existing_view
|
57
73
|
ACell.class_eval do
|
58
|
-
def existing_view
|
74
|
+
def existing_view
|
75
|
+
@a = 'a'
|
76
|
+
render :view => 'existing_view'
|
77
|
+
end
|
59
78
|
end
|
60
79
|
BCell.class_eval do
|
61
|
-
def existing_view
|
80
|
+
def existing_view
|
81
|
+
@b = 'b'
|
82
|
+
render :view => 'existing_view'
|
83
|
+
end
|
62
84
|
end
|
63
|
-
assert_equal
|
64
|
-
assert_equal
|
85
|
+
assert_equal 'A/existing_view/a', render_cell(:a, :existing_view)
|
86
|
+
assert_equal 'B/existing_view/b', render_cell(:b, :existing_view)
|
65
87
|
end
|
66
|
-
|
88
|
+
|
67
89
|
def test_render_passing_view_and_layout_with_locally_existing_view
|
68
90
|
BCell.class_eval do
|
69
|
-
def existing_view
|
70
|
-
|
91
|
+
def existing_view
|
92
|
+
@b = 'b'
|
93
|
+
render :view => 'existing_view', :layout => 'metal'
|
94
|
+
end
|
71
95
|
end
|
72
96
|
assert_equal "Metal:B/existing_view/b", render_cell(:b, :existing_view)
|
73
97
|
end
|
74
|
-
|
98
|
+
|
75
99
|
def test_render_passing_view_and_template_format_with_locally_existing_view
|
76
100
|
BCell.class_eval do
|
77
|
-
def existing_view
|
78
|
-
|
101
|
+
def existing_view
|
102
|
+
@b = 'b'
|
103
|
+
render :view => 'existing_view', :template_format => :js
|
104
|
+
end
|
79
105
|
end
|
80
|
-
assert_equal
|
106
|
+
assert_equal 'B/existing_view/b/js', render_cell(:b, :existing_view)
|
81
107
|
end
|
82
|
-
|
108
|
+
|
83
109
|
def test_render_passing_view_and_template_format_and_layout_with_locally_existing_view
|
84
110
|
BCell.class_eval do
|
85
|
-
def existing_view
|
86
|
-
|
111
|
+
def existing_view
|
112
|
+
@b = 'b'
|
113
|
+
render :view => 'existing_view', :template_format => :js, :layout => 'metal'
|
114
|
+
end
|
87
115
|
end
|
88
|
-
assert_equal
|
116
|
+
assert_equal 'Metal:B/existing_view/b/js', render_cell(:b, :existing_view)
|
89
117
|
end
|
90
|
-
|
118
|
+
|
91
119
|
# test :layout
|
92
120
|
def test_render_passing_layout_located_in_cells_layout
|
93
121
|
ACell.class_eval do
|
94
|
-
def existing_view
|
95
|
-
|
122
|
+
def existing_view
|
123
|
+
@a = 'a'
|
124
|
+
render :layout => 'metal'
|
125
|
+
end
|
96
126
|
end
|
97
|
-
assert_equal
|
127
|
+
assert_equal 'Metal:A/existing_view/a', render_cell(:a, :existing_view)
|
98
128
|
end
|
99
|
-
|
129
|
+
|
100
130
|
### DISCUSS: currently undocumented feature:
|
101
131
|
def test_render_passing_layout_located_in_cells_b_layouts
|
102
132
|
BCell.class_eval do
|
103
|
-
def existing_view
|
104
|
-
|
133
|
+
def existing_view
|
134
|
+
@b = 'b'
|
135
|
+
render :layout => 'b/layouts/metal'
|
136
|
+
end
|
105
137
|
end
|
106
|
-
assert_equal
|
138
|
+
assert_equal 'B-Metal:B/existing_view/b', render_cell(:b, :existing_view)
|
107
139
|
end
|
108
|
-
|
140
|
+
|
109
141
|
# test with inherited view:
|
110
142
|
def test_render_without_arguments_with_inherited_view
|
111
143
|
BCell.class_eval do
|
112
|
-
def inherited_view
|
144
|
+
def inherited_view
|
145
|
+
@a = 'b'
|
146
|
+
render
|
147
|
+
end
|
113
148
|
end
|
114
|
-
assert_equal
|
149
|
+
assert_equal 'A/inherited_view/b', render_cell(:b, :inherited_view)
|
115
150
|
end
|
116
|
-
|
151
|
+
|
117
152
|
def test_render_passing_view_with_inherited_view
|
118
153
|
BCell.class_eval do
|
119
|
-
def existing_view
|
154
|
+
def existing_view
|
155
|
+
@a = 'b'
|
156
|
+
render :view => 'inherited_view'
|
157
|
+
end
|
120
158
|
end
|
121
|
-
assert_equal
|
159
|
+
assert_equal 'A/inherited_view/b', render_cell(:b, :existing_view)
|
122
160
|
end
|
123
|
-
|
161
|
+
|
124
162
|
def test_render_passing_view_and_layout_with_inherited_view
|
125
163
|
BCell.class_eval do
|
126
|
-
def inherited_view
|
127
|
-
|
164
|
+
def inherited_view
|
165
|
+
@a = 'b'
|
166
|
+
render :view => 'inherited_view', :layout => 'metal'
|
167
|
+
end
|
128
168
|
end
|
129
|
-
assert_equal
|
169
|
+
assert_equal 'Metal:A/inherited_view/b', render_cell(:b, :inherited_view)
|
130
170
|
end
|
131
|
-
|
171
|
+
|
132
172
|
def test_render_passing_view_and_template_format_with_inherited_view
|
133
173
|
BCell.class_eval do
|
134
|
-
def inherited_view
|
135
|
-
|
174
|
+
def inherited_view
|
175
|
+
@a = 'b'
|
176
|
+
render :view => 'inherited_view', :template_format => :js
|
177
|
+
end
|
136
178
|
end
|
137
|
-
assert_equal
|
179
|
+
assert_equal 'A/inherited_view/b/js', render_cell(:b, :inherited_view)
|
138
180
|
end
|
139
|
-
|
181
|
+
|
140
182
|
def test_render_passing_view_and_template_format_and_layout_with_inherited_view
|
141
183
|
BCell.class_eval do
|
142
|
-
def existing_view
|
143
|
-
|
184
|
+
def existing_view
|
185
|
+
@a = 'b'
|
186
|
+
render :view => 'inherited_view', :template_format => :js, :layout => 'metal'
|
187
|
+
end
|
144
188
|
end
|
145
|
-
assert_equal
|
189
|
+
assert_equal 'Metal:A/inherited_view/b/js', render_cell(:b, :existing_view)
|
146
190
|
end
|
147
|
-
|
148
|
-
|
191
|
+
|
149
192
|
def test_render_passing_locals
|
150
193
|
ACell.class_eval do
|
151
|
-
def view_with_locals
|
152
|
-
|
194
|
+
def view_with_locals
|
195
|
+
@a = 'a'
|
196
|
+
render :locals => {:name => 'Nick'}
|
197
|
+
end
|
153
198
|
end
|
154
|
-
assert_equal
|
199
|
+
assert_equal 'A/view_with_locals/a/Nick', render_cell(:a, :view_with_locals)
|
155
200
|
end
|
156
|
-
|
157
|
-
|
201
|
+
|
158
202
|
def test_recursive_render_view_with_existing_view
|
159
203
|
ACell.class_eval do
|
160
|
-
def view_with_render_call
|
161
|
-
|
204
|
+
def view_with_render_call
|
205
|
+
@a = 'a'
|
206
|
+
render
|
207
|
+
end
|
162
208
|
end
|
163
|
-
assert_equal
|
209
|
+
assert_equal 'A/view_with_render_call/a:A/existing_view/a', render_cell(:a, :view_with_render_call)
|
164
210
|
end
|
165
|
-
|
211
|
+
|
166
212
|
def test_recursive_render_view_with_inherited_view
|
167
213
|
BCell.class_eval do
|
168
|
-
def view_with_render_call
|
169
|
-
|
214
|
+
def view_with_render_call
|
215
|
+
@a = 'b'
|
216
|
+
render
|
217
|
+
end
|
170
218
|
end
|
171
|
-
assert_equal
|
219
|
+
assert_equal 'B/view_with_render_call/b:A/inherited_view/b', render_cell(:b, :view_with_render_call)
|
172
220
|
end
|
173
|
-
|
221
|
+
|
174
222
|
def test_render_text
|
175
223
|
ACell.class_eval do
|
176
|
-
def existing_view
|
177
|
-
render :text =>
|
224
|
+
def existing_view
|
225
|
+
render :text => 'Cells kick ass!'
|
226
|
+
end
|
178
227
|
end
|
179
|
-
assert_equal
|
228
|
+
assert_equal 'Cells kick ass!', render_cell(:a, :existing_view)
|
180
229
|
end
|
181
|
-
|
230
|
+
|
182
231
|
def test_render_text_with_layout
|
183
232
|
ACell.class_eval do
|
184
|
-
def existing_view
|
185
|
-
render :text =>
|
233
|
+
def existing_view
|
234
|
+
render :text => 'Cells kick ass!', :layout => 'metal'
|
235
|
+
end
|
186
236
|
end
|
187
|
-
assert_equal
|
237
|
+
assert_equal 'Metal:Cells kick ass!', render_cell(:a, :existing_view)
|
188
238
|
end
|
189
|
-
|
239
|
+
|
190
240
|
def test_render_nothing
|
191
241
|
ACell.class_eval do
|
192
|
-
def existing_view
|
193
|
-
render :nothing => true
|
242
|
+
def existing_view
|
243
|
+
render :nothing => true
|
244
|
+
end
|
194
245
|
end
|
195
|
-
assert_equal
|
246
|
+
assert_equal '', render_cell(:a, :existing_view)
|
196
247
|
end
|
197
|
-
|
248
|
+
|
198
249
|
def test_render_inline
|
199
250
|
ACell.class_eval do
|
200
|
-
def existing_view
|
201
|
-
|
251
|
+
def existing_view
|
252
|
+
@a = 'a'
|
253
|
+
render :inline => 'A/existing_view/a:<%= a %>', :type => :erb, :locals => {:a => 'a'}
|
254
|
+
end
|
202
255
|
end
|
203
|
-
assert_equal
|
256
|
+
assert_equal 'A/existing_view/a:a', render_cell(:a, :existing_view)
|
204
257
|
end
|
205
|
-
|
258
|
+
|
206
259
|
def test_render_state
|
207
260
|
ACell.class_eval do
|
208
|
-
def existing_view
|
261
|
+
def existing_view
|
262
|
+
@a = 'a'
|
209
263
|
render :state => :another_state
|
210
264
|
end
|
211
|
-
def another_state
|
265
|
+
def another_state
|
266
|
+
@b = 'b'
|
212
267
|
render
|
213
268
|
end
|
214
269
|
end
|
215
270
|
assert_equal "A/another_state/a,b", render_cell(:a, :existing_view)
|
216
271
|
end
|
217
|
-
|
272
|
+
|
218
273
|
def test_render_state_with_layout
|
219
274
|
ACell.class_eval do
|
220
|
-
def existing_view
|
275
|
+
def existing_view
|
276
|
+
@a = 'a'
|
221
277
|
render :state => :another_state, :layout => 'metal'
|
222
278
|
end
|
223
|
-
def another_state
|
279
|
+
def another_state
|
280
|
+
@b = 'b'
|
224
281
|
render
|
225
282
|
end
|
226
283
|
end
|
227
284
|
assert_equal "Metal:A/another_state/a,b", render_cell(:a, :existing_view)
|
228
285
|
end
|
229
|
-
end
|
286
|
+
end
|