unidom-product 1.7.6 → 1.7.7
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/product/concerns/as_source_product.rb +15 -1
- data/app/models/unidom/product/concerns/as_target_product.rb +15 -1
- data/lib/rspec/models/unidom/product/concerns/as_source_product_shared_examples.rb +5 -0
- data/lib/rspec/models/unidom/product/concerns/as_target_product_shared_examples.rb +5 -0
- data/lib/unidom/product/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: 8d95506197821fb2b86634f9ea4767b1b66eb970
|
4
|
+
data.tar.gz: 2582a40999d61d3699e43f22370e5b470d6c215f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 450b179167a954f7cf03345416b43b2135bb6052386254e6284544510813d2273cc54fd0c2b006e1f5301726eb8dd41404f8bd7f814bbf44f406d8d758adf145
|
7
|
+
data.tar.gz: 95a98fb6e2cf23a8b35eb0b51d32fc75a26cac4c012326fc57693ae9722d7c0be3cdf33fd5da30f8ce3b9ae7d8ff7044b4b42188b890263c7995241a012c98b1
|
@@ -3,7 +3,8 @@
|
|
3
3
|
|
4
4
|
module Unidom::Product::Concerns::AsSourceProduct
|
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,24 @@ module Unidom::Product::Concerns::AsSourceProduct
|
|
11
12
|
has_many :target_products, through: :target_product_associatings, source: :target
|
12
13
|
|
13
14
|
def associate?(target, due_to: nil, 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_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
|
21
|
+
|
15
22
|
end
|
16
23
|
|
17
24
|
def associate!(target, due_to: nil, at: Time.now, ordinal: 1)
|
25
|
+
|
26
|
+
assert_present! :target, target
|
27
|
+
assert_present! :due_to, due_to
|
28
|
+
assert_present! :at, at
|
29
|
+
assert_present! :ordinal, ordinal
|
30
|
+
|
18
31
|
target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.first_or_create! ordinal: ordinal, opened_at: at
|
32
|
+
|
19
33
|
end
|
20
34
|
|
21
35
|
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
|
4
4
|
module Unidom::Product::Concerns::AsTargetProduct
|
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,24 @@ module Unidom::Product::Concerns::AsTargetProduct
|
|
11
12
|
has_many :source_products, through: :source_product_associatings, source: :source
|
12
13
|
|
13
14
|
def is_associated?(source, due_to: nil, at: Time.now)
|
15
|
+
|
16
|
+
assert_present! :source, source
|
17
|
+
assert_present! :due_to, due_to
|
18
|
+
assert_present! :at, at
|
19
|
+
|
14
20
|
source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
|
21
|
+
|
15
22
|
end
|
16
23
|
|
17
24
|
def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
|
25
|
+
|
26
|
+
assert_present! :source, source
|
27
|
+
assert_present! :due_to, due_to
|
28
|
+
assert_present! :at, at
|
29
|
+
assert_present! :ordinal, ordinal
|
30
|
+
|
18
31
|
source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.first_or_create! ordinal: ordinal, opened_at: at
|
32
|
+
|
19
33
|
end
|
20
34
|
|
21
35
|
end
|
@@ -18,6 +18,11 @@ shared_examples 'Unidom::Product::Concerns::AsSourceProduct' do |model_attribute
|
|
18
18
|
|
19
19
|
it_behaves_like 'has_many', model_attributes, :target_product_associatings, Unidom::Product::ProductAssociating, [ target_product_associating_1_attribtues, target_product_associating_2_attribtues ]
|
20
20
|
|
21
|
+
model = described_class.create! model_attributes
|
22
|
+
target = described_class.create! model_attributes
|
23
|
+
it_behaves_like 'assert_present!', model, :associate!, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
|
24
|
+
it_behaves_like 'assert_present!', model, :associate?, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
|
25
|
+
|
21
26
|
end
|
22
27
|
|
23
28
|
end
|
@@ -18,6 +18,11 @@ shared_examples 'Unidom::Product::Concerns::AsTargetProduct' do |model_attribute
|
|
18
18
|
|
19
19
|
it_behaves_like 'has_many', model_attributes, :source_product_associatings, Unidom::Product::ProductAssociating, [ source_product_associating_1_attribtues, source_product_associating_2_attribtues ]
|
20
20
|
|
21
|
+
model = described_class.create! model_attributes
|
22
|
+
source = described_class.create! model_attributes
|
23
|
+
it_behaves_like 'assert_present!', model, :is_associated!, [ source, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :source }, :due_to, :at ]
|
24
|
+
it_behaves_like 'assert_present!', model, :is_associated?, [ source, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :source }, :due_to, :at ]
|
25
|
+
|
21
26
|
end
|
22
27
|
|
23
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-product
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.7
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|