committee 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/committee/response_validator.rb +5 -7
- data/test/response_validator_test.rb +10 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e94b1d2b86d37d5a8caf1038b86f586b1abcc0e
|
4
|
+
data.tar.gz: 6c8eeb7064f3153067f00a0435a5a05531e054e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 409d877ea286153b57ca5b3492c53ea86b2b307777c01f64f84612fc5ce22c7125d3ab9f1ec9baab9ebcacbd27bf6d0f18526e847b5b1d34d5853255ca4c69b5
|
7
|
+
data.tar.gz: 04777cf0d9a53e69f9cbc702cd1c6f83c338fbb2e4c1d7e65d40c387e8428fdc16071a2c7397642a2af508b49704fc2234d74c0890d1cb4daa2d3f4aacbea77c
|
@@ -11,7 +11,8 @@ module Committee
|
|
11
11
|
|
12
12
|
def call(status, headers, data)
|
13
13
|
unless status == 204 # 204 No Content
|
14
|
-
|
14
|
+
response = Rack::Response.new(data, status, headers)
|
15
|
+
check_content_type!(response)
|
15
16
|
end
|
16
17
|
|
17
18
|
if @link.rel == "instances" && !@link.target_schema
|
@@ -35,13 +36,10 @@ module Committee
|
|
35
36
|
|
36
37
|
private
|
37
38
|
|
38
|
-
def check_content_type!(
|
39
|
-
match
|
40
|
-
headers["Content-Type"] =~ m
|
41
|
-
}
|
42
|
-
unless match
|
39
|
+
def check_content_type!(response)
|
40
|
+
unless Rack::Mime.match?(response.content_type.to_s, @link.enc_type)
|
43
41
|
raise Committee::InvalidResponse,
|
44
|
-
%{"Content-Type" response header must be set to "
|
42
|
+
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
@@ -35,21 +35,24 @@ describe Committee::ResponseValidator do
|
|
35
35
|
assert_equal message, e.message
|
36
36
|
end
|
37
37
|
|
38
|
-
it "detects
|
38
|
+
it "detects a blank response Content-Type" do
|
39
39
|
@headers = {}
|
40
40
|
e = assert_raises(Committee::InvalidResponse) { call }
|
41
41
|
message =
|
42
|
-
%{"Content-Type" response header must be set to "
|
42
|
+
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
43
43
|
assert_equal message, e.message
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
47
|
-
@
|
48
|
-
call
|
46
|
+
it "detects an invalid response Content-Type" do
|
47
|
+
@headers = { "Content-Type" => "text/html" }
|
48
|
+
e = assert_raises(Committee::InvalidResponse) { call }
|
49
|
+
message =
|
50
|
+
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
51
|
+
assert_equal message, e.message
|
49
52
|
end
|
50
53
|
|
51
|
-
it "allows
|
52
|
-
@headers = {
|
54
|
+
it "allows no Content-Type for 204 No Content" do
|
55
|
+
@status, @headers = 204, {}
|
53
56
|
call
|
54
57
|
end
|
55
58
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: committee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_schema
|