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::DefaultHash do
|
4
|
-
it "should be a kind of Hash" do
|
5
|
-
Orange::DefaultHash.new.should be_a_kind_of Hash
|
6
|
-
end
|
7
|
-
it "should handle setting default" do
|
8
|
-
x = Orange::DefaultHash.new
|
9
|
-
y = Orange::DefaultHash.new
|
10
|
-
x.default = true
|
11
|
-
y.default = false
|
12
|
-
x[:not_there].should be_true
|
13
|
-
y[:not_there].should be_false
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should handle default in key access []" do
|
17
|
-
x = Orange::DefaultHash.new
|
18
|
-
x.default = 'baz'
|
19
|
-
x[:not_there].should == 'baz'
|
20
|
-
x[:not_there, 'bar'].should == 'bar'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe Orange::Ignore do
|
25
|
-
it "should silently accept method" do
|
26
|
-
o = Orange::Ignore.new
|
27
|
-
lambda {
|
28
|
-
o.banana
|
29
|
-
o.args
|
30
|
-
o.foo.bar('banana').baz
|
31
|
-
}.should_not raise_error
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "Orange::Options" do
|
36
|
-
it "should give a hash on hash" do
|
37
|
-
Orange::Options.new.hash.should be_an_instance_of(Hash)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should accept hash key options" do
|
41
|
-
hash1 = Orange::Options.new(:one => '1', :two => ['foo']).hash
|
42
|
-
hash2 = Orange::Options.new(:one => '1').hash
|
43
|
-
hash3 = Orange::Options.new({:one => '1', :two => ['foo']}).hash
|
44
|
-
hash4 = Orange::Options.new({:one => '1'}).hash
|
45
|
-
hash5 = Orange::Options.new(1,2, {:one => '1', :two => ['foo']}).hash
|
46
|
-
hash6 = Orange::Options.new(1,2, {:one => '1'}).hash
|
47
|
-
[hash2, hash4, hash6].each{ |hash|
|
48
|
-
hash.should have_key(:one)
|
49
|
-
hash.should_not have_key(:three)
|
50
|
-
hash[:one].should == '1'
|
51
|
-
}
|
52
|
-
[hash1, hash3, hash5].each{ |hash|
|
53
|
-
hash.should have_key(:one)
|
54
|
-
hash.should have_key(:two)
|
55
|
-
hash.should_not have_key(:three)
|
56
|
-
hash[:one].should == '1'
|
57
|
-
hash[:two].should == ['foo']
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should accept block options" do
|
62
|
-
hash = Orange::Options.new {
|
63
|
-
one '1'
|
64
|
-
two ['foo']
|
65
|
-
}.hash
|
66
|
-
hash.should have_key(:one)
|
67
|
-
hash.should have_key(:two)
|
68
|
-
hash.should_not have_key(:three)
|
69
|
-
hash[:one].should == '1'
|
70
|
-
hash[:two].should == ['foo']
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should accept both kinds of options" do
|
74
|
-
hash = Orange::Options.new(:one => '1'){
|
75
|
-
two ['foo']
|
76
|
-
}.hash
|
77
|
-
|
78
|
-
hash.should have_key(:one)
|
79
|
-
hash.should have_key(:two)
|
80
|
-
hash.should_not have_key(:three)
|
81
|
-
hash[:one].should == '1'
|
82
|
-
hash[:two].should == ['foo']
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should override hash key options with block options" do
|
86
|
-
hash = Orange::Options.new(:one => '1', :two => [:baz]){
|
87
|
-
two ['foo']
|
88
|
-
}.hash
|
89
|
-
|
90
|
-
hash.should have_key(:one)
|
91
|
-
hash.should have_key(:two)
|
92
|
-
hash.should_not have_key(:three)
|
93
|
-
hash[:one].should == '1'
|
94
|
-
hash[:two].should == ['foo']
|
95
|
-
end
|
96
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
describe Orange::Middleware::Base do
|
2
|
-
it "should call init after initializing" do
|
3
|
-
lambda{
|
4
|
-
mid = MockOrangeDeathMiddleware.new(nil, Orange::Core.new, :foo => 'bar')
|
5
|
-
}.should raise_error(RuntimeError, "middleware_init with foo=bar")
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should create a packet and call packet call" do
|
9
|
-
mid = MockOrangeBasedMiddlewareTwo.new(nil, Orange::Core.new)
|
10
|
-
mid.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
|
11
|
-
mid.call({})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should pass the packet on by default for packet_call" do
|
15
|
-
mid = MockOrangeBasedMiddlewareTwo.new(nil, Orange::Core.new)
|
16
|
-
mid.should_receive(:pass).with(an_instance_of(Orange::Packet))
|
17
|
-
mid.packet_call(empty_packet)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should call the downstream app on pass" do
|
21
|
-
app = mock("downstream")
|
22
|
-
app2 = mock("downstream_orange")
|
23
|
-
my_hash = {:foo => :bar}
|
24
|
-
app.should_receive(:call).with(my_hash).and_return([{},200,[]])
|
25
|
-
app2.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
|
26
|
-
mid = MockOrangeBasedMiddlewareTwo.new(app, Orange::Core.new)
|
27
|
-
mid2 = MockOrangeBasedMiddlewareTwo.new(app2, Orange::Core.new)
|
28
|
-
mid.call(my_hash)
|
29
|
-
mid2.call(my_hash)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should give access to the orange core on calling orange" do
|
33
|
-
c = Orange::Core.new
|
34
|
-
mid = MockOrangeBasedMiddlewareTwo.new(nil, c)
|
35
|
-
mid.orange.should equal c
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class MockCarton < Orange::Carton
|
2
|
-
def self.scaffold_properties
|
3
|
-
@scaffold_properties
|
4
|
-
end
|
5
|
-
id
|
6
|
-
admin do
|
7
|
-
text :admin
|
8
|
-
end
|
9
|
-
orange do
|
10
|
-
text :orange
|
11
|
-
end
|
12
|
-
front do
|
13
|
-
text :front
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class MockCartonTwo < Orange::Carton
|
18
|
-
id
|
19
|
-
def self.get(id)
|
20
|
-
'mock_get'
|
21
|
-
end
|
22
|
-
def self.all
|
23
|
-
'mock_all'
|
24
|
-
end
|
25
|
-
def save
|
26
|
-
raise 'mock_save'
|
27
|
-
end
|
28
|
-
def destroy!
|
29
|
-
raise 'mock_destroy'
|
30
|
-
end
|
31
|
-
def update(*args)
|
32
|
-
raise 'mock_update'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class MockCartonBlank < Orange::Carton
|
37
|
-
def self.levels
|
38
|
-
@levels
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class MockCartonBlankTwo < Orange::Carton
|
43
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class MockOrangeBasedMiddleware < Orange::Middleware::Base
|
2
|
-
def packet_call(packet)
|
3
|
-
raise "It's over 9000 #{@core.class.to_s}s!"
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
class MockMiddleware
|
8
|
-
def initialize(app)
|
9
|
-
end
|
10
|
-
def call(env)
|
11
|
-
raise "I'm in ur #{env[:test]}"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class MockOrangeBasedMiddlewareTwo < Orange::Middleware::Base; end
|
16
|
-
class MockOrangeBasedMiddlewareThree < Orange::Middleware::Base
|
17
|
-
def stack_init
|
18
|
-
end
|
19
|
-
end
|
20
|
-
class MockOrangeDeathMiddleware < Orange::Middleware::Base
|
21
|
-
def init(*args)
|
22
|
-
opts = args.extract_options!
|
23
|
-
raise "middleware_init with foo=#{opts[:foo]}"
|
24
|
-
end
|
25
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module MockMixinOrange1
|
2
|
-
def mixin_orange_one
|
3
|
-
end
|
4
|
-
end
|
5
|
-
|
6
|
-
module MockMixinOrange2
|
7
|
-
def mixin_orange_two
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module MockMixinCore1
|
12
|
-
def mixin_core_one
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module MockMixinCore2
|
17
|
-
def mixin_core_two
|
18
|
-
end
|
19
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
class MockModelResource < Orange::ModelResource
|
2
|
-
use MockCarton
|
3
|
-
end
|
4
|
-
|
5
|
-
class MockModelResourceOne < Orange::ModelResource
|
6
|
-
use MockCarton
|
7
|
-
def index(packet, *args)
|
8
|
-
raise 'I see you\'re using index'
|
9
|
-
end
|
10
|
-
def show(packet, *args)
|
11
|
-
raise 'I see you\'re using show'
|
12
|
-
end
|
13
|
-
def other(packet, *args)
|
14
|
-
raise 'I see you\'re using other'
|
15
|
-
end
|
16
|
-
def find_one(packet, mode, resource_id =false)
|
17
|
-
raise 'calling find_one'
|
18
|
-
end
|
19
|
-
def find_list(packet, mode)
|
20
|
-
raise 'calling find_list'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class MockModelResourceTwo < Orange::ModelResource
|
25
|
-
use MockCartonTwo
|
26
|
-
end
|
27
|
-
|
28
|
-
class MockModelResourceThree < Orange::ModelResource
|
29
|
-
use MockCarton
|
30
|
-
def find_extras(packet, mode)
|
31
|
-
raise 'calling find_extras'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class MockModelResourceFour < Orange::ModelResource
|
36
|
-
use MockCarton
|
37
|
-
def find_one(packet, mode, resource_id =false)
|
38
|
-
'mock_one'
|
39
|
-
end
|
40
|
-
def find_list(packet, mode)
|
41
|
-
'mock_list'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class MockModelResourceExtreme < Orange::ModelResource
|
46
|
-
|
47
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module MockPulpOrange1
|
2
|
-
def pulp_orange_one
|
3
|
-
end
|
4
|
-
end
|
5
|
-
|
6
|
-
module MockPulpOrange2
|
7
|
-
def pulp_orange_two
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module MockPulpCore1
|
12
|
-
def pulp_core_one
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module MockPulpCore2
|
17
|
-
def pulp_core_two
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
module MockPulp
|
22
|
-
def my_new_mock_method
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class MockResource < Orange::Resource
|
2
|
-
def mock_method
|
3
|
-
'MockResource#mock_method'
|
4
|
-
end
|
5
|
-
def afterLoad
|
6
|
-
@options[:mocked] = true
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class MockResourceTwo < Orange::Resource
|
11
|
-
def mock_method
|
12
|
-
'MockResource#mock_method'
|
13
|
-
end
|
14
|
-
def afterLoad
|
15
|
-
@options[:mocked] = true
|
16
|
-
end
|
17
|
-
def stack_init
|
18
|
-
true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class MockHamlParser < Orange::Resource
|
23
|
-
def haml(template, packet, opts)
|
24
|
-
[template, packet, opts]
|
25
|
-
end
|
26
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
describe Orange do
|
2
|
-
it "should allow core mixin via mixin method" do
|
3
|
-
c= Orange::Core.new
|
4
|
-
c.should_not respond_to(:mixin_orange_one)
|
5
|
-
Orange.mixin MockMixinOrange1
|
6
|
-
c2= Orange::Core.new
|
7
|
-
c.should respond_to(:mixin_orange_one)
|
8
|
-
c2.should respond_to(:mixin_orange_one)
|
9
|
-
end
|
10
|
-
it "should allow pulp mixin via pulp method" do
|
11
|
-
c= Orange::Core.new
|
12
|
-
p= Orange::Packet.new(c, {})
|
13
|
-
p.should_not respond_to(:pulp_orange_one)
|
14
|
-
Orange.add_pulp MockPulpOrange1
|
15
|
-
p2= Orange::Packet.new(c, {})
|
16
|
-
p.should respond_to(:pulp_orange_one)
|
17
|
-
p2.should respond_to(:pulp_orange_one)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,203 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Orange::Packet do
|
4
|
-
it "should return a default header content type of html" do
|
5
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
6
|
-
p.finish[1].should have_key("Content-Type")
|
7
|
-
p.finish[1]["Content-Type"].should eql("text/html")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should not create a new object for env if one already exists" do
|
11
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
12
|
-
env = p.env
|
13
|
-
p2= Orange::Packet.new(Orange::Core.new, env)
|
14
|
-
p.should equal p2 # Exact equality - same instances
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should save core passed to it on initialization" do
|
18
|
-
c= Orange::Core.new
|
19
|
-
p= Orange::Packet.new(c, {})
|
20
|
-
p.orange.should equal c
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should save the env passed to it on init" do
|
24
|
-
p= Orange::Packet.new(Orange::Core.new, {:test => :foo})
|
25
|
-
p.env.should have_key(:test)
|
26
|
-
p.env[:test].should == :foo
|
27
|
-
p.env.should_not be_empty
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should add orange.packet and orange.env to env on init" do
|
31
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
32
|
-
p.env.should have_key('orange.packet')
|
33
|
-
p.env['orange.packet'].should equal p
|
34
|
-
p.env.should have_key('orange.env')
|
35
|
-
p.env['orange.env'].should have_key(:request)
|
36
|
-
p.env['orange.env'][:request].should be_an_instance_of(Rack::Request)
|
37
|
-
p.env['orange.env'].should have_key(:headers)
|
38
|
-
p.env['orange.env'][:headers].should be_an_instance_of(Hash)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should have access to the orange.env through []" do
|
42
|
-
p= Orange::Packet.new(Orange::Core.new, {'orange.env' => {'foo' => :true}})
|
43
|
-
p['foo'].should == :true
|
44
|
-
p['foo'] = 'banana'
|
45
|
-
p.env['orange.env']['foo'].should == 'banana'
|
46
|
-
p['foo'].should == 'banana'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should allow defaults through [] calls" do
|
50
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
51
|
-
p['nonexistent'].should be_false
|
52
|
-
p['nonexistent', true].should be_true
|
53
|
-
p['nonexistent', true].should_not be_an_instance_of Hash
|
54
|
-
p['nonexistent', {}].should be_an_instance_of Hash
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should give access to the rack.session env" do
|
58
|
-
p= Orange::Packet.new(Orange::Core.new, {'rack.session' => {'foo' => 'banana'}})
|
59
|
-
p.session.should have_key 'foo'
|
60
|
-
p.session.should have_key 'flash'
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should give always have a flash" do
|
64
|
-
p= Orange::Packet.new(Orange::Core.new, {'rack.session' => {}})
|
65
|
-
p.session.should have_key 'flash'
|
66
|
-
p.flash.should == {}
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should destruct a flash value upon reading" do
|
70
|
-
p= Orange::Packet.new(Orange::Core.new, {'rack.session' => {}})
|
71
|
-
p.session.should have_key 'flash'
|
72
|
-
p.session["flash"]["foo"] = "bar"
|
73
|
-
p.flash("foo").should == "bar"
|
74
|
-
p.flash("foo").should be_nil
|
75
|
-
p.session["flash"].should_not have_key("foo")
|
76
|
-
p.flash("foo", "bar")
|
77
|
-
p.flash("foo").should == "bar"
|
78
|
-
p.flash("foo").should be_nil
|
79
|
-
p.session["flash"].should_not have_key("foo")
|
80
|
-
p.flash["foo"] = "bar"
|
81
|
-
p.flash("foo").should == "bar"
|
82
|
-
p.flash("foo").should be_nil
|
83
|
-
p.flash.should_not have_key("foo")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should give headers by combining :headers with defaults" do
|
87
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
88
|
-
p.headers.should == p[:headers, {}].with_defaults(Orange::Packet::DEFAULT_HEADERS)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should allow setting headers via header(key, val)" do
|
92
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
93
|
-
p.header('Content-Type', 'text/plain')
|
94
|
-
p.headers['Content-Type'].should == 'text/plain'
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should allow adding headers with add_header" do
|
98
|
-
p1= Orange::Packet.new(Orange::Core.new, {})
|
99
|
-
p2= Orange::Packet.new(Orange::Core.new, {})
|
100
|
-
p1.add_header('Content-Type', 'text/plain')
|
101
|
-
p2.header('Content-Type', 'text/plain')
|
102
|
-
p1.headers['Content-Type'].should == p2.headers['Content-Type']
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should give access to the core object via orange" do
|
106
|
-
c= Orange::Core.new
|
107
|
-
p= Orange::Packet.new(c, {})
|
108
|
-
p.orange.should equal c
|
109
|
-
p.orange.should be_an_instance_of(Orange::Core)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should create a triple according to rack standards on #finish" do
|
113
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
114
|
-
fin = p.finish
|
115
|
-
fin[0].should be_a_kind_of Integer
|
116
|
-
fin[1].should be_a_kind_of Hash
|
117
|
-
fin[2].should be_a_kind_of Array
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should give self when using packet" do
|
121
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
122
|
-
p.packet.should equal p
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should mixin when calling mixin" do
|
126
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
127
|
-
p.should_not respond_to(:pulp_orange_two)
|
128
|
-
Orange::Packet.mixin MockPulpOrange2
|
129
|
-
p.should respond_to(:pulp_orange_two)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should raise an error if no router set" do
|
133
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
134
|
-
lambda{
|
135
|
-
p.route
|
136
|
-
}.should raise_error(RuntimeError, 'Router not found')
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should pass self to assigned router's route method" do
|
140
|
-
class MockDeathRouter
|
141
|
-
def route(p); raise "die, die, death, #{p[:lame]}"; end
|
142
|
-
end
|
143
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
144
|
-
p['route.router'] = MockDeathRouter.new
|
145
|
-
p[:lame] = 'death'
|
146
|
-
lambda{
|
147
|
-
p.route
|
148
|
-
}.should_not raise_error(RuntimeError, 'Router not found')
|
149
|
-
lambda{
|
150
|
-
p.route
|
151
|
-
}.should raise_error(RuntimeError, 'die, die, death, death')
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should give a request object" do
|
155
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
156
|
-
p.request.should be_an_instance_of Rack::Request
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should store method matchers for extending method_missing handlers" do
|
160
|
-
class Orange::Packet
|
161
|
-
meta_methods(/pretend_method_we_dont_want/) do |match, args|
|
162
|
-
"my mock meta method"
|
163
|
-
end
|
164
|
-
|
165
|
-
meta_methods(/pretend_method_we_dont_want(\w+)/) do |match, args|
|
166
|
-
"my mock meta method"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
170
|
-
p.matchers.size.should >= 2
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should have method_missing capabilities" do
|
174
|
-
p= Orange::Packet.new(Orange::Core.new, {})
|
175
|
-
p.should respond_to(:method_missing)
|
176
|
-
lambda {
|
177
|
-
p.my_mock_meta_method
|
178
|
-
p.mock_meta_test
|
179
|
-
p.mock_meta_test_with_args
|
180
|
-
}.should raise_error(NoMethodError)
|
181
|
-
class Orange::Packet
|
182
|
-
meta_methods(/my_mock_meta_method/) do
|
183
|
-
"my mock meta method"
|
184
|
-
end
|
185
|
-
|
186
|
-
meta_methods(/mock_meta_(\w+)/) do |packet, match|
|
187
|
-
"my mock #{match[1]} method"
|
188
|
-
end
|
189
|
-
|
190
|
-
meta_methods(/mock_meta_(\w+)_with_args/) do |packet, match, args|
|
191
|
-
"my mock #{match[1]} method args0 = #{args[0]}"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
lambda {
|
195
|
-
p.my_mock_meta_method
|
196
|
-
p.mock_meta_test
|
197
|
-
p.mock_meta_test_with_args 'test'
|
198
|
-
}.should_not raise_error(NoMethodError)
|
199
|
-
p.my_mock_meta_method.should == "my mock meta method"
|
200
|
-
p.mock_meta_test.should == "my mock test method"
|
201
|
-
p.mock_meta_test_with_args('test').should == "my mock test method args0 = test"
|
202
|
-
end
|
203
|
-
end
|