openstax_api 5.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/openstax/api/v1/api_controller.rb +7 -1
- data/app/representers/openstax/api/v1/abstract_search_representer.rb +1 -1
- data/lib/openstax/api/roar.rb +3 -2
- data/lib/openstax/api/rspec_helpers.rb +2 -1
- data/lib/openstax/api/version.rb +1 -1
- data/spec/dummy/app/representers/user_representer.rb +2 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +2380 -0
- metadata +6 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c1cb250aa64fa4c52fabc8df85b84382dbfa073
|
4
|
+
data.tar.gz: 9965f611b7b19b5374b164be159f44623ae419a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e137dd7072ffa37e0e1bf64573e707189e6bb52a66f9d4286e4efcd5ea58aa40e3c6b1adc32f7b1f9873f62c7d9c63ea00c3b7b9a3dfa45f13fde0fbcd13cec
|
7
|
+
data.tar.gz: 50131d6aa0fbf79facab24015f420fa912cbd9b395989fa9865240cccf1382b65f35da8571d117f206905c3b0098f2e1557f1cdbea46a581c2455e699f0a3ea2
|
@@ -8,7 +8,7 @@ module OpenStax
|
|
8
8
|
include OpenStax::Api::Roar
|
9
9
|
include OpenStax::Api::Apipie
|
10
10
|
|
11
|
-
|
11
|
+
before_action :doorkeeper_authorize!, :unless => :session_user?
|
12
12
|
skip_before_filter :verify_authenticity_token, :unless => :session_user?
|
13
13
|
|
14
14
|
respond_to :json
|
@@ -34,6 +34,12 @@ module OpenStax
|
|
34
34
|
current_api_user.human_user
|
35
35
|
end
|
36
36
|
|
37
|
+
def consume!(model, options = {})
|
38
|
+
# Don't error out if no CONTENT_TYPE header
|
39
|
+
request.env['CONTENT_TYPE'] ||= 'application/json'
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
37
43
|
protected
|
38
44
|
|
39
45
|
def session_user?
|
data/lib/openstax/api/roar.rb
CHANGED
@@ -31,7 +31,8 @@ module OpenStax
|
|
31
31
|
|
32
32
|
if model.save
|
33
33
|
respond_with model, represent_with: represent_with,
|
34
|
-
status: :created
|
34
|
+
status: :created,
|
35
|
+
location: [:api, model]
|
35
36
|
else
|
36
37
|
render_api_errors(model.errors)
|
37
38
|
end
|
@@ -72,7 +73,7 @@ module OpenStax
|
|
72
73
|
OSU::AccessPolicy.require_action_allowed!(:destroy,
|
73
74
|
current_api_user,
|
74
75
|
model)
|
75
|
-
|
76
|
+
|
76
77
|
if model.destroy
|
77
78
|
head :no_content
|
78
79
|
else
|
@@ -44,7 +44,8 @@ module OpenStax
|
|
44
44
|
header = is_a_controller_spec? ? request.env : {}
|
45
45
|
|
46
46
|
# Add the doorkeeper token info
|
47
|
-
header['HTTP_AUTHORIZATION'] = "Bearer #{doorkeeper_token.token}"
|
47
|
+
header['HTTP_AUTHORIZATION'] = "Bearer #{doorkeeper_token.token}" \
|
48
|
+
if doorkeeper_token
|
48
49
|
|
49
50
|
# Select the version of the API based on the spec metadata and populate the accept header
|
50
51
|
version_string = self.class.metadata[:version].try(:to_s)
|
data/lib/openstax/api/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'representable/json'
|
2
2
|
|
3
|
-
class UserRepresenter <
|
3
|
+
class UserRepresenter < Roar::Decorator
|
4
4
|
|
5
|
-
include Roar::
|
5
|
+
include Roar::JSON
|
6
6
|
|
7
7
|
property :username, readable: false, writeable: false,
|
8
8
|
schema_info: { required: true }
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|