unidom-standard 1.4.2 → 1.4.3

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: 2e4fdcb805d5792897f09e58c523dddcff3e415a
4
- data.tar.gz: 304ba3dc1ed7df222f1d30d3b9b56b6727408a9a
3
+ metadata.gz: 337e62c070e6119891f65796769c5a3a220bfc8f
4
+ data.tar.gz: 50f8291641b9353702b0b553fcf263070a60f342
5
5
  SHA512:
6
- metadata.gz: 6bab4fb0ef02424ca5a111c5da147a70895854d01f62b62dafed4f46188666175e5538cb92dd5140e3c3986a1c5a11a74f0d90e2c505534eb8f2121508334bd4
7
- data.tar.gz: 62a74d1a714d6c9949b375fe0edabe1c049128e34aa803a727baaa883967d2505634db8eac5d4feabd95f1fb33fd515b1667533cb79112cd771726d335af99a1
6
+ metadata.gz: a8090e10fd94919eae6a69024f7e29f0c07f07a8c61abefc9e3a05a5d41c64c87ce9e2e345485709d7a69cc0cbbe427ce9aeef4f9b4ba282b255e2ce0d3d4547
7
+ data.tar.gz: 16d6e18fb1918ab74626c6be6e67fab1c0ec41757390c652787c207f0614c7a5625fde025efaf790690c0e98cbc72246d7dc9992f10929c057362b894ac1c3c7
@@ -11,8 +11,8 @@ class Unidom::Standard::StandardAssociating < Unidom::Standard::ApplicationRecor
11
11
  belongs_to :source, class_name: 'Unidom::Standard::Standard', foreign_key: :source_id
12
12
  belongs_to :target, class_name: 'Unidom::Standard::Standard', foreign_key: :target_id
13
13
 
14
- scope :source_is, ->(source) { where source_id: (source.respond_to?(:id) ? source.id : source) }
15
- scope :target_is, ->(target) { where target_id: (target.respond_to?(:id) ? target.id : target) }
14
+ scope :source_is, ->(source) { where source: source }
15
+ scope :target_is, ->(target) { where target: target }
16
16
 
17
17
  def self.associate!(source, with: target, due_to: 'REVS', at: Time.now)
18
18
  create! source_id: to_id(source), target_id: to_id(with), association_code: due_to, opened_at: at
@@ -16,17 +16,29 @@ describe Unidom::Standard::StandardAssociating, type: :model do
16
16
 
17
17
  it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
18
18
 
19
- it_behaves_like 'scope', :source_is, [
20
- { attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:source_id] ] },
21
- { attributes_collection: [ model_attributes ], count_diff: 1, args: [ Unidom::Standard::Standard.new(id: model_attributes[:source_id]) ] },
22
- { attributes_collection: [ model_attributes.merge(source_id: SecureRandom.uuid) ], count_diff: 0, args: [ model_attributes[:source_id] ] },
23
- { attributes_collection: [ model_attributes.merge(source_id: SecureRandom.uuid) ], count_diff: 0, args: [ Unidom::Standard::Standard.new(id: model_attributes[:source_id]) ] } ]
24
-
25
- it_behaves_like 'scope', :target_is, [
26
- { attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:target_id] ] },
27
- { attributes_collection: [ model_attributes ], count_diff: 1, args: [ Unidom::Standard::Standard.new(id: model_attributes[:target_id]) ] },
28
- { attributes_collection: [ model_attributes.merge(target_id: SecureRandom.uuid) ], count_diff: 0, args: [ model_attributes[:target_id] ] },
29
- { attributes_collection: [ model_attributes.merge(target_id: SecureRandom.uuid) ], count_diff: 0, args: [ Unidom::Standard::Standard.new(id: model_attributes[:target_id]) ] } ]
19
+ source_standard_attributes = {
20
+ name: 'Source Name',
21
+ number: 'GB/T 3259-2008',
22
+ ics_code: '11-23-68',
23
+ published_on: Date.current-20.years,
24
+ applied_on: Date.current,
25
+ obsoleted_on: Date.current+1.year
26
+ }
27
+
28
+ target_standard_attributes = {
29
+ name: 'Target Name',
30
+ number: 'GB/T 3259-2018',
31
+ ics_code: '11-23-68',
32
+ published_on: Date.current+1.year,
33
+ applied_on: Date.current,
34
+ obsoleted_on: Date.current+20.years
35
+ }
36
+
37
+ it_behaves_like 'belongs_to', model_attributes, :source, Unidom::Standard::Standard, source_standard_attributes
38
+ it_behaves_like 'belongs_to', model_attributes, :target, Unidom::Standard::Standard, target_standard_attributes
39
+
40
+ it_behaves_like 'monomorphic scope', model_attributes, :source_is, :source
41
+ it_behaves_like 'monomorphic scope', model_attributes, :target_is, :target
30
42
 
31
43
  end
32
44
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Standard
3
- VERSION = '1.4.2'.freeze
3
+ VERSION = '1.4.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common