unidom-accession 2.3.3 → 2.3.4

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: 35637667e550ce271dc4b432d0da3e50e4d47770
4
- data.tar.gz: 58e760fe421bdd5936781e26cf5a236938b8c540
3
+ metadata.gz: 4706a65d450b15934cac5b2cd59fade50a0534e9
4
+ data.tar.gz: 79f2cc54b9709820fc798c0fe04b11690e945910
5
5
  SHA512:
6
- metadata.gz: 211757d42604b0934d97edf9e7c6426eb2c0f2965948c494cefac28bc7db3e8396fef7a5a7909a98bf6a49e78628b58116a8e47fe87f95fecc0c4a660cdbd826
7
- data.tar.gz: 6982d9db7e776ce0aed4af5fe1ad7e924e8278eda500a5ebee0d0df9ceb7b953091a8fe26701c7c8a92574ae28d22d6f6db1f2af92ab480b059935a8ed03b5be
6
+ metadata.gz: 29cac17f8c878a17404bcea59be8694ccbddbf8bf5e3070f8504109def78b0b9f405696b127a35725ee252d9f9054c5fceef758f2b6ceb4f22c7c7b96acf0a68
7
+ data.tar.gz: 894b4accc8160de910d2b40f728f6ff9f7d1204e865dc87dd83e83bee218e82e52795a9615c647561097ccffeb331ad1b761df1e159e51c498052a89ca40a9fa
data/README.md CHANGED
@@ -144,7 +144,15 @@ describe Unidom::Party::Person do
144
144
  name: 'Tim'
145
145
  }
146
146
 
147
- it_behaves_like 'Unidom::Accession::Concerns::AsPostFulfiller', model_attribtues
147
+ post_attribtues = {
148
+ name: 'HR Manager',
149
+ organization_id: SecureRandom.uuid,
150
+ organization_type: 'Unidom::Position::Organization::Mock',
151
+ position_id: SecureRandom.uuid
152
+ }
153
+ post = Unidom::Position::Post.create! post_attributes
154
+
155
+ it_behaves_like 'Unidom::Accession::Concerns::AsPostFulfiller', model_attribtues, post
148
156
 
149
157
  end
150
158
 
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Accession::Concerns::AsPostFulfiller
5
5
 
6
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
7
+ include Unidom::Common::Concerns::ArgumentValidation
7
8
 
8
9
  included do |includer|
9
10
 
@@ -16,9 +17,12 @@ module Unidom::Accession::Concerns::AsPostFulfiller
16
17
  # 或者
17
18
  # selected_person.fulfill_post! post, at: Time.now-1.day
18
19
  def fulfill_post!(post, at: Time.now)
19
- raise ArgumentError.new('The post argument is required.') if post.blank?
20
- raise ArgumentError.new('The at argument is required.' ) if at.blank?
20
+
21
+ assert_present! :post, post
22
+ assert_present! :at, at
23
+
21
24
  post_fulfillments.create! fulfilled: post, opened_at: at
25
+
22
26
  end
23
27
 
24
28
  ##
@@ -27,9 +31,12 @@ module Unidom::Accession::Concerns::AsPostFulfiller
27
31
  # 或者
28
32
  # post.fulfill_post? post, at: Time.now
29
33
  def fulfill_post?(post, at: Time.now)
30
- raise ArgumentError.new('The post argument is required.') if post.blank?
31
- raise ArgumentError.new('The at argument is required.' ) if at.blank?
34
+
35
+ assert_present! :post, post
36
+ assert_present! :at, at
37
+
32
38
  post_fulfillments.fulfilled_is(post).valid_at(now: at).exists?
39
+
33
40
  end
34
41
 
35
42
  end
@@ -1,31 +1,14 @@
1
1
  shared_examples 'Unidom::Accession::Concerns::AsPostFulfilled' do |model_attributes, post_fulfiller|
2
2
 
3
3
  before :each do
4
-
5
4
  @post = described_class.create! model_attributes
6
-
7
- end
8
-
9
- after :all do
10
-
11
- #@post.destroy
12
-
13
5
  end
14
6
 
15
- =begin
16
- context do
17
-
18
- post = described_class.create! model_attributes
19
- it_behaves_like 'assert_present!', post, :is_fulfilled_as_post!, [ { by: post_fulfiller, at: Time.now } ], [ :by, :at ]
20
-
7
+ after :each do
21
8
  end
22
- =end
23
9
 
24
10
  context '#is_fulfilled_as_post!' do
25
11
 
