invitational 1.3.2 → 1.4.3

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.
Files changed (36) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +30 -20
  3. data/Rakefile +6 -1
  4. data/app/modules/invitational/invitation_core.rb +1 -1
  5. data/db/migrate/20130528220144_create_invitations.rb +1 -1
  6. data/lib/generators/invitational/install/templates/invitation.rb +1 -1
  7. data/lib/invitational/cancan.rb +2 -0
  8. data/lib/invitational/version.rb +1 -1
  9. data/spec/internal/app/assets/config/manifest.js +0 -0
  10. data/spec/internal/app/models/ability.rb +29 -0
  11. data/spec/internal/app/models/child.rb +5 -0
  12. data/spec/internal/app/models/entity.rb +9 -0
  13. data/spec/internal/app/models/grandparent.rb +9 -0
  14. data/spec/internal/app/models/invitation.rb +10 -0
  15. data/spec/internal/app/models/other_entity.rb +7 -0
  16. data/spec/internal/app/models/system_thing.rb +5 -0
  17. data/spec/internal/app/models/user.rb +6 -0
  18. data/spec/internal/config/database.yml +3 -0
  19. data/spec/internal/config/routes.rb +3 -0
  20. data/spec/internal/db/combustion_test.sqlite +0 -0
  21. data/spec/internal/db/schema.rb +35 -0
  22. data/spec/internal/log/test.log +37683 -0
  23. data/spec/internal/public/favicon.ico +0 -0
  24. data/spec/invitational/models/ability_spec.rb +105 -0
  25. data/spec/invitational/models/entity_spec.rb +51 -0
  26. data/spec/invitational/models/invitation_spec.rb +145 -0
  27. data/spec/invitational/models/user_spec.rb +107 -0
  28. data/spec/invitational/services/checks_for_invitation_spec.rb +91 -0
  29. data/spec/invitational/services/claims_all_invitations_spec.rb +29 -0
  30. data/spec/invitational/services/claims_invitation_spec.rb +49 -0
  31. data/spec/invitational/services/creates_invitation_spec.rb +55 -0
  32. data/spec/invitational/services/creates_system_user_invitation_spec.rb +52 -0
  33. data/spec/invitational/services/creates_uber_admin_invitation_spec.rb +52 -0
  34. data/spec/invitational/services/service_helper.rb +78 -0
  35. data/spec/spec_helper.rb +19 -0
  36. metadata +82 -29
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'invitational/services/service_helper'
3
+
4
+ describe Invitational::ClaimsAllInvitations do
5
+ Given {no_invitations_exist}
6
+
7
+ Given(:user) { setup_user "test@d-i.co" }
8
+ Given(:entity1) { setup_entity "Test entity 1"}
9
+ Given(:entity2) { setup_entity "Test entity 2"}
10
+
11
+ context "with pending invitation for email" do
12
+ Given!(:invitation1) {invite_by_email user.email, entity1, :user}
13
+ Given!(:invitation2) {invite_by_email user.email, entity2, :user}
14
+
15
+ When { Invitational::ClaimsAllInvitations.for user }
16
+
17
+ Then { user.invitations.should include(invitation1) }
18
+ And { user.invitations.should include(invitation2) }
19
+ end
20
+
21
+ context "with pending invitation for another email" do
22
+ Given!(:invitation) {invite_by_email "foo@d-i.co", entity1, :user}
23
+
24
+ When { Invitational::ClaimsAllInvitations.for user }
25
+
26
+ Then { user.invitations.should_not include(invitation) }
27
+ end
28
+
29
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ require 'invitational/services/service_helper'
3
+
4
+ describe Invitational::ClaimsInvitation do
5
+ Given {no_invitations_exist}
6
+
7
+ Given(:user) { setup_user "test@d-i.co" }
8
+ Given(:entity) { setup_entity "Test entity"}
9
+
10
+ context "for unclaimed invitation" do
11
+ context "invitation is to the user's email" do
12
+ Given!(:invitation) {invite_by_email user.email, entity, :admin}
13
+
14
+ When (:result) { Invitational::ClaimsInvitation.for invitation.claim_hash, user }
15
+
16
+ Then { result.should == invitation}
17
+ And { user.invitations.should include(invitation) }
18
+ end
19
+
20
+ context "invitation is to another email" do
21
+ Given!(:invitation) {invite_by_email "foo@d-i.co", entity, :admin}
22
+
23
+ When (:result) { Invitational::ClaimsInvitation.for invitation.claim_hash, user }
24
+
25
+ Then { result.should == invitation}
26
+ And { user.invitations.should include(invitation) }
27
+ end
28
+ end
29
+
30
+ context "for claimed invitation" do
31
+ Given(:user2) {setup_user "foo@bar.com"}
32
+ Given(:invitation) {invite_user user2, entity, :admin}
33
+
34
+ When (:result) { Invitational::ClaimsInvitation.for invitation.claim_hash, user }
35
+
36
+ Then { expect(result).to have_failed(Invitational::AlreadyClaimedError) }
37
+ And { user.invitations.should_not include(invitation) }
38
+ end
39
+
40
+ context "If the invitation hash is bad" do
41
+ Given!(:invitation) {invite_by_email user.email, entity, :admin}
42
+
43
+ When (:result) { Invitational::ClaimsInvitation.for "THIS_IS_A_BAD_HASH", user }
44
+
45
+ Then { expect(result).to have_failed(Invitational::InvitationNotFoundError) }
46
+ And { user.invitations.should_not include(invitation) }
47
+ end
48
+
49
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'invitational/services/service_helper'
3
+
4
+ describe Invitational::CreatesInvitation do
5
+ Given {no_invitations_exist}
6
+
7
+ Given(:entity) { setup_entity "Test Entity"}
8
+
9
+ context "by email" do
10
+
11
+ context "when not already invited" do
12
+ When (:result) {Invitational::CreatesInvitation.for entity, "test@d-i.co", :admin}
13
+
14
+ Then {result.should_not be_nil}
15
+ And {result.invitable.should == entity}
16
+ And {result.email.should == "test@d-i.co"}
17
+ And {result.role.should == :admin}
18
+ And {result.unclaimed?.should be_truthy}
19
+ end
20
+
21
+ context "when already invited" do
22
+ Given {::Invitation.new(invitable: entity, role: :admin, email: 'test@d-i.co').save}
23
+
24
+ When (:result) {Invitational::CreatesInvitation.for entity, "test@d-i.co", :admin}
25
+
26
+ Then { expect(result).to have_failed(Invitational::AlreadyInvitedError) }
27
+ end
28
+
29
+ end
30
+
31
+ context "to be immediately claimed" do
32
+ Given(:user) { setup_user "test@d-i.co" }
33
+
34
+ context "when not already invited" do
35
+ When (:result) {Invitational::CreatesInvitation.for entity, user, :admin}
36
+
37
+ Then {result.should_not be_nil}
38
+ And {result.invitable.should == entity}
39
+ And {result.email.should == "test@d-i.co"}
40
+ And {result.role.should == :admin}
41
+ And {result.claimed?.should be_truthy}
42
+ And {result.user.should == user }
43
+ end
44
+
45
+ context "when already invited" do
46
+ Given {::Invitation.new(invitable: entity, role: :admin, email: 'test@d-i.co', user: user).save}
47
+
48
+ When (:result) {Invitational::CreatesInvitation.for entity, user, :admin}
49
+
50
+ Then { expect(result).to have_failed(Invitational::AlreadyInvitedError) }
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'invitational/services/service_helper'
3
+
4
+ describe Invitational::CreatesSystemUserInvitation do
5
+ Given {no_invitations_exist}
6
+
7
+ context "by email" do
8
+ context "when not already invited" do
9
+ When (:result) {Invitational::CreatesSystemUserInvitation.for "test@d-i.co", :employer}
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 == :employer }
15
+ And {result.unclaimed?.should be_truthy}
16
+ end
17
+
18
+ context "when already invited" do
19
+ Given {::Invitation.new(role: :employer, email: 'test@d-i.co').save}
20
+
21
+ When (:result) {Invitational::CreatesSystemUserInvitation.for "test@d-i.co", :employer}
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::CreatesSystemUserInvitation.for user, :employer}
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 == :employer}
38
+ And {result.claimed?.should be_truthy}
39
+ And {result.user.should == user }
40
+ end
41
+
42
+ context "when already invited" do
43
+ Given {::Invitation.new(role: :employer, email: 'test2@d-i.co', user: user).save}
44
+
45
+ When (:result) {Invitational::CreatesSystemUserInvitation.for user, :employer}
46
+
47
+ Then { expect(result).to have_failed(Invitational::AlreadyInvitedError) }
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -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_truthy}
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_truthy}
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
@@ -0,0 +1,19 @@
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
+ config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
18
+ end
19
+
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invitational
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.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-01-06 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cancancan
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
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: '0'
40
+ version: '1.13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: capybara
56
+ name: combustion
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.2
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 2.0.2
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: combustion
70
+ name: capybara
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -84,44 +84,44 @@ dependencies:
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 2.12.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.12.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 2.12.0
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 2.12.0
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec-given
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 2.3.0
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 2.3.0
124
+ version: '0'
125
125
  description: Solution that eliminates the tight coupling between user identity/authentication
