ocean-rails 1.16.1 → 1.17.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: 6eb951de7297659f9c79367775f94d75ff8a2903
4
- data.tar.gz: 33b32f1b9146fa0570294e064d6153a017121c40
3
+ metadata.gz: 657f5cff217cb3e6e5fc39cec900587db01631bb
4
+ data.tar.gz: 5189d82abe5317d0fbb120c7c70722b022c7ac91
5
5
  SHA512:
6
- metadata.gz: 297addb38efb3762a5fc2da0e9d482da97440ef0fffb6eb25fd0d39c1f52423ce7881104eb8de9529473fd752939b431a10c99cdab7f3d52c47e1bb36d1ed4ce
7
- data.tar.gz: 3cdf60d75b61819a9dc1ddc5af0c79e67bc476c0744d96dfa5b688e1bf772e39c7197c467e9190b78e2329befed95c248eb585a4179327f55a8a9137a9251d79
6
+ metadata.gz: 805073b02c7253848eeb3bce175bcc396217fd497e96e9efa0b76ee0fa9a2ef0b47a4bddc959f1ef558fc9eae74e257d781c8a4cce067d99a08a54c5e92e4b5e
7
+ data.tar.gz: 18ea51cd7aeff51beb43f64a2f1e2906d6d3e093604f2afdab739427ff5b035f3a9d0550ab4cef4801af2d8dff70f57c69857dac009bb3d1a0e3cc0d657ec16f
@@ -26,7 +26,9 @@ end
26
26
 
27
27
 
28
28
  #
29
- # For stubbing authorisation calls in RSpec
29
+ # For stubbing successful authorisation calls. Makes <tt>Api.permitted?</tt> return
30
+ # the status, and a body containing a partial authentication containing the +user_id+
31
+ # and +creator_uri+ given by the parameters.
30
32
  #
31
33
  def permit_with(status, user_id: 123, creator_uri: "https://api.example.com/v1/api_users/#{user_id}")
32
34
  Api.stub(:permitted?).
@@ -37,6 +39,10 @@ def permit_with(status, user_id: 123, creator_uri: "https://api.example.com/v1/a
37
39
  'type' => 'application/json'}}}}))
38
40
  end
39
41
 
42
+ #
43
+ # For stubbing failed authorisation calls. Makes <tt>Api.permitted?</tt> return the
44
+ # given status and a body containing a standard API error with the given error messages.
45
+ #
40
46
  def deny_with(status, *error_messages)
41
47
  Api.stub(:permitted?).
42
48
  and_return(double(:status => status,
@@ -71,6 +71,23 @@ module OceanApplicationController
71
71
  false
72
72
  end
73
73
 
74
+
75
+ #
76
+ # Requires the request to be conditional: it must have an +If-None-Match+ and/or an
77
+ # +If-Modified-Since+ HTTP header. If the request isn't conditional, a 428 error is
78
+ # returned. The body will be a standard API error message, with two strings:
79
+ # <tt>"Precondition Required"</tt> and <tt>"If-None-Match and/or If-Modified-Since missing"</tt>.
80
+ #
81
+ def require_conditional
82
+ if request.headers['If-None-Match'].blank? && request.headers['If-Modified-Since'].blank?
83
+ render_api_error 428, "Precondition Required",
84
+ "If-None-Match and/or If-Modified-Since missing"
85
+ false
86
+ else
87
+ true
88
+ end
89
+ end
90
+
74
91
 
75
92
  #
76
93
  # Updates +created_by+ and +updated_by+ to the ApiUser for which the current request
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "1.16.1"
2
+ VERSION = "1.17.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.1
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday