utopia 1.9.10 → 1.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/public/_static +1 -1
- data/documentation/tasks +1 -1
- data/lib/utopia/redirection.rb +7 -1
- data/lib/utopia/version.rb +1 -1
- data/spec/utopia/controller/respond_spec.rb +20 -0
- data/spec/utopia/controller/respond_spec.ru +3 -0
- data/spec/utopia/controller/respond_spec/rewrite/controller.rb +12 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1fd4dea2d181c046c412089844360517e6f423
|
4
|
+
data.tar.gz: 2a778d65e0224bdb6415e5db6c3967e417913749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 460ef64a197ce840c44b42cc0239249fc003e039daa5cec56b8676882b3a5b63e1b7d7a433c20f5a01a7d62f2117a46887f871267265091205d07bc44725d453
|
7
|
+
data.tar.gz: c26adcc4d5cba8e030ed842e6d329caec9f118565e328520135b635641cee559a67726dc459371c57f71c41f792f5f23751de0f26016112c3c341bbb1ebf8556
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
documentation/public/../../setup/site/public/_static
|
data/documentation/tasks
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
documentation/../setup/site/tasks
|
data/lib/utopia/redirection.rb
CHANGED
@@ -49,10 +49,16 @@ module Utopia
|
|
49
49
|
super
|
50
50
|
end
|
51
51
|
|
52
|
+
CONTENT_TYPE = 'Content-Type'.freeze
|
53
|
+
|
54
|
+
def unhandled_error?(response)
|
55
|
+
response[0] >= 400 && !response[1].include?(CONTENT_TYPE)
|
56
|
+
end
|
57
|
+
|
52
58
|
def call(env)
|
53
59
|
response = @app.call(env)
|
54
60
|
|
55
|
-
if response
|
61
|
+
if unhandled_error?(response) && location = @codes[response[0]]
|
56
62
|
error_request = env.merge(Rack::PATH_INFO => location, Rack::REQUEST_METHOD => Rack::GET)
|
57
63
|
error_response = @app.call(error_request)
|
58
64
|
|
data/lib/utopia/version.rb
CHANGED
@@ -138,5 +138,25 @@ module Utopia::Controller::RespondSpec
|
|
138
138
|
expect(last_response.headers['Content-Type']).to be == 'application/json; charset=utf-8'
|
139
139
|
expect(last_response.body).to be == '{}'
|
140
140
|
end
|
141
|
+
|
142
|
+
it "should give record as JSON" do
|
143
|
+
header 'Accept', 'application/json'
|
144
|
+
|
145
|
+
get '/rewrite/2/show'
|
146
|
+
|
147
|
+
expect(last_response.status).to be == 200
|
148
|
+
expect(last_response.headers['Content-Type']).to be == 'application/json; charset=utf-8'
|
149
|
+
expect(last_response.body).to be == '{"id":2,"foo":"bar"}'
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should give error as JSON" do
|
153
|
+
header 'Accept', 'application/json'
|
154
|
+
|
155
|
+
get '/rewrite/1/show'
|
156
|
+
|
157
|
+
expect(last_response.status).to be == 404
|
158
|
+
expect(last_response.headers['Content-Type']).to be == 'application/json; charset=utf-8'
|
159
|
+
expect(last_response.body).to be == '{"message":"Could not find record"}'
|
160
|
+
end
|
141
161
|
end
|
142
162
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|
@@ -472,6 +472,7 @@ files:
|
|
472
472
|
- spec/utopia/controller/respond_spec/api/controller.rb
|
473
473
|
- spec/utopia/controller/respond_spec/errors/controller.rb
|
474
474
|
- spec/utopia/controller/respond_spec/errors/file-not-found.xnode
|
475
|
+
- spec/utopia/controller/respond_spec/rewrite/controller.rb
|
475
476
|
- spec/utopia/controller/rewrite_spec.rb
|
476
477
|
- spec/utopia/controller/sequence_spec.rb
|
477
478
|
- spec/utopia/controller/variables_spec.rb
|
@@ -534,7 +535,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
534
535
|
version: '0'
|
535
536
|
requirements: []
|
536
537
|
rubyforge_project:
|
537
|
-
rubygems_version: 2.
|
538
|
+
rubygems_version: 2.6.10
|
538
539
|
signing_key:
|
539
540
|
specification_version: 4
|
540
541
|
summary: Utopia is a framework for building dynamic content-driven websites.
|
@@ -590,6 +591,7 @@ test_files:
|
|
590
591
|
- spec/utopia/controller/respond_spec/api/controller.rb
|
591
592
|
- spec/utopia/controller/respond_spec/errors/controller.rb
|
592
593
|
- spec/utopia/controller/respond_spec/errors/file-not-found.xnode
|
594
|
+
- spec/utopia/controller/respond_spec/rewrite/controller.rb
|
593
595
|
- spec/utopia/controller/rewrite_spec.rb
|
594
596
|
- spec/utopia/controller/sequence_spec.rb
|
595
597
|
- spec/utopia/controller/variables_spec.rb
|