openstax_api 9.0.0 → 9.0.1

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
  SHA256:
3
- metadata.gz: 2f8d716f67fca1c587540e13f7db606522238ec2b77638f8278049d1812926c2
4
- data.tar.gz: 062e0e434cb74bb13021f4211c5c919108a14d771321534ac0bf6a92b59ce556
3
+ metadata.gz: f83c98026dbc9d84ffd602fc06cf65de6b88ee89fe05c72ec01e974d82bf7cef
4
+ data.tar.gz: 7fa22ec461b66dfd46bf5e73348b33154bf272e68ff38c365cc7c37b26bd657d
5
5
  SHA512:
6
- metadata.gz: 9f97f203f831a97d8bc4ffce4a348dff922c5b4f1b7795715daf6f2ef615231f18b0921dd226b36be3e08b494843dc91fba391b991418caa229b557dfa631298
7
- data.tar.gz: 23d07578255d6cd7c84d08265ed866e02d1d20dfaa4efdcbaea260bc2064368382dab602b62fd1580c26b2a3b0f06ba7272e1d4665b21d371e8c855804dfde2f
6
+ metadata.gz: 34b6a34c6c049c3e52a86bd91adb9f9b2275eae3409730af74090ca7bdef314bfafcc58923cd61dcd4f56ecb8ea8b5ec9a543205988acb9706b187a50af05b21
7
+ data.tar.gz: c967f69e3c85fe37c387ad145156dcc6317545606981fd019c882e22fa0ae231fdc14f2a99bf51a279b172f486b57229c05b3b289980506351b52af1480fef70
@@ -13,7 +13,7 @@ module OpenStax
13
13
  model_klass = relation.base_class
14
14
  OSU::AccessPolicy.require_action_allowed!(:index, current_api_user, model_klass)
15
15
 
16
- represent_with_options = { user_options: options }.merge(represent_with: represent_with)
16
+ represent_with_options = { user_options: options, represent_with: represent_with }
17
17
 
18
18
  relation.each do |item|
19
19
  # Must be able to read each record
@@ -24,11 +24,10 @@ module OpenStax
24
24
  end
25
25
 
26
26
  def standard_search(klass, routine, represent_with, options={})
27
- search_options = { location: nil }
28
27
  user = current_api_user
29
28
  OSU::AccessPolicy.require_action_allowed!(:search, user, klass)
30
29
 
31
- represent_with_options = { user_options: options }.merge(represent_with: represent_with)
30
+ represent_with_options = { user_options: options, represent_with: represent_with }
32
31
 
33
32
  result = routine.call(params, options)
34
33
  return render_api_errors(result.errors) if result.errors.any?
@@ -38,12 +37,11 @@ module OpenStax
38
37
  OSU::AccessPolicy.require_action_allowed!(:read, user, item)
39
38
  end
40
39
 
41
- respond_with outputs, search_options.merge(represent_with_options)
40
+ respond_with outputs, { status: :ok, location: nil }.merge(represent_with_options)
42
41
  end
43
42
 
44
43
  def standard_create(model, represent_with=nil, options={})
45
- create_options = { status: :created, location: nil }
46
- represent_with_options = { user_options: options }.merge(represent_with: represent_with)
44
+ represent_with_options = { user_options: options, represent_with: represent_with }
47
45
 
48
46
  model.class.transaction do
49
47
  consume!(model, represent_with_options.dup)
@@ -51,7 +49,7 @@ module OpenStax
51
49
  OSU::AccessPolicy.require_action_allowed!(:create, current_api_user, model)
52
50
 
53
51
  if model.save
54
- respond_with model, create_options.merge(represent_with_options)
52
+ respond_with model, { status: :created, location: nil }.merge(represent_with_options)
55
53
  else
56
54
  render_api_errors(model.errors)
57
55
  end
@@ -71,9 +69,7 @@ module OpenStax
71
69
  def standard_read(model, represent_with=nil, use_timestamp_for_cache=false, options={})
72
70
  OSU::AccessPolicy.require_action_allowed!(:read, current_api_user, model)
73
71
 
74
- represent_with_options = { user_options: options }.merge(represent_with: represent_with)
75
-
76
- respond_with model, represent_with_options \
72
+ respond_with(model, { user_options: options, represent_with: represent_with }) \
77
73
  if !use_timestamp_for_cache || stale?(model, template: false)
78
74
  end
79
75
 
@@ -82,7 +78,7 @@ module OpenStax
82
78
  OSU::AccessPolicy.require_action_allowed!(:update, current_api_user, model)
83
79
 
84
80
  responder_options = { responder: ResponderWithPutPatchDeleteContent }
85
- represent_with_options = { user_options: options }.merge(represent_with: represent_with)
81
+ represent_with_options = { user_options: options, represent_with: represent_with }
86
82
 
87
83
  model.with_lock do
88
84
  consume!(model, represent_with_options.dup)
@@ -106,7 +102,7 @@ module OpenStax
106
102
  if model.respond_to?(:deleted?) && model.deleted?
107
103
 
108
104
  responder_options = { responder: ResponderWithPutPatchDeleteContent }
109
- represent_with_options = { user_options: options }.merge(represent_with: represent_with)
105
+ represent_with_options = { user_options: options, represent_with: represent_with }
110
106
 
111
107
  model.with_lock do
112
108
  if model.destroy
@@ -128,8 +124,9 @@ module OpenStax
128
124
  recursive = options.has_key?(:recursive) ? options[:recursive] : true
129
125
 
130
126
  responder_options = { responder: ResponderWithPutPatchDeleteContent }
131
- represent_with_options = { user_options: options.except(:recursive) }
132
- .merge(represent_with: represent_with)
127
+ represent_with_options = {
128
+ user_options: options.except(:recursive), represent_with: represent_with
129
+ }
133
130
 
134
131
  model.with_lock do
135
132
  if model.restore(recursive: recursive)
@@ -71,9 +71,10 @@ module OpenStax
71
71
  # be a URL fragment string -- in such a case, prepend "/api"
72
72
  # to the front of the URL as a convenience to callers
73
73
 
74
- if action.is_a? String
75
- action = "/#{action}" if !action.starts_with?("/")
76
- action = "/api#{action}" if !action.starts_with?("/api/")
74
+ action = action.to_s unless is_a_controller_spec?
75
+ if action.is_a?(String) && !action.include?('://')
76
+ action = "/#{action}" if !action.starts_with?('/')
77
+ action = "/api#{action}" if !action.starts_with?('/api/')
77
78
  end
78
79
 
79
80
  send type, action, args
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Api
3
- VERSION = '9.0.0'
3
+ VERSION = '9.0.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0
4
+ version: 9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-05-23 00:00:00.000000000 Z
12
+ date: 2019-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  - !ruby/object:Gem::Version
275
275
  version: '0'
276
276
  requirements: []
277
- rubygems_version: 3.0.1
277
+ rubygems_version: 3.0.4
278
278
  signing_key:
279
279
  specification_version: 4
280
280
  summary: API utilities for OpenStax products and tools.