unidom-accession 2.3.2 → 2.3.3

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: 570339b998187c75dffb782585abf1d5e701205a
4
- data.tar.gz: c8a60afa72db9234325900288021e65fd636e7aa
3
+ metadata.gz: 35637667e550ce271dc4b432d0da3e50e4d47770
4
+ data.tar.gz: 58e760fe421bdd5936781e26cf5a236938b8c540
5
5
  SHA512:
6
- metadata.gz: 6c16cca2d5660da1209bdd5aaf44489337ce386fdbdbff28d1891246a773d3ab855f897aace9401f56d9b456969d8d061aa92c3c40bc25bb906338ee5da3561b
7
- data.tar.gz: 7ca9c6b401d4103cd8ba304036253946f2747af1bb2772d9abed444956d512a012d8f17442d7b0fa58002def732590ddb6cb34f29af7a5fac4b0f61ab0e29e20
6
+ metadata.gz: 211757d42604b0934d97edf9e7c6426eb2c0f2965948c494cefac28bc7db3e8396fef7a5a7909a98bf6a49e78628b58116a8e47fe87f95fecc0c4a660cdbd826
7
+ data.tar.gz: 6982d9db7e776ce0aed4af5fe1ad7e924e8278eda500a5ebee0d0df9ceb7b953091a8fe26701c7c8a92574ae28d22d6f6db1f2af92ab480b059935a8ed03b5be
data/README.md CHANGED
@@ -158,7 +158,9 @@ describe Unidom::Position::Post do
158
158
  position_id: SecureRandom.uuid
159
159
  }
160
160
 
161
- it_behaves_like 'Unidom::Accession::Concerns::AsPostFulfilled', model_attribtues
161
+ post_fulfiller = Unidom::Party::Person.create! name: 'Tim'
162
+
163
+ it_behaves_like 'Unidom::Accession::Concerns::AsPostFulfilled', model_attribtues, post_fulfiller
162
164
 
163
165
  end