126
126
  and application functional authorization
127
127
  email:
@@ -156,6 +156,33 @@ files:
156
156
  - lib/invitational/exceptions.rb
157
157
  - lib/invitational/version.rb
158
158
  - lib/tasks/invitational_tasks.rake
159
+ - spec/internal/app/assets/config/manifest.js
160
+ - spec/internal/app/models/ability.rb
161
+ - spec/internal/app/models/child.rb
162
+ - spec/internal/app/models/entity.rb
163
+ - spec/internal/app/models/grandparent.rb
164
+ - spec/internal/app/models/invitation.rb
165
+ - spec/internal/app/models/other_entity.rb
166
+ - spec/internal/app/models/system_thing.rb
167
+ - spec/internal/app/models/user.rb
168
+ - spec/internal/config/database.yml
169
+ - spec/internal/config/routes.rb
170
+ - spec/internal/db/combustion_test.sqlite
171
+ - spec/internal/db/schema.rb
172
+ - spec/internal/log/test.log
173
+ - spec/internal/public/favicon.ico
174
+ - spec/invitational/models/ability_spec.rb
175
+ - spec/invitational/models/entity_spec.rb
176
+ - spec/invitational/models/invitation_spec.rb
177
+ - spec/invitational/models/user_spec.rb
178
+ - spec/invitational/services/checks_for_invitation_spec.rb
179
+ - spec/invitational/services/claims_all_invitations_spec.rb
180
+ - spec/invitational/services/claims_invitation_spec.rb
181
+ - spec/invitational/services/creates_invitation_spec.rb
182
+ - spec/invitational/services/creates_system_user_invitation_spec.rb
183
+ - spec/invitational/services/creates_uber_admin_invitation_spec.rb
184
+ - spec/invitational/services/service_helper.rb
185
+ - spec/spec_helper.rb
159
186
  homepage: http://github.com/the-refinery/invitational
