qa 4.2.1 → 4.2.2

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: dc8abbc6ff66d5aebf93fc1231c5c9fae0fd1e9a
4
- data.tar.gz: 3727fdd6f35c057029047776c8c8ba8ad53810fa
3
+ metadata.gz: 486f518740d8c668bdc6afee57d80ae3fa312438
4
+ data.tar.gz: 43960d9fac51284870ac108c6184117f08afbbf0
5
5
  SHA512:
6
- metadata.gz: efc32a97028b6325586a19b35c11ce1fa6476d34c5b91c0a625b68634fc77c4af9bc665783ecd9e4362dd60d78f10b13d67e98377eb7751a30875dbf777234e4
7
- data.tar.gz: 571f1bd47079752a99d59c80115173406068eb1ba23603e07497567c8b3f23927a14a0adce400273c2b5106bfe8dcabc9d2b303a86577aec30e5ebdddc86a96a
6
+ metadata.gz: ef00b17700e1aa0e218706286ef517cbef97331ef7f6a6127917bd54d9cc66074e55de974a64eb98b3c42ba38927a10d435b53d4537bd98afffa207e917ae16a
7
+ data.tar.gz: 7600248d02674fc92750496ea9a2cb82dd771d0a52d2a7f7ae3992dd663eb2fef577c368cd1e4d50c92bc514dcfb06029655ef9a8e8bb4305859d84c8683b4a0
@@ -30,8 +30,7 @@ class Qa::TermsController < ::ApplicationController
30
30
  def show
31
31
  term = @authority.method(:find).arity == 2 ? @authority.find(params[:id], self) : @authority.find(params[:id])
32
32
  cors_allow_origin_header(response)
33
- content_type = params["format"] == "jsonld" ? 'application/ld+json' : 'application/json'
34
- render json: term, content_type: content_type
33
+ render json: term, content_type: content_type_for_format
35
34
  end
36
35
 
37
36
  def check_vocab_param
@@ -81,4 +80,24 @@ class Qa::TermsController < ::ApplicationController
81
80
  def url_search
82
81
  params[:q].gsub("*", "%2A")
83
82
  end
83
+
84
+ def format
85
+ return 'json' unless params.key?(:format)
86
+ return 'json' if params[:format].blank?
87
+ params[:format]
88
+ end
89
+
90
+ def jsonld?
91
+ format.casecmp?('jsonld')
92
+ end
93
+
94
+ def n3?
95
+ format.casecmp?('n3')
96
+ end
97
+
98
+ def content_type_for_format
99
+ return 'application/ld+json' if jsonld?
100
+ return 'text/n3' if n3?
101
+ 'application/json'
102
+ end
84
103
  end
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "4.2.1".freeze
2
+ VERSION = "4.2.2".freeze
3
3
  end
@@ -228,5 +228,17 @@ describe Qa::TermsController, type: :controller do
228
228
  end
229
229
  end
230
230
  end
231
+ context "with request for n3" do
232
+ before do
233
+ stub_request(:get, "https://api.discogs.com/releases/3380671")
234
+ .to_return(status: 200, body: webmock_fixture("discogs-find-response-json.json"))
235
+ end
236
+ it 'Access-Control-Allow-Origin is not present' do
237
+ get :show, params: { vocab: "discogs", subauthority: "release", id: "3380671", format: 'n3' }
238
+ expect(response).to be_successful
239
+ expect(response.content_type).to eq 'text/n3'
240
+ expect(response.body).to start_with "@prefix"
241
+ end
242
+ end
231
243
  end
232
244
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2019-08-08 00:00:00.000000000 Z
19
+ date: 2019-08-14 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord-import