jsonatra 1.0.4 → 1.0.5

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: b0d8d44af79ab5cf6dee75d62af27c876641e24f
4
- data.tar.gz: 0968b006ea9a44217ed38cff192626f862c73999
3
+ metadata.gz: b70ca65553dfbc643e303901211b596bd20fde62
4
+ data.tar.gz: 2ab473350a070324ea3cf5d910504f1e6a9d46bd
5
5
  SHA512:
6
- metadata.gz: 055915bb1afe2f636053cb156a6dea217ed6271e8400c3c7394b15c9fd47b72e76fad56eb10bcae9c86f60fbd9e177e6f9cd4213bdf10690e4d892c18806e35e
7
- data.tar.gz: 290faa9e84a16a0356bc6e00bc966ae02ed922607c8d20309c61a5bb7bdef0421f4a3c8b700d078b12e777fa6b5658da8d632769d306d5b11a48f436039eb753
6
+ metadata.gz: 155a4953fce08b0e2fa2258c35bc8b1b0645af5dae81b4ddff2b64e43d01d77737f447f5420b31bb35ba1a8151231bd470e9de824ad40aa4d1eeb6ab4e023ac2
7
+ data.tar.gz: 56252f3bc023931b56796287934597611d80032744e93fe79d743c1344fdc4f65d5fb1685edede05324cc2173f8c9e4186bfd5bd982c9f491ab2705999cded68
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
4
- - "2.0.0"
5
- - jruby-19mode
6
- - rbx-19mode
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - jruby
@@ -1,3 +1,3 @@
1
1
  module Jsonatra
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
data/lib/jsonatra.rb CHANGED
@@ -52,15 +52,6 @@ module Jsonatra
52
52
 
53
53
  before do
54
54
 
55
- # default to Content-Type to JSON, or javascript if request is JSONP
56
- #
57
- content_type :json
58
- unless params[:callback].nil? or params[:callback] == ''
59
- halt param_error(:callback, :invalid, 'invalid callback') if params[:callback].index('"')
60
- response.jsonp_callback = params[:callback]
61
- content_type :js
62
- end
63
-
64
55
  # grok access control headers
65
56
  #
66
57
  achs = begin
@@ -79,6 +70,15 @@ module Jsonatra
79
70
  #
80
71
  achs.each {|k,v| headers[k] = v}
81
72
 
73
+ # default to Content-Type to JSON, or javascript if request is JSONP
74
+ #
75
+ content_type :json
76
+ unless params[:callback].nil? or params[:callback] == ''
77
+ halt param_error(:callback, :invalid, 'invalid callback') if params[:callback].index('"')
78
+ response.jsonp_callback = params[:callback]
79
+ content_type :js
80
+ end
81
+
82
82
  end
83
83
 
84
84
  after do
@@ -108,6 +108,19 @@ describe Jsonatra::Base do
108
108
  end
109
109
  end
110
110
 
111
+ it 'responds with CORS headers even when content-type is mismatched' do
112
+ params = {foo: 'bar'}.to_json
113
+ [:get, :post].each do |meth|
114
+ __send__ meth, '/', params, { 'Content-Type' => 'application/x-www-form-urlencoded' }
115
+ last_response.headers.keys.must_include 'Access-Control-Allow-Origin'
116
+ last_response.headers['Access-Control-Allow-Origin'].must_equal '*'
117
+ last_response.headers.keys.must_include 'Access-Control-Allow-Headers'
118
+ last_response.headers['Access-Control-Allow-Headers'].must_equal 'Accept, Authorization, Content-Type, Origin'
119
+ last_response.headers.keys.must_include 'Access-Control-Allow-Methods'
120
+ last_response.headers['Access-Control-Allow-Methods'].must_equal 'GET, POST'
121
+ end
122
+ end
123
+
111
124
  end
112
125
 
113
126
  describe 'access_control_headers' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra