unidom-accession 2.3 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47d8125522a52f78315a477b57d999fbfedc8494
4
- data.tar.gz: e49172c358917ebfd71f56aea682980b84cbb3d3
3
+ metadata.gz: fe5f5dc574296af56843985c519c3b5e942702b6
4
+ data.tar.gz: 5604258d182b419dc86cc9d1c971581e3d014636
5
5
  SHA512:
6
- metadata.gz: e38a27c0ca70300a90d8c1bcb829b8d775a22c48a3fc4485b5d7ed331c0557e333c97f827d7eebc9d62d0e6f9c31f22a6e7fd070ff60385b3c1382c61aab1783
7
- data.tar.gz: 38e3d6e71c1e51426bbcc5ebecb8ea9b6eaadc1a67025edbbb6dc381bd140fc740b9afb0a0faca50ae55c4f2e08318cc464c672ab6b201ea375e4fdeb860cf26
6
+ metadata.gz: 4a49645ecf78f4a07ce19d4b48be63aaaac7ab655163de2eefe29afa2373e162198d2d10f7d080c94e260d1c25bbde55bd65e783a492d61ad1e03c536bd5ac23
7
+ data.tar.gz: c469e50083172660c7d72b4ba5313e1217390fc12e17176f7ad0836431acac3f2e09120afb278fe9deb9b250a81282929ae7e8f8540a642c57261fb9ab6c27f0
@@ -10,12 +10,22 @@ module Unidom::Accession::Concerns::AsPostFulfilled
10
10
  has_many :post_fulfillments, class_name: 'Unidom::Accession::PostFulfillment', as: :fulfilled
11
11
  has_many :fulfiller_people, through: :post_fulfillments, source: :fulfiller, source_type: 'Unidom::Party::Person'
12
12
 
13
+ ##
14
+ # 让当前岗位在指定时间 at 开始被指定的参与者 by 履行。指定时间缺省为当前时间。如:
15
+ # post.is_fulfilled_as_post! by: tom
16
+ # 或者
17
+ # post.is_fulfilled_as_post! by: tom, at: Time.now
13
18
  def is_fulfilled_as_post!(by: nil, at: Time.now)
14
19
  raise ArgumentError.new('The by argument is required.') if by.blank?
15
20
  raise ArgumentError.new('The at argument is required.') if at.blank?
16
21
  post_fulfillments.create! fulfiller: by, opened_at: at
17
22
  end
18
23
 
24
+ ##
25
+ # 判断当前岗位在指定时间 at 是否被指定的参与者 by 履行。指定时间缺省为当前时间。如:
26
+ # post.is_fulfilled_as_post? by: tom
27
+ # 或者
28
+ # post.is_fulfilled_as_post? by: tom, at: Time.now
19
29
  def is_fulfilled_as_post?(by: nil, at: Time.now)
20
30
  raise ArgumentError.new('The by argument is required.') if by.blank?
21
31
  raise ArgumentError.new('The at argument is required.') if at.blank?
@@ -10,12 +10,22 @@ module Unidom::Accession::Concerns::AsPostFulfiller
10
10
  has_many :post_fulfillments, class_name: 'Unidom::Accession::PostFulfillment', as: :fulfiller
11
11
  has_many :fulfilled_posts, through: :post_fulfillments, source: :fulfilled, source_type: 'Unidom::Position::Post'
12
12
 
13
+ ##
14
+ # 让当前参与者在指定时间 at 开始履行岗位 post 。指定时间缺省为当前时间。如:
15
+ # selected_person.fulfill_post! post
16
+ # 或者
17
+ # selected_person.fulfill_post! post, at: Time.now-1.day
13
18
  def fulfill_post!(post, at: Time.now)
14
19
  raise ArgumentError.new('The post argument is required.') if post.blank?
15
20
  raise ArgumentError.new('The at argument is required.' ) if at.blank?
16
21
  post_fulfillments.create! fulfilled: post, opened_at: at
