unidom-authorization 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -0
- data/lib/rspec/models/unidom/authorization/concerns/as_authorized_shared_examples.rb +17 -0
- data/lib/rspec/models/unidom/authorization/concerns/as_permission_shared_examples.rb +19 -0
- data/lib/rspec/models/unidom/authorization/permission_spec.rb +6 -5
- data/lib/unidom/authorization/rspec_shared_examples.rb +2 -0
- data/lib/unidom/authorization/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91c5653118146a3dbd7da131ececfb0eb9797496
|
4
|
+
data.tar.gz: de0fd5e0c2c745c729afba0e8556081a5b444683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c945e41215385a5ff51f395910bd266a7f7a0aaf355e863795d91ef51f9a39f0c6ef978e075bc1fc411ca9f5d55f5308e5e08ecdb07835d66fd0463db897a05
|
7
|
+
data.tar.gz: 699a27cec19d92c15b93b72e91a96b7da375263796f185174755f87d465bc9f34c116b18d7346d060764fc750ddac2ace661234063c73fbb476ae9a12ff1c823
|
data/README.md
CHANGED
@@ -111,6 +111,8 @@ end
|
|
111
111
|
|
112
112
|
## RSpec examples
|
113
113
|
|
114
|
+
### RSpec example manifest (run automatically)
|
115
|
+
|
114
116
|
```ruby
|
115
117
|
# spec/models/unidom_spec.rb
|
116
118
|
require 'unidom/authorization/models_rspec'
|
@@ -121,3 +123,52 @@ require 'unidom/authorization/types_rspec'
|
|
121
123
|
# spec/validators/unidom_spec.rb
|
122
124
|
require 'unidom/authorization/validators_rspec'
|
123
125
|
```
|
126
|
+
|
127
|
+
### RSpec shared examples (to be integrated)
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
# lib/unidom.rb
|
131
|
+
def initialize_unidom
|
132
|
+
|
133
|
+
Unidom::Party::Person.class_eval do
|
134
|
+
include Unidom::Authorization::Concerns::AsAuthorized
|
135
|
+
end
|
136
|
+
|
137
|
+
Unidom::Position::Post.class_eval do
|
138
|
+
include Unidom::Authorization::Concerns::AsAuthorized
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
# spec/rails_helper.rb
|
144
|
+
require 'unidom'
|
145
|
+
initialize_unidom
|
146
|
+
|
147
|
+
# spec/support/unidom_rspec_shared_examples.rb
|
148
|
+
require 'unidom/authorization/rspec_shared_examples'
|
149
|
+
|
150
|
+
# spec/models/unidom/party/person_spec.rb
|
151
|
+
describe Unidom::Party::Person do
|
152
|
+
|
153
|
+
model_attribtues = {
|
154
|
+
name: 'Tim'
|
155
|
+
}
|
156
|
+
|
157
|
+
it_behaves_like 'Unidom::Authorization::Concerns::AsAuthorized', model_attribtues
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
# spec/models/unidom/position/post_spec.rb
|
162
|
+
describe Unidom::Position::Post do
|
163
|
+
|
164
|
+
model_attribtues = {
|
165
|
+
name: 'HR Manager',
|
166
|
+
organization_id: SecureRandom.uuid,
|
167
|
+
organization_type: 'Unidom::Position::Organization::Mock',
|
168
|
+
position_id: SecureRandom.uuid
|
169
|
+
}
|
170
|
+
|
171
|
+
it_behaves_like 'Unidom::Authorization::Concerns::AsAuthorized', model_attribtues
|
172
|
+
|
173
|
+
end
|
174
|
+
```
|
@@ -0,0 +1,17 @@
|
|
1
|
+
shared_examples 'Unidom::Authorization::Concerns::AsAuthorized' do |model_attributes|
|
2
|
+
|
3
|
+
authorizing_1_attribtues = {
|
4
|
+
permission_id: SecureRandom.uuid,
|
5
|
+
authorizer_id: SecureRandom.uuid,
|
6
|
+
authorizer_type: 'Unidom::Authorization::Authorizer::Mock'
|
7
|
+
}
|
8
|
+
|
9
|
+
authorizing_2_attribtues = {
|
10
|
+
permission_id: SecureRandom.uuid,
|
11
|
+
authorizer_id: SecureRandom.uuid,
|
12
|
+
authorizer_type: 'Unidom::Authorization::Authorizer::Mock'
|
13
|
+
}
|
14
|
+
|
15
|
+
it_behaves_like 'has_many', model_attributes, :authorizings, Unidom::Authorization::Authorizing, [ authorizing_1_attribtues, authorizing_2_attribtues ]
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
shared_examples 'Unidom::Authorization::Concerns::AsPermission' do |model_attributes|
|
2
|
+
|
3
|
+
authorizing_1_attribtues = {
|
4
|
+
authorized_id: SecureRandom.uuid,
|
5
|
+
authorized_type: 'Unidom::Authorization::Authorized::Mock',
|
6
|
+
authorizer_id: SecureRandom.uuid,
|
7
|
+
authorizer_type: 'Unidom::Authorization::Authorizer::Mock'
|
8
|
+
}
|
9
|
+
|
10
|
+
authorizing_2_attribtues = {
|
11
|
+
authorized_id: SecureRandom.uuid,
|
12
|
+
authorized_type: 'Unidom::Authorization::Authorized::Mock',
|
13
|
+
authorizer_id: SecureRandom.uuid,
|
14
|
+
authorizer_type: 'Unidom::Authorization::Authorizer::Mock'
|
15
|
+
}
|
16
|
+
|
17
|
+
it_behaves_like 'has_many', model_attributes, :authorizings, Unidom::Authorization::Authorizing, [ authorizing_1_attribtues, authorizing_2_attribtues ]
|
18
|
+
|
19
|
+
end
|
@@ -13,19 +13,20 @@ describe Unidom::Authorization::Permission, type: :model do
|
|
13
13
|
path: 'users'
|
14
14
|
}
|
15
15
|
|
16
|
-
#name_max_length = described_class.columns_hash['name'].limit
|
17
|
-
#path_max_length = described_class.columns_hash['path'].limit
|
18
|
-
|
19
16
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
20
17
|
|
21
|
-
it_behaves_like 'validates text', model_attributes, :name,
|
22
|
-
|
18
|
+
it_behaves_like 'validates text', model_attributes, :name,
|
19
|
+
length: 2..described_class.columns_hash['name'].limit
|
20
|
+
it_behaves_like 'validates text', model_attributes, :path,
|
21
|
+
length: 2..described_class.columns_hash['path'].limit
|
23
22
|
|
24
23
|
it_behaves_like 'scope', :path_is, [
|
25
24
|
{ attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:path] ] },
|
26
25
|
{ attributes_collection: [ model_attributes ], count_diff: 0, args: [ "/#{model_attributes[:path]}" ] },
|
27
26
|
{ attributes_collection: [ model_attributes ], count_diff: 0, args: [ "#{model_attributes[:path]}.html" ] } ]
|
28
27
|
|
28
|
+
it_behaves_like 'Unidom::Authorization::Concerns::AsPermission', model_attributes
|
29
|
+
|
29
30
|
end
|
30
31
|
|
31
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
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
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -53,11 +53,14 @@ files:
|
|
53
53
|
- db/migrate/20000401000000_create_unidom_permissions.rb
|
54
54
|
- db/migrate/20000402000000_create_unidom_authorizings.rb
|
55
55
|
- lib/rspec/models/unidom/authorization/authorizing_spec.rb
|
56
|
+
- lib/rspec/models/unidom/authorization/concerns/as_authorized_shared_examples.rb
|
57
|
+
- lib/rspec/models/unidom/authorization/concerns/as_permission_shared_examples.rb
|
56
58
|
- lib/rspec/models/unidom/authorization/permission_spec.rb
|
57
59
|
- lib/tasks/data_tasks.rake
|
58
60
|
- lib/unidom/authorization.rb
|
59
61
|
- lib/unidom/authorization/engine.rb
|
60
62
|
- lib/unidom/authorization/models_rspec.rb
|
63
|
+
- lib/unidom/authorization/rspec_shared_examples.rb
|
61
64
|
- lib/unidom/authorization/types_rspec.rb
|
62
65
|
- lib/unidom/authorization/validators_rspec.rb
|
63
66
|
- lib/unidom/authorization/version.rb
|