unidom-party 1.9.6 → 1.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/app/models/unidom/party/concerns/as_source_party.rb +14 -1
- data/app/models/unidom/party/concerns/as_target_party.rb +12 -0
- data/lib/rspec/models/unidom/party/company_spec.rb +9 -3
- data/lib/rspec/models/unidom/party/concerns/as_source_party_shared_examples.rb +6 -5
- data/lib/rspec/models/unidom/party/concerns/as_target_party_shared_examples.rb +5 -1
- data/lib/rspec/models/unidom/party/government_agency_spec.rb +9 -3
- data/lib/rspec/models/unidom/party/person_spec.rb +9 -3
- data/lib/rspec/models/unidom/party/shop_spec.rb +7 -2
- data/lib/unidom/party/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: 69112818e611dcbdcfc8975fffafbd0aa9890e32
|
4
|
+
data.tar.gz: '08375d98e15d45e6c1e78f4cf7ac8f0e9636c959'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c5cafb5160263cac4b8c4940dbcd70572cb6337d740667c03725f34975d5e84ae8e6f4bafb53461f6f6129fef59d418166d48872346dcb9b0d17401e1f221c
|
7
|
+
data.tar.gz: 9f42c3e80fe646e17546039ccb24aa4e89ffe1262ed208825551f8f0bda53046696f45eff55e6c3c1ade5ace0df97b92ec406ac08150a21da1be7fe90249ab8d
|
data/README.md
CHANGED
@@ -168,12 +168,20 @@ require 'unidom/party/rspec_shared_examples'
|
|
168
168
|
# spec/models/your_party_spec.rb
|
169
169
|
describe YourParty, type: :model do
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
171
|
+
context do
|
172
|
+
|
173
|
+
model_attribtues = {
|
174
|
+
your_attribtue: 'your value'
|
175
|
+
}
|
176
|
+
|
177
|
+
target_party = described_class.create! model_attributes
|
178
|
+
source_party = described_class.create! model_attributes
|
179
|
+
linkage_code = 'SELF'
|
180
|
+
|
181
|
+
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes, target_party, linkage_code
|
182
|
+
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes, source_party, linkage_code
|
174
183
|
|
175
|
-
|
176
|
-
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attribtues
|
184
|
+
end
|
177
185
|
|
178
186
|
end
|
179
187
|
```
|
@@ -1,17 +1,30 @@
|
|
1
1
|
module Unidom::Party::Concerns::AsSourceParty
|
2
2
|
|
3
|
-
extend
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Unidom::Common::Concerns::ArgumentValidation
|
4
5
|
|
5
6
|
included do |includer|
|
6
7
|
|
7
8
|
has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party
|
8
9
|
|
9
10
|
def relate!(to: nil, due_to: nil, at: Time.now)
|
11
|
+
|
12
|
+
assert_present! :to, to
|
13
|
+
assert_present! :due_to, due_to
|
14
|
+
assert_present! :at, at
|
15
|
+
|
10
16
|
target_party_relations.create! target_party: to, linkage_code: due_to, opened_at: at
|
17
|
+
|
11
18
|
end
|
12
19
|
|
13
20
|
def relate?(to: nil, due_to: nil, at: Time.now)
|
21
|
+
|
22
|
+
assert_present! :to, to
|
23
|
+
assert_present! :due_to, due_to
|
24
|
+
assert_present! :at, at
|
25
|
+
|
14
26
|
target_party_relations.target_party_is(to).linkage_coded_as(due_to).valid_at(now: at).alive.exists?
|
27
|
+
|
15
28
|
end
|
16
29
|
|
17
30
|
end
|
@@ -7,11 +7,23 @@ module Unidom::Party::Concerns::AsTargetParty
|
|
7
7
|
has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party
|
8
8
|
|
9
9
|
def is_related!(to: nil, due_to: nil, at: Time.now)
|
10
|
+
|
11
|
+
assert_present! :to, to
|
12
|
+
assert_present! :due_to, due_to
|
13
|
+
assert_present! :at, at
|
14
|
+
|
10
15
|
source_party_relations.create! source_party: to, linkage_code: due_to, opened_at: at
|
16
|
+
|
11
17
|
end
|
12
18
|
|
13
19
|
def is_related?(to: nil, due_to: nil, at: Time.now)
|
20
|
+
|
21
|
+
assert_present! :to, to
|
22
|
+
assert_present! :due_to, due_to
|
23
|
+
assert_present! :at, at
|
24
|
+
|
14
25
|
source_party_relations.source_party_is(to).linkage_coded_as(due_to).valid_at(now: at).alive.exists?
|
26
|
+
|
15
27
|
end
|
16
28
|
|
17
29
|
end
|
@@ -16,10 +16,16 @@ describe Unidom::Party::Company, type: :model do
|
|
16
16
|
}
|
17
17
|
|
18
18
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
19
|
-
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes
|
20
|
-
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes
|
21
19
|
|
22
|
-
|
20
|
+
target_party = described_class.create! model_attributes
|
21
|
+
source_party = described_class.create! model_attributes
|
22
|
+
linkage_code = 'SELF'
|
23
|
+
|
24
|
+
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes, target_party, linkage_code
|
25
|
+
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes, source_party, linkage_code
|
26
|
+
|
27
|
+
it_behaves_like 'validates text', model_attributes, :name,
|
28
|
+
length: 2..described_class.columns_hash['name'].limit
|
23
29
|
|
24
30
|
end
|
25
31
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
shared_examples 'Unidom::Party::Concerns::AsSourceParty' do |model_attributes|
|
1
|
+
shared_examples 'Unidom::Party::Concerns::AsSourceParty' do |model_attributes, target_party, linkage_code|
|
2
2
|
|
3
|
-
|
3
|
+
context do
|
4
4
|
|
5
5
|
target_person_1 = Unidom::Party::Person.create! name: 'Tim'
|
6
6
|
target_person_2 = Unidom::Party::Person.create! name: 'Tom'
|
@@ -10,9 +10,10 @@ shared_examples 'Unidom::Party::Concerns::AsSourceParty' do |model_attributes|
|
|
10
10
|
|
11
11
|
it_behaves_like 'has_many', model_attributes, :target_party_relations, Unidom::Party::PartyRelation, [ target_party_relation_1_attributes, target_party_relation_2_attributes ]
|
12
12
|
|
13
|
-
|
13
|
+
model = described_class.create! model_attributes
|
14
|
+
it_behaves_like 'assert_present!', model, :relate!, [ { to: target_party, due_to: linkage_code, at: Time.now } ], [ :to, :due_to, :at ]
|
15
|
+
it_behaves_like 'assert_present!', model, :relate?, [ { to: target_party, due_to: linkage_code, at: Time.now } ], [ :to, :due_to, :at ]
|
14
16
|
|
15
|
-
|
16
|
-
# relate?
|
17
|
+
end
|
17
18
|
|
18
19
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples 'Unidom::Party::Concerns::AsTargetParty' do |model_attributes|
|
1
|
+
shared_examples 'Unidom::Party::Concerns::AsTargetParty' do |model_attributes, source_party, linkage_code|
|
2
2
|
|
3
3
|
context do
|
4
4
|
|
@@ -10,6 +10,10 @@ shared_examples 'Unidom::Party::Concerns::AsTargetParty' do |model_attributes|
|
|
10
10
|
|
11
11
|
it_behaves_like 'has_many', model_attributes, :source_party_relations, Unidom::Party::PartyRelation, [ source_party_relation_1_attributes, source_party_relation_2_attributes ]
|
12
12
|
|
13
|
+
model = described_class.create! model_attributes
|
14
|
+
it_behaves_like 'assert_present!', model, :is_related!, [ { to: source_party, due_to: linkage_code, at: Time.now } ], [ :to, :due_to, :at ]
|
15
|
+
it_behaves_like 'assert_present!', model, :is_related?, [ { to: source_party, due_to: linkage_code, at: Time.now } ], [ :to, :due_to, :at ]
|
16
|
+
|
13
17
|
end
|
14
18
|
|
15
19
|
end
|
@@ -19,10 +19,16 @@ describe Unidom::Party::GovernmentAgency, type: :model do
|
|
19
19
|
}
|
20
20
|
|
21
21
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
22
|
-
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes
|
23
|
-
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes
|
24
22
|
|
25
|
-
|
23
|
+
target_party = described_class.create! model_attributes
|
24
|
+
source_party = described_class.create! model_attributes
|
25
|
+
linkage_code = 'SELF'
|
26
|
+
|
27
|
+
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes, target_party, linkage_code
|
28
|
+
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes, source_party, linkage_code
|
29
|
+
|
30
|
+
it_behaves_like 'validates text', model_attributes, :name,
|
31
|
+
length: 2..described_class.columns_hash['name'].limit
|
26
32
|
|
27
33
|
end
|
28
34
|
|
@@ -16,10 +16,16 @@ describe Unidom::Party::Person, type: :model do
|
|
16
16
|
}
|
17
17
|
|
18
18
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
19
|
-
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes
|
20
|
-
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes
|
21
19
|
|
22
|
-
|
20
|
+
target_party = described_class.create! model_attributes
|
21
|
+
source_party = described_class.create! model_attributes
|
22
|
+
linkage_code = 'SELF'
|
23
|
+
|
24
|
+
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes, target_party, linkage_code
|
25
|
+
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes, source_party, linkage_code
|
26
|
+
|
27
|
+
it_behaves_like 'validates text', model_attributes, :name,
|
28
|
+
length: 2..described_class.columns_hash['name'].limit
|
23
29
|
|
24
30
|
end
|
25
31
|
|
@@ -16,8 +16,13 @@ describe Unidom::Party::Shop, type: :model do
|
|
16
16
|
}
|
17
17
|
|
18
18
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
target_party = described_class.create! model_attributes
|
21
|
+
source_party = described_class.create! model_attributes
|
22
|
+
linkage_code = 'SELF'
|
23
|
+
|
24
|
+
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes, target_party, linkage_code
|
25
|
+
it_behaves_like 'Unidom::Party::Concerns::AsTargetParty', model_attributes, source_party, linkage_code
|
21
26
|
|
22
27
|
it_behaves_like 'validates text', model_attributes, :name,
|
23
28
|
length: 2..described_class.columns_hash['name'].limit
|
data/lib/unidom/party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|