cells 3.4.1 → 3.4.2
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/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/README.rdoc +7 -1
- data/lib/cell/rails.rb +19 -17
- data/lib/cells.rb +1 -1
- data/lib/cells/version.rb +1 -1
- data/test/rails/cells_test.rb +8 -0
- data/test/rails/integration_test.rb +10 -0
- data/test/rails/render_test.rb +22 -15
- data/test/rails/router_test.rb +1 -1
- metadata +3 -3
data/Gemfile
CHANGED
@@ -2,9 +2,9 @@ source :gemcutter
|
|
2
2
|
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' # needed in router_test, whatever.
|
3
3
|
|
4
4
|
#gem "rails" , :path => "/home/nick/projects/rails"
|
5
|
-
gem "rails" #, :git => "http://github.com/rails/rails.git"
|
5
|
+
gem "rails", '3.0.0' #, :git => "http://github.com/rails/rails.git"
|
6
6
|
gem "haml"
|
7
7
|
|
8
8
|
group :test do
|
9
9
|
gem "shoulda"
|
10
|
-
end
|
10
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -33,9 +33,9 @@ GEM
|
|
33
33
|
builder (2.1.2)
|
34
34
|
erubis (2.6.6)
|
35
35
|
abstract (>= 1.0.0)
|
36
|
-
haml (3.0.
|
36
|
+
haml (3.0.21)
|
37
37
|
i18n (0.4.1)
|
38
|
-
mail (2.2.
|
38
|
+
mail (2.2.6.1)
|
39
39
|
activesupport (>= 2.3.6)
|
40
40
|
mime-types
|
41
41
|
treetop (>= 1.4.5)
|
@@ -44,7 +44,7 @@ GEM
|
|
44
44
|
rack (1.2.1)
|
45
45
|
rack-mount (0.6.13)
|
46
46
|
rack (>= 1.0.0)
|
47
|
-
rack-test (0.5.
|
47
|
+
rack-test (0.5.6)
|
48
48
|
rack (>= 1.0)
|
49
49
|
rails (3.0.0)
|
50
50
|
actionmailer (= 3.0.0)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
rake (0.8.7)
|
63
63
|
shoulda (2.11.3)
|
64
64
|
sqlite3-ruby (1.2.5)
|
65
|
-
thor (0.14.
|
65
|
+
thor (0.14.3)
|
66
66
|
treetop (1.4.8)
|
67
67
|
polyglot (>= 0.3.1)
|
68
68
|
tzinfo (0.3.23)
|
@@ -72,6 +72,6 @@ PLATFORMS
|
|
72
72
|
|
73
73
|
DEPENDENCIES
|
74
74
|
haml
|
75
|
-
rails
|
75
|
+
rails (= 3.0.0)
|
76
76
|
shoulda
|
77
77
|
sqlite3-ruby (= 1.2.5)
|
data/README.rdoc
CHANGED
@@ -22,7 +22,7 @@ Rails 3:
|
|
22
22
|
|
23
23
|
Rails 2.3:
|
24
24
|
|
25
|
-
gem install cells -v 3.3.
|
25
|
+
gem install cells -v 3.3.5
|
26
26
|
|
27
27
|
|
28
28
|
== Generate
|
@@ -129,6 +129,12 @@ Run your tests with
|
|
129
129
|
|
130
130
|
That's easy, clean and strongly improves your component-driven software quality. How'd you do that with partials?
|
131
131
|
|
132
|
+
=== Rails 2.3 note
|
133
|
+
|
134
|
+
In order to copy the cells rake tasks to your app, run
|
135
|
+
|
136
|
+
$ script/generate cells_install
|
137
|
+
|
132
138
|
|
133
139
|
== More features
|
134
140
|
|
data/lib/cell/rails.rb
CHANGED
@@ -19,28 +19,27 @@ module Cell
|
|
19
19
|
end
|
20
20
|
|
21
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
|
+
|
22
29
|
module Rendering
|
23
30
|
# Invoke the state method for +state+ which usually renders something nice.
|
24
31
|
def render_state(state)
|
25
|
-
|
32
|
+
process(state)
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
29
36
|
|
30
37
|
module Metal
|
31
|
-
def dispatch(name, request)
|
32
|
-
@_request = request
|
33
|
-
@_env = request.env
|
34
|
-
@_env['action_controller.instance'] = self
|
35
|
-
process(name)
|
36
|
-
end
|
37
|
-
|
38
38
|
def params
|
39
39
|
@_params ||= request.parameters # DISCUSS: let rails helper access @controller.params!
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
delegate :config, :to => :parent_controller
|
42
|
+
attr_internal :request
|
44
43
|
delegate :session, :to => :parent_controller
|
45
44
|
end
|
46
45
|
|
@@ -56,8 +55,10 @@ module Cell
|
|
56
55
|
abstract!
|
57
56
|
|
58
57
|
|
59
|
-
def initialize(parent_controller
|
58
|
+
def initialize(parent_controller, options={})
|
60
59
|
@parent_controller = parent_controller
|
60
|
+
@_request = parent_controller.request # DISCUSS: save request only?
|
61
|
+
@_config = parent_controller.config.dup
|
61
62
|
@opts = @options = options
|
62
63
|
end
|
63
64
|
|
@@ -129,17 +130,18 @@ module Cell
|
|
129
130
|
|
130
131
|
# Climbs up the inheritance chain, looking for a view for the current +state+.
|
131
132
|
def find_family_view_for_state(state)
|
132
|
-
|
133
|
-
|
134
|
-
|
133
|
+
exception = nil
|
134
|
+
possible_paths = possible_paths_for_state(state)
|
135
|
+
|
136
|
+
possible_paths.each do |template_path|
|
135
137
|
begin
|
136
138
|
template = find_template(template_path)
|
137
139
|
return template if template
|
138
|
-
rescue ::ActionView::MissingTemplate =>
|
140
|
+
rescue ::ActionView::MissingTemplate => exception
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
142
|
-
raise
|
144
|
+
raise MissingTemplate.new(exception.message, possible_paths)
|
143
145
|
end
|
144
146
|
|
145
147
|
# Renders the view belonging to the given state. Will raise ActionView::MissingTemplate
|
@@ -158,7 +160,7 @@ module Cell
|
|
158
160
|
end
|
159
161
|
|
160
162
|
opts = sanitize_render_options(opts)
|
161
|
-
render_to_string(opts)
|
163
|
+
render_to_string(opts).html_safe # ActionView::Template::Text doesn't do that for us.
|
162
164
|
end
|
163
165
|
|
164
166
|
# Defaultize the passed options from #render.
|
data/lib/cells.rb
CHANGED
@@ -63,7 +63,7 @@ require 'action_controller'
|
|
63
63
|
require 'cell'
|
64
64
|
require 'cells/rails'
|
65
65
|
require 'cell/rails'
|
66
|
-
require 'cell/test_case' if Rails.env == "test"
|
66
|
+
require 'cell/test_case' if Object.const_defined?("Rails") and Rails.env == "test"
|
67
67
|
|
68
68
|
module Cells
|
69
69
|
# Any config should be placed here using +mattr_accessor+.
|
data/lib/cells/version.rb
CHANGED
data/test/rails/cells_test.rb
CHANGED
@@ -27,6 +27,14 @@ class RailsCellsTest < ActiveSupport::TestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
should "respond to #request" do
|
31
|
+
assert_equal @request, cell(:bassist).request
|
32
|
+
end
|
33
|
+
|
34
|
+
should "respond to #config" do
|
35
|
+
assert_equal({}, cell(:bassist).config)
|
36
|
+
end
|
37
|
+
|
30
38
|
|
31
39
|
context "invoking defaultize_render_options_for" do
|
32
40
|
should "set default values" do
|
@@ -34,6 +34,16 @@ class RailsIntegrationTest < ActionController::TestCase
|
|
34
34
|
get 'skills', :note => "D"
|
35
35
|
assert_equal "That's a D", @response.body
|
36
36
|
end
|
37
|
+
|
38
|
+
should "respond to #config" do
|
39
|
+
BassistCell.class_eval do
|
40
|
+
def listen
|
41
|
+
render :view => 'contact_form' # form_tag internally calls config.allow_forgery_protection
|
42
|
+
end
|
43
|
+
end
|
44
|
+
get 'skills'
|
45
|
+
assert_equal "<form accept-charset=\"UTF-8\" action=\"musician/index\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div>\n", @response.body
|
46
|
+
end
|
37
47
|
end
|
38
48
|
|
39
49
|
end
|
data/test/rails/render_test.rb
CHANGED
@@ -13,15 +13,11 @@ class RailsRenderTest < ActiveSupport::TestCase
|
|
13
13
|
assert_equal "Doo", render_cell(:bassist, :play)
|
14
14
|
end
|
15
15
|
|
16
|
-
should "also render alternative engines" do
|
16
|
+
should "also render alternative engines, like haml" do
|
17
17
|
BassistCell.class_eval do
|
18
|
-
def sing;
|
18
|
+
def sing; render; end
|
19
19
|
end
|
20
|
-
assert_equal "", render_cell(:bassist, :sing)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "accept the :template_format option" do
|
24
|
-
|
20
|
+
assert_equal "<h1>Laaa</h1>\n", render_cell(:bassist, :sing)
|
25
21
|
end
|
26
22
|
|
27
23
|
should "accept the :nothing option" do
|
@@ -44,6 +40,7 @@ class RailsRenderTest < ActiveSupport::TestCase
|
|
44
40
|
def sing; render :text => "Shoobie"; end
|
45
41
|
end
|
46
42
|
assert_equal "Shoobie", render_cell(:bassist, :sing)
|
43
|
+
assert render_cell(:bassist, :sing).html_safe?
|
47
44
|
end
|
48
45
|
|
49
46
|
should "accept the :inline option" do
|
@@ -85,8 +82,18 @@ class RailsRenderTest < ActiveSupport::TestCase
|
|
85
82
|
assert_raises ActionView::MissingTemplate do
|
86
83
|
render_cell(:bassist, :groove)
|
87
84
|
end
|
85
|
+
end
|
86
|
+
|
87
|
+
should "raise an error for a non-existent template" do
|
88
|
+
BadGuitaristCell.class_eval do
|
89
|
+
def groove; render; end
|
90
|
+
end
|
88
91
|
|
89
|
-
|
92
|
+
e = assert_raise Cell::Rails::MissingTemplate do
|
93
|
+
render_cell(:bad_guitarist, :groove)
|
94
|
+
end
|
95
|
+
|
96
|
+
assert_equal "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 \"/home/nick/projects/cells/app/cells\", \"/home/nick/projects/cells/app/cells/layouts\", \"/home/nick/projects/cells/test/app/cells\", \"/home/nick/projects/cells/test/app/cells/layouts\" and possible paths [\"bad_guitarist/groove\", \"bassist/groove\", \"cell/rails/groove\"]", e.message
|
90
97
|
end
|
91
98
|
|
92
99
|
should "render instance variables from the cell" do
|
@@ -101,23 +108,23 @@ class RailsRenderTest < ActiveSupport::TestCase
|
|
101
108
|
should "allow subsequent calls to render in the rendered view" do
|
102
109
|
BassistCell.class_eval do
|
103
110
|
def jam; @chords = [:a, :c]; render; end
|
104
|
-
def
|
111
|
+
def sing; render; end
|
105
112
|
end
|
106
|
-
assert_equal "
|
113
|
+
assert_equal "<h1>Laaa</h1>\n\n<h1>Laaa</h1>\n\n", render_cell(:bassist, :jam)
|
107
114
|
end
|
108
115
|
|
109
116
|
should "allow multiple calls to render" do
|
110
117
|
BassistCell.class_eval do
|
111
|
-
def
|
118
|
+
def sing; render + render + render; end
|
112
119
|
end
|
113
|
-
assert_equal "
|
120
|
+
assert_equal "<h1>Laaa</h1>\n<h1>Laaa</h1>\n<h1>Laaa</h1>\n", render_cell(:bassist, :sing)
|
114
121
|
end
|
115
122
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
123
|
# inheriting
|
120
124
|
should "inherit play.html.erb from BassistCell" do
|
125
|
+
BassistCell.class_eval do
|
126
|
+
def play; render; end
|
127
|
+
end
|
121
128
|
assert_equal "Doo", render_cell(:bad_guitarist, :play)
|
122
129
|
end
|
123
130
|
end
|
data/test/rails/router_test.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 3
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 3.4.
|
8
|
+
- 2
|
9
|
+
version: 3.4.2
|
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: 2010-10-
|
17
|
+
date: 2010-10-11 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|