righter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +28 -0
- data/app/models/righter_right.rb +75 -0
- data/app/models/righter_rights_righter_role.rb +4 -0
- data/app/models/righter_role.rb +82 -0
- data/app/models/righter_role_grant.rb +7 -0
- data/app/models/righter_roles_user.rb +2 -0
- data/db/migrate/20150910000000_create_righter_rights.rb +21 -0
- data/db/migrate/20150910000001_create_righter_roles.rb +20 -0
- data/db/migrate/20150910000002_righter_roles_righter_access_rights.rb +14 -0
- data/db/migrate/20150910000003_create_righter_roles_users.rb +14 -0
- data/lib/init.rb +1 -0
- data/lib/injections/righter_for_application_controller.rb +31 -0
- data/lib/injections/righter_for_resource.rb +110 -0
- data/lib/injections/righter_for_user.rb +186 -0
- data/lib/righter.rb +9 -0
- data/lib/righter/version.rb +3 -0
- data/lib/righter_error.rb +8 -0
- data/lib/tasks/righter_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +11 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/controllers/doors_controller.rb +23 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/door.rb +10 -0
- data/test/dummy/app/models/house.rb +7 -0
- data/test/dummy/app/models/player.rb +7 -0
- data/test/dummy/app/models/righter_roles_player.rb +2 -0
- data/test/dummy/app/models/user.rb +4 -0
- data/test/dummy/app/views/doors/show.html.erb +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +8 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20150911000000_create_players.rb +18 -0
- data/test/dummy/db/migrate/20150911000002_create_users_table.rb +15 -0
- data/test/dummy/db/migrate/20150911000003_create_doors.rb +14 -0
- data/test/dummy/db/migrate/20150911000004_create_houses.rb +13 -0
- data/test/dummy/db/migrate/20150911000005_add_house_reference_to_doors.rb +9 -0
- data/test/dummy/db/schema.rb +90 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +35 -0
- data/test/dummy/log/test.log +117973 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/0-mgT1BVDUIUlj7bJxvh7Ud3uSbC1DJf0Ok7Ehgieds.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/9jPCqzZvmeFf31Rz8y3OEo8OQXEHVcwmLgkx0tXs-o8.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/VTeG_7OBrkPzWFSh3MrTa0NSl2wOuJfTJ-XP7JqBG2w.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/a2CYO1s9hME5T1pntwZMB7J6dYjS0zCmDxw_7zX1T14.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/d71F8V8hdfF1jAttqkXKdizYR9PcM_zuKn_Lj_73gfE.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hCBjLjjeqhUCs4tdwCYlGcFA4xohMwurjmZx6OY1a7g.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/ifgPguUzTOUeqB0zW0GV8DL6HEvPpakIWAzNPVuCGW0.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/j8yaH5wiyIN5a2xePYA_lQm39RgOQh27UiF5A7i6b28.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/o2kqwqoUQ3gkgncZO1IWdVRzFD0wCSQ-HyL62cINFOU.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pIwp2wi1sfaJlhiwzzvyyV0hKOihhYkP6709hRtpHxg.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pQIgTfLmEPykNamzxdqBww21SMT7YlZlZGy6hgQ6eVE.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/td9wUl9SLRnSSgE2ZK_VqCzLxTkFiCW50KkOhE916Wo.cache +1 -0
- data/test/factories/doors.rb +10 -0
- data/test/factories/houses.rb +7 -0
- data/test/factories/players.rb +6 -0
- data/test/factories/righter_rights.rb +11 -0
- data/test/factories/righter_roles.rb +9 -0
- data/test/factories/users.rb +9 -0
- data/test/fixtures/players.yml +6 -0
- data/test/fixtures/righter_rights.yml +21 -0
- data/test/fixtures/righter_roles.yml +29 -0
- data/test/fixtures/users.yml +27 -0
- data/test/functional/doors_controller_test.rb +71 -0
- data/test/righter_test.rb +9 -0
- data/test/test_helper.rb +54 -0
- data/test/unit/righter_for_resource_test.rb +137 -0
- data/test/unit/righter_right_test.rb +74 -0
- data/test/unit/righter_role_test.rb +197 -0
- data/test/unit/righter_user_test.rb +271 -0
- metadata +271 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
"%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
|
@@ -0,0 +1 @@
|
|
1
|
+
I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=885962cb9ca2137c1c8d6505d5ce631f919ec693f1439c629daa04f5573e2112:ET
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
"%Ѱč@�����6H�uZoX�Z�gbh0W��V
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
"%�W\�yho9S���ƫ˥��)|�~���(���
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=cddb5f7477b3bebb0b2950976cdfc8e31d6d4767de7efd0a752ffa3f2342db26:ET
|
@@ -0,0 +1,2 @@
|
|
1
|
+
[o:Set:
|
2
|
+
@hash{I"environment-version:ETTI"environment-paths;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI")file-digest://app/assets/javascripts;TT
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
I"�app/assets/javascripts/application.js?type=application/javascript&id=8a1d1e50cdd2800d11241aaa9838a4f558bbff72cae1c4939101114f2b1f68c6:ET
|
@@ -0,0 +1 @@
|
|
1
|
+
I"}app/assets/stylesheets/application.css?type=text/css&id=025b8080d22a0d3c66a91a07c1d953ae3f558271f5992dcea9a300738f43103e:ET
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :righter_right do
|
5
|
+
name 'manage_doors'
|
6
|
+
human_name 'Any actions done in doors_controller'
|
7
|
+
controller 'doors'
|
8
|
+
actions ['*']
|
9
|
+
hidden false
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :user do
|
5
|
+
login { "user_#{id}" }
|
6
|
+
encrypted_password '$2a$10$DC7veLNgRP3J4zFT7nPFfuMAzHau.0/76iK8P9U8DiufyT3R0thuO'
|
7
|
+
password_salt '$2a$10$DC7veLNgRP3J4zFT7nPFfu'
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
kill:
|
2
|
+
id: 1
|
3
|
+
name: kill
|
4
|
+
|
5
|
+
vamp:
|
6
|
+
id: 2
|
7
|
+
name: vamp
|
8
|
+
|
9
|
+
access_rights:
|
10
|
+
id: 3
|
11
|
+
name: manage_rights
|
12
|
+
controller: righter_rights
|
13
|
+
actions: ['*']
|
14
|
+
|
15
|
+
access_roles:
|
16
|
+
id: 4
|
17
|
+
name: manage_roles
|
18
|
+
controller: righter_roles
|
19
|
+
actions: ['*']
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
secret_agent:
|
2
|
+
id: 1
|
3
|
+
name: secret_agent
|
4
|
+
human_name: 1
|
5
|
+
|
6
|
+
bond_girl:
|
7
|
+
id: 2
|
8
|
+
name: bond_girl
|
9
|
+
human_name: 2
|
10
|
+
|
11
|
+
one:
|
12
|
+
id: 3
|
13
|
+
name: one
|
14
|
+
human_name: 3
|
15
|
+
|
16
|
+
two:
|
17
|
+
id: 4
|
18
|
+
name: two
|
19
|
+
human_name: 4
|
20
|
+
|
21
|
+
three:
|
22
|
+
id: 5
|
23
|
+
name: three
|
24
|
+
human_name: 5
|
25
|
+
|
26
|
+
manage_roles_and_rights:
|
27
|
+
id: 6
|
28
|
+
name: manage_roles_and_rights
|
29
|
+
human_name: Manage Roles and Rights
|
@@ -0,0 +1,27 @@
|
|
1
|
+
admin:
|
2
|
+
id: 4
|
3
|
+
login: admin
|
4
|
+
encrypted_password: $2a$10$DC7veLNgRP3J4zFT7nPFfuMAzHau.0/76iK8P9U8DiufyT3R0thuO
|
5
|
+
password_salt: $2a$10$DC7veLNgRP3J4zFT7nPFfu
|
6
|
+
|
7
|
+
admin2:
|
8
|
+
id: 14
|
9
|
+
login: admin2
|
10
|
+
encrypted_password: $2a$10$DC7veLNgRP3J4zFT7nPFfuMAzHau.0/76iK8P9U8DiufyT3R0thuO
|
11
|
+
password_salt: $2a$10$DC7veLNgRP3J4zFT7nPFfu
|
12
|
+
|
13
|
+
template:
|
14
|
+
id: 20
|
15
|
+
login: template
|
16
|
+
|
17
|
+
one:
|
18
|
+
id: 21
|
19
|
+
login: smth
|
20
|
+
|
21
|
+
two:
|
22
|
+
id: 22
|
23
|
+
login: smth2
|
24
|
+
|
25
|
+
three:
|
26
|
+
id: 23
|
27
|
+
login: smth3
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DoorsControllerTest < ActionController::TestCase
|
4
|
+
def setup
|
5
|
+
@user = FactoryGirl.create(:user, login: 'user')
|
6
|
+
@admin = FactoryGirl.create(:user, login: 'admin')
|
7
|
+
|
8
|
+
@controller_role = FactoryGirl.create(:righter_role, name: 'doors_controller')
|
9
|
+
@controller_right = FactoryGirl.create(:righter_right, name: 'all_door_actions', controller: 'doors', actions: ['*'])
|
10
|
+
@controller_role.add_right(@controller_right)
|
11
|
+
|
12
|
+
@admin_role = FactoryGirl.create(:righter_role, name: 'admin')
|
13
|
+
@user_role = FactoryGirl.create(:righter_role, name: 'user')
|
14
|
+
|
15
|
+
@admin.add_role(@controller_role)
|
16
|
+
@admin.add_role(@admin_role)
|
17
|
+
|
18
|
+
@user.add_role(@controller_role)
|
19
|
+
@user.add_role(@user_role)
|
20
|
+
|
21
|
+
@admin.reload
|
22
|
+
@user.reload
|
23
|
+
|
24
|
+
sign_out
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'signed_out user cannot access the controller - enforced by controller access rights' do
|
28
|
+
door = FactoryGirl.create(:door)
|
29
|
+
sign_out
|
30
|
+
assert_raises(RighterNoUserError) do
|
31
|
+
get :show, id: door.id
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'signed in user with authorization controller actions will be examined to access resources' do
|
36
|
+
door = FactoryGirl.create(:door)
|
37
|
+
|
38
|
+
# @user is authorized to:
|
39
|
+
# - access the controller
|
40
|
+
# - open the door
|
41
|
+
sign_in(@user)
|
42
|
+
|
43
|
+
assert_nothing_raised do
|
44
|
+
get :show, id: door.id
|
45
|
+
get :open, id: door.id
|
46
|
+
end
|
47
|
+
assert_raises(RighterError) do
|
48
|
+
get :change, id: door.id
|
49
|
+
end
|
50
|
+
|
51
|
+
# @admin is authorized to:
|
52
|
+
# - access the controller
|
53
|
+
# - open the door
|
54
|
+
# - change the door
|
55
|
+
sign_in(@admin)
|
56
|
+
|
57
|
+
assert_nothing_raised do
|
58
|
+
get :show, id: door.id
|
59
|
+
get :open, id: door.id
|
60
|
+
get :change, id: door.id
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
test 'signed in user with authorization can access simple controller action' do
|
65
|
+
door = FactoryGirl.create(:door)
|
66
|
+
sign_in(@user) # authorized user
|
67
|
+
assert_nothing_raised do
|
68
|
+
get :show, id: door.id
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|