invitational 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/Rakefile +6 -1
  4. data/lib/invitational/version.rb +1 -1
  5. data/spec/internal/app/models/ability.rb +28 -0
  6. data/spec/internal/app/models/child.rb +5 -0
  7. data/spec/internal/app/models/entity.rb +9 -0
  8. data/spec/internal/app/models/grandparent.rb +9 -0
  9. data/spec/internal/app/models/invitation.rb +10 -0
  10. data/spec/internal/app/models/other_entity.rb +7 -0
  11. data/spec/internal/app/models/system_thing.rb +5 -0
  12. data/spec/internal/app/models/user.rb +6 -0
  13. data/spec/internal/config/database.yml +3 -0
  14. data/spec/internal/config/routes.rb +3 -0
  15. data/spec/internal/db/combustion_test.sqlite +0 -0
  16. data/spec/internal/db/schema.rb +35 -0
  17. data/spec/internal/log/test.log +5958 -0
  18. data/spec/internal/public/favicon.ico +0 -0
  19. data/spec/invitational/models/ability_spec.rb +94 -0
  20. data/spec/invitational/models/entity_spec.rb +51 -0
  21. data/spec/invitational/models/invitation_spec.rb +145 -0
  22. data/spec/invitational/models/user_spec.rb +107 -0
  23. data/spec/invitational/services/checks_for_invitation_spec.rb +91 -0
  24. data/spec/invitational/services/claims_all_invitations_spec.rb +29 -0
  25. data/spec/invitational/services/claims_invitation_spec.rb +49 -0
  26. data/spec/invitational/services/creates_invitation_spec.rb +55 -0
  27. data/spec/invitational/services/creates_system_user_invitation_spec.rb +52 -0
  28. data/spec/invitational/services/creates_uber_admin_invitation_spec.rb +52 -0
  29. data/spec/invitational/services/service_helper.rb +78 -0
  30. data/spec/spec_helper.rb +18 -0
  31. metadata +60 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa0308853121b61e0485e83fabfe5bec0fcca305
4
- data.tar.gz: 89208f4dd480f07394e1ed7b6f25c99dc5d055d2
3
+ metadata.gz: e0889fe8e1a1dc03eb4e916f7dbc5d017ef42ebf
4
+ data.tar.gz: 14411cf23d8c69ab0a4d66679045268a7c871964
5
5
  SHA512:
6
- metadata.gz: 299d2c4a4931fc17593d46fdc3aea3bf15e5f8fa76187e2b32ed104b52efe6e47c3ba2bb432f0911b334b3eacef54d9f918016a3026356d6bb7a03521b8d4f1c
7
- data.tar.gz: 3088c2e22b59d5853a34dd83debfd46fb3b1cb7911d0d29a41a9cfd56270ef47491c72b57507945bfb0b70e59885748e6c563516c12e42e82d34cf0c27784717
6
+ metadata.gz: cfaf00ad35f5d9052b2bb20fe2fee2833ce534ec8d97823d2bb8d120e45d8453116159a7be958baf74857d75b666e5806c775f8bef13d55c4b1ec8be67e9cdb2
7
+ data.tar.gz: cfe17e74133867dcd025ea1d00dc004ce2bda11c0ad09ccc632aee1b15bfd8a3a98f0c948734aaa1198955000f67700b690556119cc8f7bbcc015fa299a85867
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/invitational.png)](http://badge.fury.io/rb/invitational)
2
+ [![Build Status](https://travis-ci.org/the-refinery/invitational.svg?branch=master)](https://travis-ci.org/the-refinery/invitational)
2
3
 
3
4
  #Overview
4
5
 
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ rescue LoadError
13
13
  end
14
14
 
15
15
  require "bundler/gem_tasks"
16
+ require 'rspec/core/rake_task'
16
17
 
17
18
  RDoc::Task.new(:rdoc) do |rdoc|
18
19
  rdoc.rdoc_dir = 'rdoc'
@@ -34,5 +35,9 @@ Rake::TestTask.new(:test) do |t|
34
35
  t.verbose = false
35
36
  end
36
37
 
38
+ RSpec::Core::RakeTask.new(:spec) do |t|
39
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
40
+ t.rspec_opts = '--format documentation'
41
+ end
37
42
 
38
- task :default => :test
43
+ task :default => :spec
@@ -1,3 +1,3 @@
1
1
  module Invitational
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -0,0 +1,28 @@
1
+ require 'invitational/cancan'
2
+
3
+ class Ability
4
+ include CanCan::Ability
5
+ include Invitational::CanCan::Ability
6
+
7
+ attr_reader :role_mappings, :user
8
+
9
+ def initialize(user)
10
+
11
+ @role_mappings = {}
12
+ @user = user
13
+
14
+ can :manage, Entity, roles: [:admin]
15
+ can :read, Entity, roles: [:user]
16
+
17
+ can :read, Child
18
+
19
+ can :manage, Child, roles: [:admin, attribute_roles(:entity, [:admin, :user]) ]
20
+ can :manage, Child, roles: [attribute_roles([:entity, :grandparent], [:admin]) ]
21
+
22
+ can :manage, OtherEntity, roles: [:uberadmin]
23
+
24
+ can :manage, SystemThing, roles: [system_roles(:employer)]
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,5 @@
1
+ class Child < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+
4
+ belongs_to :entity
5
+ end
@@ -0,0 +1,9 @@
1
+ class Entity < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+ include Invitational::AcceptsInvitationAs
4
+
5
+ belongs_to :grandparent
6
+ has_many :children
7
+
8
+ accepts_invitation_as :admin, :user
9
+ end
@@ -0,0 +1,9 @@
1
+ class Grandparent < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+ include Invitational::AcceptsInvitationAs
4
+
5
+ has_many :entities
6
+
7
+ accepts_invitation_as :admin
8
+ end
9
+
@@ -0,0 +1,10 @@
1
+ class Invitation < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+ include Invitational::InvitationCore
4
+
5
+ belongs_to :user
6
+
7
+ accepts_system_roles_as :employer, :consultant
8
+
9
+
10
+ end
@@ -0,0 +1,7 @@
1
+ class OtherEntity < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+ include Invitational::AcceptsInvitationAs
4
+
5
+ accepts_invitation_as :other_role
6
+ end
7
+
@@ -0,0 +1,5 @@
1
+ class SystemThing < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+ include Invitational::AcceptsInvitationAs
4
+
5
+ end
@@ -0,0 +1,6 @@
1
+ class User < ActiveRecord::Base
2
+ include ActiveModel::ForbiddenAttributesProtection
3
+ include Invitational::InvitedTo
4
+
5
+ invited_to :entity, :child
6
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,35 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ create_table :users, force: true do |t|
4
+ t.string :email
5
+ t.timestamps
6
+ end
7
+
8
+ create_table :grandparents, force: true do |t|
9
+ t.string :name
10
+ t.timestamps
11
+ end
12
+
13
+ create_table :entities, force: true do |t|
14
+ t.string :name
15
+ t.integer :grandparent_id
16
+ t.timestamps
17
+ end
18
+
19
+ create_table :children, force: true do |t|
20
+ t.string :name
21
+ t.integer :entity_id
22
+ t.timestamps
23
+ end
24
+
25
+ create_table :other_entities, force: true do |t|
26
+ t.string :name
27
+ t.timestamps
28
+ end
29
+
30
+ create_table :system_things, force: true do |t|
31
+ t.string :name
32
+ t.timestamps
33
+ end
34
+
35
+ end