160
187
  licenses: []
161
188
  metadata: {}
@@ -174,10 +201,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
201
  - !ruby/object:Gem::Version
175
202
  version: '0'
176
203
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.4.8
204
+ rubygems_version: 3.1.4
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/spec_helper.rb
211
+ - spec/internal/app/models/entity.rb
212
+ - spec/internal/app/models/system_thing.rb
213
+ - spec/internal/app/models/other_entity.rb
214
+ - spec/internal/app/models/child.rb
215
+ - spec/internal/app/models/ability.rb
216
+ - spec/internal/app/models/user.rb
217
+ - spec/internal/app/models/grandparent.rb
218
+ - spec/internal/app/models/invitation.rb
219
+ - spec/internal/app/assets/config/manifest.js
220
+ - spec/internal/log/test.log
221
+ - spec/internal/config/routes.rb
222
+ - spec/internal/config/database.yml
223
+ - spec/internal/public/favicon.ico
224
+ - spec/internal/db/combustion_test.sqlite
225
+ - spec/internal/db/schema.rb
226
+ - spec/invitational/models/entity_spec.rb
227
+ - spec/invitational/models/invitation_spec.rb
228
+ - spec/invitational/models/ability_spec.rb
229
+ - spec/invitational/models/user_spec.rb
230
+ - spec/invitational/services/claims_all_invitations_spec.rb
231
+ - spec/invitational/services/creates_uber_admin_invitation_spec.rb
232
+ - spec/invitational/services/creates_system_user_invitation_spec.rb
233
+ - spec/invitational/services/checks_for_invitation_spec.rb
234
+ - spec/invitational/services/service_helper.rb
235
+ - spec/invitational/services/creates_invitation_spec.rb
236
+ - spec/invitational/services/claims_invitation_spec.rb