orange 0.5.5 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/orange.rb +2 -5
- data/spec/orange_spec.rb +5 -0
- data/spec/{orange-core/spec_helper.rb → spec_helper.rb} +0 -0
- metadata +28 -235
- data/lib/orange-core.rb +0 -8
- data/lib/orange-core/application.rb +0 -132
- data/lib/orange-core/assets/css/exceptions.css +0 -50
- data/lib/orange-core/assets/js/exceptions.js +0 -44
- data/lib/orange-core/carton.rb +0 -178
- data/lib/orange-core/core.rb +0 -266
- data/lib/orange-core/magick.rb +0 -270
- data/lib/orange-core/middleware/base.rb +0 -96
- data/lib/orange-core/middleware/database.rb +0 -45
- data/lib/orange-core/middleware/four_oh_four.rb +0 -45
- data/lib/orange-core/middleware/globals.rb +0 -17
- data/lib/orange-core/middleware/loader.rb +0 -13
- data/lib/orange-core/middleware/rerouter.rb +0 -53
- data/lib/orange-core/middleware/restful_router.rb +0 -99
- data/lib/orange-core/middleware/route_context.rb +0 -39
- data/lib/orange-core/middleware/route_site.rb +0 -51
- data/lib/orange-core/middleware/show_exceptions.rb +0 -80
- data/lib/orange-core/middleware/static.rb +0 -67
- data/lib/orange-core/middleware/static_file.rb +0 -32
- data/lib/orange-core/middleware/template.rb +0 -60
- data/lib/orange-core/packet.rb +0 -232
- data/lib/orange-core/plugin.rb +0 -172
- data/lib/orange-core/resource.rb +0 -96
- data/lib/orange-core/resources/mapper.rb +0 -36
- data/lib/orange-core/resources/model_resource.rb +0 -228
- data/lib/orange-core/resources/not_found.rb +0 -10
- data/lib/orange-core/resources/page_parts.rb +0 -68
- data/lib/orange-core/resources/parser.rb +0 -113
- data/lib/orange-core/resources/routable_resource.rb +0 -16
- data/lib/orange-core/resources/scaffold.rb +0 -106
- data/lib/orange-core/stack.rb +0 -226
- data/lib/orange-core/templates/exceptions.haml +0 -111
- data/lib/orange-core/views/default_resource/create.haml +0 -4
- data/lib/orange-core/views/default_resource/edit.haml +0 -9
- data/lib/orange-core/views/default_resource/list.haml +0 -10
- data/lib/orange-core/views/default_resource/show.haml +0 -4
- data/lib/orange-core/views/default_resource/table_row.haml +0 -7
- data/lib/orange-core/views/not_found/404.haml +0 -2
- data/lib/orange-more.rb +0 -23
- data/lib/orange-more/administration.rb +0 -1
- data/lib/orange-more/administration/assets/css/admin.css +0 -286
- data/lib/orange-more/administration/assets/css/blueprint-ie.css +0 -35
- data/lib/orange-more/administration/assets/css/blueprint-print.css +0 -29
- data/lib/orange-more/administration/assets/css/blueprint.css +0 -257
- data/lib/orange-more/administration/assets/js/jquery.js +0 -152
- data/lib/orange-more/administration/cartons/site.rb +0 -7
- data/lib/orange-more/administration/cartons/site_carton.rb +0 -12
- data/lib/orange-more/administration/cartons/user.rb +0 -27
- data/lib/orange-more/administration/middleware/access_control.rb +0 -156
- data/lib/orange-more/administration/middleware/site_load.rb +0 -25
- data/lib/orange-more/administration/plugin.rb +0 -23
- data/lib/orange-more/administration/resources/admin_resource.rb +0 -27
- data/lib/orange-more/administration/resources/site_resource.rb +0 -10
- data/lib/orange-more/administration/resources/user_resource.rb +0 -40
- data/lib/orange-more/administration/templates/admin.haml +0 -25
- data/lib/orange-more/administration/views/openid_login.haml +0 -14
- data/lib/orange-more/administration/views/users/create.haml +0 -10
- data/lib/orange-more/administration/views/users/edit.haml +0 -15
- data/lib/orange-more/adverts.rb +0 -1
- data/lib/orange-more/adverts/cartons/adverts_carton.rb +0 -14
- data/lib/orange-more/adverts/plugin.rb +0 -13
- data/lib/orange-more/adverts/resources/adverts_resource.rb +0 -27
- data/lib/orange-more/adverts/views/adverts/adverts.haml +0 -2
- data/lib/orange-more/analytics.rb +0 -1
- data/lib/orange-more/analytics/middleware/analytics.rb +0 -30
- data/lib/orange-more/analytics/plugin.rb +0 -11
- data/lib/orange-more/analytics/resources/analytics_resource.rb +0 -42
- data/lib/orange-more/assets.rb +0 -1
- data/lib/orange-more/assets/cartons/asset_carton.rb +0 -27
- data/lib/orange-more/assets/plugin.rb +0 -13
- data/lib/orange-more/assets/resources/asset_resource.rb +0 -115
- data/lib/orange-more/assets/views/assets/change.haml +0 -1
- data/lib/orange-more/assets/views/assets/create.haml +0 -13
- data/lib/orange-more/assets/views/assets/insert.haml +0 -1
- data/lib/orange-more/blog.rb +0 -1
- data/lib/orange-more/blog/cartons/blog.rb +0 -8
- data/lib/orange-more/blog/cartons/blog_post.rb +0 -60
- data/lib/orange-more/blog/plugin.rb +0 -14
- data/lib/orange-more/blog/resources/blog_post_resource.rb +0 -53
- data/lib/orange-more/blog/resources/blog_resource.rb +0 -104
- data/lib/orange-more/blog/views/blog/blog_archive_view.haml +0 -6
- data/lib/orange-more/blog/views/blog/blog_offset_list_view.haml +0 -12
- data/lib/orange-more/blog/views/blog/blog_post_view.haml +0 -4
- data/lib/orange-more/blog/views/blog/sitemap_row.haml +0 -14
- data/lib/orange-more/blog/views/blog_posts/edit.haml +0 -8
- data/lib/orange-more/blog/views/blog_posts/show.haml +0 -4
- data/lib/orange-more/cloud.rb +0 -1
- data/lib/orange-more/cloud/plugin.rb +0 -10
- data/lib/orange-more/cloud/resources/cloud_resource.rb +0 -21
- data/lib/orange-more/contactforms.rb +0 -1
- data/lib/orange-more/contactforms/assets/js/jquery.validate.pack.js +0 -15
- data/lib/orange-more/contactforms/assets/js/lib/jquery-1.4.2.js +0 -6240
- data/lib/orange-more/contactforms/assets/js/lib/jquery.form.js +0 -660
- data/lib/orange-more/contactforms/assets/js/lib/jquery.js +0 -4376
- data/lib/orange-more/contactforms/assets/js/lib/jquery.metadata.js +0 -122
- data/lib/orange-more/contactforms/cartons/contactforms_carton.rb +0 -12
- data/lib/orange-more/contactforms/plugin.rb +0 -13
- data/lib/orange-more/contactforms/resources/contactforms_resource.rb +0 -56
- data/lib/orange-more/contactforms/views/contactforms/contactform.haml +0 -20
- data/lib/orange-more/debugger.rb +0 -1
- data/lib/orange-more/debugger/assets/css/debug_bar.css +0 -46
- data/lib/orange-more/debugger/middleware/debugger.rb +0 -50
- data/lib/orange-more/debugger/plugin.rb +0 -12
- data/lib/orange-more/debugger/views/debug_bar.haml +0 -87
- data/lib/orange-more/disqus.rb +0 -1
- data/lib/orange-more/disqus/plugin.rb +0 -11
- data/lib/orange-more/disqus/resources/disqus_resource.rb +0 -9
- data/lib/orange-more/disqus/views/disqus/comment_thread.haml +0 -7
- data/lib/orange-more/donations.rb +0 -1
- data/lib/orange-more/donations/cartons/donation_carton.rb +0 -9
- data/lib/orange-more/donations/plugin.rb +0 -12
- data/lib/orange-more/donations/resources/donations_resource.rb +0 -51
- data/lib/orange-more/donations/views/donations/donate_form.haml +0 -21
- data/lib/orange-more/donations/views/donations/donate_thanks.haml +0 -2
- data/lib/orange-more/donations/views/donations/paypal_form.haml +0 -13
- data/lib/orange-more/events.rb +0 -1
- data/lib/orange-more/events/assets/js/events.js +0 -55
- data/lib/orange-more/events/cartons/orange_calendar.rb +0 -8
- data/lib/orange-more/events/cartons/orange_event.rb +0 -60
- data/lib/orange-more/events/plugin.rb +0 -14
- data/lib/orange-more/events/resources/calendar_resource.rb +0 -33
- data/lib/orange-more/events/resources/event_resource.rb +0 -147
- data/lib/orange-more/events/views/calendar/calendar.haml +0 -8
- data/lib/orange-more/events/views/events/create.haml +0 -55
- data/lib/orange-more/events/views/events/edit.haml +0 -59
- data/lib/orange-more/events/views/events/list.haml +0 -13
- data/lib/orange-more/events/views/events/show.haml +0 -4
- data/lib/orange-more/events/views/events/table_row.haml +0 -17
- data/lib/orange-more/members.rb +0 -1
- data/lib/orange-more/members/cartons/member_carton.rb +0 -38
- data/lib/orange-more/members/plugin.rb +0 -13
- data/lib/orange-more/members/resources/members_resource.rb +0 -327
- data/lib/orange-more/members/views/members/create.haml +0 -12
- data/lib/orange-more/members/views/members/edit.haml +0 -15
- data/lib/orange-more/members/views/members/live.show.haml +0 -1
- data/lib/orange-more/members/views/members/login.haml +0 -17
- data/lib/orange-more/members/views/members/logout.haml +0 -1
- data/lib/orange-more/members/views/members/profile.haml +0 -50
- data/lib/orange-more/members/views/members/register.haml +0 -37
- data/lib/orange-more/news.rb +0 -1
- data/lib/orange-more/news/cartons/news.rb +0 -12
- data/lib/orange-more/news/plugin.rb +0 -13
- data/lib/orange-more/news/resources/news_resource.rb +0 -82
- data/lib/orange-more/news/views/news/archive.haml +0 -14
- data/lib/orange-more/news/views/news/edit.haml +0 -7
- data/lib/orange-more/news/views/news/latest.haml +0 -8
- data/lib/orange-more/news/views/news/sitemap_row.haml +0 -14
- data/lib/orange-more/pages.rb +0 -1
- data/lib/orange-more/pages/cartons/page_carton.rb +0 -14
- data/lib/orange-more/pages/cartons/page_version_carton.rb +0 -12
- data/lib/orange-more/pages/plugin.rb +0 -13
- data/lib/orange-more/pages/resources/page_resource.rb +0 -179
- data/lib/orange-more/pages/views/pages/edit.haml +0 -34
- data/lib/orange-more/pages/views/pages/show.haml +0 -6
- data/lib/orange-more/sitemap.rb +0 -1
- data/lib/orange-more/sitemap/assets/img/sitemap_down.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_down_d.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_indent.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_indent_d.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_outdent.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_outdent_d.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_up.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_up_d.png +0 -0
- data/lib/orange-more/sitemap/assets/js/sitemap.js +0 -11
- data/lib/orange-more/sitemap/cartons/route.rb +0 -43
- data/lib/orange-more/sitemap/middleware/flex_router.rb +0 -25
- data/lib/orange-more/sitemap/plugin.rb +0 -17
- data/lib/orange-more/sitemap/resources/sitemap_resource.rb +0 -295
- data/lib/orange-more/sitemap/views/default_resource/sitemap_row.haml +0 -30
- data/lib/orange-more/sitemap/views/sitemap/breadcrumb.haml +0 -12
- data/lib/orange-more/sitemap/views/sitemap/list.haml +0 -4
- data/lib/orange-more/sitemap/views/sitemap/one_level.haml +0 -7
- data/lib/orange-more/sitemap/views/sitemap/route_actions.haml +0 -15
- data/lib/orange-more/sitemap/views/sitemap/sitemap_links.haml +0 -14
- data/lib/orange-more/sitemap/views/sitemap/table_row.haml +0 -30
- data/lib/orange-more/sitemap/views/sitemap/two_level.haml +0 -13
- data/lib/orange-more/slices.rb +0 -1
- data/lib/orange-more/slices/middleware/radius_parser.rb +0 -24
- data/lib/orange-more/slices/plugin.rb +0 -15
- data/lib/orange-more/slices/resources/radius.rb +0 -117
- data/lib/orange-more/slices/resources/slices.rb +0 -35
- data/lib/orange-more/subsites.rb +0 -1
- data/lib/orange-more/subsites/cartons/subsite.rb +0 -8
- data/lib/orange-more/subsites/middleware/subsite_load.rb +0 -29
- data/lib/orange-more/subsites/plugin.rb +0 -17
- data/lib/orange-more/subsites/resources/subsite_resource.rb +0 -54
- data/lib/orange-more/subsites/views/subsites/index.haml +0 -2
- data/lib/orange-more/testimonials.rb +0 -1
- data/lib/orange-more/testimonials/cartons/testimonials_carton.rb +0 -15
- data/lib/orange-more/testimonials/plugin.rb +0 -13
- data/lib/orange-more/testimonials/resources/testimonials_resource.rb +0 -42
- data/lib/orange-more/testimonials/views/testimonials/testimonials.haml +0 -4
- data/spec/orange-core/application_spec.rb +0 -183
- data/spec/orange-core/carton_spec.rb +0 -136
- data/spec/orange-core/core_spec.rb +0 -248
- data/spec/orange-core/magick_spec.rb +0 -96
- data/spec/orange-core/middleware/base_spec.rb +0 -38
- data/spec/orange-core/middleware/globals_spec.rb +0 -3
- data/spec/orange-core/middleware/rerouter_spec.rb +0 -3
- data/spec/orange-core/middleware/restful_router_spec.rb +0 -3
- data/spec/orange-core/middleware/route_context_spec.rb +0 -3
- data/spec/orange-core/middleware/route_site_spec.rb +0 -3
- data/spec/orange-core/middleware/show_exceptions_spec.rb +0 -3
- data/spec/orange-core/middleware/static_file_spec.rb +0 -3
- data/spec/orange-core/middleware/static_spec.rb +0 -3
- data/spec/orange-core/mock/mock_app.rb +0 -16
- data/spec/orange-core/mock/mock_carton.rb +0 -43
- data/spec/orange-core/mock/mock_core.rb +0 -2
- data/spec/orange-core/mock/mock_middleware.rb +0 -25
- data/spec/orange-core/mock/mock_mixins.rb +0 -19
- data/spec/orange-core/mock/mock_model_resource.rb +0 -47
- data/spec/orange-core/mock/mock_pulp.rb +0 -24
- data/spec/orange-core/mock/mock_resource.rb +0 -26
- data/spec/orange-core/mock/mock_router.rb +0 -10
- data/spec/orange-core/orange_spec.rb +0 -19
- data/spec/orange-core/packet_spec.rb +0 -203
- data/spec/orange-core/resource_spec.rb +0 -96
- data/spec/orange-core/resources/mapper_spec.rb +0 -5
- data/spec/orange-core/resources/model_resource_spec.rb +0 -246
- data/spec/orange-core/resources/parser_spec.rb +0 -5
- data/spec/orange-core/resources/routable_resource_spec.rb +0 -5
- 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,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,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
|