unidom-standard 1.4.7 → 1.4.8

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: c4ab89fdbec6549a33676cb976331004d2d82b15
4
- data.tar.gz: 73d0e889a61027e8782ee8a08c53af62ec1adec8
3
+ metadata.gz: e64e20b9eb93af195a1485c47b5de002463d860e
4
+ data.tar.gz: fd9a944a3ecc71f738cb66f21aa1cea5b681f204
5
5
  SHA512:
6
- metadata.gz: c7903c4b78ae5b28c2369f6549f7cff557fa6c9a5d725c2f14d9d51ac80eb9681c13530c03cb229a00dc43f3fd055dcca36a352976659d1ea03988927943574b
7
- data.tar.gz: 7695693980fe07166e88115b3b590fedadac9bd681237896ec71dd0856ab476cdc6ab2c40f1f1aa36ac7137986a97d945dabf7804e82f42418ee0f5dc9bce5e5
6
+ metadata.gz: 72791825b90de002a221a516c7353347c87850553baa76f5d017c8ee7ba87370ab028c35876cb2df94b43dfd6cd4c48c075c349cb272fac66c1e431ac1e0e951
7
+ data.tar.gz: d630b93497c9518e728fdeba587e18230743424c8388ee8ce802c8afb8c32baac8555703d1ffd0256b8c914b9e9dfe52e3a706f2ef39b054c6f286e3fed5c3ce
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Standard::Concerns::AsSourceStandard
5
5
 
6
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
7
+ include Unidom::Common::Concerns::ArgumentValidation
7
8
 
8
9
  included do |includer|
9
10
 
@@ -11,11 +12,23 @@ module Unidom::Standard::Concerns::AsSourceStandard
11
12
  has_many :target_standards, through: :target_associatings, source: :target
12
13
 
13
14
  def associate!(target, due_to: 'REVS', at: Time.now)
15
+
16
+ assert_present! :target, target
17
+ assert_present! :due_to, due_to
18
+ assert_present! :at, at
19
+
14
20
  target_associatings.target_is(target).association_coded_as(due_to).valid_at(now: at).alive.first_or_create! opened_at: at
21
+
15
22
  end
16
23
 
17
24
  def associate?(target, due_to: 'REVS', at: Time.now)
25
+
26
+ assert_present! :target, target
27
+ assert_present! :due_to, due_to
28
+ assert_present! :at, at
29
+
18
30
  target_associatings.target_is(target).association_coded_as(due_to).valid_at(now: at).alive.exists?
31
+
19
32
  end
20
33
 
21
34
  end
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Standard::Concerns::AsTargetStandard
5
5
 
6
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
7
+ include Unidom::Common::Concerns::ArgumentValidation
7
8
 
8
9
  included do |includer|
9
10
 
@@ -11,7 +12,11 @@ module Unidom::Standard::Concerns::AsTargetStandard
11
12
  has_many :source_standards, through: :source_associatings, source: :source
12
13
 
13
14
  def is_associated!(source, due_to: 'REVS', at: Time.now)
15
+
16
+ assert_present! :source, source
17
+
14
18
  source_associatings.source_is(source).association_coded_as(due_to).valid_at(now: at).alive.first_or_create! opened_at: at
19
+
15
20
  end
16
21
 
17
22
  def is_associated?(source, due_to: 'REVS', at: Time.now)
@@ -12,6 +12,18 @@ shared_examples 'Unidom::Standard::Concerns::AsSourceStandard' do |model_attribu
12
12
 
13
13
  it_behaves_like 'has_many', model_attributes, :target_associatings, Unidom::Standard::StandardAssociating, [ target_associating_1_attributes, target_associating_2_attributes ]
14
14
 
15
+ model = described_class.create! model_attributes
16
+
17
+ target_attributes = {
18
+ name: 'Target Standard Name',
19
+ #number: 'GB/T 9999-1845.A',
20
+ ics_code: '01-02-03'
21
+ }
22
+ target = Unidom::Standard::Standard.number_is('GB/T 9999-1845.A').first_or_create! target_attributes
23
+
24
+ it_behaves_like 'assert_present!', model, :associate!, [ target, due_to: 'REVS', at: Time.now ], [ { 0 => :target }, :due_to, :at ]
25
+ it_behaves_like 'assert_present!', model, :associate?, [ target, due_to: 'REVS', at: Time.now ], [ { 0 => :target }, :due_to, :at ]
26
+
15
27
  end
