invitational 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +6 -1
- data/lib/invitational/version.rb +1 -1
- data/spec/internal/app/models/ability.rb +28 -0
- data/spec/internal/app/models/child.rb +5 -0
- data/spec/internal/app/models/entity.rb +9 -0
- data/spec/internal/app/models/grandparent.rb +9 -0
- data/spec/internal/app/models/invitation.rb +10 -0
- data/spec/internal/app/models/other_entity.rb +7 -0
- data/spec/internal/app/models/system_thing.rb +5 -0
- data/spec/internal/app/models/user.rb +6 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +35 -0
- data/spec/internal/log/test.log +5958 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/invitational/models/ability_spec.rb +94 -0
- data/spec/invitational/models/entity_spec.rb +51 -0
- data/spec/invitational/models/invitation_spec.rb +145 -0
- data/spec/invitational/models/user_spec.rb +107 -0
- data/spec/invitational/services/checks_for_invitation_spec.rb +91 -0
- data/spec/invitational/services/claims_all_invitations_spec.rb +29 -0
- data/spec/invitational/services/claims_invitation_spec.rb +49 -0
- data/spec/invitational/services/creates_invitation_spec.rb +55 -0
- data/spec/invitational/services/creates_system_user_invitation_spec.rb +52 -0
- data/spec/invitational/services/creates_uber_admin_invitation_spec.rb +52 -0
- data/spec/invitational/services/service_helper.rb +78 -0
- data/spec/spec_helper.rb +18 -0
- metadata +60 -8
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'invitational/services/service_helper'
|
3
|
+
|
4
|
+
describe Invitational::CreatesUberAdminInvitation do
|
5
|
+
Given {no_invitations_exist}
|
6
|
+
|
7
|
+
context "by email" do
|
8
|
+
context "when not already invited" do
|
9
|
+
When (:result) {Invitational::CreatesUberAdminInvitation.for "test@d-i.co"}
|
10
|
+
|
11
|
+
Then {result.should_not be_nil}
|
12
|
+
And {result.invitable.should be_nil}
|
13
|
+
And {result.email.should == "test@d-i.co"}
|
14
|
+
And {result.role.should == :uberadmin }
|
15
|
+
And {result.unclaimed?.should be_true}
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when already invited" do
|
19
|
+
Given {::Invitation.new(role: :uberadmin, email: 'test@d-i.co').save}
|
20
|
+
|
21
|
+
When (:result) {Invitational::CreatesUberAdminInvitation.for "test@d-i.co"}
|
22
|
+
|
23
|
+
Then { expect(result).to have_failed(Invitational::AlreadyInvitedError) }
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "to be immediately claimed" do
|
29
|
+
Given(:user) { setup_user "test2@d-i.co" }
|
30
|
+
|
31
|
+
context "when not already invited" do
|
32
|
+
When (:result) {Invitational::CreatesUberAdminInvitation.for user}
|
33
|
+
|
34
|
+
Then {result.should_not be_nil}
|
35
|
+
And {result.invitable.should be_nil}
|
36
|
+
And {result.email.should == "test2@d-i.co"}
|
37
|
+
And {result.role.should == :uberadmin}
|
38
|
+
And {result.claimed?.should be_true}
|
39
|
+
And {result.user.should == user }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when already invited" do
|
43
|
+
Given {::Invitation.new(role: :uberadmin, email: 'test2@d-i.co', user: user).save}
|
44
|
+
|
45
|
+
When (:result) {Invitational::CreatesUberAdminInvitation.for user}
|
46
|
+
|
47
|
+
Then { expect(result).to have_failed(Invitational::AlreadyInvitedError) }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
def setup_user email
|
2
|
+
user = User.new(email: email)
|
3
|
+
user.save
|
4
|
+
|
5
|
+
user
|
6
|
+
end
|
7
|
+
|
8
|
+
def setup_entity name
|
9
|
+
entity = Entity.new(name: name)
|
10
|
+
entity.save
|
11
|
+
|
12
|
+
entity
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup_child name, entity
|
16
|
+
child = Child.new(name: name)
|
17
|
+
child.save
|
18
|
+
|
19
|
+
entity.children << child
|
20
|
+
|
21
|
+
child
|
22
|
+
end
|
23
|
+
|
24
|
+
def setup_grandparent name, entity
|
25
|
+
grandparent = Grandparent.new(name: name)
|
26
|
+
grandparent.save
|
27
|
+
|
28
|
+
grandparent.entities << entity
|
29
|
+
|
30
|
+
|
31
|
+
grandparent
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_other_entity name
|
35
|
+
other_entity = OtherEntity.new(name: name)
|
36
|
+
other_entity.save
|
37
|
+
|
38
|
+
other_entity
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_system_thing name
|
42
|
+
system_thing = SystemThing.new(name: name)
|
43
|
+
system_thing.save
|
44
|
+
|
45
|
+
system_thing
|
46
|
+
end
|
47
|
+
|
48
|
+
def invite_by_email email, entity, role
|
49
|
+
invitation = Invitation.new(email: email, invitable: entity, role: role)
|
50
|
+
invitation.save
|
51
|
+
|
52
|
+
invitation
|
53
|
+
end
|
54
|
+
|
55
|
+
def invite_user user, entity, role
|
56
|
+
invitation = Invitation.new(email: user.email, invitable: entity, role: role, user: user, date_accepted: DateTime.now)
|
57
|
+
invitation.save
|
58
|
+
|
59
|
+
invitation
|
60
|
+
end
|
61
|
+
|
62
|
+
def invite_uber_admin user
|
63
|
+
invitation = Invitation.new(email: user.email, role: :uberadmin, user: user)
|
64
|
+
invitation.save
|
65
|
+
|
66
|
+
invitation
|
67
|
+
end
|
68
|
+
|
69
|
+
def invite_system_role user, role
|
70
|
+
invitation = Invitation.new(email: user.email, role: role, user: user)
|
71
|
+
invitation.save
|
72
|
+
|
73
|
+
invitation
|
74
|
+
end
|
75
|
+
|
76
|
+
def no_invitations_exist
|
77
|
+
Invitation.destroy_all
|
78
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'combustion'
|
5
|
+
require 'capybara/rspec'
|
6
|
+
|
7
|
+
require 'invitational'
|
8
|
+
|
9
|
+
Combustion.initialize! :active_record, :action_controller, :action_view, :sprockets
|
10
|
+
|
11
|
+
require 'rspec/rails'
|
12
|
+
require 'rspec-given'
|
13
|
+
require 'capybara/rails'
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.use_transactional_fixtures = true
|
17
|
+
end
|
18
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invitational
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Goerlich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: cancancan
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.13'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +156,32 @@ files:
|
|
156
156
|
- lib/invitational/exceptions.rb
|
157
157
|
- lib/invitational/version.rb
|
158
158
|
- lib/tasks/invitational_tasks.rake
|
159
|
+
- spec/internal/app/models/ability.rb
|
160
|
+
- spec/internal/app/models/child.rb
|
161
|
+
- spec/internal/app/models/entity.rb
|
162
|
+
- spec/internal/app/models/grandparent.rb
|
163
|
+
- spec/internal/app/models/invitation.rb
|
164
|
+
- spec/internal/app/models/other_entity.rb
|
165
|
+
- spec/internal/app/models/system_thing.rb
|
166
|
+
- spec/internal/app/models/user.rb
|
167
|
+
- spec/internal/config/database.yml
|
168
|
+
- spec/internal/config/routes.rb
|
169
|
+
- spec/internal/db/combustion_test.sqlite
|
170
|
+
- spec/internal/db/schema.rb
|
171
|
+
- spec/internal/log/test.log
|
172
|
+
- spec/internal/public/favicon.ico
|
173
|
+
- spec/invitational/models/ability_spec.rb
|
174
|
+
- spec/invitational/models/entity_spec.rb
|
175
|
+
- spec/invitational/models/invitation_spec.rb
|
176
|
+
- spec/invitational/models/user_spec.rb
|
177
|
+
- spec/invitational/services/checks_for_invitation_spec.rb
|
178
|
+
- spec/invitational/services/claims_all_invitations_spec.rb
|
179
|
+
- spec/invitational/services/claims_invitation_spec.rb
|
180
|
+
- spec/invitational/services/creates_invitation_spec.rb
|
181
|
+
- spec/invitational/services/creates_system_user_invitation_spec.rb
|
182
|
+
- spec/invitational/services/creates_uber_admin_invitation_spec.rb
|
183
|
+
- spec/invitational/services/service_helper.rb
|
184
|
+
- spec/spec_helper.rb
|
159
185
|
homepage: http://github.com/the-refinery/invitational
|
160
186
|
licenses: []
|
161
187
|
metadata: {}
|
@@ -175,9 +201,35 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
201
|
version: '0'
|
176
202
|
requirements: []
|
177
203
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.2.2
|
179
205
|
signing_key:
|
180
206
|
specification_version: 4
|
181
207
|
summary: Solution that eliminates the tight coupling between user identity/authentication
|
182
208
|
and application functional authorization
|
183
|
-
test_files:
|
209
|
+
test_files:
|
210
|
+
- spec/internal/log/test.log
|
211
|
+
- spec/internal/config/database.yml
|
212
|
+
- spec/internal/config/routes.rb
|
213
|
+
- spec/internal/db/schema.rb
|
214
|
+
- spec/internal/db/combustion_test.sqlite
|
215
|
+
- spec/internal/public/favicon.ico
|
216
|
+
- spec/internal/app/models/child.rb
|
217
|
+
- spec/internal/app/models/user.rb
|
218
|
+
- spec/internal/app/models/invitation.rb
|
219
|
+
- spec/internal/app/models/system_thing.rb
|
220
|
+
- spec/internal/app/models/grandparent.rb
|
221
|
+
- spec/internal/app/models/entity.rb
|
222
|
+
- spec/internal/app/models/ability.rb
|
223
|
+
- spec/internal/app/models/other_entity.rb
|
224
|
+
- spec/invitational/models/ability_spec.rb
|
225
|
+
- spec/invitational/models/user_spec.rb
|
226
|
+
- spec/invitational/models/invitation_spec.rb
|
227
|
+
- spec/invitational/models/entity_spec.rb
|
228
|
+
- spec/invitational/services/service_helper.rb
|
229
|
+
- spec/invitational/services/creates_invitation_spec.rb
|
230
|
+
- spec/invitational/services/creates_uber_admin_invitation_spec.rb
|
231
|
+
- spec/invitational/services/claims_invitation_spec.rb
|
232
|
+
- spec/invitational/services/checks_for_invitation_spec.rb
|
233
|
+
- spec/invitational/services/creates_system_user_invitation_spec.rb
|
234
|
+
- spec/invitational/services/claims_all_invitations_spec.rb
|
235
|
+
- spec/spec_helper.rb
|