exposure 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/exposure/behaviors/responding.rb +1 -1
- data/lib/exposure/configuration.rb +1 -1
- data/lib/exposure/patterns/resources.rb +12 -1
- data/spec/finders/default_finder_spec.rb +45 -0
- metadata +14 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -26,7 +26,7 @@ module Exposure
|
|
26
26
|
def response_for(*actions, &block)
|
27
27
|
options = actions.extract_options!
|
28
28
|
options[:is] ||= block
|
29
|
-
formats = options[:formats] || [:html]
|
29
|
+
formats = options[:formats] || [:html, :xml, :json]
|
30
30
|
|
31
31
|
case options[:on]
|
32
32
|
when NilClass, :any
|
@@ -39,6 +39,7 @@ module Exposure
|
|
39
39
|
'destroy.success.html'=> proc { redirect_to({:action => 'index'}) },
|
40
40
|
'create.failure.html' => proc { render('new') },
|
41
41
|
'update.failure.html' => proc { render('edit') },
|
42
|
+
|
42
43
|
'index.success.xml' => proc { render(:xml => @resources) },
|
43
44
|
'show.success.xml' => proc { render(:xml => @resource) },
|
44
45
|
'new.success.xml' => proc { render(:xml => @resource) },
|
@@ -46,7 +47,17 @@ module Exposure
|
|
46
47
|
'created.failure.xml'=> proc { render(:xml => @resource.errors, :status => :unprocessable_entity)},
|
47
48
|
'update.success.xml' => proc { head(:ok)},
|
48
49
|
'update.failure.xml' => proc { render(:xml => @resource.errors, :status => :unprocessable_entity)},
|
49
|
-
'destroy.success.xml'=> proc { head(:ok)}
|
50
|
+
'destroy.success.xml'=> proc { head(:ok)},
|
51
|
+
|
52
|
+
'index.success.json' => proc { render(:json => @resources) },
|
53
|
+
'show.success.json' => proc { render(:json => @resource) },
|
54
|
+
'new.success.json' => proc { render(:json => @resource) },
|
55
|
+
'create.success.json' => proc { render({:json => @resource, :status => :created, :location => @resource}) },
|
56
|
+
'created.failure.json'=> proc { render(:json => @resource.errors, :status => :unprocessable_entity)},
|
57
|
+
'update.success.json' => proc { render(:json => @resource)},
|
58
|
+
'update.failure.json' => proc { render(:json => @resource.errors, :status => :unprocessable_entity)},
|
59
|
+
'destroy.success.json'=> proc { render(:json => @resource)}
|
60
|
+
|
50
61
|
}
|
51
62
|
|
52
63
|
module Actions
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "finders", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
end
|
8
|
+
|
9
|
+
ActionController::Routing::Routes.draw do |map|
|
10
|
+
map.resources :pirates
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
setup.call
|
15
|
+
controller_name :pirates
|
16
|
+
Object.remove_class(PiratesController)
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
setup.call
|
20
|
+
@controller = PiratesController.new
|
21
|
+
@request = ActionController::TestRequest.new
|
22
|
+
@response = ActionController::TestResponse.new
|
23
|
+
|
24
|
+
@pirate = Factory.stub(:pirate)
|
25
|
+
@pirates = [Factory.stub(:pirate)]
|
26
|
+
Pirate.stub(:find => @pirate)
|
27
|
+
Pirate.stub(:all => @pirates)
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:each) do
|
31
|
+
Object.remove_class(PiratesController)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "finds member resource params[:id]" do
|
35
|
+
Pirate.should_receive(:find).with('1').and_return(@pirate)
|
36
|
+
get(:show, {:id => '1'})
|
37
|
+
should assign_to(:pirate).with(@pirate)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "finds the collection resource with Model.all" do
|
41
|
+
Pirate.should_receive(:all).and_return(@pirates)
|
42
|
+
get(:index)
|
43
|
+
should assign_to(:pirates).with(@pirates)
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exposure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Trek Glowacki
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-05-29 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -48,6 +53,7 @@ files:
|
|
48
53
|
- spec/factories/cannon_factory.rb
|
49
54
|
- spec/factories/pirate_factory.rb
|
50
55
|
- spec/factories/ship_factory.rb
|
56
|
+
- spec/finders/default_finder_spec.rb
|
51
57
|
- spec/finders/finder_spec.rb
|
52
58
|
- spec/finders/nested_resources_finder_spec.rb
|
53
59
|
- spec/fixtures/pirates/edit.erb
|
@@ -88,18 +94,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
94
|
requirements:
|
89
95
|
- - ">="
|
90
96
|
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
91
99
|
version: "0"
|
92
|
-
version:
|
93
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
101
|
requirements:
|
95
102
|
- - ">="
|
96
103
|
- !ruby/object:Gem::Version
|
104
|
+
segments:
|
105
|
+
- 0
|
97
106
|
version: "0"
|
98
|
-
version:
|
99
107
|
requirements: []
|
100
108
|
|
101
109
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.3.
|
110
|
+
rubygems_version: 1.3.6
|
103
111
|
signing_key:
|
104
112
|
specification_version: 3
|
105
113
|
summary: exposed resources
|
@@ -113,6 +121,7 @@ test_files:
|
|
113
121
|
- spec/factories/cannon_factory.rb
|
114
122
|
- spec/factories/pirate_factory.rb
|
115
123
|
- spec/factories/ship_factory.rb
|
124
|
+
- spec/finders/default_finder_spec.rb
|
116
125
|
- spec/finders/finder_spec.rb
|
117
126
|
- spec/finders/nested_resources_finder_spec.rb
|
118
127
|
- spec/flashers/flash_with_block_spec.rb
|