utopia 1.9.10 → 1.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d93b751226f2a2d2f1223e3d130350cad98d3e7e
4
- data.tar.gz: 6ead01dad6ec80dd6c8008eca8138a66d818c15b
3
+ metadata.gz: 9d1fd4dea2d181c046c412089844360517e6f423
4
+ data.tar.gz: 2a778d65e0224bdb6415e5db6c3967e417913749
5
5
  SHA512:
6
- metadata.gz: d7ad52b27e644c19d6c23e8dcccdddfd7105e6e0ae95a684bcd95c2b9267daf196dca2e0b3bdd6349a877d37743940c0a211f3faebed29336ebf282ec43b3ffa
7
- data.tar.gz: 6cf337b69acecb40bc163b552b9ded754028d4f7b57a22771065ce6a3b48253da731542e78cc8cbcaa0a3337c15b3656ee7b0a53b4fcb2b8cb0a8489ae81b975
6
+ metadata.gz: 460ef64a197ce840c44b42cc0239249fc003e039daa5cec56b8676882b3a5b63e1b7d7a433c20f5a01a7d62f2117a46887f871267265091205d07bc44725d453
7
+ data.tar.gz: c26adcc4d5cba8e030ed842e6d329caec9f118565e328520135b635641cee559a67726dc459371c57f71c41f792f5f23751de0f26016112c3c341bbb1ebf8556
@@ -1 +1 @@
1
- ../../setup/site/public/_static
1
+ documentation/public/../../setup/site/public/_static
@@ -1 +1 @@
1
- ../setup/site/tasks
1
+ documentation/../setup/site/tasks
@@ -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[0] >= 400 and location = @codes[response[0]]
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
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.9.10"
22
+ VERSION = "1.9.11"
23
23
  end
@@ -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
@@ -1,4 +1,7 @@
1
1
 
2
+ use Utopia::Redirection::Errors,
3
+ 404 => '/fail'
4
+
2
5
  use Utopia::Controller,
3
6
  root: File.expand_path('respond_spec', __dir__),
4
7
  base: Utopia::Controller::Base
@@ -0,0 +1,12 @@
1
+
2
+ prepend Respond, Rewrite, Actions
3
+
4
+ respond.with_json
5
+
6
+ rewrite.extract_prefix id: Integer do |request|
7
+ fail! :not_found, message: "Could not find record" if @id == 1
8
+ end
9
+
10
+ on 'show' do
11
+ succeed! content: {id: @id, foo: 'bar'}
12
+ 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.10
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-01-15 00:00:00.000000000 Z
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.5.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