yodatra 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7349a147b6bcf971ec9513001df3c40bb0045a64
4
- data.tar.gz: e6493a087ec7c5245a164f0b6c296dea59f78fef
3
+ metadata.gz: 581ebcb300386a581d11626427193627caefcced
4
+ data.tar.gz: 32373f7bfc1606cc44bca3368e1fa4204058f733
5
5
  SHA512:
6
- metadata.gz: 0d0c05c695b12c24ff569537560f2d7202325848d091b010155951fb1649f89ae7718bcdc8beb3d0d45c70a2fba0853b9a618c8277f1f36a2371b3e013caada2
7
- data.tar.gz: ebb0f1ba3bacbbd2d76a90dfb63720cffadd22b7ebe06632b34859a44a3c7ff2aa58c7cbaef177dc6394c360892c868ce48fad1bc1d214fe24fb7508c2048766
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 = model.send(method, resource, current_user) if model.respond_to?(method) && !current_user.nil?
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 = parent_model.limit_read_for parent_model, current_user if parent_model.respond_to?(:limit_read_for) && !current_user.nil?
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
@@ -1,3 +1,3 @@
1
1
  module Yodatra
2
- VERSION = '0.3.9'
2
+ VERSION = '0.3.10'
3
3
  end
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 'Model controller' do
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.9
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-01 00:00:00.000000000 Z
11
+ date: 2014-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack