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 +4 -4
- data/README.md +19 -0
- data/app/models/unidom/action/concerns/as_state_subject.rb +6 -1
- data/lib/rspec/models/unidom/action/concerns/as_state_subject_shared_examples.rb +29 -0
- data/lib/unidom/action/rspec_shared_examples.rb +1 -0
- data/lib/unidom/action/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c538a071370f0477b02a6632a1fd990b1ede3dc7
|
|
4
|
+
data.tar.gz: d9fd30627b99860e8428dafec8edac29d6f1ae8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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'
|
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.
|
|
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-
|
|
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
|