orange 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/lib/orange.rb +2 -5
  2. data/spec/orange_spec.rb +5 -0
  3. data/spec/{orange-core/spec_helper.rb → spec_helper.rb} +0 -0
  4. metadata +28 -235
  5. data/lib/orange-core.rb +0 -8
  6. data/lib/orange-core/application.rb +0 -132
  7. data/lib/orange-core/assets/css/exceptions.css +0 -50
  8. data/lib/orange-core/assets/js/exceptions.js +0 -44
  9. data/lib/orange-core/carton.rb +0 -178
  10. data/lib/orange-core/core.rb +0 -266
  11. data/lib/orange-core/magick.rb +0 -270
  12. data/lib/orange-core/middleware/base.rb +0 -96
  13. data/lib/orange-core/middleware/database.rb +0 -45
  14. data/lib/orange-core/middleware/four_oh_four.rb +0 -45
  15. data/lib/orange-core/middleware/globals.rb +0 -17
  16. data/lib/orange-core/middleware/loader.rb +0 -13
  17. data/lib/orange-core/middleware/rerouter.rb +0 -53
  18. data/lib/orange-core/middleware/restful_router.rb +0 -99
  19. data/lib/orange-core/middleware/route_context.rb +0 -39
  20. data/lib/orange-core/middleware/route_site.rb +0 -51
  21. data/lib/orange-core/middleware/show_exceptions.rb +0 -80
  22. data/lib/orange-core/middleware/static.rb +0 -67
  23. data/lib/orange-core/middleware/static_file.rb +0 -32
  24. data/lib/orange-core/middleware/template.rb +0 -60
  25. data/lib/orange-core/packet.rb +0 -232
  26. data/lib/orange-core/plugin.rb +0 -172
  27. data/lib/orange-core/resource.rb +0 -96
  28. data/lib/orange-core/resources/mapper.rb +0 -36
  29. data/lib/orange-core/resources/model_resource.rb +0 -228
  30. data/lib/orange-core/resources/not_found.rb +0 -10
  31. data/lib/orange-core/resources/page_parts.rb +0 -68
  32. data/lib/orange-core/resources/parser.rb +0 -113
  33. data/lib/orange-core/resources/routable_resource.rb +0 -16
  34. data/lib/orange-core/resources/scaffold.rb +0 -106
  35. data/lib/orange-core/stack.rb +0 -226
  36. data/lib/orange-core/templates/exceptions.haml +0 -111
  37. data/lib/orange-core/views/default_resource/create.haml +0 -4
  38. data/lib/orange-core/views/default_resource/edit.haml +0 -9
  39. data/lib/orange-core/views/default_resource/list.haml +0 -10
  40. data/lib/orange-core/views/default_resource/show.haml +0 -4
  41. data/lib/orange-core/views/default_resource/table_row.haml +0 -7
  42. data/lib/orange-core/views/not_found/404.haml +0 -2
  43. data/lib/orange-more.rb +0 -23
  44. data/lib/orange-more/administration.rb +0 -1
  45. data/lib/orange-more/administration/assets/css/admin.css +0 -286
  46. data/lib/orange-more/administration/assets/css/blueprint-ie.css +0 -35
  47. data/lib/orange-more/administration/assets/css/blueprint-print.css +0 -29
  48. data/lib/orange-more/administration/assets/css/blueprint.css +0 -257
  49. data/lib/orange-more/administration/assets/js/jquery.js +0 -152
  50. data/lib/orange-more/administration/cartons/site.rb +0 -7
  51. data/lib/orange-more/administration/cartons/site_carton.rb +0 -12
  52. data/lib/orange-more/administration/cartons/user.rb +0 -27
  53. data/lib/orange-more/administration/middleware/access_control.rb +0 -156
  54. data/lib/orange-more/administration/middleware/site_load.rb +0 -25
  55. data/lib/orange-more/administration/plugin.rb +0 -23
  56. data/lib/orange-more/administration/resources/admin_resource.rb +0 -27
  57. data/lib/orange-more/administration/resources/site_resource.rb +0 -10
  58. data/lib/orange-more/administration/resources/user_resource.rb +0 -40
  59. data/lib/orange-more/administration/templates/admin.haml +0 -25
  60. data/lib/orange-more/administration/views/openid_login.haml +0 -14
  61. data/lib/orange-more/administration/views/users/create.haml +0 -10
  62. data/lib/orange-more/administration/views/users/edit.haml +0 -15
  63. data/lib/orange-more/adverts.rb +0 -1
  64. data/lib/orange-more/adverts/cartons/adverts_carton.rb +0 -14
  65. data/lib/orange-more/adverts/plugin.rb +0 -13
  66. data/lib/orange-more/adverts/resources/adverts_resource.rb +0 -27
  67. data/lib/orange-more/adverts/views/adverts/adverts.haml +0 -2
  68. data/lib/orange-more/analytics.rb +0 -1
  69. data/lib/orange-more/analytics/middleware/analytics.rb +0 -30
  70. data/lib/orange-more/analytics/plugin.rb +0 -11
  71. data/lib/orange-more/analytics/resources/analytics_resource.rb +0 -42
  72. data/lib/orange-more/assets.rb +0 -1
  73. data/lib/orange-more/assets/cartons/asset_carton.rb +0 -27
  74. data/lib/orange-more/assets/plugin.rb +0 -13
  75. data/lib/orange-more/assets/resources/asset_resource.rb +0 -115
  76. data/lib/orange-more/assets/views/assets/change.haml +0 -1
  77. data/lib/orange-more/assets/views/assets/create.haml +0 -13
  78. data/lib/orange-more/assets/views/assets/insert.haml +0 -1
  79. data/lib/orange-more/blog.rb +0 -1
  80. data/lib/orange-more/blog/cartons/blog.rb +0 -8
  81. data/lib/orange-more/blog/cartons/blog_post.rb +0 -60
  82. data/lib/orange-more/blog/plugin.rb +0 -14
  83. data/lib/orange-more/blog/resources/blog_post_resource.rb +0 -53
  84. data/lib/orange-more/blog/resources/blog_resource.rb +0 -104
  85. data/lib/orange-more/blog/views/blog/blog_archive_view.haml +0 -6
  86. data/lib/orange-more/blog/views/blog/blog_offset_list_view.haml +0 -12
  87. data/lib/orange-more/blog/views/blog/blog_post_view.haml +0 -4
  88. data/lib/orange-more/blog/views/blog/sitemap_row.haml +0 -14
  89. data/lib/orange-more/blog/views/blog_posts/edit.haml +0 -8
  90. data/lib/orange-more/blog/views/blog_posts/show.haml +0 -4
  91. data/lib/orange-more/cloud.rb +0 -1
  92. data/lib/orange-more/cloud/plugin.rb +0 -10
  93. data/lib/orange-more/cloud/resources/cloud_resource.rb +0 -21
  94. data/lib/orange-more/contactforms.rb +0 -1
  95. data/lib/orange-more/contactforms/assets/js/jquery.validate.pack.js +0 -15
  96. data/lib/orange-more/contactforms/assets/js/lib/jquery-1.4.2.js +0 -6240
  97. data/lib/orange-more/contactforms/assets/js/lib/jquery.form.js +0 -660
  98. data/lib/orange-more/contactforms/assets/js/lib/jquery.js +0 -4376
  99. data/lib/orange-more/contactforms/assets/js/lib/jquery.metadata.js +0 -122
  100. data/lib/orange-more/contactforms/cartons/contactforms_carton.rb +0 -12
  101. data/lib/orange-more/contactforms/plugin.rb +0 -13
  102. data/lib/orange-more/contactforms/resources/contactforms_resource.rb +0 -56
  103. data/lib/orange-more/contactforms/views/contactforms/contactform.haml +0 -20
  104. data/lib/orange-more/debugger.rb +0 -1
  105. data/lib/orange-more/debugger/assets/css/debug_bar.css +0 -46
  106. data/lib/orange-more/debugger/middleware/debugger.rb +0 -50
  107. data/lib/orange-more/debugger/plugin.rb +0 -12
  108. data/lib/orange-more/debugger/views/debug_bar.haml +0 -87
  109. data/lib/orange-more/disqus.rb +0 -1
  110. data/lib/orange-more/disqus/plugin.rb +0 -11
  111. data/lib/orange-more/disqus/resources/disqus_resource.rb +0 -9
  112. data/lib/orange-more/disqus/views/disqus/comment_thread.haml +0 -7
  113. data/lib/orange-more/donations.rb +0 -1
  114. data/lib/orange-more/donations/cartons/donation_carton.rb +0 -9
  115. data/lib/orange-more/donations/plugin.rb +0 -12
  116. data/lib/orange-more/donations/resources/donations_resource.rb +0 -51
  117. data/lib/orange-more/donations/views/donations/donate_form.haml +0 -21
  118. data/lib/orange-more/donations/views/donations/donate_thanks.haml +0 -2
  119. data/lib/orange-more/donations/views/donations/paypal_form.haml +0 -13
  120. data/lib/orange-more/events.rb +0 -1
  121. data/lib/orange-more/events/assets/js/events.js +0 -55
  122. data/lib/orange-more/events/cartons/orange_calendar.rb +0 -8
  123. data/lib/orange-more/events/cartons/orange_event.rb +0 -60
  124. data/lib/orange-more/events/plugin.rb +0 -14
  125. data/lib/orange-more/events/resources/calendar_resource.rb +0 -33
  126. data/lib/orange-more/events/resources/event_resource.rb +0 -147
  127. data/lib/orange-more/events/views/calendar/calendar.haml +0 -8
  128. data/lib/orange-more/events/views/events/create.haml +0 -55
  129. data/lib/orange-more/events/views/events/edit.haml +0 -59
  130. data/lib/orange-more/events/views/events/list.haml +0 -13
  131. data/lib/orange-more/events/views/events/show.haml +0 -4
  132. data/lib/orange-more/events/views/events/table_row.haml +0 -17
  133. data/lib/orange-more/members.rb +0 -1
  134. data/lib/orange-more/members/cartons/member_carton.rb +0 -38
  135. data/lib/orange-more/members/plugin.rb +0 -13
  136. data/lib/orange-more/members/resources/members_resource.rb +0 -327
  137. data/lib/orange-more/members/views/members/create.haml +0 -12
  138. data/lib/orange-more/members/views/members/edit.haml +0 -15
  139. data/lib/orange-more/members/views/members/live.show.haml +0 -1
  140. data/lib/orange-more/members/views/members/login.haml +0 -17
  141. data/lib/orange-more/members/views/members/logout.haml +0 -1
  142. data/lib/orange-more/members/views/members/profile.haml +0 -50
  143. data/lib/orange-more/members/views/members/register.haml +0 -37
  144. data/lib/orange-more/news.rb +0 -1
  145. data/lib/orange-more/news/cartons/news.rb +0 -12
  146. data/lib/orange-more/news/plugin.rb +0 -13
  147. data/lib/orange-more/news/resources/news_resource.rb +0 -82
  148. data/lib/orange-more/news/views/news/archive.haml +0 -14
  149. data/lib/orange-more/news/views/news/edit.haml +0 -7
  150. data/lib/orange-more/news/views/news/latest.haml +0 -8
  151. data/lib/orange-more/news/views/news/sitemap_row.haml +0 -14
  152. data/lib/orange-more/pages.rb +0 -1
  153. data/lib/orange-more/pages/cartons/page_carton.rb +0 -14
  154. data/lib/orange-more/pages/cartons/page_version_carton.rb +0 -12
  155. data/lib/orange-more/pages/plugin.rb +0 -13
  156. data/lib/orange-more/pages/resources/page_resource.rb +0 -179
  157. data/lib/orange-more/pages/views/pages/edit.haml +0 -34
  158. data/lib/orange-more/pages/views/pages/show.haml +0 -6
  159. data/lib/orange-more/sitemap.rb +0 -1
  160. data/lib/orange-more/sitemap/assets/img/sitemap_down.png +0 -0
  161. data/lib/orange-more/sitemap/assets/img/sitemap_down_d.png +0 -0
  162. data/lib/orange-more/sitemap/assets/img/sitemap_indent.png +0 -0
  163. data/lib/orange-more/sitemap/assets/img/sitemap_indent_d.png +0 -0
  164. data/lib/orange-more/sitemap/assets/img/sitemap_outdent.png +0 -0
  165. data/lib/orange-more/sitemap/assets/img/sitemap_outdent_d.png +0 -0
  166. data/lib/orange-more/sitemap/assets/img/sitemap_up.png +0 -0
  167. data/lib/orange-more/sitemap/assets/img/sitemap_up_d.png +0 -0
  168. data/lib/orange-more/sitemap/assets/js/sitemap.js +0 -11
  169. data/lib/orange-more/sitemap/cartons/route.rb +0 -43
  170. data/lib/orange-more/sitemap/middleware/flex_router.rb +0 -25
  171. data/lib/orange-more/sitemap/plugin.rb +0 -17
  172. data/lib/orange-more/sitemap/resources/sitemap_resource.rb +0 -295
  173. data/lib/orange-more/sitemap/views/default_resource/sitemap_row.haml +0 -30
  174. data/lib/orange-more/sitemap/views/sitemap/breadcrumb.haml +0 -12
  175. data/lib/orange-more/sitemap/views/sitemap/list.haml +0 -4
  176. data/lib/orange-more/sitemap/views/sitemap/one_level.haml +0 -7
  177. data/lib/orange-more/sitemap/views/sitemap/route_actions.haml +0 -15
  178. data/lib/orange-more/sitemap/views/sitemap/sitemap_links.haml +0 -14
  179. data/lib/orange-more/sitemap/views/sitemap/table_row.haml +0 -30
  180. data/lib/orange-more/sitemap/views/sitemap/two_level.haml +0 -13
  181. data/lib/orange-more/slices.rb +0 -1
  182. data/lib/orange-more/slices/middleware/radius_parser.rb +0 -24
  183. data/lib/orange-more/slices/plugin.rb +0 -15
  184. data/lib/orange-more/slices/resources/radius.rb +0 -117
  185. data/lib/orange-more/slices/resources/slices.rb +0 -35
  186. data/lib/orange-more/subsites.rb +0 -1
  187. data/lib/orange-more/subsites/cartons/subsite.rb +0 -8
  188. data/lib/orange-more/subsites/middleware/subsite_load.rb +0 -29
  189. data/lib/orange-more/subsites/plugin.rb +0 -17
  190. data/lib/orange-more/subsites/resources/subsite_resource.rb +0 -54
  191. data/lib/orange-more/subsites/views/subsites/index.haml +0 -2
  192. data/lib/orange-more/testimonials.rb +0 -1
  193. data/lib/orange-more/testimonials/cartons/testimonials_carton.rb +0 -15
  194. data/lib/orange-more/testimonials/plugin.rb +0 -13
  195. data/lib/orange-more/testimonials/resources/testimonials_resource.rb +0 -42
  196. data/lib/orange-more/testimonials/views/testimonials/testimonials.haml +0 -4
  197. data/spec/orange-core/application_spec.rb +0 -183
  198. data/spec/orange-core/carton_spec.rb +0 -136
  199. data/spec/orange-core/core_spec.rb +0 -248
  200. data/spec/orange-core/magick_spec.rb +0 -96
  201. data/spec/orange-core/middleware/base_spec.rb +0 -38
  202. data/spec/orange-core/middleware/globals_spec.rb +0 -3
  203. data/spec/orange-core/middleware/rerouter_spec.rb +0 -3
  204. data/spec/orange-core/middleware/restful_router_spec.rb +0 -3
  205. data/spec/orange-core/middleware/route_context_spec.rb +0 -3
  206. data/spec/orange-core/middleware/route_site_spec.rb +0 -3
  207. data/spec/orange-core/middleware/show_exceptions_spec.rb +0 -3
  208. data/spec/orange-core/middleware/static_file_spec.rb +0 -3
  209. data/spec/orange-core/middleware/static_spec.rb +0 -3
  210. data/spec/orange-core/mock/mock_app.rb +0 -16
  211. data/spec/orange-core/mock/mock_carton.rb +0 -43
  212. data/spec/orange-core/mock/mock_core.rb +0 -2
  213. data/spec/orange-core/mock/mock_middleware.rb +0 -25
  214. data/spec/orange-core/mock/mock_mixins.rb +0 -19
  215. data/spec/orange-core/mock/mock_model_resource.rb +0 -47
  216. data/spec/orange-core/mock/mock_pulp.rb +0 -24
  217. data/spec/orange-core/mock/mock_resource.rb +0 -26
  218. data/spec/orange-core/mock/mock_router.rb +0 -10
  219. data/spec/orange-core/orange_spec.rb +0 -19
  220. data/spec/orange-core/packet_spec.rb +0 -203
  221. data/spec/orange-core/resource_spec.rb +0 -96
  222. data/spec/orange-core/resources/mapper_spec.rb +0 -5
  223. data/spec/orange-core/resources/model_resource_spec.rb +0 -246
  224. data/spec/orange-core/resources/parser_spec.rb +0 -5
  225. data/spec/orange-core/resources/routable_resource_spec.rb +0 -5
  226. data/spec/orange-core/stack_spec.rb +0 -232
