utopia 2.3.0 → 2.4.0

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
  SHA256:
3
- metadata.gz: 281493fd02c38ac70b4717044a5cc1cf6e75a77891a824705bfb4535d43ab0e6
4
- data.tar.gz: 2b6a12707192d90030e2bc9ef07dd34aa799d0fa416fdeda1c7910eadc7ded1d
3
+ metadata.gz: 76b2bddad99a2b2de5f470d20cad43effd23ec9cada64002a7adf737cda1a359
4
+ data.tar.gz: 4f65e88162e376b6bba06910de4cd71fe62fa8aa5a4afd3f800ee36c6622d182
5
5
  SHA512:
6
- metadata.gz: d60e658394b717982b04177ff3ae04b4ffb9207b4f7f8a4b797136c3b5debc46b1d088c4766cfc3234f5ee85d6a9d3b654f6f88ad3fe0db1f550b5eff7b1efdf
7
- data.tar.gz: 998b66866873427ac342f3abe04e9b8c67172a3fb9d232633ad096af6af915ba4564ac9656c6d4be3c376362784ca7bacc0d56ad8d4697fb1c3ec15b504fd034
6
+ metadata.gz: fbb318c33f6dfc0ba5a7ba7cd17e59d5c940a582fce3f3c62e1cead4afc2551a0d82cb837d4de6be676e79ff37ffbacb176762f8937ef94413a4518f409df7a7
7
+ data.tar.gz: 7c3ea554b35fe6dffed5ec37e9e1950b92335bb5b7a65a09b0384f195f24cf249da460178747ab8f5d8f859fb39e5cb65b251da6455b1e8b05f9856a65c42bc9
@@ -11,10 +11,10 @@ before_install:
11
11
  # I don't know why I need to install this on travis in order for tests to function.
12
12
  - gem install bundler samovar
13
13
  rvm:
14
- - 2.2
15
14
  - 2.3
16
15
  - 2.4
17
16
  - 2.5
17
+ - 2.6
18
18
  - jruby-head
19
19
  - ruby-head
20
20
  env: COVERAGE=true BENCHMARK=true
@@ -165,10 +165,15 @@ module Utopia
165
165
  end
166
166
  end
167
167
 
168
- # Invokes super. If a response is generated, format it based on the Accept: header.
168
+ # Invokes super. If a response is generated, format it based on the Accept: header, unless the content type was already specified.
169
169
  def process!(request, path)
170
170
  if response = super
171
- response = self.class.response_for(self, request, path, response)
171
+ headers = response[1]
172
+
173
+ # Don't try to convert the response if a content type was explicitly specified.
174
+ unless headers[Rack::CONTENT_TYPE]
175
+ response = self.class.response_for(self, request, path, response)
176
+ end
172
177
 
173
178
  response
174
179
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "2.3.0"
22
+ VERSION = "2.4.0"
23
23
  end
@@ -110,6 +110,16 @@ module Utopia::Controller::RespondSpec
110
110
  expect(last_response.body).to be == '{"message":"File not found"}'
111
111
  end
112
112
 
113
+ it 'should get html response' do
114
+ header 'Accept', '*/*'
115
+
116
+ get '/html/hello-world'
117
+
118
+ expect(last_response.status).to be == 200
119
+ expect(last_response.headers['Content-Type']).to be == 'text/html'
120
+ expect(last_response.body).to be == '<p>Hello World</p>'
121
+ end
122
+
113
123
  it "should get version 1 response" do
114
124
  header 'Accept', 'application/json;version=1'
115
125
 
@@ -0,0 +1,10 @@
1
+
2
+ prepend Respond, Actions
3
+
4
+ # Respond with json:
5
+ respond.with_json
6
+
7
+ # This method should return HTML, even thought this controller responds with JSON.
8
+ on 'hello-world' do
9
+ succeed! content: "<p>Hello World</p>", :type => 'text/html'
10
+ 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: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-24 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -667,6 +667,7 @@ files:
667
667
  - spec/utopia/controller/respond_spec/api/controller.rb
668
668
  - spec/utopia/controller/respond_spec/errors/controller.rb
669
669
  - spec/utopia/controller/respond_spec/errors/file-not-found.xnode
670
+ - spec/utopia/controller/respond_spec/html/controller.rb
670
671
  - spec/utopia/controller/respond_spec/rewrite/controller.rb
671
672
  - spec/utopia/controller/rewrite_spec.rb
672
673
  - spec/utopia/controller/sequence_spec.rb
@@ -792,6 +793,7 @@ test_files:
792
793
  - spec/utopia/controller/respond_spec/api/controller.rb
793
794
  - spec/utopia/controller/respond_spec/errors/controller.rb
794
795
  - spec/utopia/controller/respond_spec/errors/file-not-found.xnode
796
+ - spec/utopia/controller/respond_spec/html/controller.rb
795
797
  - spec/utopia/controller/respond_spec/rewrite/controller.rb
796
798
  - spec/utopia/controller/rewrite_spec.rb
797
799
  - spec/utopia/controller/sequence_spec.rb