snusnu-merb_resource_controller 0.1.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.
Files changed (47) hide show
  1. data/LICENSE +20 -0
  2. data/README.textile +306 -0
  3. data/Rakefile +81 -0
  4. data/TODO +7 -0
  5. data/lib/merb_resource_controller/action_timeout_support.rb +53 -0
  6. data/lib/merb_resource_controller/actions.rb +169 -0
  7. data/lib/merb_resource_controller/identity_map_support.rb +20 -0
  8. data/lib/merb_resource_controller/resource_controller.rb +160 -0
  9. data/lib/merb_resource_controller/resource_proxy.rb +317 -0
  10. data/lib/merb_resource_controller.rb +29 -0
  11. data/spec/mrc_test_app/Rakefile +52 -0
  12. data/spec/mrc_test_app/app/controllers/application.rb +6 -0
  13. data/spec/mrc_test_app/app/controllers/articles.rb +3 -0
  14. data/spec/mrc_test_app/app/controllers/community/comments.rb +9 -0
  15. data/spec/mrc_test_app/app/controllers/community/ratings.rb +9 -0
  16. data/spec/mrc_test_app/app/controllers/editors.rb +7 -0
  17. data/spec/mrc_test_app/app/models/article.rb +19 -0
  18. data/spec/mrc_test_app/app/models/editor.rb +11 -0
  19. data/spec/mrc_test_app/app/views/articles/edit.html.erb +13 -0
  20. data/spec/mrc_test_app/app/views/articles/index.html.erb +25 -0
  21. data/spec/mrc_test_app/app/views/articles/new.html.erb +12 -0
  22. data/spec/mrc_test_app/app/views/articles/show.html.erb +8 -0
  23. data/spec/mrc_test_app/app/views/community/comments/edit.html.erb +12 -0
  24. data/spec/mrc_test_app/app/views/community/comments/index.html.erb +25 -0
  25. data/spec/mrc_test_app/app/views/community/comments/new.html.erb +3 -0
  26. data/spec/mrc_test_app/app/views/community/comments/show.html.erb +3 -0
  27. data/spec/mrc_test_app/app/views/community/ratings/edit.html.erb +11 -0
  28. data/spec/mrc_test_app/app/views/community/ratings/index.html.erb +25 -0
  29. data/spec/mrc_test_app/app/views/community/ratings/show.html.erb +3 -0
  30. data/spec/mrc_test_app/app/views/editors/edit.html.erb +12 -0
  31. data/spec/mrc_test_app/app/views/editors/new.html.erb +12 -0
  32. data/spec/mrc_test_app/app/views/editors/show.html.erb +7 -0
  33. data/spec/mrc_test_app/config/database.yml +33 -0
  34. data/spec/mrc_test_app/config/environments/development.rb +15 -0
  35. data/spec/mrc_test_app/config/environments/rake.rb +11 -0
  36. data/spec/mrc_test_app/config/environments/test.rb +12 -0
  37. data/spec/mrc_test_app/config/init.rb +36 -0
  38. data/spec/mrc_test_app/config/rack.rb +11 -0
  39. data/spec/mrc_test_app/config/router.rb +50 -0
  40. data/spec/mrc_test_app/spec/lib/resource_proxy_spec.rb +292 -0
  41. data/spec/mrc_test_app/spec/request/article_comments_spec.rb +208 -0
  42. data/spec/mrc_test_app/spec/request/article_editor_spec.rb +202 -0
  43. data/spec/mrc_test_app/spec/request/articles_spec.rb +208 -0
  44. data/spec/mrc_test_app/spec/request/comments_spec.rb +221 -0
  45. data/spec/mrc_test_app/spec/spec.opts +2 -0
  46. data/spec/mrc_test_app/spec/spec_helper.rb +206 -0
  47. metadata +166 -0
