Skip to content

Commit 4ecfca9

Browse files
Updated Test Cases
1 parent 47ae52d commit 4ecfca9

File tree

9 files changed

+78
-12
lines changed

9 files changed

+78
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ role = Role.create({
109109
arguments: Takes a list of permission ids or permission collection
110110
2. attach_permission: Adds a permission to a role
111111
arguments: Takes permission model object or permission id
112-
3. detatch_permission: Removes a permission from the role
112+
3. detach_permission: Removes a permission from the role
113113
arguments: Takes permission model object or permission id
114114
"""
115115
```

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ role = Role.create({
109109
arguments: Takes a list of permission ids or permission collection
110110
2. attach_permission: Adds a permission to a role
111111
arguments: Takes permission model object or permission id
112-
3. detatch_permission: Removes a permission from the role
112+
3. detach_permission: Removes a permission from the role
113113
arguments: Takes permission model object or permission id
114114
"""
115115
```

masonite.sqlite3

8 KB
Binary file not shown.

src/masonite_permission/models/permission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def attach_role(self, role):
4242
if not exists:
4343
self.attach("roles", role)
4444

45-
def detatch_role(self, role):
45+
def detach_role(self, role):
4646
"""Detach a role from a permission
4747
4848
Arguments:

src/masonite_permission/models/role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def attach_permission(self, permission):
4242
if not exists:
4343
self.attach("permissions", permission)
4444

45-
def detatch_permission(self, permission):
45+
def detach_permission(self, permission):
4646
"""Detach a permission from a role
4747
4848
Arguments:

tests/integrations/app/controllers/WelcomeController.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def test(self):
7171
Methods:
7272
role.sync_permissions([permission])
7373
role.attach_permission(permission)
74-
role.detatch_permission(permission)
74+
role.detach_permission(permission)
7575
"""
7676

7777
"""Permission related methods
7878
7979
Methods:
8080
permission.sync_roles([role])
8181
permission.attach_role(role)
82-
permission.detatch_role(role)
82+
permission.detach_role(role)
8383
"""
8484

8585
"""User related methods

tests/unit/test_package.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/unit/test_permission.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from masonite.tests import TestCase
2+
from src.masonite_permission.models import Permission
3+
4+
5+
class TestPermission(TestCase):
6+
def test_permission_created(self):
7+
Permission.create(
8+
{
9+
"name": "Create Post",
10+
"slug": "create-post",
11+
}
12+
)
13+
self.assertDatabaseHas(
14+
"permissions",
15+
{
16+
"slug": "create-post",
17+
},
18+
)
19+
20+
def test_permission_updated(self):
21+
permission = Permission.create(
22+
{
23+
"name": "Create Post",
24+
"slug": "create-post",
25+
}
26+
)
27+
28+
permission.update(
29+
{
30+
"name": "Create Post (Updated)",
31+
}
32+
)
33+
34+
self.assertDatabaseHas(
35+
"permissions",
36+
{
37+
"name": "Create Post (Updated)",
38+
},
39+
)

tests/unit/test_role.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from masonite.tests import TestCase
2+
from src.masonite_permission.models import Role
3+
4+
5+
class TestRole(TestCase):
6+
def test_role_created(self):
7+
Role.create(
8+
{
9+
"name": "Admin",
10+
"slug": "admin",
11+
}
12+
)
13+
self.assertDatabaseHas(
14+
"roles",
15+
{
16+
"slug": "admin",
17+
},
18+
)
19+
20+
def test_role_updated(self):
21+
role = Role.first()
22+
role.update(
23+
{
24+
"name": "Admin (Updated)",
25+
}
26+
)
27+
28+
self.assertDatabaseHas(
29+
"roles",
30+
{
31+
"name": "Admin (Updated)",
32+
},
33+
)

0 commit comments

Comments
 (0)