unidom-standard 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/unidom/standard/concerns/as_source_standard.rb +14 -1
- data/app/models/unidom/standard/concerns/as_target_standard.rb +6 -1
- data/lib/rspec/models/unidom/standard/concerns/as_source_standard_shared_examples.rb +12 -0
- data/lib/rspec/models/unidom/standard/standard_associating_spec.rb +2 -2
- data/lib/rspec/models/unidom/standard/standard_spec.rb +10 -9
- data/lib/unidom/standard/version.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: e64e20b9eb93af195a1485c47b5de002463d860e
|
4
|
+
data.tar.gz: fd9a944a3ecc71f738cb66f21aa1cea5b681f204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
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
|
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
|
44
|
-
{ attributes_collection: [ model_attributes
|
45
|
-
{ attributes_collection: [ model_attributes.merge(number:
|
46
|
-
{ attributes_collection: [ model_attributes.merge(number:
|
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
|
|
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.
|
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-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|