26
- it 'should reject the by argument = nil' do expect { @post.is_fulfilled_as_post! by: nil, at: Time.now }.to raise_error(ArgumentError, 'The by argument is required.') end
27
- it 'should reject the at argument = nil' do expect { @post.is_fulfilled_as_post! by: post_fulfiller, at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
28
-
29
12
  it "should be able to be fulfilled as post by #{post_fulfiller.inspect}" do
30
13
  post_fulfillment = @post.is_fulfilled_as_post! by: post_fulfiller
31
14
  expect(post_fulfillment).to be_present
@@ -44,9 +27,6 @@ shared_examples 'Unidom::Accession::Concerns::AsPostFulfilled' do |model_attribu
44
27
 
45
28
  context '#is_fulfilled_as_post?' do
46
29
 
47
- it 'should reject the by argument = nil' do expect { @post.is_fulfilled_as_post? by: nil, at: Time.now }.to raise_error(ArgumentError, 'The by argument is required.') end
48
- it 'should reject the at argument = nil' do expect { @post.is_fulfilled_as_post? by: post_fulfiller, at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
49
-
50
30
  it "should be able to be fulfilled as post by #{post_fulfiller.inspect}" do
51
31
  expect(@post.is_fulfilled_as_post? by: post_fulfiller).to be_falsey
52
32
  @post.is_fulfilled_as_post! by: post_fulfiller
@@ -75,6 +55,10 @@ shared_examples 'Unidom::Accession::Concerns::AsPostFulfilled' do |model_attribu
75
55
 
76
56
  it_behaves_like 'has_many', model_attributes, :post_fulfillments, Unidom::Accession::PostFulfillment, [ post_fulfillment_1_attribtues, post_fulfillment_2_attribtues ]
77
57
 
58
+ post = described_class.create! model_attributes
59
+ it_behaves_like 'assert_present!', post, :is_fulfilled_as_post!, [ { by: post_fulfiller, at: Time.now } ], [ :by, :at ]
60
+ it_behaves_like 'assert_present!', post, :is_fulfilled_as_post?, [ { by: post_fulfiller, at: Time.now } ], [ :by, :at ]
61
+
78
62
  end
79
63
 
80
64
  end
@@ -1,15 +1,64 @@
1
- shared_examples 'Unidom::Accession::Concerns::AsPostFulfiller' do |model_attributes|
1
+ shared_examples 'Unidom::Accession::Concerns::AsPostFulfiller' do |model_attributes, post|
2
2
 
3
- post_fulfillment_1_attribtues = {
4
- fulfilled_id: SecureRandom.uuid,
5
- fulfilled_type: 'Unidom::Accession::Fulfilled::Mock'
6
- }
3
+ before :each do
4
+ @post_fulfiller = described_class.create! model_attributes
5
+ end
7
6
 
8
- post_fulfillment_2_attribtues = {
9
- fulfilled_id: SecureRandom.uuid,
10
- fulfilled_type: 'Unidom::Accession::Fulfilled::Mock'
11
- }
7
+ after :each do
8
+ end
12
9
 
13
- it_behaves_like 'has_many', model_attributes, :post_fulfillments, Unidom::Accession::PostFulfillment, [ post_fulfillment_1_attribtues, post_fulfillment_2_attribtues ]
10
+ context '#fulfill_post!' do
11
+
12
+ it "should be able to fulfill post #{post.inspect}" do
13
+ post_fulfillment = @post_fulfiller.fulfill_post! post
14
+ expect(post_fulfillment).to be_present
15
+ expect(post_fulfillment).to be_a(Unidom::Accession::PostFulfillment)
16
+ expect(post_fulfillment).not_to be_new_record
17
+ end
18
+
19
+ it "should be able to fulfill post #{post.inspect}, at #{Time.now.inspect}" do
20
+ post_fulfillment = @post_fulfiller.fulfill_post! post, at: Time.now
21
+ expect(post_fulfillment).to be_present
22
+ expect(post_fulfillment).to be_a(Unidom::Accession::PostFulfillment)
23
+ expect(post_fulfillment).not_to be_new_record
24
+ end
25
+
26
+ end
27
+
28
+ context '#fulfill_post?' do
29
+
30
+ it "should be able to fulfill post #{post.inspect}" do
31
+ expect(@post_fulfiller.fulfill_post? post).to be_falsey
32
+ @post_fulfiller.fulfill_post! post
33
+ expect(@post_fulfiller.fulfill_post? post).to be_truthy
34
+ end
35
+
36
+ it "should be able to fulfill post #{post.inspect}, at #{Time.now.inspect}" do
37
+ expect(@post_fulfiller.fulfill_post? post, at: Time.now).to be_falsey
38
+ @post_fulfiller.fulfill_post! post, at: Time.now
39
+ expect(@post_fulfiller.fulfill_post? post, at: Time.now).to be_truthy
40
+ end
41
+
42
+ end
43
+
44
+ context do
45
+
46
+ post_fulfillment_1_attribtues = {
47
+ fulfilled_id: SecureRandom.uuid,
48
+ fulfilled_type: 'Unidom::Accession::Fulfilled::Mock'
49
+ }
50
+
51
+ post_fulfillment_2_attribtues = {
52
+ fulfilled_id: SecureRandom.uuid,
53
+ fulfilled_type: 'Unidom::Accession::Fulfilled::Mock'
54
+ }
55
+
56
+ it_behaves_like 'has_many', model_attributes, :post_fulfillments, Unidom::Accession::PostFulfillment, [ post_fulfillment_1_attribtues, post_fulfillment_2_attribtues ]
57
+
58
+ post_fulfiller = described_class.create! model_attributes
59
+ it_behaves_like 'assert_present!', post_fulfiller, :fulfill_post!, [ post, { at: Time.now } ], [ { 0 => :post }, :at ]
60
+ it_behaves_like 'assert_present!', post_fulfiller, :fulfill_post?, [ post, { at: Time.now } ], [ { 0 => :post }, :at ]
61
+
62
+ end
14
63
 
15
64
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Accession
3
- VERSION = '2.3.3'.freeze
3
+ VERSION = '2.3.4'.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.3
4
+ version: 2.3.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-03-23 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common