unidom-visitor 1.13.5 → 1.13.6

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: 1548e1bbdb03bf173876665278c0f89b3b780212
4
- data.tar.gz: aa7195117c0aa319e0a7e199de9b40388c1b7845
3
+ metadata.gz: 965c0d4b461fa86cb4de642a82d12a11ba39ce2e
4
+ data.tar.gz: 7d65ee1adaf397f5526620f4ed3459573c0ec1d6
5
5
  SHA512:
6
- metadata.gz: f6ac8dbce79296442cb7f32308e994059bbd654c14cbe9c294cbb9ae64b8663a2f2b39ea6b7da0808f946d9e30d12d4b2a5b43f90d218d60ce82aee43094ae09
7
- data.tar.gz: 6549bc235bb223f97f522acd955b167f4b802f2f96a6b18ee92d65d58bae0de8b6f8a27dfdef466bfc404077b5ba5c63dcd7c10918ff79f0b3854dab3a7fa1b0
6
+ metadata.gz: 95de860e9cbecfcdda077f54472543aba0b0b27fb55f8d1ef1f4e4533ae8db56401ce15c6b3c3f5530ae0f238518ebb05d4437aaef0f0228b171e70cf16660a8
7
+ data.tar.gz: 6e59631301751832e8cdb7a0bed2441220bb9c5e7a18c95489ad788072816bdae52020070a76b4d81cb509d632c712460296d338773e79af0c1e713643c69bfc
data/README.md CHANGED
@@ -160,6 +160,8 @@ end
160
160
 
161
161
  ## RSpec examples
162
162
 
163
+ ### RSpec example manifest (run automatically)
164
+
163
165
  ```ruby
164
166
  # spec/models/unidom_spec.rb
165
167
  require 'unidom/visitor/models_rspec'
@@ -170,3 +172,31 @@ require 'unidom/visitor/types_rspec'
170
172
  # spec/validators/unidom_spec.rb
171
173
  require 'unidom/visitor/validators_rspec'
172
174
  ```
175
+
176
+ ### RSpec shared examples (to be integrated)
177
+
178
+ ```ruby
179
+ # The Unidom::Visitor::Password model already include the Unidom::Visitor::Concerns::AsCredential concern
180
+
181
+ # app/models/your_credential.rb
182
+ class YourCredential < ApplicationRecord
183
+
184
+ include Unidom::Common::Concerns::ModelExtension
185
+ include Unidom::Visitor::Concerns::AsCredential
186
+
187
+ end
188
+
189
+ # spec/support/unidom_rspec_shared_examples.rb
190
+ require 'unidom/visitor/rspec_shared_examples'
191
+
192
+ # spec/models/your_credential_spec.rb
193
+ describe YourCredential, type: :model do
194
+
195
+ model_attribtues = {
196
+ your_attribute: 'your value'
197
+ }
198
+
199
+ it_behaves_like 'Unidom::Visitor::Concerns::AsCredential', model_attribtues
200
+
201
+ end
202
+ ```
@@ -25,7 +25,13 @@ class Unidom::Visitor::Authenticating < Unidom::Visitor::ApplicationRecord
25
25
  # 将访问者 visitor 和信任状 credential 关联起来。关联时间是 opened_at ,缺省是当前时间。如:
26
26
  # Unidom::Visitor::Authenticating.authenticate! user, with: password
27
27
  def self.authenticate!(visitor, with: nil, opened_at: Time.now)
28
+
29
+ #assert_present! :visitor, visitor
30
+ #assert_present! :with, with
31
+ #assert_present! :opened_at, opened_at
32
+
28
33
  credential_is(with).visitor_is(visitor).valid_at.alive.first_or_create! opened_at: opened_at
34
+
29
35
  end
30
36
 
31
37
  end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Visitor::Authenticating'
@@ -31,6 +31,10 @@ describe Unidom::Visitor::Authenticating, type: :model do
31
31
  it_behaves_like 'polymorphic scope', model_attributes, :visitor_is, :visitor, [ Unidom::Visitor::User, Unidom::Visitor::Guest ]
32
32
  it_behaves_like 'polymorphic scope', model_attributes, :credential_is, :credential, [ Unidom::Visitor::Password ]
33
33
 
34
+ #visitor = Unidom::Visitor::User.create! user_attributes
35
+ #password = Unidom::Visitor::Password.create! password_attributes
36
+ #it_behaves_like 'assert_present!', described_class, :authenticate!, [ visitor, { with: password, opened_at: Time.now } ], [ { 0 => :visitor }, :with, :opened_at ]
37
+
34
38
  end
35
39
 
36
40
  end
@@ -0,0 +1,15 @@
1
+ shared_examples 'Unidom::Visitor::Concerns::AsCredential' do |model_attributes|
2
+
3
+ context do
4
+
5
+ authenticating_attributes = {
6
+ visitor_id: SecureRandom.uuid,
7
+ visitor_type: 'Unidom::Visitor::Visitor::Mock',
8
+ flag_code: Unidom::Visitor::Flag::REQUIRED.code
9
+ }
10
+
11
+ it_behaves_like 'has_one', model_attributes, :authenticating, Unidom::Visitor::Authenticating, authenticating_attributes
12
+
13
+ end
14
+
15
+ end
@@ -1,3 +1,5 @@
1
+ require 'rspec/models/unidom/visitor/concerns/as_credential_shared_examples'
2
+
1
3
  describe Unidom::Visitor::Password, type: :model do
2
4
 
3
5
  before :each do
@@ -13,6 +15,7 @@ describe Unidom::Visitor::Password, type: :model do
13
15
  }
14
16
 
15
17
  it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
18
+ it_behaves_like 'Unidom::Visitor::Concerns::AsCredential', model_attributes
16
19
 
17
20
  it_behaves_like 'validates text', model_attributes, :clear_text,
18
21
  length: 6..200
@@ -0,0 +1 @@
1
+ require 'rspec/models/unidom/visitor/concerns/as_credential_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Visitor
3
- VERSION = '1.13.5'.freeze
3
+ VERSION = '1.13.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-visitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.5
4
+ version: 1.13.6
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-21 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
@@ -66,6 +66,7 @@ files:
66
66
  - db/migrate/20000211000000_create_unidom_users.rb
67
67
  - db/migrate/20000220000000_create_unidom_passwords.rb
68
68
  - lib/rspec/models/unidom/visitor/authenticating_spec.rb
69
+ - lib/rspec/models/unidom/visitor/concerns/as_credential_shared_examples.rb
69
70
  - lib/rspec/models/unidom/visitor/guest_spec.rb
70
71
  - lib/rspec/models/unidom/visitor/identificating_spec.rb
71
72
  - lib/rspec/models/unidom/visitor/password_spec.rb
@@ -76,6 +77,7 @@ files:
76
77
  - lib/unidom/visitor.rb
77
78
  - lib/unidom/visitor/engine.rb
78
79
  - lib/unidom/visitor/models_rspec.rb
80
+ - lib/unidom/visitor/rspec_shared_examples.rb
79
81
  - lib/unidom/visitor/types_rspec.rb
80
82
  - lib/unidom/visitor/validators_rspec.rb
81
83
  - lib/unidom/visitor/version.rb