yodatra 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yodatra/models_controller.rb +4 -2
- data/lib/yodatra/version.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/models_controller_spec.rb +1 -1
- 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: 581ebcb300386a581d11626427193627caefcced
|
4
|
+
data.tar.gz: 32373f7bfc1606cc44bca3368e1fa4204058f733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8501f66cb7f3f40a9c7b325543a4af79cae4e74f1b01ff801f0c5622376bfa333913b2ab03ae61223835d1f5165f1c50f4bb2f0617c8eda87363bdf4f5bf92fd
|
7
|
+
data.tar.gz: 111d95bb8d5c5ca04eddf54238f72d7d3bd57c217a2bc1b6e42bc954d13a3a0e8c32de49c4777797b80a7ef006cf8b125b58b3b5e0968e0113e6646a3cddd343
|
@@ -184,7 +184,7 @@ module Yodatra
|
|
184
184
|
|
185
185
|
# Check access to the resource
|
186
186
|
method = "limit_#{action}_for".to_sym
|
187
|
-
resource =
|
187
|
+
resource = self.class.send(method, resource, current_user) if self.class.respond_to?(method) && !current_user.nil?
|
188
188
|
|
189
189
|
# ONE resource else COLLECTION
|
190
190
|
one_id = nested? ? params[:captures].fourth : params[:captures].second if params[:captures].length == 4
|
@@ -203,12 +203,14 @@ module Yodatra
|
|
203
203
|
resources = nil
|
204
204
|
begin
|
205
205
|
parent_model = params[:captures].first.classify.constantize
|
206
|
+
parent_controller = "#{parent_model}sController".constantize
|
206
207
|
rescue NameError
|
207
208
|
parent_model = nil
|
209
|
+
parent_controller = nil
|
208
210
|
end
|
209
211
|
|
210
212
|
unless parent_model.nil?
|
211
|
-
parent_model =
|
213
|
+
parent_model = parent_controller.limit_read_for parent_model, current_user if parent_controller.respond_to?(:limit_read_for) && !current_user.nil?
|
212
214
|
parent = parent_model.find params[:captures].second
|
213
215
|
if parent.respond_to? :reflections
|
214
216
|
# This is AR 4.0.x compatibility
|
data/lib/yodatra/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,10 @@ require 'rspec'
|
|
11
11
|
require File.expand_path '../../lib/yodatra.rb', __FILE__
|
12
12
|
require File.expand_path '../../lib/yodatra/api_formatter.rb', __FILE__
|
13
13
|
require File.expand_path '../../lib/yodatra/models_controller.rb', __FILE__
|
14
|
+
# dirty Hack for testing
|
15
|
+
class ModelsController < Yodatra::ModelsController
|
16
|
+
end
|
17
|
+
|
14
18
|
require File.expand_path '../data/ar_models_controller.rb', __FILE__
|
15
19
|
|
16
20
|
module RSpecMixin
|
@@ -3,7 +3,7 @@ require File.expand_path '../../active_record/connection_adapters/fake_adapter.r
|
|
3
3
|
require File.expand_path '../../data/model.rb', __FILE__
|
4
4
|
require File.expand_path '../../data/ar_model.rb', __FILE__
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe Yodatra::ModelsController do
|
7
7
|
|
8
8
|
before do
|
9
9
|
@errors = ['error']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yodatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Bonaud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|