unidom-party 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -12
- data/app/models/unidom/party/collaborating.rb +1 -0
- data/app/models/unidom/party/company.rb +1 -0
- data/app/models/unidom/party/government_agency.rb +2 -0
- data/app/models/unidom/party/party_relation.rb +1 -0
- data/app/models/unidom/party/person.rb +1 -0
- data/app/models/unidom/party/shop.rb +1 -0
- data/lib/rspec/models/unidom/party/concerns/as_source_party_shared_examples.rb +18 -0
- data/lib/rspec/models/unidom/party/party_relation_spec.rb +31 -0
- data/lib/rspec/models/unidom/party/person_spec.rb +39 -0
- data/lib/unidom/party/rspec.rb +4 -0
- data/lib/unidom/party/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1956c99e00b08efad2d2a80ed4e97080ac480bad
|
4
|
+
data.tar.gz: ffca347fc30b824c8609e8ed764e0484fc0963d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef7a3e183d09c02863740534c6aeef257c2f5acc7c8df93966a993f3ce23fa7342756072fa1dbab8e5339f6c90942f88584abeb4623db139179e59ff5fd7e7da
|
7
|
+
data.tar.gz: 356234bfb5ca61b2c1261c9913118112d5c20eeaf64d6c56e4049bb70c9346ca751928b7d186d0072b135efac108294755de015a4aa5da7a50a1b7519adf5df3
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Unidom Party 参与者领域模型引擎
|
2
2
|
|
3
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-party/frames)
|
3
4
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
5
|
+
|
4
6
|
[![Gem Version](https://badge.fury.io/rb/unidom-party.svg)](https://badge.fury.io/rb/unidom-party)
|
5
7
|
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-party.svg)](https://gemnasium.com/github.com/topbitdu/unidom-party)
|
6
8
|
|
@@ -72,30 +74,30 @@ include Unidom::Party::Concerns::AsCollaborator
|
|
72
74
|
|
73
75
|
### As Source Party concern
|
74
76
|
|
75
|
-
The As Source Party concern do the following tasks for the includer automatically:
|
76
|
-
1. Define the has_many :target_party_relations macro as: ``has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party``
|
77
|
-
2. Define the #relate! method as: ``relate!(to: nil, due_to: nil, at: Time.now)``
|
77
|
+
The As Source Party concern do the following tasks for the includer automatically:
|
78
|
+
1. Define the has_many :target_party_relations macro as: ``has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party``
|
79
|
+
2. Define the #relate! method as: ``relate!(to: nil, due_to: nil, at: Time.now)``
|
78
80
|
3. Define the #relate? method as: ``relate?(to: nil, due_to: nil, at: Time.now)``
|
79
81
|
|
80
82
|
### As Target Party concern
|
81
83
|
|
82
|
-
The As Target Party concern do the following tasks for the includer automatically:
|
83
|
-
1. Define the has_many :source_party_relations macro as: ``has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party``
|
84
|
-
2. Define the #is_related! method as: ``is_related!(to: nil, due_to: nil, at: Time.now)``
|
84
|
+
The As Target Party concern do the following tasks for the includer automatically:
|
85
|
+
1. Define the has_many :source_party_relations macro as: ``has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party``
|
86
|
+
2. Define the #is_related! method as: ``is_related!(to: nil, due_to: nil, at: Time.now)``
|
85
87
|
3. Define the #is_related? method as: ``is_related?(to: nil, due_to: nil, at: Time.now)``
|
86
88
|
|
87
89
|
### As Collaboration concern
|
88
90
|
|
89
|
-
The As Collaboration concern do the following tasks for the includer automatically:
|
90
|
-
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaboration``
|
91
|
-
2. Define the #is_collaborated! method as: ``is_collaborated!(by: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)``
|
91
|
+
The As Collaboration concern do the following tasks for the includer automatically:
|
92
|
+
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaboration``
|
93
|
+
2. Define the #is_collaborated! method as: ``is_collaborated!(by: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)``
|
92
94
|
3. Define the #is_collaborated? method as: ``is_collaborated?(by: nil, as: nil, at: Time.now, priority: 0, grade: 0)``
|
93
95
|
|
94
96
|
### As Collaborator concern
|
95
97
|
|
96
|
-
The As Collaborator concern do the following tasks for the includer automatically:
|
97
|
-
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaborator``
|
98
|
-
2. Define the #collaborate! method as: ``collaborate!(on: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)``
|
98
|
+
The As Collaborator concern do the following tasks for the includer automatically:
|
99
|
+
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaborator``
|
100
|
+
2. Define the #collaborate! method as: ``collaborate!(on: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)``
|
99
101
|
3. Define the #collaborate? method as: ``collaborate?(on: nil, as: nil, at: Time.now, priority: 0, grade: 0)``
|
100
102
|
|
101
103
|
|
@@ -112,3 +114,12 @@ Unidom::Party::Gender::MALE
|
|
112
114
|
Unidom::Party::Gender::FEMALE
|
113
115
|
Unidom::Party::Gender::NOT_APPLICABLE
|
114
116
|
```
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
## RSpec examples
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
# spec/unidom_spec.rb
|
124
|
+
require 'unidom/party/rspec'
|
125
|
+
```
|
@@ -0,0 +1,18 @@
|
|
1
|
+
shared_examples 'Unidom::Party::Concerns::AsSourceParty' do |model_attributes|
|
2
|
+
|
3
|
+
describe '#target_party_relations' do
|
4
|
+
|
5
|
+
target_person_1 = Unidom::Party::Person.create! name: 'Tim'
|
6
|
+
target_person_2 = Unidom::Party::Person.create! name: 'Tom'
|
7
|
+
|
8
|
+
target_party_relation_1_attributes = { target_party: target_person_1 }
|
9
|
+
target_party_relation_2_attributes = { target_party: target_person_2 }
|
10
|
+
|
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
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
# relate!
|
16
|
+
# relate?
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
describe Unidom::Party::PartyRelation, type: :model do
|
2
|
+
|
3
|
+
before :each do
|
4
|
+
end
|
5
|
+
|
6
|
+
after :each do
|
7
|
+
end
|
8
|
+
|
9
|
+
context do
|
10
|
+
|
11
|
+
tim_attributes = { name: 'Tim' }
|
12
|
+
tom_attributes = { name: 'Tom' }
|
13
|
+
friendship_attributes = { linkage_code: 'FRND', priority: 1, grade: 5 }
|
14
|
+
|
15
|
+
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', friendship_attributes.merge({
|
16
|
+
source_party_id: Unidom::Common::NULL_UUID,
|
17
|
+
source_party_type: 'Unidom::Party::Person',
|
18
|
+
target_party_id: Unidom::Common::NULL_UUID,
|
19
|
+
target_party_type: 'Unidom::Party::Person' #,
|
20
|
+
#priority: nil,
|
21
|
+
#grade: nil
|
22
|
+
})
|
23
|
+
|
24
|
+
it_behaves_like 'belongs_to', friendship_attributes.merge({ target_party_id: Unidom::Common::NULL_UUID, target_party_type: 'Unidom::Party::Person' }),
|
25
|
+
:source_party, Unidom::Party::Person, tim_attributes
|
26
|
+
it_behaves_like 'belongs_to', friendship_attributes.merge({ source_party_id: Unidom::Common::NULL_UUID, source_party_type: 'Unidom::Party::Person' }),
|
27
|
+
:target_party, Unidom::Party::Person, tom_attributes
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
describe Unidom::Party::Person, type: :model do
|
2
|
+
|
3
|
+
before :each do
|
4
|
+
end
|
5
|
+
|
6
|
+
after :each do
|
7
|
+
end
|
8
|
+
|
9
|
+
context '.validates' do
|
10
|
+
|
11
|
+
model_attributes = { name: 'Tim' }
|
12
|
+
|
13
|
+
it_behaves_like 'validates', model_attributes, :name,
|
14
|
+
{ } => 0,
|
15
|
+
{ name: nil } => 2,
|
16
|
+
{ name: '' } => 2,
|
17
|
+
{ name: 'A' } => 1,
|
18
|
+
{ name: 'AA' } => 0,
|
19
|
+
{ name: 'AAA' } => 0,
|
20
|
+
{ name: '0' } => 1,
|
21
|
+
{ name: '00' } => 0,
|
22
|
+
{ name: '000' } => 0,
|
23
|
+
{ name: 0 } => 1,
|
24
|
+
{ name: 'A'*(described_class.columns_hash['name'].limit-1) } => 0,
|
25
|
+
{ name: 'A'*described_class.columns_hash['name'].limit } => 0,
|
26
|
+
{ name: 'A'*(described_class.columns_hash['name'].limit+1) } => 1
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context do
|
31
|
+
|
32
|
+
model_attributes = { name: 'Tim' }
|
33
|
+
|
34
|
+
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
35
|
+
it_behaves_like 'Unidom::Party::Concerns::AsSourceParty', model_attributes
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
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.8.
|
4
|
+
version: 1.8.4
|
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-01-
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -65,9 +65,13 @@ files:
|
|
65
65
|
- db/migrate/20010104000000_create_unidom_government_agencies.rb
|
66
66
|
- db/migrate/20010105000000_create_unidom_companies.rb
|
67
67
|
- db/migrate/20010111000000_create_unidom_collaboratings.rb
|
68
|
+
- lib/rspec/models/unidom/party/concerns/as_source_party_shared_examples.rb
|
69
|
+
- lib/rspec/models/unidom/party/party_relation_spec.rb
|
70
|
+
- lib/rspec/models/unidom/party/person_spec.rb
|
68
71
|
- lib/tasks/party_tasks.rake
|
69
72
|
- lib/unidom/party.rb
|
70
73
|
- lib/unidom/party/engine.rb
|
74
|
+
- lib/unidom/party/rspec.rb
|
71
75
|
- lib/unidom/party/version.rb
|
72
76
|
homepage: http://github.com/topbitdu/unidom-party
|
73
77
|
licenses:
|