public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Add specs for action-level only_provides

Oh, and fix the bug, so they pass :)
ivey (author)
Sat Mar 22 16:17:52 -0700 2008
commit  7698ddb3d316da71408683158e1adeba6d0cab74
tree    1529f9cca405b94a2b6ab1420503256dc5238325
parent  575f80ac6497ea09c5488656ec5f34e216ba0391
...
256
257
258
259
 
260
261
262
...
256
257
258
 
259
260
261
262
0
@@ -256,7 +256,7 @@
0
     #---
0
     # @public
0
     def only_provides(*formats)
0
- self._provided_formats = *formats
0
+ _set_provided_formats(*formats)
0
     end
0
     
0
     # Removes formats from the list of provided formats for this particular
...
15
16
17
18
 
19
20
21
22
23
 
24
25
26
27
28
29
30
31
 
32
33
34
35
36
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
...
15
16
17
 
18
19
20
21
 
 
22
23
24
25
26
27
28
 
 
29
30
31
32
33
34
 
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
0
@@ -15,25 +15,37 @@
0
 
0
   class HtmlDefault < Responder; end
0
 
0
- class ClassProvides < Responder;
0
+ class ClassProvides < Responder
0
     provides :xml
0
   end
0
 
0
- class LocalProvides < Responder;
0
-
0
+ class LocalProvides < Responder
0
     def index
0
       provides :xml
0
       render
0
     end
0
   end
0
 
0
- class MultiProvides < Responder;
0
-
0
+ class MultiProvides < Responder
0
     def index
0
       provides :html, :js
0
       render
0
     end
0
   end
0
-
0
+
0
+ class ClassOnlyProvides < Responder
0
+ only_provides :text, :xml
0
+
0
+ def index
0
+ "nothing"
0
+ end
0
+ end
0
+
0
+ class OnlyProvides < Responder
0
+ def index
0
+ only_provides :text, :xml
0
+ "nothing"
0
+ end
0
+ end
0
 end
...
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
0
@@ -62,5 +62,25 @@
0
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::LocalProvides, :index, :format => "xml")
0
     controller.content_type.should == :xml
0
   end
0
+
0
+ it "should properly add formats when only_provides is called in action" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept => "application/xml")
0
+ controller.content_type.should == :xml
0
+ end
0
+
0
+ it "should properly remove formats when only_provides is called in action" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept => "application/html")
0
+ lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
0
+ end
0
+
0
+ it "should properly add formats when only_provides is called in controller" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept => "application/xml")
0
+ controller.content_type.should == :xml
0
+ end
0
+
0
+ it "should properly remove formats when only_provides is called in controller" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept => "application/html")
0
+ lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
0
+ end
0
 end

Comments

    No one has commented yet.