cells 3.5.6 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.textile +6 -0
- data/README.rdoc +1 -1
- data/cells.gemspec +2 -2
- data/lib/cell.rb +0 -22
- data/lib/cell/caching.rb +1 -1
- data/lib/cell/rails.rb +13 -46
- data/lib/cell/rails3_0_strategy.rb +69 -0
- data/lib/cell/rails3_1_strategy.rb +24 -0
- data/lib/cells.rb +15 -7
- data/lib/cells/version.rb +1 -1
- data/test/app/cells/bassist/play.js.erb +1 -0
- data/test/cell_module_test.rb +15 -14
- data/test/cells_module_test.rb +22 -10
- data/test/dummy/config/routes.rb +1 -1
- data/test/rails/cells_test.rb +14 -43
- data/test/rails/render_test.rb +19 -4
- data/test/rails/router_test.rb +6 -0
- metadata +7 -8
- data/test/active_helper_test.rb +0 -57
data/CHANGES.textile
CHANGED
data/README.rdoc
CHANGED
data/cells.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "actionpack", "~> 3.0
|
23
|
-
s.add_dependency "railties", "~> 3.0
|
22
|
+
s.add_dependency "actionpack", "~> 3.0"
|
23
|
+
s.add_dependency "railties", "~> 3.0"
|
24
24
|
|
25
25
|
s.add_development_dependency "shoulda"
|
26
26
|
s.add_development_dependency "haml"
|
data/lib/cell.rb
CHANGED
@@ -70,23 +70,6 @@ module Cell
|
|
70
70
|
@builders ||= []
|
71
71
|
end
|
72
72
|
|
73
|
-
# Return the default view path for +state+. Override this if you cell has a differing naming style.
|
74
|
-
def view_for_state(state)
|
75
|
-
"#{cell_name}/#{state}"
|
76
|
-
end
|
77
|
-
|
78
|
-
# Returns all possible view paths for +state+ by invoking #view_for_state on all classes up
|
79
|
-
# the inheritance chain.
|
80
|
-
def find_class_view_for_state(state)
|
81
|
-
return [view_for_state(state)] unless superclass.respond_to?(:find_class_view_for_state)
|
82
|
-
|
83
|
-
superclass.find_class_view_for_state(state) << view_for_state(state)
|
84
|
-
end
|
85
|
-
|
86
|
-
def cell_name # TODO: remove in 3.6.
|
87
|
-
controller_path
|
88
|
-
end
|
89
|
-
|
90
73
|
# The cell class constant for +cell_name+.
|
91
74
|
def class_from_cell_name(cell_name)
|
92
75
|
"#{cell_name}_cell".classify.constantize
|
@@ -94,11 +77,6 @@ module Cell
|
|
94
77
|
end
|
95
78
|
|
96
79
|
module InstanceMethods
|
97
|
-
# Computes all possible paths for +state+ by traversing up the inheritance chain.
|
98
|
-
def possible_paths_for_state(state)
|
99
|
-
self.class.find_class_view_for_state(state).reverse!
|
100
|
-
end
|
101
|
-
|
102
80
|
def state_accepts_args?(state)
|
103
81
|
method(state).arity != 0
|
104
82
|
end
|
data/lib/cell/caching.rb
CHANGED
@@ -60,7 +60,7 @@ module Cell
|
|
60
60
|
|
61
61
|
# Computes the complete, namespaced cache key for +state+.
|
62
62
|
def state_cache_key(state, key_parts={})
|
63
|
-
expand_cache_key([
|
63
|
+
expand_cache_key([controller_path, state, key_parts])
|
64
64
|
end
|
65
65
|
|
66
66
|
def expire_cache_key(key, *args)
|
data/lib/cell/rails.rb
CHANGED
@@ -7,8 +7,13 @@ module Cell
|
|
7
7
|
include AbstractController
|
8
8
|
include Rendering, Layouts, Helpers, Callbacks, Translation, Logger
|
9
9
|
include ActionController::RequestForgeryProtection
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
if Cells.rails3_0?
|
12
|
+
require 'cell/rails3_0_strategy'
|
13
|
+
elsif Cells.rails3_1?
|
14
|
+
require 'cell/rails3_1_strategy'
|
15
|
+
end
|
16
|
+
|
12
17
|
class View < ActionView::Base
|
13
18
|
def render(*args, &block)
|
14
19
|
options = args.first.is_a?(::Hash) ? args.first : {} # this is copied from #render by intention.
|
@@ -17,15 +22,8 @@ module Cell
|
|
17
22
|
super
|
18
23
|
end
|
19
24
|
end
|
20
|
-
|
21
|
-
|
22
|
-
class MissingTemplate < ActionView::ActionViewError
|
23
|
-
def initialize(message, possible_paths)
|
24
|
-
super(message + " and possible paths #{possible_paths}")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
25
|
+
|
26
|
+
|
29
27
|
module Rendering
|
30
28
|
# Invoke the state method for +state+ which usually renders something nice.
|
31
29
|
def render_state(state, *args)
|
@@ -35,13 +33,15 @@ module Cell
|
|
35
33
|
|
36
34
|
|
37
35
|
module Metal
|
38
|
-
delegate :session, :params, :request, :config, :to => :parent_controller
|
36
|
+
delegate :session, :params, :request, :config, :env, :to => :parent_controller
|
39
37
|
end
|
40
38
|
|
41
39
|
|
42
40
|
include Metal
|
43
41
|
include Rendering
|
44
42
|
include Caching
|
43
|
+
include VersionStrategy
|
44
|
+
|
45
45
|
|
46
46
|
attr_reader :parent_controller
|
47
47
|
attr_accessor :options
|
@@ -60,18 +60,6 @@ module Cell
|
|
60
60
|
@opts = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :options)
|
61
61
|
end
|
62
62
|
|
63
|
-
def self.view_context_class
|
64
|
-
controller = self
|
65
|
-
|
66
|
-
View.class_eval do
|
67
|
-
include controller._helpers
|
68
|
-
include controller._routes.url_helpers
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
@view_context_class ||= View
|
73
|
-
end
|
74
|
-
|
75
63
|
def self.controller_path
|
76
64
|
@controller_path ||= name.sub(/Cell$/, '').underscore unless anonymous?
|
77
65
|
end
|
@@ -142,22 +130,6 @@ module Cell
|
|
142
130
|
end
|
143
131
|
|
144
132
|
private
|
145
|
-
# Climbs up the inheritance chain, looking for a view for the current +state+.
|
146
|
-
def find_family_view_for_state(state)
|
147
|
-
exception = nil
|
148
|
-
possible_paths = possible_paths_for_state(state)
|
149
|
-
|
150
|
-
possible_paths.each do |template_path|
|
151
|
-
begin
|
152
|
-
template = find_template(template_path)
|
153
|
-
return template if template
|
154
|
-
rescue ::ActionView::MissingTemplate => exception
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
raise MissingTemplate.new(exception.message, possible_paths)
|
159
|
-
end
|
160
|
-
|
161
133
|
# Renders the view belonging to the given state. Will raise ActionView::MissingTemplate
|
162
134
|
# if it can't find a view.
|
163
135
|
def render_view_for(state, *args)
|
@@ -168,15 +140,10 @@ module Cell
|
|
168
140
|
if opts[:state]
|
169
141
|
opts[:text] = render_state(opts.delete(:state), *args)
|
170
142
|
elsif (opts.keys & [:text, :inline, :file]).blank?
|
171
|
-
|
172
|
-
opts[:template] = find_family_view_for_state(opts.delete(:view))
|
143
|
+
process_opts_for(opts, state)
|
173
144
|
end
|
174
145
|
|
175
146
|
render_to_string(opts).html_safe # ActionView::Template::Text doesn't do that for us.
|
176
147
|
end
|
177
|
-
|
178
|
-
def defaultize_render_options_for(opts, state)
|
179
|
-
opts.reverse_merge!(:view => state)
|
180
|
-
end
|
181
148
|
end
|
182
149
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Cell
|
2
|
+
# Methods to be included in Cell::Rails in 3.0 context, where there's no view inheritance.
|
3
|
+
module VersionStrategy
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
class MissingTemplate < ActionView::ActionViewError
|
7
|
+
def initialize(message, possible_paths)
|
8
|
+
super(message + " and possible paths #{possible_paths}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def view_context_class
|
15
|
+
controller = self
|
16
|
+
|
17
|
+
Cell::Rails::View.class_eval do
|
18
|
+
include controller._helpers
|
19
|
+
include controller._routes.url_helpers
|
20
|
+
end
|
21
|
+
|
22
|
+
@view_context_class ||= Cell::Rails::View
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return the default view path for +state+. Override this if you cell has a differing naming style.
|
26
|
+
def view_for_state(state)
|
27
|
+
"#{cell_name}/#{state}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all possible view paths for +state+ by invoking #view_for_state on all classes up
|
31
|
+
# the inheritance chain.
|
32
|
+
def find_class_view_for_state(state)
|
33
|
+
return [view_for_state(state)] unless superclass.respond_to?(:find_class_view_for_state)
|
34
|
+
|
35
|
+
superclass.find_class_view_for_state(state) << view_for_state(state)
|
36
|
+
end
|
37
|
+
|
38
|
+
def cell_name
|
39
|
+
controller_path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
# Computes all possible paths for +state+ by traversing up the inheritance chain.
|
45
|
+
def possible_paths_for_state(state)
|
46
|
+
self.class.find_class_view_for_state(state).reverse!
|
47
|
+
end
|
48
|
+
|
49
|
+
# Climbs up the inheritance chain, looking for a view for the current +state+.
|
50
|
+
def find_family_view_for_state(state)
|
51
|
+
exception = nil
|
52
|
+
possible_paths = possible_paths_for_state(state)
|
53
|
+
|
54
|
+
possible_paths.each do |template_path|
|
55
|
+
begin
|
56
|
+
template = find_template(template_path)
|
57
|
+
return template if template
|
58
|
+
rescue ::ActionView::MissingTemplate => exception
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
raise MissingTemplate.new(exception.message, possible_paths)
|
63
|
+
end
|
64
|
+
|
65
|
+
def process_opts_for(opts, state)
|
66
|
+
opts[:template] = find_family_view_for_state(opts.delete(:view) || state)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cell
|
2
|
+
# Methods to be included in Cell::Rails in 3.1 context.
|
3
|
+
module VersionStrategy
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
include AbstractController::UrlFor # must be included before _routes is set in Railstie.
|
7
|
+
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def view_context_class
|
11
|
+
@view_context_class ||= begin
|
12
|
+
routes = _routes #if respond_to?(:_routes)
|
13
|
+
helpers = _helpers #if respond_to?(:_helpers)
|
14
|
+
Cell::Rails::View.prepare(routes, helpers)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def process_opts_for(opts, state)
|
21
|
+
opts[:action] = opts[:view] || state
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/cells.rb
CHANGED
@@ -58,13 +58,6 @@
|
|
58
58
|
# Beside your new class you'd provide a star-sprangled button view in +xmas_cart/order_button.haml+.
|
59
59
|
# When rendering the +cart+ state, the states as well as the "missing" views are inherited from ancesting cells,
|
60
60
|
# this is pretty DRY and object-oriented, isn't it?
|
61
|
-
|
62
|
-
require 'cell/rails'
|
63
|
-
require 'cells/railtie'
|
64
|
-
require 'cells/rails'
|
65
|
-
require 'cell/test_case' if Rails.env == "test"
|
66
|
-
require 'cells/rails_compat' # fixes a bug in Rails <3.0.4. # TODO: remove me as soon as we support 3.1, only.
|
67
|
-
|
68
61
|
module Cells
|
69
62
|
# Setup your special needs for Cells here. Use this to add new view paths.
|
70
63
|
#
|
@@ -77,6 +70,21 @@ module Cells
|
|
77
70
|
def self.setup
|
78
71
|
yield(Cell::Base)
|
79
72
|
end
|
73
|
+
|
74
|
+
def self.rails3_0?
|
75
|
+
::Rails::VERSION::MINOR == 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.rails3_1?
|
79
|
+
::Rails::VERSION::MINOR == 1
|
80
|
+
end
|
80
81
|
end
|
81
82
|
|
83
|
+
require 'cell/rails'
|
84
|
+
require 'cells/railtie'
|
85
|
+
require 'cells/rails'
|
86
|
+
require 'cell/test_case' if Rails.env == "test"
|
87
|
+
|
88
|
+
require 'cells/rails_compat' # fixes a bug in Rails <3.0.4. # TODO: remove me as soon as we support 3.1, only.
|
89
|
+
|
82
90
|
Cell::Base = Cell::Rails
|
data/lib/cells/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
alert("Doo");
|
data/test/cell_module_test.rb
CHANGED
@@ -134,24 +134,25 @@ class CellModuleTest < ActiveSupport::TestCase
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
should "provide
|
138
|
-
assert_equal
|
139
|
-
end
|
140
|
-
|
141
|
-
should "provide Cell.cell_name" do
|
142
|
-
assert_equal 'bassist', cell(:bassist).class.cell_name
|
137
|
+
should "provide class_from_cell_name" do
|
138
|
+
assert_equal BassistCell, ::Cell::Base.class_from_cell_name('bassist')
|
143
139
|
end
|
144
140
|
|
145
|
-
|
146
|
-
|
141
|
+
if Cells.rails3_0?
|
142
|
+
should "provide possible_paths_for_state" do
|
143
|
+
assert_equal ["bad_guitarist/play", "bassist/play", "cell/rails/play"], cell(:bad_guitarist).send(:possible_paths_for_state, :play)
|
147
144
|
end
|
148
145
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
146
|
+
should "provide Cell.cell_name" do
|
147
|
+
assert_equal 'bassist', cell(:bassist).class.cell_name
|
148
|
+
end
|
149
|
+
|
150
|
+
should "provide cell_name for modules, too" do
|
151
|
+
class SingerCell < Cell::Base
|
152
|
+
end
|
153
|
+
|
154
|
+
assert_equal "cell_module_test/singer", CellModuleTest::SingerCell.cell_name
|
155
|
+
end
|
155
156
|
end
|
156
157
|
|
157
158
|
context "#state_accepts_args?" do
|
data/test/cells_module_test.rb
CHANGED
@@ -2,20 +2,32 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class CellsModuleTest < ActiveSupport::TestCase
|
4
4
|
context "Cells" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
context "view_paths" do
|
6
|
+
setup do
|
7
|
+
@old_view_paths = Cell::Base.view_paths.clone
|
8
|
+
end
|
9
|
+
|
10
|
+
teardown do
|
11
|
+
Cell::Base.view_paths = @old_view_paths
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
should "provide .setup" do
|
15
|
+
Cells.setup do |c|
|
16
|
+
c.append_view_path "/road/to/nowhere"
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_equal "/road/to/nowhere", Cell::Base.view_paths.last.to_s
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
|
-
|
18
|
-
|
23
|
+
should "respond to #rails3_1?" do
|
24
|
+
if Rails::VERSION::MINOR == 0
|
25
|
+
assert ! Cells.rails3_1?
|
26
|
+
assert Cells.rails3_0?
|
27
|
+
elsif
|
28
|
+
assert Cells.rails3_1?
|
29
|
+
assert ! Cells.rails3_0?
|
30
|
+
end
|
19
31
|
end
|
20
32
|
end
|
21
33
|
end
|
data/test/dummy/config/routes.rb
CHANGED
data/test/rails/cells_test.rb
CHANGED
@@ -91,43 +91,25 @@ class RailsCellsTest < ActiveSupport::TestCase
|
|
91
91
|
assert_equal({:song => "Lockdown"}, cell(:bassist, :song => "Lockdown").options)
|
92
92
|
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
if Cells.rails3_0?
|
95
|
+
puts "rails-3.0"
|
96
|
+
context "invoking find_family_view_for_state" do
|
97
|
+
should "raise an error when a template is missing" do
|
98
|
+
assert_raises ActionView::MissingTemplate do
|
99
|
+
cell(:bassist).find_template("bassist/playyy")
|
100
|
+
end
|
101
|
+
|
102
|
+
#puts "format: #{cell(:bassist).find_template("bassist/play.js").formats.inspect}"
|
103
|
+
end
|
97
104
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
should "allow overriding defaults" do
|
102
|
-
assert cell(:bassist).send(:defaultize_render_options_for, {:view => :slap}, :play)[:view] == :slap
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context "invoking find_family_view_for_state" do
|
107
|
-
should "raise an error when a template is missing" do
|
108
|
-
assert_raises ActionView::MissingTemplate do
|
109
|
-
cell(:bassist).find_template("bassist/playyy")
|
105
|
+
should "return play.html.erb" do
|
106
|
+
assert_equal "bassist/play", cell(:bassist).send(:find_family_view_for_state, :play).virtual_path
|
110
107
|
end
|
111
108
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
should "return play.html.erb" do
|
116
|
-
assert_equal "bassist/play", cell(:bassist).send(:find_family_view_for_state, :play).virtual_path
|
117
|
-
end
|
118
|
-
|
119
|
-
should "find inherited play.html.erb" do
|
120
|
-
assert_equal "bassist/play", cell(:bad_guitarist).send(:find_family_view_for_state, :play).virtual_path
|
121
|
-
end
|
122
|
-
|
123
|
-
should_eventually "find the EN-version if i18n instructs" do
|
124
|
-
swap I18n, :locale => :en do
|
125
|
-
assert_equal "bassist/yell.en.html.erb", cell(:bassist).find_family_view_for_state(:yell).virtual_path
|
109
|
+
should "find inherited play.html.erb" do
|
110
|
+
assert_equal "bassist/play", cell(:bad_guitarist).send(:find_family_view_for_state, :play).virtual_path
|
126
111
|
end
|
127
112
|
end
|
128
|
-
|
129
|
-
|
130
|
-
should_eventually "return an already cached family view"
|
131
113
|
end
|
132
114
|
|
133
115
|
context "delegation" do
|
@@ -156,16 +138,5 @@ class RailsCellsTest < ActiveSupport::TestCase
|
|
156
138
|
assert_equal({"song" => "Creatures"}, cell(:bassist, "song" => "Lockdown").params)
|
157
139
|
end
|
158
140
|
end
|
159
|
-
|
160
|
-
|
161
|
-
# DISCUSS: do we really need that test anymore?
|
162
|
-
should "precede cell ivars over controller ivars" do
|
163
|
-
@controller.instance_variable_set(:@note, "E")
|
164
|
-
BassistCell.class_eval do
|
165
|
-
def slap; @note = "A"; render; end
|
166
|
-
end
|
167
|
-
assert_equal "Boing in A", render_cell(:bassist, :slap)
|
168
|
-
end
|
169
|
-
|
170
141
|
end
|
171
142
|
end
|
data/test/rails/render_test.rb
CHANGED
@@ -12,6 +12,13 @@ class RailsRenderTest < ActiveSupport::TestCase
|
|
12
12
|
assert_equal "Doo", render_cell(:bassist, :play)
|
13
13
|
end
|
14
14
|
|
15
|
+
should "accept :format" do
|
16
|
+
BassistCell.class_eval do
|
17
|
+
def play; render :format => :js; end
|
18
|
+
end
|
19
|
+
assert_equal "alert(\"Doo\");", render_cell(:bassist, :play)
|
20
|
+
end
|
21
|
+
|
15
22
|
should "also render alternative engines, like haml" do
|
16
23
|
BassistCell.class_eval do
|
17
24
|
def sing; render; end
|
@@ -106,11 +113,19 @@ class RailsRenderTest < ActiveSupport::TestCase
|
|
106
113
|
def groove; render; end
|
107
114
|
end
|
108
115
|
|
109
|
-
|
110
|
-
|
116
|
+
if Cells.rails3_0?
|
117
|
+
e = assert_raise Cell::Rails::MissingTemplate do
|
118
|
+
render_cell(:bad_guitarist, :groove)
|
119
|
+
end
|
120
|
+
|
121
|
+
assert_includes e.message, "Missing template cell/rails/groove with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]} in view paths"
|
122
|
+
else # 3.1
|
123
|
+
e = assert_raise ActionView::MissingTemplate do
|
124
|
+
render_cell(:bad_guitarist, :groove)
|
125
|
+
end
|
126
|
+
|
127
|
+
assert_includes e.message, "Missing template bad_guitarist/groove, bassist/groove with {:handlers=>[:erb, :builder, :haml], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}. Searched in:\n "
|
111
128
|
end
|
112
|
-
|
113
|
-
assert_includes e.message, "Missing template cell/rails/groove with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]} in view paths"
|
114
129
|
end
|
115
130
|
|
116
131
|
should "render instance variables from the cell" do
|
data/test/rails/router_test.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
module ApplicationTests
|
2
4
|
class RouterTest < ActionController::TestCase
|
3
5
|
tests MusicianController
|
4
6
|
|
5
7
|
context "A Rails app" do
|
8
|
+
should "pass url_helpers to the cell instance" do
|
9
|
+
assert_equal "/", BassistCell.new(@controller).root_path
|
10
|
+
end
|
11
|
+
|
6
12
|
should "allow cells to use url_helpers" do
|
7
13
|
BassistCell.class_eval do
|
8
14
|
def promote; render; end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 3
|
7
|
-
- 5
|
8
7
|
- 6
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 3.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Sutterer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-06-14 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,7 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 3
|
30
30
|
- 0
|
31
|
-
|
32
|
-
version: 3.0.0
|
31
|
+
version: "3.0"
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
- !ruby/object:Gem::Dependency
|
@@ -43,8 +42,7 @@ dependencies:
|
|
43
42
|
segments:
|
44
43
|
- 3
|
45
44
|
- 0
|
46
|
-
|
47
|
-
version: 3.0.0
|
45
|
+
version: "3.0"
|
48
46
|
type: :runtime
|
49
47
|
version_requirements: *id002
|
50
48
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +104,8 @@ files:
|
|
106
104
|
- lib/cell.rb
|
107
105
|
- lib/cell/caching.rb
|
108
106
|
- lib/cell/rails.rb
|
107
|
+
- lib/cell/rails3_0_strategy.rb
|
108
|
+
- lib/cell/rails3_1_strategy.rb
|
109
109
|
- lib/cell/test_case.rb
|
110
110
|
- lib/cells.rb
|
111
111
|
- lib/cells/cells.rake
|
@@ -127,7 +127,6 @@ files:
|
|
127
127
|
- lib/generators/templates/view.haml
|
128
128
|
- lib/generators/templates/view.slim
|
129
129
|
- lib/generators/test_unit/cell_generator.rb
|
130
|
-
- test/active_helper_test.rb
|
131
130
|
- test/app/cells/bad_guitarist/_dii.html.erb
|
132
131
|
- test/app/cells/bad_guitarist_cell.rb
|
133
132
|
- test/app/cells/bassist/_dii.html.erb
|
data/test/active_helper_test.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
### DISCUSS: how can we limit that test to systems where ActiveHelper's around?
|
4
|
-
|
5
|
-
class ActiveHelperTest < ActiveSupport::TestCase
|
6
|
-
context "The Cell::Base class" do
|
7
|
-
setup do
|
8
|
-
class FingeringHelper < ActiveHelper::Base
|
9
|
-
provides :finger
|
10
|
-
end
|
11
|
-
|
12
|
-
class SlappingHelper < ActiveHelper::Base
|
13
|
-
provides :slap
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
should_eventually "respond to active_helper" do
|
18
|
-
assert_respond_to Cell::Base, :active_helper
|
19
|
-
end
|
20
|
-
|
21
|
-
should_eventually "store helper constants from active_helper" do
|
22
|
-
@cell = Class.new(BassistCell)
|
23
|
-
@cell.active_helper SlappingHelper
|
24
|
-
assert_equal [SlappingHelper], @cell.active_helpers
|
25
|
-
end
|
26
|
-
|
27
|
-
should_eventually "inherit helper constants from active_helper" do
|
28
|
-
@base_cell = Class.new(BassistCell)
|
29
|
-
@base_cell.active_helper SlappingHelper
|
30
|
-
@cell = Class.new(@base_cell)
|
31
|
-
@cell.active_helper FingeringHelper
|
32
|
-
assert_equal [SlappingHelper, FingeringHelper], @cell.active_helpers
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
context "An Cell::View::Base instance" do
|
37
|
-
should_eventually "respond to use" do
|
38
|
-
# we didn't extend the view at this point.
|
39
|
-
@view = bassist_mock.setup_action_view
|
40
|
-
assert_respond_to @view, :use
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context "The view rendered by the cell" do
|
46
|
-
should_eventually "respond to used helper methods" do
|
47
|
-
@cell = bassist_mock
|
48
|
-
@cell.class.active_helper SlappingHelper
|
49
|
-
|
50
|
-
@view = @cell.setup_action_view
|
51
|
-
@cell.prepare_action_view_for(@view, {})
|
52
|
-
|
53
|
-
assert_respond_to @view, :slap # from the SlappingHelper
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|