17
22
  end
18
23
 
24
+ ##
25
+ # 判断当前参与者在指定时间 at 是否被履行制定的岗位 post 。指定时间缺省为当前时间。如:
26
+ # post.fulfill_post? post
27
+ # 或者
28
+ # post.fulfill_post? post, at: Time.now
19
29
  def fulfill_post?(post, at: Time.now)
20
30
  raise ArgumentError.new('The post argument is required.') if post.blank?
21
31
  raise ArgumentError.new('The at argument is required.' ) if at.blank?
@@ -16,8 +16,12 @@ class Unidom::Accession::PostFulfillment < Unidom::Accession::ApplicationRecord
16
16
  scope :part_time, ->(part_time = true) { where part_time: part_time }
17
17
  scope :temporary, ->(temporary = true) { where temporary: temporary }
18
18
 
19
+ ##
20
+ # 将工作岗位 fulfilled 和履行者 fulfiller 在给定的时间 opened_at 关联起来。 opened_at 缺省为当前时间。如:
21
+ # Unidom::Accession::PostFulfillment.fulfill! fulfilled: post, fulfiller: selected_person
19
22
  def self.fulfill!(fulfilled: nil, fulfiller: nil, opened_at: Time.now)
20
- raise ArgumentError.new('Argument fulfilled is required.') if fulfilled.blank?
23
+ assert_present! :fulfilled, fulfilled
24
+ #raise ArgumentError.new('Argument fulfilled is required.') if fulfilled.blank?
21
25
  raise ArgumentError.new('Argument fulfiller is required.') if fulfiller.blank?
22
26
  raise ArgumentError.new('Argument opened_at is required.') if opened_at.blank?
23
27
  self.create! fulfiller: fulfiller, fulfilled: fulfilled, opened_at: opened_at
@@ -6,29 +6,6 @@ describe Unidom::Accession::PostFulfillment, type: :model do
6
6
  after :each do
7
7
  end
8
8
 
9
- =begin
10
- context '.validates' do
11
-
12
- model_attributes = { name: 'Tim' }
13
-
14
- it_behaves_like 'validates', model_attributes, :name,
15
- { } => 0,
16
- { name: nil } => 2,
17
- { name: '' } => 2,
18
- { name: 'A' } => 1,
19
- { name: 'AA' } => 0,
20
- { name: 'AAA' } => 0,
21
- { name: '0' } => 1,
22
- { name: '00' } => 0,
23
- { name: '000' } => 0,
24
- { name: 0 } => 1,
25
- { name: 'A'*(described_class.columns_hash['name'].limit-1) } => 0,
26
- { name: 'A'*described_class.columns_hash['name'].limit } => 0,
27
- { name: 'A'*(described_class.columns_hash['name'].limit+1) } => 1
28
-
29
- end
30
- =end
31
-
32
9
  context do
33
10
 
34
11
  model_attributes = {
@@ -40,6 +17,18 @@ describe Unidom::Accession::PostFulfillment, type: :model do
40
17
 
41
18
  it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
42
19
 
20
+ it_behaves_like 'scope', :part_time, [
21
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ true ] },
22
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ false ] },
23
+ { attributes_collection: [ model_attributes.merge(part_time: true) ], count_diff: 1, args: [ true ] },
24
+ { attributes_collection: [ model_attributes.merge(part_time: true) ], count_diff: 0, args: [ false ] } ]
25
+
26
+ it_behaves_like 'scope', :temporary, [
27
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ true ] },
28
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ false ] },
29
+ { attributes_collection: [ model_attributes.merge(temporary: true) ], count_diff: 1, args: [ true ] },
30
+ { attributes_collection: [ model_attributes.merge(temporary: true) ], count_diff: 0, args: [ false ] } ]
31
+
43
32
  end
44
33
 
45
34
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Accession
3
- VERSION = '2.3'.freeze
3
+ VERSION = '2.3.1'.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
+ version: 2.3.1
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-29 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common