164
166
  ```
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Accession::Concerns::AsPostFulfilled
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,8 +17,10 @@ module Unidom::Accession::Concerns::AsPostFulfilled
16
17
  # 或者
17
18
  # post.is_fulfilled_as_post! by: tom, at: Time.now
18
19
  def is_fulfilled_as_post!(by: nil, at: Time.now)
19
- raise ArgumentError.new('The by argument is required.') if by.blank?
20
- raise ArgumentError.new('The at argument is required.') if at.blank?
20
+ assert_present! :by, by
21
+ 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?
21
24
  post_fulfillments.create! fulfiller: by, opened_at: at
22
25
  end
23
26
 
@@ -27,8 +30,10 @@ module Unidom::Accession::Concerns::AsPostFulfilled
27
30
  # 或者
28
31
  # post.is_fulfilled_as_post? by: tom, at: Time.now
29
32
  def is_fulfilled_as_post?(by: nil, at: Time.now)
30
- raise ArgumentError.new('The by argument is required.') if by.blank?
31
- raise ArgumentError.new('The at argument is required.') if at.blank?
33
+ assert_present! :by, by
34
+ 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?
32
37
  post_fulfillments.fulfilled_by(by).valid_at(now: at).exists?
33
38
  end
34
39
 
@@ -22,9 +22,8 @@ class Unidom::Accession::PostFulfillment < Unidom::Accession::ApplicationRecord
22
22
  def self.fulfill!(fulfilled: nil, fulfiller: nil, opened_at: Time.now)
23
23
  assert_present! :fulfilled, fulfilled
24
24
  assert_present! :fulfiller, fulfiller
25
- #raise ArgumentError.new('Argument fulfilled is required.') if fulfilled.blank?
26
- #raise ArgumentError.new('Argument fulfiller is required.') if fulfiller.blank?
27
- raise ArgumentError.new('Argument opened_at is required.') if opened_at.blank?
25
+ assert_present! :opened_at, opened_at
26
+
28
27
  self.create! fulfiller: fulfiller, fulfilled: fulfilled, opened_at: opened_at
29
28
  end
30
29
 
@@ -1,15 +1,80 @@
1
- shared_examples 'Unidom::Accession::Concerns::AsPostFulfilled' do |model_attributes|
1
+ shared_examples 'Unidom::Accession::Concerns::AsPostFulfilled' do |model_attributes, post_fulfiller|
2
2
 
3
- post_fulfillment_1_attribtues = {
4
- fulfiller_id: SecureRandom.uuid,
5
- fulfiller_type: 'Unidom::Accession::Fulfiller::Mock'
6
- }
3
+ before :each do
7
4
 
8
- post_fulfillment_2_attribtues = {
9
- fulfiller_id: SecureRandom.uuid,
10
- fulfiller_type: 'Unidom::Accession::Fulfiller::Mock'
11
- }
5
+ @post = described_class.create! model_attributes
12
6
 
13
- it_behaves_like 'has_many', model_attributes, :post_fulfillments, Unidom::Accession::PostFulfillment, [ post_fulfillment_1_attribtues, post_fulfillment_2_attribtues ]
7
+ end
8
+
9
+ after :all do
10
+
11
+ #@post.destroy
12
+
13
+ end
14
+
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
+
21
+ end
22
+ =end
23
+
24
+ context '#is_fulfilled_as_post!' do
25
+
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
+ it "should be able to be fulfilled as post by #{post_fulfiller.inspect}" do
30
+ post_fulfillment = @post.is_fulfilled_as_post! by: post_fulfiller
31
+ expect(post_fulfillment).to be_present
32
+ expect(post_fulfillment).to be_a(Unidom::Accession::PostFulfillment)
33
+ expect(post_fulfillment).not_to be_new_record
34
+ end
35
+
36
+ it "should be able to be fulfilled as post by #{post_fulfiller.inspect}, at #{Time.now.inspect}" do
37
+ post_fulfillment = @post.is_fulfilled_as_post! by: post_fulfiller, at: Time.now
38
+ expect(post_fulfillment).to be_present
39
+ expect(post_fulfillment).to be_a(Unidom::Accession::PostFulfillment)
40
+ expect(post_fulfillment).not_to be_new_record
41
+ end
42
+
43
+ end
44
+
45
+ context '#is_fulfilled_as_post?' do
46
+
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
+ it "should be able to be fulfilled as post by #{post_fulfiller.inspect}" do
51
+ expect(@post.is_fulfilled_as_post? by: post_fulfiller).to be_falsey
52
+ @post.is_fulfilled_as_post! by: post_fulfiller
53
+ expect(@post.is_fulfilled_as_post? by: post_fulfiller).to be_truthy
54
+ end
55
+
56
+ it "should be able to be fulfilled as post by #{post_fulfiller.inspect}, at #{Time.now.inspect}" do
57
+ expect(@post.is_fulfilled_as_post? by: post_fulfiller).to be_falsey
58
+ @post.is_fulfilled_as_post! by: post_fulfiller, at: Time.now
59
+ expect(@post.is_fulfilled_as_post? by: post_fulfiller).to be_truthy
60
+ end
61
+
62
+ end
63
+
64
+ context do
65
+
66
+ post_fulfillment_1_attribtues = {
67
+ fulfiller_id: SecureRandom.uuid,
68
+ fulfiller_type: 'Unidom::Accession::Fulfiller::Mock'
69
+ }
70
+
71
+ post_fulfillment_2_attribtues = {
72
+ fulfiller_id: SecureRandom.uuid,
73
+ fulfiller_type: 'Unidom::Accession::Fulfiller::Mock'
74
+ }
75
+
76
+ it_behaves_like 'has_many', model_attributes, :post_fulfillments, Unidom::Accession::PostFulfillment, [ post_fulfillment_1_attribtues, post_fulfillment_2_attribtues ]
77
+
78
+ end
14
79
 
15
80
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Accession
3
- VERSION = '2.3.2'.freeze
3
+ VERSION = '2.3.3'.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.2
4
+ version: 2.3.3
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-11 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common