unidom-accession 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4706a65d450b15934cac5b2cd59fade50a0534e9
4
- data.tar.gz: 79f2cc54b9709820fc798c0fe04b11690e945910
3
+ metadata.gz: 339bbd7ef3480c595a5e8dd76400f0cc877cb0d3
4
+ data.tar.gz: afbcb88c986ba663c30deafdf4dd1fc220995ed4
5
5
  SHA512:
6
- metadata.gz: 29cac17f8c878a17404bcea59be8694ccbddbf8bf5e3070f8504109def78b0b9f405696b127a35725ee252d9f9054c5fceef758f2b6ceb4f22c7c7b96acf0a68
7
- data.tar.gz: 894b4accc8160de910d2b40f728f6ff9f7d1204e865dc87dd83e83bee218e82e52795a9615c647561097ccffeb331ad1b761df1e159e51c498052a89ca40a9fa
6
+ metadata.gz: d34a7a17f7a97f66425cfcee48c9156ced1ccf80983f51afaf4767c84185a3ee1818a25c3bf067593cc1c8195675774c18c34c084aeadff701273afd18e0a40f
7
+ data.tar.gz: 6023424ec20593f9307f52d60a1340afcbee27cd8d6316ec72d2b8fd985ccbbbb7c29614a88e4f2fd2c31351a293bfad6c8291dd5e90e60fea5644f713b942a5
data/README.md CHANGED
@@ -137,6 +137,30 @@ initialize_unidom
137
137
  # spec/support/unidom_rspec_shared_examples.rb
138
138
  require 'unidom/accession/rspec_shared_examples'
139
139
 
140
+ # spec/models/unidom/accession/post_fulfillment_spec.rb
141
+ describe Unidom::Accession::PostFulfillment, type: :model do
142
+
143
+ before :each do
144
+ end
145
+
146
+ after :each do
147
+ end
148
+
149
+ context do
150
+
151
+ model_attributes = {}
152
+
153
+ post_fulfiller = Unidom::Party::Person.create! name: 'Tim'
154
+ company = Unidom::Party::Company.create! name: 'Space X'
155
+ occupation = Unidom::Position::Occupation.first_or_create! scheme_id: SecureRandom.uuid, scheme_type: 'Unidom::Accession::Scheme::Mock', code: 'OC-00', name: 'Some Occupation'
156
+ position = occupation.positions.first_or_create! organization: company, name: occupation.name
157
+ post_fulfilled = position.posts.first_or_create! organization: company, name: position.name
158
+
159
+ it_behaves_like 'Unidom::Accession::PostFulfillment', model_attributes, post_fulfilled, post_fulfiller
160
+ end
161
+
162
+ end
163
+
140
164
  # spec/models/unidom/party/person_spec.rb
141
165
  describe Unidom::Party::Person do
142
166
 
@@ -17,11 +17,12 @@ module Unidom::Accession::Concerns::AsPostFulfilled
17
17
  # 或者
18
18
  # post.is_fulfilled_as_post! by: tom, at: Time.now
19
19
  def is_fulfilled_as_post!(by: nil, at: Time.now)
20
+
20
21
  assert_present! :by, by
21
22
  assert_present! :at, at
22
- #raise ArgumentError.new('The by argument is required.') if by.blank?
23
- #raise ArgumentError.new('The at argument is required.') if at.blank?
23
+
24
24
  post_fulfillments.create! fulfiller: by, opened_at: at
25
+
25
26
  end
26
27
 
27
28
  ##
@@ -30,11 +31,12 @@ module Unidom::Accession::Concerns::AsPostFulfilled
30
31
  # 或者
31
32
  # post.is_fulfilled_as_post? by: tom, at: Time.now
32
33
  def is_fulfilled_as_post?(by: nil, at: Time.now)
34
+
33
35
  assert_present! :by, by
34
36
  assert_present! :at, at
35
- #raise ArgumentError.new('The by argument is required.') if by.blank?
36
- #raise ArgumentError.new('The at argument is required.') if at.blank?
37
+
37
38
  post_fulfillments.fulfilled_by(by).valid_at(now: at).exists?
39
+
38
40
  end
39
41
 
40
42
  end
@@ -20,11 +20,13 @@ class Unidom::Accession::PostFulfillment < Unidom::Accession::ApplicationRecord
20
20
  # 将工作岗位 fulfilled 和履行者 fulfiller 在给定的时间 opened_at 关联起来。 opened_at 缺省为当前时间。如:
21
21
  # Unidom::Accession::PostFulfillment.fulfill! fulfilled: post, fulfiller: selected_person
22
22
  def self.fulfill!(fulfilled: nil, fulfiller: nil, opened_at: Time.now)
23
+
23
24
  assert_present! :fulfilled, fulfilled
24
25
  assert_present! :fulfiller, fulfiller
25
26
  assert_present! :opened_at, opened_at
26
27
 
27
- self.create! fulfiller: fulfiller, fulfilled: fulfilled, opened_at: opened_at
28
+ create! fulfiller: fulfiller, fulfilled: fulfilled, opened_at: opened_at
29
+
28
30
  end
29
31
 
30
32
  end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Accession::PostFulfillment'
@@ -0,0 +1,13 @@
1
+ shared_examples 'Unidom::Accession::PostFulfillment' do |model_attributes, fulfilled, fulfiller|
2
+
3
+ before :each do
4
+ end
5
+
6
+ after :each do
7
+ end
8
+
9
+ context do
10
+ it_behaves_like 'assert_present!', described_class, :fulfill!, [ { fulfilled: fulfilled, fulfiller: fulfiller, opened_at: Time.now } ], [ :fulfilled, :fulfiller, :opened_at ]
11
+ end
12
+
13
+ end
@@ -1,2 +1,3 @@
1
+ require 'rspec/models/unidom/accession/post_fulfillment_shared_examples'
1
2
  require 'rspec/models/unidom/accession/concerns/as_post_fulfilled_shared_examples'
2
3
  require 'rspec/models/unidom/accession/concerns/as_post_fulfiller_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Accession
3
- VERSION = '2.3.4'.freeze
3
+ VERSION = '2.3.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-accession
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.5
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-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -52,6 +52,7 @@ files:
52
52
  - db/migrate/20040501000000_create_unidom_post_fulfillments.rb
53
53
  - lib/rspec/models/unidom/accession/concerns/as_post_fulfilled_shared_examples.rb
54
54
  - lib/rspec/models/unidom/accession/concerns/as_post_fulfiller_shared_examples.rb
55
+ - lib/rspec/models/unidom/accession/post_fulfillment_shared_examples.rb
55
56
  - lib/rspec/models/unidom/accession/post_fulfillment_spec.rb
56
57
  - lib/tasks/accession_tasks.rake
57
58
  - lib/unidom/accession.rb