mno-enterprise-core 2.0.6 → 2.0.7

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
  SHA1:
3
- metadata.gz: e97f70735ab98bb1b3bff86657960ced3660fec3
4
- data.tar.gz: 37550a7f9e952087af9528da9cf42b94ee5fdce9
3
+ metadata.gz: b8199d332fbf50bd3d639dfe2459e7329eb96b50
4
+ data.tar.gz: beccbb31a39bbcdd02b6c1f17a331dc004e8b629
5
5
  SHA512:
6
- metadata.gz: e5b872bbc67a77473f0bf98c4dce1cfbb73d5e92b7662305613af70ca0f399575922e99fd464799fef86784e616a1851b2908de0c783d39ae26fbf11a7a7bb89
7
- data.tar.gz: b7f2a1a8f29ca87ee0dd196c703d32a0596d3e444409573ea3f026bdc8d4f607ec289973017fac519a3ddfa9e604dcaaafdccccc03a201fc775f343789e34b46
6
+ metadata.gz: e1b5c8f95e08f2cd2cbbb9cadbb07a752d31f03d830aac0af8f4024208f59720138923d10000acf74d7114058bd6e48d5d1997661d01d242edde32953d1fdb89
7
+ data.tar.gz: de3c722cb6e6df6f3854d511d2472746f1a7f326b80def73f428b1a75b86050f61e0818e74825116243a2d9cabf0ec10fb696e44913f4df805d2570be61845b9
@@ -142,7 +142,8 @@ module MnoEnterprise
142
142
  if perform_validations(options)
143
143
  ret = super()
144
144
  process_response_errors
145
- raise_record_invalid
145
+ raise_record_invalid if self.errors.any?
146
+ ret
146
147
  else
147
148
  false
148
149
  end
@@ -0,0 +1,25 @@
1
+ # Backport https://github.com/remiprev/her/pull/343/files
2
+ # Fix belongs_to when foreign key is nil
3
+ module Her
4
+ module Model
5
+ module Associations
6
+ class BelongsToAssociation < Association
7
+ # @private
8
+ def fetch
9
+ foreign_key_value = @parent.attributes[@opts[:foreign_key].to_sym]
10
+ data_key_value = @parent.attributes[@opts[:data_key].to_sym]
11
+ return @opts[:default].try(:dup) if (@parent.attributes.include?(@name) && @parent.attributes[@name].nil? && @params.empty?) || (foreign_key_value.blank? && data_key_value.blank?)
12
+
13
+ return @cached_result unless @params.any? || @cached_result.nil?
14
+ return @parent.attributes[@name] unless @params.any? || @parent.attributes[@name].blank?
15
+
16
+ path_params = @parent.attributes.merge(@params.merge(@klass.primary_key => foreign_key_value))
17
+ path = build_association_path lambda { @klass.build_request_path(path_params) }
18
+ @klass.get(path, @params).tap do |result|
19
+ @cached_result = result if @params.blank?
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -17,6 +17,7 @@ require "her_extension/model/parse"
17
17
  require "her_extension/model/associations/association"
18
18
  require "her_extension/model/associations/association_proxy"
19
19
  require "her_extension/model/associations/has_many_association"
20
+ require "her_extension/model/associations/belongs_to_association"
20
21
  require "her_extension/middleware/mnoe_api_v1_parse_json"
21
22
  require "her_extension/middleware/mnoe_raise_error"
22
23
  require "faraday_middleware"
@@ -1,3 +1,3 @@
1
1
  module MnoEnterprise
2
- VERSION = '2.0.6'
2
+ VERSION = '2.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mno-enterprise-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Lachaume
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-27 00:00:00.000000000 Z
12
+ date: 2016-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -316,6 +316,7 @@ files:
316
316
  - lib/her_extension/middleware/mnoe_raise_error.rb
317
317
  - lib/her_extension/model/associations/association.rb
318
318
  - lib/her_extension/model/associations/association_proxy.rb
319
+ - lib/her_extension/model/associations/belongs_to_association.rb
319
320
  - lib/her_extension/model/associations/has_many_association.rb
320
321
  - lib/her_extension/model/attributes.rb
321
322
  - lib/her_extension/model/orm.rb
@@ -402,7 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
403
  version: '0'
403
404
  requirements: []
404
405
  rubyforge_project:
405
- rubygems_version: 2.4.8
406
+ rubygems_version: 2.5.1
406
407
  signing_key:
407
408
  specification_version: 4
408
409
  summary: Maestrano Enterprise - Core functionnality