restfulness 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c6d3884753e3b58d9c9d459a633f5973de4b5f2
4
- data.tar.gz: 7694025035531b633586bbb361978b543c37a532
3
+ metadata.gz: 7c75c4e41bde16b35b2e5ea93df0958073b8d114
4
+ data.tar.gz: 4d72d5c989d8d4cc1fdabdeb92475a07ee0e354a
5
5
  SHA512:
6
- metadata.gz: dc2abb03ebf2caea3f7f2e528b19917bbb7d7144c4f4ddc78ee5e8469c0aa53c2a2f45b8d4865b21ca21ffbfaa4c10072864358361238b92eb0b9b84cf7b21d9
7
- data.tar.gz: ae4f3c662aeb5b5e78a331fc5225d27289727ccc22c22f8d957d89e6178d7dfd262aaa65d45a301d3ae14dfa74b6f7fbf2580f222f7adc5aa9f3dddeab41df68
6
+ metadata.gz: f78f392d57d5d9c64fc446def406f99fe12fdad295ad415bf15a9f3d7c789def2b304face6fc1e1a60f7db8dc256002aa6bce2a936e46f69b07abdfef1046183
7
+ data.tar.gz: 198200ae4575a6f756a75b142c4d07683cd1f4105cf8cd317603c018491c3d5644c5add334fbdcbeb4251b529bf6b4d648c1eb44e4256a04e1904b05c9365516
data/README.md CHANGED
@@ -246,7 +246,7 @@ Resources also have support for simple set of built-in callbacks. These have sim
246
246
 
247
247
  The supported callbacks are:
248
248
 
249
- * `exists?` - True by default, not called in create actions like POST.
249
+ * `exists?` - True by default, not called in create actions like POST or PUT.
250
250
  * `authorized?` - True by default, is the current user valid?
251
251
  * `allowed?` - True by default, does the current have access to the resource?
252
252
  * `last_modified` - The date of last update on the model, only called for GET and HEAD requests. Validated against the `If-Modified-Since` header.
@@ -331,8 +331,8 @@ request.path[0] # 'project
331
331
  request.path.to_s # '/project/123456/task/234567'
332
332
  request.path # ['project', '123456', 'task', '234567']
333
333
  request.path[:id] # '234567'
334
- require.path[:project_id] # '123456'
335
- require.path[2] # 'task'
334
+ request.path[:project_id] # '123456'
335
+ request.path[2] # 'task'
336
336
 
337
337
  # The request query
338
338
  request.query # {:page => 1} - Hash with indifferent access
@@ -618,6 +618,11 @@ Restfulness is still a work in progress but at Cabify we are using it in product
618
618
 
619
619
  ## History
620
620
 
621
+ ### 0.3.0 - May 13, 2014
622
+
623
+ * Possible breaking change: `put` requests no longer check for existing resource via `exists?` callback. (@samlown)
624
+ * Avoid Rack Lint errors by not providing Content-Type or Length in empty responses. (@samlown)
625
+
621
626
  ### 0.2.6 - March 7, 2014
622
627
 
623
628
  * Support scope block when adding a resource to router. (@samlown)
@@ -60,7 +60,7 @@ module Restfulness
60
60
  forbidden! unless allowed?
61
61
 
62
62
  # The following callbacks only make sense for certain methods
63
- if [:head, :get, :put, :patch, :delete].include?(request.action)
63
+ if [:head, :get, :patch, :delete].include?(request.action)
64
64
  resource_not_found! unless exists?
65
65
 
66
66
  if [:get, :head].include?(request.action)
@@ -70,10 +70,10 @@ module Restfulness
70
70
  def payload=(body)
71
71
  if body.nil? || body.is_a?(String)
72
72
  @payload = body.to_s
73
- update_content_headers(:text)
73
+ update_content_headers(:text) unless @payload.empty?
74
74
  else
75
75
  @payload = MultiJson.encode(body)
76
- update_content_headers(:json)
76
+ update_content_headers(:json) unless @payload.empty?
77
77
  end
78
78
  end
79
79
 
@@ -1,3 +1,3 @@
1
1
  module Restfulness
2
- VERSION = "0.2.6"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -142,7 +142,7 @@ describe Restfulness::Resource do
142
142
  }.to raise_error(Restfulness::HTTPException, "Method Not Allowed")
143
143
  end
144
144
 
145
- [:head, :get, :put, :delete].each do |action|
145
+ [:head, :get, :patch, :delete].each do |action|
146
146
  it "should raise error when not exists for #{action.to_s.upcase}" do
147
147
  request.action = action
148
148
  obj.stub(:exists?).and_return(false)
@@ -152,7 +152,7 @@ describe Restfulness::Resource do
152
152
  end
153
153
  end
154
154
 
155
- [:post].each do |action|
155
+ [:put, :post].each do |action|
156
156
  it "should not check exists? for #{action.to_s.upcase}" do
157
157
  obj.request.action = action
158
158
  obj.should_not_receive(:exists?)
@@ -40,8 +40,8 @@ describe Restfulness::Response do
40
40
  obj.run
41
41
  obj.status.should eql(404)
42
42
  obj.payload.should be_empty
43
- obj.headers['Content-Type'].should match(/text\/plain/)
44
- obj.headers['Content-Length'].should eql(0.to_s)
43
+ obj.headers['Content-Type'].should be_nil
44
+ obj.headers['Content-Length'].should be_nil
45
45
  end
46
46
  end
47
47
  context "with route" do
@@ -75,7 +75,8 @@ describe Restfulness::Response do
75
75
  route.stub(:build_resource).and_return(resource)
76
76
  obj.run
77
77
  obj.status.should eql(204)
78
- obj.headers['Content-Type'].should match(/text\/plain/)
78
+ obj.headers['Content-Type'].should be_nil
79
+ obj.headers['Content-Length'].should be_nil
79
80
  end
80
81
 
81
82
  it "should set string content type if payload is a string" do
@@ -48,10 +48,10 @@ describe Restfulness::Router do
48
48
  add 'examples', SecondRouterResource
49
49
  end
50
50
  route = obj.routes.first
51
- route.resource.should eql(RouterResource)
51
+ route.resource.should eql(SecondRouterResource)
52
52
  route.path.should eql(['project', 'examples'])
53
53
  route = obj.routes.last
54
- route.resource.should eql(SecondRouterResource)
54
+ route.resource.should eql(RouterResource)
55
55
  route.path.should eql(['project'])
56
56
  end
57
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restfulness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Lown
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-07 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack