openstax_api 5.3.0 → 5.4.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 -6
- data/app/representers/openstax/api/v1/abstract_search_representer.rb +19 -6
- data/lib/openstax/api/routing_mapper_includes.rb +1 -2
- data/lib/openstax/api/rspec_helpers.rb +5 -1
- data/lib/openstax/api/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +1665 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd1e28d0e4f377076268137319caa8627e4946f1
|
4
|
+
data.tar.gz: 9594e636215544dc1a2f1d39e88cebb983434c0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe53719d70cdc83b38bae3987ad2d112341ef147a8a2a527cc295c0ddbcdf0bedbef72e50d675fd1f899804f902335d1513e9c29724658d98835542670ee4953
|
7
|
+
data.tar.gz: 340faad4b368f2a7af64c7a0c29bde1ed6266434b0fe369489182f7e901ed1e492eb09f8477dcb7af6903fbbfa6751cebe006414dcc5645891f562876775fc93
|
@@ -13,6 +13,7 @@ module OpenStax
|
|
13
13
|
|
14
14
|
respond_to :json
|
15
15
|
|
16
|
+
before_filter :force_json_content_type
|
16
17
|
after_filter :set_date_header
|
17
18
|
|
18
19
|
# Keep old current_user method so we can use it
|
@@ -36,12 +37,6 @@ module OpenStax
|
|
36
37
|
current_api_user.human_user
|
37
38
|
end
|
38
39
|
|
39
|
-
def consume!(model, options = {})
|
40
|
-
# Don't error out if no CONTENT_TYPE header
|
41
|
-
request.env['CONTENT_TYPE'] ||= 'application/json'
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
40
|
protected
|
46
41
|
|
47
42
|
def session_user?
|
@@ -52,6 +47,12 @@ module OpenStax
|
|
52
47
|
response.date = Time.now unless response.date?
|
53
48
|
end
|
54
49
|
|
50
|
+
def force_json_content_type
|
51
|
+
# Force JSON content_type
|
52
|
+
request.env['CONTENT_TYPE'] = 'application/json'
|
53
|
+
request.env['action_dispatch.request.content_type'] = 'application/json'
|
54
|
+
end
|
55
|
+
|
55
56
|
end
|
56
57
|
|
57
58
|
end
|
@@ -25,18 +25,31 @@ module OpenStax
|
|
25
25
|
collection :items,
|
26
26
|
readable: true,
|
27
27
|
writeable: false,
|
28
|
+
exec_context: :decorator,
|
28
29
|
schema_info: {
|
29
30
|
required: true,
|
30
31
|
description: "The items matching the query or a subset thereof when paginating"
|
31
32
|
}
|
32
33
|
|
34
|
+
def items
|
35
|
+
return represented.items if represented.respond_to?(:items)
|
36
|
+
return represented[:items] if represented.respond_to?(:has_key?) && \
|
37
|
+
represented.has_key?(:items)
|
38
|
+
represented
|
39
|
+
end
|
40
|
+
|
33
41
|
def total_count
|
34
|
-
return represented
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
return represented.total_count if represented.respond_to?(:total_count)
|
43
|
+
return represented[:total_count] if represented.respond_to?(:has_key?) && \
|
44
|
+
represented.has_key?(:total_count)
|
45
|
+
|
46
|
+
@items = items
|
47
|
+
if @items.respond_to?(:length)
|
48
|
+
if @items.respond_to?(:limit) && @items.respond_to?(:offset)
|
49
|
+
@items.limit(nil).offset(nil).length
|
50
|
+
else
|
51
|
+
@items.length
|
52
|
+
end
|
40
53
|
else
|
41
54
|
1
|
42
55
|
end
|
@@ -14,8 +14,7 @@ module OpenStax
|
|
14
14
|
scope(except: [:new, :edit],
|
15
15
|
module: version,
|
16
16
|
constraints: constraints) do
|
17
|
-
get '/', to: '/apipie/apipies#index', defaults: {format: 'html',
|
18
|
-
version: version.to_s}
|
17
|
+
get '/', to: '/apipie/apipies#index', defaults: {format: 'html', version: version.to_s}
|
19
18
|
|
20
19
|
yield
|
21
20
|
|
@@ -90,8 +90,12 @@ module OpenStax
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
if
|
93
|
+
# Add the helpers to RSpec but don't error out if the rspec gem is not present
|
94
|
+
begin
|
95
|
+
require 'rspec/core'
|
96
|
+
|
94
97
|
RSpec.configure do |c|
|
95
98
|
c.include OpenStax::Api::RSpecHelpers
|
96
99
|
end
|
100
|
+
rescue LoadError
|
97
101
|
end
|
data/lib/openstax/api/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|