hookercookerman-merb-resource-scope 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.
- data/LICENSE +20 -0
- data/README.textile +297 -0
- data/Rakefile +82 -0
- data/TODO +3 -0
- data/lib/dependencies.rb +1 -0
- data/lib/merb-resource-scope.rb +25 -0
- data/lib/merb-resource-scope/controller/actions.rb +67 -0
- data/lib/merb-resource-scope/controller/helpers.rb +252 -0
- data/lib/merb-resource-scope/controller/scoped_resource_mixin.rb +300 -0
- data/lib/merb-resource-scope/controller/singleton_actions.rb +25 -0
- data/lib/merb-resource-scope/merbtasks.rb +6 -0
- data/lib/merb-resource-scope/router/resource_specification.rb +144 -0
- data/lib/merb-resource-scope/specification.rb +36 -0
- data/spec/app.rb +7 -0
- data/spec/controller/_build_enclosing_scope_spec.rb +107 -0
- data/spec/controller/scope_resource_mixin_spec.rb +0 -0
- data/spec/integration/admin_posts_controller_spec.rb +158 -0
- data/spec/integration/campaign_post_comments_controller_spec.rb +158 -0
- data/spec/integration/campaign_posts_controller_spec.rb +73 -0
- data/spec/integration/campaigns_controller_spec.rb +43 -0
- data/spec/integration/images_spec.rb +17 -0
- data/spec/integration/myhome_controller_spec.rb +29 -0
- data/spec/integration/myhome_posts_comment_controller_spec.rb +44 -0
- data/spec/integration/myhome_posts_controller_spec.rb +55 -0
- data/spec/integration/profile_images_controller_spec.rb +61 -0
- data/spec/integration/tags_controller_spec.rb +34 -0
- data/spec/integration/user_posts_controller_spec.rb +71 -0
- data/spec/request_with_controller.rb +103 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/specification_spec.rb +1 -0
- metadata +88 -0
@@ -0,0 +1,158 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
given "requsting campaigns/:id/posts/:id/comments" do
|
4
|
+
DataMapper.auto_migrate!
|
5
|
+
@user = User.gen
|
6
|
+
@campaign = Campaign.gen
|
7
|
+
@post = Post.gen :campaign => @campaign, :user => @user
|
8
|
+
Comment.gen :post => @post
|
9
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "comments controller spec", :given => "requsting campaigns/:id/posts/:id/comments" do
|
13
|
+
it "should be cool to request my 'campaigns/:id/posts/:id/comments'" do
|
14
|
+
@rack.should be_successful
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should current_resource as Campaign.get(:id).posts.get(:id).comments" do
|
18
|
+
@rack.controller.current_resources.should == Campaign.get(@campaign.id).posts.get(@post.id).comments
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have a current_resoures url of 'campaigns/:id/posts/:id/comments'" do
|
22
|
+
@rack.controller.current_resources_url.should == "/campaigns/#{@campaign.id}/posts/#{@post.id}/comments"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have a enclosing_resource_url of 'campaigns/:id/posts/:id'" do
|
26
|
+
@rack.controller.enclosing_resource_url.should == "/campaigns/#{@campaign.id}/posts/#{@post.id}"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a enclosing_resources_url of 'campaigns/:id/posts'" do
|
30
|
+
@rack.controller.enclosing_resources_url.should == "/campaigns/#{@campaign.id}/posts"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "Should have a body of 'Comments controller, index action'" do
|
34
|
+
@rack.body.to_s.should contain("Comments controller, index action")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have an instance variable of @comments" do
|
38
|
+
@rack.controller.instance_variable_get("@comments").should_not be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have an instance variable of @post" do
|
42
|
+
@rack.controller.instance_variable_get("@post").should_not be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have an instance variable of @campaign" do
|
46
|
+
@rack.controller.instance_variable_get("@campaign").should_not be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "generating urls" do
|
50
|
+
it "should have a edit enclosing_resource_url of 'campaigns/:id/posts:id/posts/:id/edit'" do
|
51
|
+
@rack.controller.enclosing_resource_url(:edit).should == "/campaigns/#{@campaign.id}/posts/#{@post.id}/edit"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have a new new_enclosing_resource_url of 'campaigns/:id/posts:id/posts/new'" do
|
55
|
+
@rack.controller.new_enclosing_resource_url.should == "/campaigns/#{@campaign.id}/posts/new"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
#
|
60
|
+
given "requsting campaigns/:id/posts/:id/comments/new" do
|
61
|
+
DataMapper.auto_migrate!
|
62
|
+
@user = User.gen
|
63
|
+
@campaign = Campaign.gen
|
64
|
+
@post = Post.gen :campaign => @campaign, :user => @user
|
65
|
+
Comment.gen :post => @post
|
66
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments/new")
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "Comments controller spec", :given => "requsting campaigns/:id/posts/:id/comments/new" do
|
70
|
+
it "should be cool to request my 'campaigns/:id/posts/:id/comments/new'" do
|
71
|
+
@rack.should be_successful
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should have an enclosing resource of post" do
|
75
|
+
@rack.controller.enclosing_resource == @post
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should create a new comment with the attributes with a post'" do
|
79
|
+
@rack.controller.new_resource.post.should == @post
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should have current_resources_url of " do
|
83
|
+
@rack.controller.current_resources_url == "/campaigns/#{@campaign.id}/posts/#{@post.id}/comments"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should have an enclosing_resource_url of '/campaigns/:id/posts/:id'" do
|
87
|
+
@rack.controller.enclosing_resource_url.should == "/campaigns/#{@campaign.id}/posts/#{@post.id}"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should have a enclosing_resources_url of '/campaigns/:id/posts'" do
|
91
|
+
@rack.controller.enclosing_resources_url.should == "/campaigns/#{@campaign.id}/posts"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
#
|
95
|
+
#
|
96
|
+
|
97
|
+
given "requsting campaigns/:id/posts/:id/comments/:id with PUT" do
|
98
|
+
DataMapper.auto_migrate!
|
99
|
+
@user = User.gen
|
100
|
+
@campaign = Campaign.gen
|
101
|
+
@post = Post.gen :campaign => @campaign, :user => @user
|
102
|
+
@comment = Comment.gen :post => @post
|
103
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments/#{@comment.id}", :method => "PUT",
|
104
|
+
:params => {:comment => {:body => "themakeup"}})
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
describe "Comments controller spec", :given => "requsting campaigns/:id/posts/:id/comments/:id with PUT" do
|
109
|
+
it "should be cool to request my 'campaigns/:id/posts/:id/comments/:id with PUT' and then redirect" do
|
110
|
+
@rack.should redirect_to("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments/#{@comment.id}")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should update the comment to have the new body of 'themakeup'" do
|
114
|
+
@comment.reload.body.should == "themakeup"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
given "requsting campaigns/:id/posts/:id/comments with POST" do
|
121
|
+
DataMapper.auto_migrate!
|
122
|
+
@user = User.gen
|
123
|
+
@campaign = Campaign.gen
|
124
|
+
@post = Post.gen :campaign => @campaign, :user => @user
|
125
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments", :method => "POST",
|
126
|
+
:params => {:comment => {:body => "thedoors"}})
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "Comments controller spec", :given => "requsting campaigns/:id/posts/:id/comments with POST" do
|
130
|
+
it "should be cool to request my 'campaigns/:id/posts/:id/comments with POST' and then redirect" do
|
131
|
+
@rack.should redirect_to("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments")
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should create a new comment with a body of 'thedoors'" do
|
135
|
+
Comment.first :conditions => {:body => "thedoors"}
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
given "requsting campaigns/:id/posts/:id/comments/:id with DELETE" do
|
142
|
+
DataMapper.auto_migrate!
|
143
|
+
@user = User.gen
|
144
|
+
@campaign = Campaign.gen
|
145
|
+
@post = Post.gen :campaign => @campaign, :user => @user
|
146
|
+
@comment = Comment.gen :post => @post, :body => "whattheegg"
|
147
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments/#{@comment.id}", :method => "DELETE")
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "Comments controller spec", :given => "requsting campaigns/:id/posts/:id/comments/:id with DELETE" do
|
151
|
+
it "should be cool to request my 'campaigns/:id/posts/:id/comments/:id with DELETE' and then redirect" do
|
152
|
+
@rack.should redirect_to("/campaigns/#{@campaign.id}/posts/#{@post.id}/comments")
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should delete the comment" do
|
156
|
+
Comment.first(:conditions => {:body => "whattheegg"}).should be_nil
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
given "requsting campaign/:id/posts" do
|
4
|
+
DataMapper.auto_migrate!
|
5
|
+
@user = User.gen
|
6
|
+
@campaign = Campaign.gen
|
7
|
+
100.times {Post.gen :campaign => @campaign, :user => @user}
|
8
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts")
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "posts controller spec", :given => "requsting campaign/:id/posts" do
|
12
|
+
it "should be cool to request my 'campaigns/:id/posts'" do
|
13
|
+
@rack.should be_successful
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have current_resources as Campaign.get(campaign_id).posts" do
|
17
|
+
@rack.controller.current_resources.should == Campaign.get(@campaign.id).posts
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have an enclosing resource of Campaign.get(:id)" do
|
21
|
+
@rack.controller.enclosing_resource.should == Campaign.get(@campaign.id)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have a enclosing_resource_url of '/campaigns/:id'" do
|
25
|
+
@rack.controller.enclosing_resource_url.should == "/campaigns/#{@campaign.id}"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a enclosing_resources_url of '/campaigns'" do
|
29
|
+
@rack.controller.enclosing_resources_url.should == "/campaigns"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have a current_specificaiton with a class_name of CampaignPost via using the scoped_class_name" do
|
33
|
+
@rack.controller._current_specification.klass_name.should == "CampaignPost"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a current_specification klass of nil as CampaignPost does not exist" do
|
37
|
+
@rack.controller._current_specification.klass.should be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
#
|
41
|
+
#
|
42
|
+
|
43
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
44
|
+
|
45
|
+
given "requsting campaign/:id/posts/id" do
|
46
|
+
DataMapper.auto_migrate!
|
47
|
+
@user = User.gen
|
48
|
+
@campaign = Campaign.gen
|
49
|
+
@post = Post.gen :campaign => @campaign, :user => @user
|
50
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}/posts/#{@post.id}")
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "Posts controller spec", :given => "requsting campaign/:id/posts/id" do
|
54
|
+
it "should be cool to request my 'campaigns/:id/posts/:id'" do
|
55
|
+
@rack.should be_successful
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have current_resources as Campaign.get(campaign_id).posts" do
|
59
|
+
@rack.controller.current_resource.should == Campaign.get(@campaign.id).posts.get(@post.id)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should have an enclosing resource of Campaign.get(:id)" do
|
63
|
+
@rack.controller.enclosing_resource.should == Campaign.get(@campaign.id)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have a enclosing_resource_url of '/campaigns/:id'" do
|
67
|
+
@rack.controller.enclosing_resource_url.should == "/campaigns/#{@campaign.id}"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should have a enclosing_resources_url of '/campaigns'" do
|
71
|
+
@rack.controller.enclosing_resources_url.should == "/campaigns"
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
given "requsting /campaigns" do
|
4
|
+
DataMapper.auto_migrate!
|
5
|
+
@campaign = Campaign.gen
|
6
|
+
|
7
|
+
@rack = request_with_controller("/campaigns")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "posts controller spec", :given => "requsting /campaigns" do
|
11
|
+
it "should be cool to request my 'campaign/'" do
|
12
|
+
@rack.should be_successful
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have current_resources as Campaign.all" do
|
16
|
+
@rack.controller.current_resources.should == Campaign.all
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have a current_resoures url of '/campaigns'" do
|
20
|
+
@rack.controller.current_resources_url.should == '/campaigns'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
#
|
24
|
+
given "requsting /campaigns/:id" do
|
25
|
+
DataMapper.auto_migrate!
|
26
|
+
@campaign = Campaign.gen
|
27
|
+
|
28
|
+
@rack = request_with_controller("/campaigns/#{@campaign.id}")
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Campaigns controller spec", :given => "requsting /campaigns/:id" do
|
32
|
+
it "should be cool to request my 'campaign/:id'" do
|
33
|
+
@rack.should be_successful
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have current_resources as Campaign.get(campaign_id)" do
|
37
|
+
@rack.controller.current_resource.should == Campaign.get(@campaign.id)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a current_resoure url of '/campaigns/:id'" do
|
41
|
+
@rack.controller.current_resource_url(@campaign).should == "/campaigns/#{@campaign.id}"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
given "requsting /images" do
|
3
|
+
DataMapper.auto_migrate!
|
4
|
+
@imags = 10.times{Image.gen}
|
5
|
+
@rack = request_with_controller("/images")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "images controller spec", :given => "requsting /images" do
|
9
|
+
it "should be cool 'images' as there there is an action" do
|
10
|
+
@rack.should be_successful
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a current_resources of 'Image.all'" do
|
14
|
+
@rack.controller.current_resources.should == Image.all
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
given "requsting 'myhome'" do
|
4
|
+
User.gen
|
5
|
+
@rack = request_with_controller("/myhome")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "myhome controller spec", :given => "requsting 'myhome'" do
|
9
|
+
it "should be cool to request my home" do
|
10
|
+
@rack.should be_successful
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a current_resource (current_user == User.first)" do
|
14
|
+
@rack.controller.current_resource.should == User.first
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have a current_resoure url of '/myhome'" do
|
18
|
+
@rack.controller.current_resource_url(:myhome).should == "/myhome"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have enclosing_resource_url of nil" do
|
22
|
+
@rack.controller.enclosing_resource_url.should be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
given "requsting 'myhome' with index'" do
|
27
|
+
User.gen
|
28
|
+
@rack = request_with_controller("/myhome/index")
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
given "requsting myhome/posts/:id/comments" do
|
3
|
+
DataMapper.auto_migrate!
|
4
|
+
@user = User.gen
|
5
|
+
@post = Post.gen :user => @user
|
6
|
+
@comments = 10.times {Comment.gen :post => @post}
|
7
|
+
@rack = request_with_controller("/myhome/posts/#{@post.id}/comments")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "Comments controller spec", :given => "requsting myhome/posts/:id/comments" do
|
11
|
+
it "should be cool to request my 'requsting myhome/posts/:id/comments'" do
|
12
|
+
@rack.should be_successful
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have a current_resources as User.first.posts.get(:id).comments" do
|
16
|
+
@rack.controller.current_resources.should == User.first.posts.get(@post.id).comments
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have a enclosing_resource of User.first.posts.get(:id)" do
|
20
|
+
@rack.controller.enclosing_resource.should == User.first.posts.get(@post.id)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have an enclosing_resource_url of /myhome/posts/:id" do
|
24
|
+
@rack.controller.enclosing_resource_url.should == "/myhome/posts/#{@post.id}"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be able to extend the enclosing_resource_url with image named_route" do
|
28
|
+
@rack.controller.enclosing_resource_url{|route| route.add(:image)}.should == "/myhome/posts/#{@post.id}/image"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be able to extend the enclosing_resource_url with new image named_route" do
|
32
|
+
@rack.controller.enclosing_resource_url{|route| route.add(:image, :new)}.should == "/myhome/posts/#{@post.id}/image/new"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to extend the enclosing_resource_url with edit image named_route" do
|
36
|
+
@rack.controller.enclosing_resource_url{|route| route.add(:image, :edit)}.should == "/myhome/posts/#{@post.id}/image/edit"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have an enclosing_resources_url of /myhome/posts" do
|
40
|
+
@rack.controller.enclosing_resources_url.should == "/myhome/posts"
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
given "requsting myhome/posts" do
|
4
|
+
DataMapper.auto_migrate!
|
5
|
+
@user = User.gen
|
6
|
+
10.times {Post.gen}
|
7
|
+
@rack = request_with_controller("/myhome/posts")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "Posts controller spec", :given => "requsting myhome/posts" do
|
11
|
+
it "should be cool to request my 'myhome/posts'" do
|
12
|
+
@rack.should be_successful
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have current_resources as User.first.posts.all" do
|
16
|
+
@rack.controller.current_resources.should == User.first.posts.all
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have a current_resoures url of 'myhome/posts'" do
|
20
|
+
@rack.controller.current_resources_url.should == '/myhome/posts'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have an enclosing resource of User.first" do
|
24
|
+
@rack.controller.enclosing_resource.should == User.first
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have a enclosing_resource_url of 'myhome'" do
|
28
|
+
@rack.controller.enclosing_resource_url.should == '/myhome'
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "generating urls" do
|
32
|
+
it "should have a edit enclosing_resource_url of 'myhome/edit" do
|
33
|
+
@rack.controller.enclosing_resource_url(:edit).should == "/myhome/edit"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a extend enclosing_resource_url of 'myhome/edit with posts" do
|
37
|
+
@rack.controller.enclosing_resource_url{|route| route.add(:posts)} == "/myhome/posts"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a extend enclosing_resource_url of 'myhome/edit with posts/:id" do
|
41
|
+
@post = Post.pick
|
42
|
+
@rack.controller.enclosing_resource_url{|route| route.add(:post, @post)} == "/myhome/posts/#{@post.id}"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have a extend enclosing_resource_url of 'myhome/edit with posts/:id/edit" do
|
46
|
+
@post = Post.pick
|
47
|
+
@rack.controller.enclosing_resource_url{|route| route.add(:post, :edit, @post)} == "/myhome/posts/#{@post.id}/edit"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a new enclosing_resources_url of 'myhome/new'" do
|
51
|
+
@rack.controller.enclosing_resource_url(:new).should == "/myhome/new"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
given "requsting myhome/profile_image" do
|
4
|
+
DataMapper.auto_migrate!
|
5
|
+
@user = User.gen
|
6
|
+
@post_image = ProfileImage.gen :user => @user
|
7
|
+
@rack = request_with_controller("/myhome/profile_image")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "profile_images controller spec", :given => "requsting myhome/profile_image" do
|
11
|
+
it "should be cool to request my 'myhome/profile_image'" do
|
12
|
+
@rack.should be_successful
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have current_resource of User.first.profile_image" do
|
16
|
+
@rack.controller.current_resource.should == User.first.profile_image
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have an enclosing resource of User.first" do
|
20
|
+
@rack.controller.enclosing_resource.should == User.first
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have a current_resource url of 'myhome/profile_image'" do
|
24
|
+
@rack.controller.current_resource_url(:profile_image).should == "/myhome/profile_image"
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "generating urls" do
|
28
|
+
it "should have a edit current_resource_url of 'myhome/profile_image/edit'" do
|
29
|
+
@rack.controller.current_resource_url(:profile_image, :edit).should == "/myhome/profile_image/edit"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have a new current_resource_url of 'myhome/profile_image/new'" do
|
33
|
+
@rack.controller.new_current_resource_url.should == "/myhome/profile_image/new"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a edit enclosing_resource_url of 'myhome/edit" do
|
37
|
+
@rack.controller.enclosing_resource_url(:edit).should == "/myhome/edit"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a new enclosing_resources_url of 'myhome/new'" do
|
41
|
+
@rack.controller.enclosing_resource_url(:new).should == "/myhome/new"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
given "requsting myhome/profile_image/new" do
|
48
|
+
DataMapper.auto_migrate!
|
49
|
+
@user = User.gen
|
50
|
+
@rack = request_with_controller("/myhome/profile_image/new")
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "profile_images controller spec", :given => "requsting myhome/profile_image/new" do
|
54
|
+
it "should be cool to request my 'myhome/profile_image/new'" do
|
55
|
+
@rack.should be_successful
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have current_resource of a new profile image with myhome being User.first as the user" do
|
59
|
+
@rack.controller.current_resource.user.should == @user
|
60
|
+
end
|
61
|
+
end
|