@@ -0,0 +1,12 @@
1
+ <h2>Edit Comment</h2>
2
+
3
+ <%= form_for(@comment, :action => resource(@comment), :method => :put) do %>
4
+
5
+ <p><%= text_field :body, :label => "Body" %></p>
6
+ <p><%= submit "Update" %></p>
7
+
8
+ <% end =%>
9
+
10
+ <%= link_to 'Show Comment', resource(@comment) %> |
11
+ <%= link_to 'Show Article', resource(@comment.article) if @comment.article %> |
12
+ <%= link_to 'All Articles', resource(:articles) %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing Comments</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>ID</th>
6
+ <th>Article</th>
7
+ <th>Body</th>
8
+
9
+ <th colspan="3">Actions</th>
10
+ </tr>
11
+
12
+ <% @comments.each do |comment| %>
13
+ <tr>
14
+ <td><%=h comment.id %></td>
15
+ <td><%=h comment.article_title %></td>
16
+ <td><%=h comment.body %></td>
17
+
18
+ <td><%= link_to 'Show', resource(comment) %></td>
19
+ <td><%= link_to 'Edit', resource(comment, :edit) %></td>
20
+ <td><%= delete_button(comment, "Delete") %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <%= link_to 'New Comment', resource(:comments, :new) %>
@@ -0,0 +1,3 @@
1
+ <h2>New Comment</h2>
2
+
3
+ <p><%=h @comment.body %></p>
@@ -0,0 +1,3 @@
1
+ <h2>Show Comment</h2>
2
+
3
+ <p><%=h @comment.body %></p>
@@ -0,0 +1,11 @@
1
+ <h2>Edit Rating</h2>
2
+
3
+ <%= form_for(@rating, :action => resource(@comment, @rating), :method => :put) do %>
4
+
5
+ <p><%= text_field :rate, :label => "Rating" %></p>
6
+ <p><%= submit "Update" %></p>
7
+
8
+ <% end =%>
9
+
10
+ <%= link_to 'Show Comment', resource(@comment) %> |
11
+ <%= link_to 'Show Rating', resource(@comment, @rating) %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing Ratings</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>ID</th>
6
+ <th>Article</th>
7
+ <th>Body</th>
8
+
9
+ <th colspan="3">Actions</th>
10
+ </tr>
11
+
12
+ <% @ratings.each do |rating| %>
13
+ <tr>
14
+ <td><%=h rating.id %></td>
15
+ <td><%=h rating.comment_body %></td>
16
+ <td><%=h rating.rate %></td>
17
+
18
+ <td><%= link_to 'Show', resource(@comment, rating) %></td>
19
+ <td><%= link_to 'Edit', resource(@comment, rating, :edit) %></td>
20
+ <td><%= delete_button(resource(@comment, rating), "Delete") %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <%= link_to 'New Rating', resource(@comment, :ratings, :new) %>
@@ -0,0 +1,3 @@
1
+ <h2>Show Rating</h2>
2
+
3
+ <p><%=h @rating.rate %></p>
@@ -0,0 +1,12 @@
1
+ <h2>Edit Editor</h2>
2
+
3
+ <%= form_for(@editor, :action => resource(@article, :editor), :method => :put) do %>
4
+
5
+ <p><%= text_field :name, :label => "Name" %></p>
6
+ <p><%= submit "Update" %></p>
7
+
8
+ <% end =%>
9
+
10
+ <%= link_to 'Show Editor', resource(@article, :editor) %> |
11
+ <%= link_to 'Show Article', resource(@article) %> |
12
+ <%= link_to 'All Articles', resource(:articles) %>
@@ -0,0 +1,12 @@
1
+ <h2>New Editor</h2>
2
+
3
+ <%= form_for(@editor, :action => resource(@article, :editor) ) do %>
4
+
5
+ <p><%= text_field :name, :label => "Name" %></p>
6
+ <p><%= submit "Create" %></p>
7
+
8
+ <% end =%>
9
+
10
+ <%= link_to 'Show Article', resource(@article) %>
11
+ <%= link_to 'All Articles', resource(:articles) %>
12
+
@@ -0,0 +1,7 @@
1
+ <h1>Show Editor</h1>
2
+
3
+ <h3><%=h @editor.name %></h3>
4
+
5
+ <%= link_to 'Show Article', resource(@article) %>
6
+ <%= link_to 'All Articles', resource(:articles) %>
7
+
@@ -0,0 +1,33 @@
1
+ ---
2
+ # This is a sample database file for the DataMapper ORM
3
+ development: &defaults
4
+ # These are the settings for repository :default
5
+ adapter: sqlite3
6
+ database: mrc_development.db
7
+
8
+ # Add more repositories
9
+ # repositories:
10
+ # repo1:
11
+ # adapter: sqlite3
12
+ # database: sample_1_development.db
13
+ # repo2:
14
+ # ...
15
+
16
+ test:
17
+ <<: *defaults
18
+ database: mrc_test.db
19
+
20
+ # repositories:
21
+ # repo1:
22
+ # database: sample_1_test.db
23
+
24
+ production:
25
+ <<: *defaults
26
+ database: mrc_production.db
27
+
28
+ # repositories:
29
+ # repo1:
30
+ # database: sample_production.db
31
+
32
+ rake:
33
+ <<: *defaults
@@ -0,0 +1,15 @@
1
+ Merb.logger.info("Loaded DEVELOPMENT Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:exception_details] = true
4
+ c[:reload_templates] = true
5
+ c[:reload_classes] = true
6
+ c[:reload_time] = 0.5
7
+ c[:ignore_tampered_cookies] = true
8
+ c[:log_auto_flush ] = true
9
+ c[:log_level] = :debug
10
+
11
+ c[:log_stream] = STDOUT
12
+ c[:log_file] = nil
13
+ # Or redirect logging into a file:
14
+ # c[:log_file] = Merb.root / "log" / "development.log"
15
+ }
@@ -0,0 +1,11 @@
1
+ Merb.logger.info("Loaded RAKE Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:exception_details] = true
4
+ c[:reload_classes] = false
5
+ c[:log_auto_flush ] = true
6
+
7
+ c[:log_stream] = STDOUT
8
+ c[:log_file] = nil
9
+ # Or redirect logging into a file:
10
+ # c[:log_file] = Merb.root / "log" / "development.log"
11
+ }
@@ -0,0 +1,12 @@
1
+ Merb.logger.info("Loaded TEST Environment...")
2
+ Merb::Config.use { |c|
3
+ c[:testing] = true
4
+ c[:exception_details] = true
5
+ c[:log_auto_flush ] = true
6
+ # log less in testing environment
7
+ c[:log_level] = :error
8
+
9
+ #c[:log_file] = Merb.root / "log" / "test.log"
10
+ # or redirect logger using IO handle
11
+ c[:log_stream] = STDOUT
12
+ }
@@ -0,0 +1,36 @@
1
+ # Go to http://wiki.merbivore.com/pages/init-rb
2
+
3
+ merb_gems_version = "~>1.0"
4
+ dm_gems_version = "~>0.9.8"
5
+
6
+ dependency "dm-core", dm_gems_version
7
+ dependency "dm-validations", dm_gems_version
8
+ dependency "dm-serializer", dm_gems_version
9
+ dependency "dm-constraints", dm_gems_version
10
+
11
+ dependency "merb-assets", merb_gems_version
12
+ dependency "merb-helpers", merb_gems_version
13
+
14
+
15
+ use_orm :datamapper
16
+ use_test :rspec
17
+ use_template_engine :erb
18
+
19
+ Merb::Config.use do |c|
20
+ c[:use_mutex] = false
21
+ c[:session_store] = 'cookie' # can also be 'memory', 'memcache', 'container', 'datamapper
22
+
23
+ # cookie session store configuration
24
+ c[:session_secret_key] = 'snusnu' # required for cookie session store
25
+ # c[:session_id_key] = '_session_id' # cookie session id key, defaults to "_session_id"
26
+ end
27
+
28
+ Merb::BootLoader.before_app_loads do
29
+ # This will get executed after dependencies have been loaded but before your app's classes have loaded.
30
+ require Merb.root / '..' / '..' / 'lib' /'merb_resource_controller'
31
+ end
32
+
33
+ Merb::BootLoader.after_app_loads do
34
+ # This will get executed after your app's classes have been loaded.
35
+ DataMapper.auto_migrate!
36
+ end
@@ -0,0 +1,11 @@
1
+ # use PathPrefix Middleware if :path_prefix is set in Merb::Config
2
+ if prefix = ::Merb::Config[:path_prefix]
3
+ use Merb::Rack::PathPrefix, prefix
4
+ end
5
+
6
+ # comment this out if you are running merb behind a load balancer
7
+ # that serves static files
8
+ use Merb::Rack::Static, Merb.dir_for(:public)
9
+
10
+ # this is our main merb application
11
+ run Merb::Rack::Application.new
@@ -0,0 +1,50 @@
1
+ # Merb::Router is the request routing mapper for the merb framework.
2
+ #
3
+ # You can route a specific URL to a controller / action pair:
4
+ #
5
+ # match("/contact").
6
+ # to(:controller => "info", :action => "contact")
7
+ #
8
+ # You can define placeholder parts of the url with the :symbol notation. These
9
+ # placeholders will be available in the params hash of your controllers. For example:
10
+ #
11
+ # match("/books/:book_id/:action").
12
+ # to(:controller => "books")
13
+ #
14
+ # Or, use placeholders in the "to" results for more complicated routing, e.g.:
15
+ #
16
+ # match("/admin/:module/:controller/:action/:id").
17
+ # to(:controller => ":module/:controller")
18
+ #
19
+ # You can specify conditions on the placeholder by passing a hash as the second
20
+ # argument of "match"
21
+ #
22
+ # match("/registration/:course_name", :course_name => /^[a-z]{3,5}-\d{5}$/).
23
+ # to(:controller => "registration")
24
+ #
25
+ # You can also use regular expressions, deferred routes, and many other options.
26
+ # See merb/specs/merb/router.rb for a fairly complete usage sample.
27
+
28
+ Merb.logger.info("Compiling routes...")
29
+ Merb::Router.prepare do
30
+
31
+ resources :articles do
32
+ resources :comments, Community::Comment, :controller => "community/comments" do
33
+ resources :ratings, Community::Rating, :controller => "community/ratings"
34
+ end
35
+ resource :editor
36
+ end
37
+
38
+ resources :comments, Community::Comment, :controller => "community/comments" do
39
+ resources :ratings, Community::Rating, :controller => "community/ratings"
40
+ end
41
+
42
+ # This is the default route for /:controller/:action/:id
43
+ # This is fine for most cases. If you're heavily using resource-based
44
+ # routes, you may want to comment/remove this line to prevent
45
+ # clients from calling your create or destroy actions with a GET
46
+ # default_routes
47
+
48
+ # Change this for your home page to be available at /
49
+ # match('/').to(:controller => 'whatever', :action =>'index')
50
+ end
@@ -0,0 +1,292 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Merb::ResourceController::ResourceProxy" do
4
+
5
+ describe "every ResourceProxy", :shared => true do
6
+
7
+ it "should be able to load not namespaced models" do
8
+ @p.send(:load_resource, Article).should == Article
9
+ @p.send(:load_resource, :articles).should == Article
10
+ @p.send(:load_resource, "Article").should == Article
11
+ end
12
+
13
+ end
14
+
15
+ describe "every nested resource", :shared => true do
16
+
17
+ it "should know that it has parent resource" do
18
+ @p.has_parent?.should be_true
19
+ end
20
+
21
+ end
22
+
23
+ describe "every toplevel resource", :shared => true do
24
+
25
+ it "should know that it has no parent resource(s)" do
26
+ @p.has_parent?.should be_false
27
+ end
28
+
29
+ end
30
+
31
+ describe "with default options" do
32
+
33
+ before(:each) do
34
+ options = { :defaults => true, :flash => true, :use => :all }
35
+ @p = Merb::ResourceController::ResourceProxy.new(:articles, options)
36
+ end
37
+
38
+ it_should_behave_like "every ResourceProxy"
39
+ it_should_behave_like "every toplevel resource"
40
+
41
+
42
+ it "should be able to load the resource it proxies" do
43
+ @p.resource.should == Article
44
+ end
45
+
46
+ it "should be able to infer the collection_name for the resource it proxies" do
47
+ @p.collection_name.should == :articles
48
+ end
49
+
50
+ it "should be able to infer the member_name for the resource it proxies" do
51
+ @p.member_name.should == :article
52
+ end
53
+
54
+ it "should have the default actions registered" do
55
+ default_actions = [ :index, :show, :new, :edit, :create, :update, :destroy ]
56
+ actions = @p.registered_actions.map { |h| h[:name] }
57
+
58
+ actions.size.should == default_actions.size
59
+ actions.all? { |a| default_actions.include?(a) }.should be_true
60
+ end
61
+
62
+
63
+ it "should have no specific methods registered" do
64
+ @p.specific_methods_registered?.should be_false
65
+ end
66
+
67
+ it "should have no parents" do
68
+ @p.parents.should be_empty
69
+ end
70
+
71
+ it "should have no parent_keys" do
72
+ @p.parent_keys.should be_empty
73
+ end
74
+
75
+ end
76
+
77
+ describe "with invalid (parent) resource" do
78
+
79
+ it "should raise NameError when initialized with an invalid resource" do
80
+ options = { :defaults => true, :flash => true, :use => :all }
81
+ lambda {
82
+ Merb::ResourceController::ResourceProxy.new(:foo, options)
83
+ }.should raise_error(NameError)
84
+ end
85
+
86
+ it "should raise NameError when it should belong to an invalid parent resource" do
87
+ options = { :defaults => true, :flash => true, :use => :all }
88
+ lambda {
89
+ p = Merb::ResourceController::ResourceProxy.new("Community::Comment", options)
90
+ p.belongs_to :foo
91
+ }.should raise_error(NameError)
92
+ end
93
+
94
+ end
95
+
96
+
97
+ describe "with no parent resource" do
98
+
99
+ before(:each) do
100
+ options = { :defaults => true, :flash => true, :use => :all }
101
+ @p = Merb::ResourceController::ResourceProxy.new(:articles, options)
102
+ end
103
+
104
+ it_should_behave_like "every toplevel resource"
105
+
106
+ it "should return an empty array for parent_resources" do
107
+ @p.parent_resources.should == []
108
+ end
109
+
110
+ it "should return nil for parent_resource" do
111
+ @p.parent_resource.should be_nil
112
+ end
113
+
114
+
115
+ it "should return an empty array for parent_keys" do
116
+ @p.parent_keys.should == []
117
+ end
118
+
119
+ it "should return nil for parent_key" do
120
+ @p.parent_key.should be_nil
121
+ end
122
+
123
+
124
+
125
+ it "should return an array with one member for nesting strategy" do
126
+ @p.nesting_strategy.should == [ [Article, false, false] ]
127
+ end
128
+
129
+ it "should know its nesting_level" do
130
+ @p.nesting_level.should == 1
131
+ end
132
+
133
+ it "should be able to build a nesting strategy template for a collection route" do
134
+ params = {}
135
+ @p.nesting_strategy_template(params).should == [ [Article, false, false, nil] ]
136
+ end
137
+
138
+ it "should be able to build a nesting strategy template for a member route" do
139
+ params = { "id" => 1}
140
+ @p.nesting_strategy_template(params).should == [ [Article, false, false, 1] ]
141
+ end
142
+
143
+ end
144
+
145
+
146
+ describe "with a single parent resource" do
147
+
148
+ before(:each) do
149
+ options = { :defaults => true, :flash => true, :use => :all }
150
+ @p = Merb::ResourceController::ResourceProxy.new("Community::Comment", options)
151
+ @p.belongs_to :article
152
+ end
153
+
154
+ it_should_behave_like "every nested resource"
155
+
156
+
157
+ it "should know that it belongs_to? a single parent resource" do
158
+ @p.belongs_to?(:article).should be_true
159
+ end
160
+
161
+ it "should be able to load all parent resources" do
162
+ @p.parent_resources.should == [ [Article, false, false] ]
163
+ end
164
+
165
+ it "should be able to load a single parent resource" do
166
+ @p.parent_resource.should == [ Article, false, false ]
167
+ end
168
+
169
+
170
+ it "should be able to return all parent resource param keys" do
171
+ @p.parent_keys.should == [ "article_id" ]
172
+ end
173
+
174
+ it "should be able to return its immediate parent resource param key" do
175
+ @p.parent_key.should == "article_id"
176
+ end
177
+
178
+ it "should be able to build member_params from params Hash" do
179
+ params = { :article_id => 1, :comment => { :id => 1, :body => "foo" } }
180
+ @p.member_params(params).should == { :id => 1, :article_id => 1, :body => "foo" }
181
+
182
+ params = { :article_id => 1, :comment => { :id => 1, :article_id => 2, :body => "foo" } }
183
+ @p.member_params(params).should == { :id => 1, :article_id => 2, :body => "foo" }
184
+ end
185
+
186
+
187
+
188
+ it "should be able to build a nesting strategy" do
189
+ @p.nesting_strategy.should == [ [Article, false, false], [Community::Comment, false, false] ]
190
+ end
191
+
192
+ it "should know its nesting_level" do
193
+ @p.nesting_level.should == 2
194
+ end
195
+
196
+ it "should be able to build a nesting strategy template for a collection route" do
197
+ params = { "article_id" => 1 }
198
+ @p.nesting_strategy_template(params).should == [ [Article, false, false, 1], [Community::Comment, false, false, nil] ]
199
+ end
200
+
201
+ it "should be able to build a nesting strategy template for a member route" do
202
+ params = { "article_id" => 1, "id" => 1}
203
+ @p.nesting_strategy_template(params).should == [ [Article, false, false, 1], [Community::Comment, false, false, 1] ]
204
+ end
205
+
206
+ end
207
+
208
+ describe "with multiple parent resources with default keys" do
209
+
210
+ before(:each) do
211
+ options = { :defaults => true, :flash => true, :use => :all }
212
+ @p = Merb::ResourceController::ResourceProxy.new("Community::Rating", options)
213
+ @p.belongs_to [ :article, "Community::Comment" ]
214
+ end
215
+
216
+ it_should_behave_like "every nested resource"
217
+
218
+
219
+ it "should know that it belongs_to? all of its parent resources" do
220
+ @p.belongs_to?(:article).should be_true
221
+ @p.belongs_to?("Community::Comment").should be_true
222
+ end
223
+
224
+ it "should be able to load the immediate parent resource" do
225
+ @p.parent_resource.should == [ Community::Comment, false, false ]
226
+ end
227
+
228
+ it "should be able to load all parent resources" do
229
+ @p.parent_resources.should == [ [Article, false, false], [Community::Comment, false, false] ]
230
+ end
231
+
232
+ it "should be able to return all parent resource param keys" do
233
+ @p.parent_keys.should == [ "article_id", "comment_id" ]
234
+ end
235
+
236
+ it "should be able to return all parent params" do
237
+ params = { "article_id" => 1, "comment_id" => 2}
238
+ @p.parent_param_values(params).should == [ 1, 2 ]
239
+ end
240
+
241
+ it "should be able to return its immediate parent resource param key" do
242
+ @p.parent_key.should == "comment_id"
243
+ end
244
+
245
+
246
+ it "should know its nesting_level" do
247
+ @p.nesting_level.should == 3
248
+ end
249
+
250
+ it "should be able to build a nesting strategy" do
251
+ @p.nesting_strategy.should == [ [Article, false, false], [Community::Comment, false, false], [Community::Rating, false, false] ]
252
+ end
253
+
254
+
255
+ it "should be able to build a nesting strategy template for a collection route" do
256
+ params = { "article_id" => 1, "comment_id" => 1 }
257
+ @p.nesting_strategy_template(params).should == [ [Article, false, false, 1], [Community::Comment, false, false, 1], [Community::Rating, false, false, nil] ]
258
+ end
259
+
260
+ it "should be able to build a nesting strategy instance for a collection route" do
261
+ Article.all.destroy!
262
+ Community::Comment.all.destroy!
263
+ Community::Rating.all.destroy!
264
+ a = Article.create(:id => 1, :title => "title", :body => "body")
265
+ c = Community::Comment.create(:id => 1, :article_id => 1, :body => "say what")
266
+ r = Community::Rating.create(:id => 1, :comment_id => 1, :rate => 1)
267
+
268
+ params = { "article_id" => 1, "comment_id" => 1 }
269
+ @p.path_to_resource(params).should == [ [:article,a], [:comment,c], [:ratings, [r]] ]
270
+ end
271
+
272
+
273
+ it "should be able to build a nesting strategy template for a member route" do
274
+ params = { "article_id" => 1, "comment_id" => 1, "id" => 1 }
275
+ @p.nesting_strategy_template(params).should == [ [Article, false, false, 1], [Community::Comment, false, false, 1], [Community::Rating, false, false, 1] ]
276
+ end
277
+
278
+ it "should be able to build a nesting strategy instance for a member route" do
279
+ Article.all.destroy!
280
+ Community::Comment.all.destroy!
281
+ Community::Rating.all.destroy!
282
+ a = Article.create(:id => 1, :title => "title", :body => "body")
283
+ c = Community::Comment.create(:id => 1, :article_id => 1, :body => "say what")
284
+ r = Community::Rating.create(:id => 1, :comment_id => 1, :rate => 1)
285
+
286
+ params = { "article_id" => 1, "comment_id" => 1, "id" => 1}
287
+ @p.path_to_resource(params).should == [ [:article,a], [:comment,c], [:rating, r] ]
288
+ end
289
+
290
+ end
291
+
292
+ end