@@ -1,96 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Orange::Resource do
4
- it "should allow options" do
5
- r= Orange::Resource.new(:opt_1 => true){ opt_2 true }
6
- r.options[:opt_1].should == true
7
- r.options[:opt_2].should == true
8
- r.options.should have_key(:opt_1)
9
- r.options.should_not have_key(:opt_3)
10
- end
11
-
12
- it "should accept an orange core on set_orange" do
13
- c= Orange::Core.new
14
- r= Orange::Resource.new
15
- r.set_orange(c, :name)
16
- r.orange.should equal(c)
17
- r.orange.should be_a_kind_of(Orange::Core)
18
- end
19
-
20
- it "should call afterLoad after calling set_orange" do
21
- c= Orange::Core.new
22
- r= MockResource.new
23
- r.options.should_not have_key(:mocked)
24
- r.set_orange(c, :name)
25
- r.options.should have_key(:mocked)
26
- r.options[:mocked].should == true
27
- end
28
-
29
- it "should set the orange_name after calling set_orange" do
30
- c= Orange::Core.new
31
- r= Orange::Resource.new
32
- r2= Orange::Resource.new
33
- r.set_orange(c, :name)
34
- r2.set_orange(c, 'name')
35
- r.orange_name.should == :name
36
- r2.orange_name.should_not == :name
37
- r2.orange_name.should == 'name'
38
- end
39
-
40
- it "should return self after set_orange" do
41
- c= Orange::Core.new
42
- r= Orange::Resource.new
43
- me = r.set_orange(c, :name)
44
- me.should equal r
45
- end
46
-
47
- it "should register for stack_loaded iff stack_init method present" do
48
- c = Orange::Core.new
49
- c.should_receive(:register).with(:stack_loaded).once
50
- mid1 = c.load MockResource.new
51
- mid2 = c.load MockResourceTwo.new
52
- end
53
-
54
- it "should return an error if setting orange on a class" do
55
- lambda {
56
- Orange::Resource.set_orange(Orange::Core.new, :mock)
57
- }.should raise_error(RuntimeError, "instantiate the resource before calling set orange")
58
- end
59
-
60
- it "should give access to the core through orange" do
61
- c= Orange::Core.new
62
- r= Orange::Resource.new
63
- r.set_orange(c, :name)
64
- r.orange.should equal(c)
65
- r.orange.should be_a_kind_of(Orange::Core)
66
- end
67
-
68
- it "should respond to routable" do
69
- r = Orange::Resource.new
70
- r.should respond_to(:routable)
71
- r.routable.should be_false
72
- end
73
-
74
- it "should return an empty string on calling view" do
75
- r = Orange::Resource.new
76
- r.view.should == ''
77
- r.view(Orange::Packet.new(Orange::Core.new, {})).should == ''
78
- end
79
-
80
- it "should accept an options hash to view" do
81
- p = Orange::Packet.new(Orange::Core.new, {})
82
- r = Orange::Resource.new
83
- lambda{
84
- r.view(p, :opts => 'foo', :test => 'bar')
85
- }.should_not raise_error
86
- end
87
-
88
- it "should give access to the orange name attribute" do
89
- c= Orange::Core.new
90
- r= Orange::Resource.new
91
- r.set_orange(c, :name)
92
- r.orange_name.should == :name
93
- end
94
-
95
-
96
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe Orange::Mapper do
4
- it "should be spec'ed"
5
- end
@@ -1,246 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe Orange::ModelResource do
4
-
5
- it "should extend class inheritable attributes" do
6
- Orange::ModelResource.should be_a_kind_of(ClassInheritableAttributes)
7
- end
8
-
9
- it "should have a model class when calling use" do
10
- a = MockModelResourceOne.new
11
- b = MockModelResourceTwo.new
12
- MockModelResourceOne.model_class.should equal MockCarton
13
- a.model_class.should equal MockCarton
14
- MockModelResourceTwo.model_class.should equal MockCartonTwo
15
- b.model_class.should equal MockCartonTwo
16
- end
17
-
18
- it "have a usable view method" do
19
- a = MockModelResource.new
20
- a.should respond_to(:view)
21
- end
22
-
23
- it "should call index or show by default for an orange packet" do
24
- c = Orange::Core.new
25
- c.load(MockModelResourceOne.new, :mocked)
26
- p = Orange::Packet.new(c, {})
27
- p2 = Orange::Packet.new(c, {})
28
- p2['route.resource_id'] = 1
29
- lambda {
30
- c[:mocked].view(p)
31
- }.should raise_error(RuntimeError, "I see you're using index")
32
- lambda {
33
- c[:mocked].view(p2)
34
- }.should raise_error(RuntimeError, "I see you're using show")
35
- end
36
-
37
- it "should send the mode to the appropriate method" do
38
- c = Orange::Core.new
39
- c.load(MockModelResourceOne.new, :mocked)
40
- p = Orange::Packet.new(c, {})
41
- lambda {
42
- c[:mocked].view(p, :mode => :other)
43
- }.should raise_error(RuntimeError, "I see you're using other")
44
- end
45
-
46
- it "shouldn't give a shit" do
47
- lambda{
48
- MockModelResource.shit
49
- }.should raise_error(NoMethodError)
50
- end
51
-
52
- it "should call find_one if calling view_opts with is_list false" do
53
- a= MockModelResourceOne.new
54
- lambda{
55
- a.view_opts(Orange::Packet.new(Orange::Core.new, {}), :list, false)
56
- }.should raise_error(RuntimeError, "calling find_one")
57
- end
58
-
59
- it "should call find_list if calling view_opts with is_list true" do
60
- a= MockModelResourceOne.new
61
- lambda{
62
- a.view_opts(Orange::Packet.new(Orange::Core.new, {}), :list, true)
63
- }.should raise_error(RuntimeError, "calling find_list")
64
- end
65
-
66
- it "should return a hash of options on calling view_opts" do
67
- a= MockModelResourceFour.new
68
- c= Orange::Core.new
69
- p= Orange::Packet.new(c, {})
70
- lambda{
71
- a.view_opts(p, :list, true)
72
- }.should_not raise_error(RuntimeError)
73
- opts = a.view_opts(p, :list, true, :extra => 'foo')
74
- opts3 = a.view_opts(p, :list, false, :extra => 'foo')
75
- opts2 = a.view_opts(p, :list, true, :list => 'banana')
76
- opts[:props].should == MockCarton.form_props(p['route.context'])
77
- opts.should have_key(:list)
78
- opts3.should_not have_key(:list)
79
- opts.should have_key(:resource)
80
- opts.should have_key(:model_name)
81
- opts.should_not have_key(:model)
82
- opts3.should have_key(:model)
83
- opts.should have_key(:extra)
84
- opts3.should have_key(:extra)
85
- opts[:extra].should == 'foo'
86
- opts3[:extra].should == 'foo'
87
- opts[:list].should_not == opts2[:list]
88
- opts2[:list].should == 'banana'
89
- opts[:list].should == 'mock_list'
90
- end
91
-
92
- it "should call view_extras after during view_opts" do
93
- a= MockModelResourceThree.new
94
- lambda{
95
- a.view_opts(Orange::Packet.new(Orange::Core.new, {}), :list, true)
96
- }.should raise_error(RuntimeError, "calling find_extras")
97
- end
98
-
99
- it "should call haml parser with opts on do_view" do
100
- c= Orange::Core.new
101
- p= Orange::Packet.new(c, {})
102
- c.load(MockHamlParser.new, :parser)
103
- c.load(MockModelResourceFour.new, :mocked)
104
- parsed = c[:mocked].do_view(p, :test, :extra => 'foo')
105
- parsed.first.should == 'test.haml'
106
- parsed.last.should == c[:mocked].view_opts(p, :test, false, :extra => 'foo')
107
- parsed.last.should_not == c[:mocked].view_opts(p, :test, true, :extra => 'foo')
108
- parsed.last.should have_key(:extra)
109
- parsed[1].should equal(p)
110
- end
111
-
112
- it "should call haml parser with opts on do_list_view" do
113
- c= Orange::Core.new
114
- p= Orange::Packet.new(c, {})
115
- c.load(MockHamlParser.new, :parser)
116
- c.load(MockModelResourceFour.new, :mocked)
117
- parsed = c[:mocked].do_list_view(p, :test, :extra => 'foo')
118
- parsed.first.should == 'test.haml'
119
- parsed.last.should == c[:mocked].view_opts(p, :test, true, :extra => 'foo')
120
- parsed.last.should_not == c[:mocked].view_opts(p, :test, false, :extra => 'foo')
121
- parsed.last.should have_key(:extra)
122
- parsed[1].should equal(p)
123
- end
124
-
125
- it "should call carton's get on find_one(packet, mode, id)" do
126
- a= MockModelResourceTwo.new
127
- a.find_one(Orange::Packet.new(Orange::Core.new, {}), :show).should == false
128
- a.find_one(Orange::Packet.new(Orange::Core.new, {}), :show, 1).should == 'mock_get'
129
- end
130
-
131
- it "should call carton's all on find_list(packet, mode)" do
132
- a= MockModelResourceTwo.new
133
- a.find_list(Orange::Packet.new(Orange::Core.new, {}), :show).should == 'mock_all'
134
- end
135
-
136
- it "should return an empty hash by default for find_extras" do
137
- a= MockModelResourceTwo.new
138
- a.find_extras(Orange::Packet.new(Orange::Core.new, {}), :show).should == {}
139
- end
140
-
141
- it "should have the view_list method in packet" do
142
- c = Orange::Core.new
143
- c.load(MockModelResourceOne.new, :mocked)
144
- p = Orange::Packet.new(c, {})
145
- lambda {
146
- p.view_index(:mocked)
147
- }.should raise_error(RuntimeError, "I see you're using index")
148
- lambda {
149
- p.view_show(:mocked)
150
- }.should raise_error(RuntimeError, "I see you're using show")
151
- lambda {
152
- p.view_other(:mocked)
153
- }.should raise_error(RuntimeError, "I see you're using other")
154
- end
155
-
156
- it "should call carton's save on POST new and reroute" do
157
- a= MockModelResourceTwo.new
158
- m= mock("carton", :null_object => true)
159
- m.should_receive(:save)
160
- a.stub!(:model_class).and_return(m)
161
- p2 = mock("packet", :null_object => true)
162
- p2.should_receive(:reroute)
163
- p2.stub!(:request).and_return(mock_post)
164
- lambda{
165
- a.new(Orange::Packet.new(Orange::Core.new, {}))
166
- }.should raise_error(Orange::Reroute, 'Unhandled reroute')
167
- a.new(p2)
168
- end
169
-
170
- it "should call carton's destroy! on DELETE delete and reroute" do
171
- a= MockModelResourceTwo.new
172
- m= mock("carton", :null_object => true)
173
- m.should_receive(:destroy)
174
- a.stub!(:model_class).and_return(m)
175
- p2 = mock("packet", :null_object => true)
176
- p2.should_receive(:reroute)
177
- p2.stub!(:request).and_return(mock_delete)
178
- lambda{
179
- a.delete(Orange::Packet.new(Orange::Core.new, {}))
180
- }.should raise_error(Orange::Reroute, 'Unhandled reroute')
181
- a.delete(p2)
182
- end
183
-
184
- it "should call carton's update on POST save and reroute" do
185
- a= MockModelResourceTwo.new
186
- m= mock("carton", :null_object => true)
187
- m.should_receive(:update)
188
- a.stub!(:model_class).and_return(m)
189
- p2 = mock("packet", :null_object => true)
190
- p2.should_receive(:reroute)
191
- p2.stub!(:request).and_return(mock_post)
192
- lambda{
193
- a.delete(Orange::Packet.new(Orange::Core.new, {}))
194
- }.should raise_error(Orange::Reroute, 'Unhandled reroute')
195
- a.save(p2)
196
- end
197
-
198
- it "should call do_view with mode = :show for show" do
199
- a= MockModelResource.new
200
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :show)
201
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :show, {})
202
- a.show(empty_packet)
203
- a.show(empty_packet, {})
204
- end
205
- it "should call do_view with mode = :edit for edit" do
206
- a= MockModelResource.new
207
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :edit)
208
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :edit, {})
209
- a.edit(empty_packet)
210
- a.edit(empty_packet, {})
211
- end
212
- it "should call do_view with mode = :create for create" do
213
- a= MockModelResource.new
214
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :create)
215
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :create, {})
216
- a.create(empty_packet)
217
- a.create(empty_packet, {})
218
- end
219
-
220
- it "should call do_view with mode = :table_row for table_row" do
221
- a= MockModelResource.new
222
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :table_row)
223
- a.should_receive(:do_view).with(an_instance_of(Orange::Packet), :table_row, {})
224
- a.table_row(empty_packet)
225
- a.table_row(empty_packet, {})
226
- end
227
-
228
- it "should call do_list_view with mode = :list for list" do
229
- a= MockModelResource.new
230
- a.should_receive(:do_list_view).with(an_instance_of(Orange::Packet), :list)
231
- a.should_receive(:do_list_view).with(an_instance_of(Orange::Packet), :list, {})
232
- a.list(empty_packet)
233
- a.list(empty_packet, {})
234
- end
235
-
236
-
237
- it "should call do_list_view with mode = :list for index" do
238
- a= MockModelResource.new
239
- a.should_receive(:do_list_view).with(an_instance_of(Orange::Packet), :list)
240
- a.should_receive(:do_list_view).with(an_instance_of(Orange::Packet), :list, {})
241
- a.index(empty_packet)
242
- a.index(empty_packet, {})
243
- end
244
-
245
-
246
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe Orange::Parser do
4
- it "should be spec'ed"
5
- end
@@ -1,5 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe Orange::RoutableResource do
4
- it "should be spec'ed"
5
- end
@@ -1,232 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Orange::Stack do
4
- before(:all) do
5
- # allow deep introspection into rack builder
6
- class Rack::Builder
7
- attr_accessor :ins
8
- # introspection into the Builder object's list of items
9
- # builder uses Proc magic to chain the middleware together,
10
- # so we undo it.
11
- def ins_no_procs
12
- @ins.map{|x| x.instance_of?(Proc)? x.call(nil) : x }
13
- end
14
- end
15
- class Orange::Stack
16
- attr_accessor :build
17
- def middlewarez
18
- build.ins_no_procs
19
- end
20
- end
21
- end
22
-
23
- def app
24
- MockApplication.app
25
- end
26
-
27
- it "should create a default stack when called by Application" do
28
- MockApplication2.app.should be_an_instance_of(Orange::Stack)
29
- MockApplication2.app.main_app.should be_a_kind_of(Orange::Application)
30
- end
31
-
32
- it "should have access to core" do
33
- MockApplication.app.orange.should be_an_instance_of(Orange::Core)
34
- end
35
-
36
- it "should have access to the main application instance" do
37
- MockApplication2.app.main_app.should be_an_instance_of(MockApplication2)
38
- end
39
-
40
- it "should have the run function" do
41
- x= Orange::Stack.new do
42
- run MockExitware.new
43
- end
44
- lambda {
45
- x.call({:test => 'middlewarez'})
46
- }.should raise_error(RuntimeError, "Mock Exitware")
47
- end
48
-
49
- it "should accept a core object in initialization" do
50
- c = Orange::Core.new
51
- c2 = Orange::Core.new
52
-
53
- x = Orange::Stack.new(nil, c) do
54
- run MockExitware.new
55
- end
56
- x.orange.should equal(c)
57
- x.orange.should_not equal(c2)
58
- end
59
-
60
- it "should have the use function" do
61
- x= Orange::Stack.new do
62
- use MockMiddleware
63
- run MockExitware.new
64
- end
65
- lambda {
66
- x.call({:test => 'middlewarez'})
67
- }.should raise_error(RuntimeError, "I'm in ur middlewarez")
68
- lambda {
69
- x.call({:test => 'middlewarez'})
70
- }.should_not raise_error(RuntimeError, "It's over 9000")
71
- end
72
-
73
- it "should have the stack function" do
74
- x= Orange::Stack.new do
75
- stack MockOrangeBasedMiddleware
76
- run MockExitware.new
77
- end
78
- lambda {
79
- x.call({:test => 'middlewarez'})
80
- }.should raise_error(RuntimeError, "It's over 9000 Orange::Cores!")
81
- end
82
-
83
- it "should respect order of stack/use cases" do
84
- x= Orange::Stack.new do
85
- use MockMiddleware
86
- stack MockOrangeBasedMiddleware
87
- run MockExitware.new
88
- end
89
- y= Orange::Stack.new do
90
- stack MockOrangeBasedMiddleware
91
- use MockMiddleware
92
- run MockExitware.new
93
- end
94
- lambda {
95
- x.call({:test => 'middlewarez'})
96
- }.should raise_error(RuntimeError, "I'm in ur middlewarez")
97
- lambda {
98
- y.call({:test => 'middlewarez'})
99
- }.should raise_error(RuntimeError, "It's over 9000 Orange::Cores!")
100
- end
101
-
102
- it "should load a resource when using load" do
103
- x= Orange::Stack.new
104
- x.load(MockResource.new, :test)
105
- x.orange[:test].mock_method.should == 'MockResource#mock_method'
106
- end
107
-
108
- it "should not rebuild stack if auto_reload not set" do
109
- x= Orange::Stack.new do
110
- run MockExitware.new
111
- end
112
- x.app.should eql(x.app)
113
- end
114
-
115
- it "should fire the stack events" do
116
- c = Orange::Core.new
117
- c2 = Orange::Core.new
118
- x= Orange::Stack.new(nil, c) do
119
- run MockExitware.new
120
- end
121
- x2= Orange::Stack.new(nil, c2) do
122
- auto_reload!
123
- run MockExitware.new
124
- end
125
- c.should_receive(:fire).with(:stack_loaded, anything()).once
126
- c.should_receive(:fire).with(:stack_reloading, anything()).exactly(0).times
127
- x.app
128
- x.app
129
- c2.should_receive(:fire).with(:stack_loaded, anything()).exactly(3).times
130
- c2.should_receive(:fire).with(:stack_reloading, anything()).twice
131
- x2.app
132
- x2.app
133
- x2.app
134
- end
135
-
136
- it "should rebuild stack if auto_reload! set" do
137
- x= Orange::Stack.new do
138
- auto_reload!
139
- use MockMiddleware
140
- run MockExitware.new
141
- end
142
- x.app.should_not eql(x.app)
143
- end
144
-
145
- it "should include ShowExceptions in stack if use_exceptions called" do
146
- x= Orange::Stack.new do
147
- use_exceptions
148
- run MockExitware.new
149
- end
150
- mapped = x.middlewarez
151
- mapped.should_not eql([])
152
- mapped.select{|x| x.instance_of?(Orange::Middleware::ShowExceptions)}.should_not be_empty
153
- mapped.select{|x| x.instance_of?(Orange::Middleware::ShowExceptions)}.should have(1).items
154
- end
155
-
156
- it "should add middleware when calling prerouting" do
157
- x= Orange::Stack.new do
158
- no_recapture
159
- run MockExitware.new
160
- end
161
- x.middlewarez.should have(1).middlewares
162
- x.prerouting
163
- x.middlewarez.should have(9).middlewares
164
- x.middlewarez.select{|y| y.instance_of?(Rack::AbstractFormat)}.should_not be_empty
165
- x.middlewarez.select{|y| y.instance_of?(Orange::Middleware::RouteSite)}.should_not be_empty
166
- end
167
-
168
- it "should have routing, postrouting and responder middleware hooks" do
169
- x = Orange::Stack.new do
170
- run MockExitware.new
171
- end
172
- x.should respond_to(:routing)
173
- x.should respond_to(:postrouting)
174
- x.should respond_to(:responders)
175
- q = mock(:plugins)
176
- plugin = mock(:plugin)
177
- Orange.should_receive(:plugins).exactly(3).times.and_return(q)
178
- q.should_receive(:each).exactly(3).times.and_return([plugin])
179
- x.routing
180
- x.postrouting
181
- x.responders
182
- end
183
-
184
- it "should add one less middleware when calling prerouting with opt :no_abstract_format" do
185
- x= Orange::Stack.new do
186
- no_recapture
187
- run MockExitware.new
188
- end
189
- x.middlewarez.should have(1).middlewares
190
- x.prerouting(:no_abstract_format => true)
191
- x.middlewarez.should have(8).middlewares
192
- x.middlewarez.select{|y| y.instance_of?(Rack::AbstractFormat)}.should be_empty
193
- x.middlewarez.select{|y| y.instance_of?(Orange::Middleware::RouteSite)}.should_not be_empty
194
- end
195
-
196
-
197
- it "should have not have extra middleware for a default stack" do
198
- x= Orange::Stack.new MockApplication
199
- x.middlewarez.should have(1).middlewares
200
- end
201
-
202
- # it "should not include Rack::OpenID unless openid_access_control enabled" do
203
- # defined?(Rack::OpenID).should be_nil
204
- # x= Orange::Stack.new do
205
- # openid_access_control
206
- # run MockExitware.new
207
- # end
208
- # defined?(Rack::OpenID).should == "constant"
209
- # end
210
-
211
- # it "should add middleware when calling openid_access_control" do
212
- # x= Orange::Stack.new do
213
- # no_recapture
214
- # run MockExitware.new
215
- # end
216
- # x.middlewarez.should have(1).middlewares
217
- # x.openid_access_control
218
- # x.middlewarez.should have(3).middlewares
219
- # x.middlewarez.select{|y| y.instance_of?(Rack::OpenID)}.should_not be_empty
220
- # x.middlewarez.select{|y| y.instance_of?(Orange::Middleware::AccessControl)}.should_not be_empty
221
- # end
222
-
223
- it "should include a module into Orange::Packet on add_pulp" do
224
- x= Orange::Stack.new
225
- p= Orange::Packet.new(Orange::Core.new, {})
226
- p.should_not respond_to(:my_new_mock_method)
227
- x.add_pulp(MockPulp)
228
- p.should respond_to(:my_new_mock_method)
229
- p.should be_a_kind_of(MockPulp)
230
- end
231
-
232
- end