16
28
 
17
29
  end
@@ -18,7 +18,7 @@ describe Unidom::Standard::StandardAssociating, type: :model do
18
18
 
19
19
  source_standard_attributes = {
20
20
  name: 'Source Name',
21
- number: 'GB/T 3259-2008',
21
+ number: 'GB/T 8888-000',
22
22
  ics_code: '11-23-68',
23
23
  published_on: Date.current-20.years,
24
24
  applied_on: Date.current,
@@ -27,7 +27,7 @@ describe Unidom::Standard::StandardAssociating, type: :model do
27
27
 
28
28
  target_standard_attributes = {
29
29
  name: 'Target Name',
30
- number: 'GB/T 3259-2018',
30
+ number: 'GB/T 8888-001',
31
31
  ics_code: '11-23-68',
32
32
  published_on: Date.current+1.year,
33
33
  applied_on: Date.current,
@@ -20,15 +20,15 @@ describe Unidom::Standard::Standard, type: :model do
20
20
  obsoleted_on: Date.current+20.years
21
21
  }
22
22
 
23
- it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
24
- it_behaves_like 'Unidom::Standard::Concerns::AsSourceStandard', model_attributes
25
- it_behaves_like 'Unidom::Standard::Concerns::AsTargetStandard', model_attributes
23
+ it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes.merge(number: 'GB/T 9999-000')
24
+ it_behaves_like 'Unidom::Standard::Concerns::AsSourceStandard', model_attributes.merge(number: 'GB/T 9999-001')
25
+ it_behaves_like 'Unidom::Standard::Concerns::AsTargetStandard', model_attributes.merge(number: 'GB/T 9999-002')
26
26
 
27
- it_behaves_like 'validates text', model_attributes, :name,
27
+ it_behaves_like 'validates text', model_attributes.merge(number: 'GB/T 9999-003'), :name,
28
28
  length: 2..described_class.columns_hash['name'].limit
29
29
 
30
30
  number_max_length = described_class.columns_hash['number'].limit
31
- it_behaves_like 'validates', model_attributes, :number,
31
+ it_behaves_like 'validates', model_attributes.merge(number: 'GB/T 9999-004'), :number,
32
32
  { } => 0,
33
33
  { number: nil } => 2,
34
34
  { number: '' } => 2,
@@ -40,10 +40,11 @@ describe Unidom::Standard::Standard, type: :model do
40
40
  { number: 'A'*(number_max_length+1) } => 1
41
41
 
42
42
  it_behaves_like 'scope', :number_is, [
43
- { attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:number] ] },
44
- { attributes_collection: [ model_attributes ], count_diff: 0, args: [ "#{model_attributes[:number]}0" ] },
45
- { attributes_collection: [ model_attributes.merge(number: "#{model_attributes[:number]}0") ], count_diff: 0, args: [ model_attributes[:number] ] },
46
- { attributes_collection: [ model_attributes.merge(number: "#{model_attributes[:number]}0") ], count_diff: 1, args: [ "#{model_attributes[:number]}0" ] } ]
43
+ { attributes_collection: [ model_attributes.merge(number: 'GB/T 9999-005') ], count_diff: 1, args: [ 'GB/T 9999-005' ] },
44
+ { attributes_collection: [ model_attributes.merge(number: 'GB/T 9999-006') ], count_diff: 0, args: [ 'GB/T 9999-005' ] },
45
+ { attributes_collection: [ model_attributes.merge(number: 'GB/T 9999-007') ], count_diff: 0, args: [ 'GB/T 9999-008' ] },
46
+ { attributes_collection: [ model_attributes.merge(number: 'GB/T 9999-008') ], count_diff: 1, args: [ 'GB/T 9999-008' ] }
47
+ ]
47
48
 
48
49
  end
49
50
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Standard
3
- VERSION = '1.4.7'.freeze
3
+ VERSION = '1.4.8'.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.7
4
+ version: 1.4.8
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-04-15 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common