unidom-action 1.17.12 → 1.17.13

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: 0b29999f3681ca306b2fe4f69bae7d55e128e0a7
4
- data.tar.gz: 4413ac91f03d72e32039ad8e6e8f58d6009b92e9
3
+ metadata.gz: c538a071370f0477b02a6632a1fd990b1ede3dc7
4
+ data.tar.gz: d9fd30627b99860e8428dafec8edac29d6f1ae8e
5
5
  SHA512:
6
- metadata.gz: 5afbb1c448ec18b487bdc93ad97eba451113276fc810562ba6a96a2f8ab026f96a80c5aa0249c9e6f3491c180e9192202a5123b4f58365b8bb1c93dea5df7187
7
- data.tar.gz: 2bfa02dc38bb02c6f3c7d2062571f8e18496113ad6fc96f6e0664fd1cc9fa008217cd8f285165c60206a6ec2e8ac4ca9895411df21652e0c58f35eb0663a0775
6
+ metadata.gz: 0fcf367babbfa792c4070c2ab1a87e05b49ebcb9aaf58634fa04887a899070ca40b9908f22e89e380660e6d418cc6c15e1ffac3b95934716e93cdc108032b2c8
7
+ data.tar.gz: a567cde908bbbe79e9cdb319373c7eda6f4493a48e8e396446fc0af88906ff6fb94e811a1faa045b75b81c9a568770040ea721e7e1256234e5192f708e35451c
data/README.md CHANGED
@@ -289,6 +289,14 @@ class YourSearcherParty < ApplicationRecord
289
289
 
290
290
  end
291
291
 
292
+ # app/models/your_as_state_subject.rb
293
+ class YourStateSubject < ApplicationRecord
294
+
295
+ include Unidom::Common::Concerns::ModelExtension
296
+ include Unidom::Action::Concerns::AsStateSubject
297
+
298
+ end
299
+
292
300
  # spec/support/unidom_rspec_shared_examples.rb
293
301
  require 'unidom/action/rspec_shared_examples'
294
302
 
@@ -358,3 +366,14 @@ describe YourSearcherParty, type: :model do
358
366
 
359
367
  end
360
368
  ```
369
+ # spec/models/your_state_subject_spec.rb
370
+ describe YourStateSubject, type: :model do
371
+
372
+ model_attribtues = {
373
+ your_attribute: 'your value'
374
+ }
375
+
376
+ it_behaves_like 'Unidom::Action::Concerns::AsStateSubject', model_attribtues
377
+
378
+ end
379
+ ```
@@ -1,13 +1,18 @@
1
1
  module Unidom::Action::Concerns::AsStateSubject
2
2
 
3
- extend ActiveSupport::Concern
3
+ extend ActiveSupport::Concern
4
+ include Unidom::Common::Concerns::ArgumentValidation
4
5
 
5
6
  included do |includer|
6
7
 
7
8
  has_many :state_transitions, class_name: 'Unidom::Action::StateTransition', as: :subject
8
9
 
9
10
  def is_transited!(from: nil, thru: nil, due_to: nil, via: nil, by: nil, at: Time.now)
11
+
12
+ assert_present! :from, from
13
+
10
14
  state_transitions.create! from_state: from, thru_state: thru, transitor_visitor: via, transitor_party: by, reason: due_to, opened_at: at
15
+
11
16
  end
12
17
 
13
18
  def is_transited?(from: nil, thru: nil, due_to: nil, via: nil, by: nil, at: Time.now)
@@ -0,0 +1,29 @@
1
+ shared_examples 'Unidom::Action::Concerns::AsStateSubject' do |model_attributes|
2
+
3
+ context do
4
+
5
+ state_transition_1_attributes = {
6
+ transitor_party_id: SecureRandom.uuid,
7
+ transitor_party_type: 'Unidom::Action::Subject::Mock',
8
+ transitor_visitor_id: SecureRandom.uuid,
9
+ transitor_visitor_type: 'Unidom::Action::SearcherVisitor::Mock',
10
+ reason_id: SecureRandom.uuid,
11
+ from_state: 'C',
12
+ thru_state: 'A'
13
+ }
14
+
15
+ state_transition_2_attributes = {
16
+ transitor_party_id: SecureRandom.uuid,
17
+ transitor_party_type: 'Unidom::Action::Subject::Mock',
18
+ transitor_visitor_id: SecureRandom.uuid,
19
+ transitor_visitor_type: 'Unidom::Action::SearcherVisitor::Mock',
20
+ reason_id: SecureRandom.uuid,
21
+ from_state: 'K',
22
+ thru_state: 'E'
23
+ }
24
+
25
+ it_behaves_like 'has_many', model_attributes, :state_transitions, Unidom::Action::StateTransition, [ state_transition_1_attributes, state_transition_2_attributes ]
26
+
27
+ end
28
+
29
+ end
@@ -4,3 +4,4 @@ require 'rspec/models/unidom/action/concerns/as_caused_shared_examples'
4
4
  require 'rspec/models/unidom/action/concerns/as_obsolesced_shared_examples'
5
5
  require 'rspec/models/unidom/action/concerns/as_obsolescer_party_shared_examples'
6
6
  require 'rspec/models/unidom/action/concerns/as_searcher_party_shared_examples'
7
+ require 'rspec/models/unidom/action/concerns/as_state_subject_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Action
3
- VERSION = '1.17.12'.freeze
3
+ VERSION = '1.17.13'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-action
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.12
4
+ version: 1.17.13
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-04-17 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -75,6 +75,7 @@ files:
75
75
  - lib/rspec/models/unidom/action/concerns/as_obsolesced_shared_examples.rb
76
76
  - lib/rspec/models/unidom/action/concerns/as_obsolescer_party_shared_examples.rb
77
77
  - lib/rspec/models/unidom/action/concerns/as_searcher_party_shared_examples.rb
78
+ - lib/rspec/models/unidom/action/concerns/as_state_subject_shared_examples.rb
78
79
  - lib/rspec/models/unidom/action/obsolescing_spec.rb
79
80
  - lib/rspec/models/unidom/action/reason_spec.rb
80
81
  - lib/rspec/models/unidom/action/searching_spec.rb