arcadex 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/migrate/20141020173616_add_max_uses_to_arcadex_tokens.rb +5 -0
- data/lib/arcadex/authentication.rb +45 -51
- data/lib/arcadex/create.rb +2 -1
- data/lib/arcadex/header.rb +8 -21
- data/lib/arcadex/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +2 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +15 -0
- data/test/dummy/log/test.log +35 -0
- data/test/test_app/Gemfile +77 -0
- data/test/test_app/Gemfile.lock +281 -0
- data/test/test_app/README.md +1 -0
- data/test/test_app/Rakefile +6 -0
- data/test/test_app/app/admin/arcadex_token.rb +94 -0
- data/test/test_app/app/admin/dashboard.rb +69 -0
- data/test/test_app/app/admin/defcon_admin_user.rb +99 -0
- data/test/test_app/app/admin/people_user.rb +83 -0
- data/test/test_app/app/assets/javascripts/active_admin.js.coffee +1 -0
- data/test/test_app/app/assets/javascripts/application.js +16 -0
- data/test/test_app/app/assets/stylesheets/active_admin.css.scss +17 -0
- data/test/test_app/app/assets/stylesheets/application.css +13 -0
- data/test/test_app/app/controllers/api/v1/api_controller.rb +71 -0
- data/test/test_app/app/controllers/app_index_controller.rb +4 -0
- data/test/test_app/app/controllers/application_controller.rb +21 -0
- data/test/test_app/app/helpers/application_helper.rb +2 -0
- data/test/test_app/app/views/app_index/app.html.erb +0 -0
- data/test/test_app/app/views/layouts/app_index.html.erb +9 -0
- data/test/test_app/app/views/layouts/application.html.erb +14 -0
- data/test/test_app/bin/bundle +3 -0
- data/test/test_app/bin/rails +4 -0
- data/test/test_app/bin/rake +4 -0
- data/test/test_app/config.ru +4 -0
- data/test/test_app/config/application.rb +27 -0
- data/test/test_app/config/boot.rb +4 -0
- data/test/test_app/config/database.yml +25 -0
- data/test/test_app/config/environment.rb +5 -0
- data/test/test_app/config/environments/development.rb +29 -0
- data/test/test_app/config/environments/production.rb +80 -0
- data/test/test_app/config/environments/test.rb +36 -0
- data/test/test_app/config/initializers/active_admin.rb +252 -0
- data/test/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/test_app/config/initializers/inflections.rb +16 -0
- data/test/test_app/config/initializers/mime_types.rb +5 -0
- data/test/test_app/config/initializers/secret_token.rb +12 -0
- data/test/test_app/config/initializers/session_store.rb +3 -0
- data/test/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/test/test_app/config/locales/en.yml +23 -0
- data/test/test_app/config/routes.rb +66 -0
- data/test/test_app/config/schedule.rb +20 -0
- data/test/test_app/db/development.sqlite3 +0 -0
- data/test/test_app/db/migrate/20141016225515_create_active_admin_comments.rb +19 -0
- data/test/test_app/db/migrate/20141016225555_create_people_users.people.rb +14 -0
- data/test/test_app/db/migrate/20141016225556_create_arcadex_tokens.arcadex.rb +12 -0
- data/test/test_app/db/migrate/20141016225557_add_index_to_token.arcadex.rb +6 -0
- data/test/test_app/db/migrate/20141016225558_add_first_ip_address_to_arcadex_tokens.arcadex.rb +6 -0
- data/test/test_app/db/migrate/20141016225559_add_current_ip_address_to_arcadex_tokens.arcadex.rb +6 -0
- data/test/test_app/db/migrate/20141016225560_add_times_used_to_arcadex_tokens.arcadex.rb +6 -0
- data/test/test_app/db/migrate/20141016225561_add_expiration_minutes_to_arcadex_tokens.arcadex.rb +6 -0
- data/test/test_app/db/migrate/20141016225562_create_defcon_admin_users.defcon.rb +16 -0
- data/test/test_app/db/migrate/20141016225563_add_index_to_defcon_admin_users.defcon.rb +6 -0
- data/test/test_app/db/migrate/20141016225564_add_email_to_defcon_admin_users.defcon.rb +7 -0
- data/test/test_app/db/migrate/20141020173805_add_max_uses_to_arcadex_tokens.arcadex.rb +6 -0
- data/test/test_app/db/production.sqlite3 +0 -0
- data/test/test_app/db/schema.rb +73 -0
- data/test/test_app/db/seeds.rb +10 -0
- data/test/test_app/db/test.sqlite3 +0 -0
- data/test/test_app/engines/people/Gemfile +14 -0
- data/test/test_app/engines/people/Gemfile.lock +81 -0
- data/test/test_app/engines/people/MIT-LICENSE +20 -0
- data/test/test_app/engines/people/README.md +1 -0
- data/test/test_app/engines/people/Rakefile +34 -0
- data/test/test_app/engines/people/app/assets/javascripts/people/application.js +13 -0
- data/test/test_app/engines/people/app/assets/javascripts/people/users.js +2 -0
- data/test/test_app/engines/people/app/assets/stylesheets/people/application.css +13 -0
- data/test/test_app/engines/people/app/assets/stylesheets/people/users.css +4 -0
- data/test/test_app/engines/people/app/assets/stylesheets/scaffold.css +56 -0
- data/test/test_app/engines/people/app/controllers/people/api/v1/application_controller.rb +5 -0
- data/test/test_app/engines/people/app/controllers/people/api/v1/users_controller.rb +169 -0
- data/test/test_app/engines/people/app/controllers/people/application_controller.rb +4 -0
- data/test/test_app/engines/people/app/controllers/people/users_controller.rb +62 -0
- data/test/test_app/engines/people/app/helpers/people/application_helper.rb +4 -0
- data/test/test_app/engines/people/app/helpers/people/users_helper.rb +4 -0
- data/test/test_app/engines/people/app/models/people/user.rb +9 -0
- data/test/test_app/engines/people/app/models/people/v1/user.rb +32 -0
- data/test/test_app/engines/people/app/serializers/people/v1/user_serializer.rb +43 -0
- data/test/test_app/engines/people/app/views/layouts/people/default/application.html.erb +14 -0
- data/test/test_app/engines/people/app/views/people/users/_form.html.erb +29 -0
- data/test/test_app/engines/people/app/views/people/users/edit.html.erb +6 -0
- data/test/test_app/engines/people/app/views/people/users/index.html.erb +31 -0
- data/test/test_app/engines/people/app/views/people/users/new.html.erb +5 -0
- data/test/test_app/engines/people/app/views/people/users/show.html.erb +19 -0
- data/test/test_app/engines/people/bin/rails +12 -0
- data/test/test_app/engines/people/config/routes.rb +28 -0
- data/test/test_app/engines/people/db/migrate/20141016225548_create_people_users.rb +13 -0
- data/test/test_app/engines/people/lib/people.rb +4 -0
- data/test/test_app/engines/people/lib/people/engine.rb +5 -0
- data/test/test_app/engines/people/lib/people/version.rb +3 -0
- data/test/test_app/engines/people/lib/tasks/people_tasks.rake +4 -0
- data/test/test_app/engines/people/people.gemspec +33 -0
- data/test/test_app/engines/people/test/controllers/people/users_controller_test.rb +51 -0
- data/test/test_app/engines/people/test/dummy/README.rdoc +28 -0
- data/test/test_app/engines/people/test/dummy/Rakefile +6 -0
- data/test/test_app/engines/people/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/test_app/engines/people/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/test_app/engines/people/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/test_app/engines/people/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/test_app/engines/people/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/test_app/engines/people/test/dummy/bin/bundle +3 -0
- data/test/test_app/engines/people/test/dummy/bin/rails +4 -0
- data/test/test_app/engines/people/test/dummy/bin/rake +4 -0
- data/test/test_app/engines/people/test/dummy/config.ru +4 -0
- data/test/test_app/engines/people/test/dummy/config/application.rb +23 -0
- data/test/test_app/engines/people/test/dummy/config/boot.rb +5 -0
- data/test/test_app/engines/people/test/dummy/config/database.yml +25 -0
- data/test/test_app/engines/people/test/dummy/config/environment.rb +5 -0
- data/test/test_app/engines/people/test/dummy/config/environments/development.rb +29 -0
- data/test/test_app/engines/people/test/dummy/config/environments/production.rb +80 -0
- data/test/test_app/engines/people/test/dummy/config/environments/test.rb +36 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/test_app/engines/people/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/test_app/engines/people/test/dummy/config/locales/en.yml +23 -0
- data/test/test_app/engines/people/test/dummy/config/routes.rb +4 -0
- data/test/test_app/engines/people/test/dummy/public/404.html +58 -0
- data/test/test_app/engines/people/test/dummy/public/422.html +58 -0
- data/test/test_app/engines/people/test/dummy/public/500.html +57 -0
- data/test/test_app/engines/people/test/dummy/public/favicon.ico +0 -0
- data/test/test_app/engines/people/test/fixtures/people/users.yml +11 -0
- data/test/test_app/engines/people/test/helpers/people/users_helper_test.rb +6 -0
- data/test/test_app/engines/people/test/integration/navigation_test.rb +10 -0
- data/test/test_app/engines/people/test/models/people/user_test.rb +9 -0
- data/test/test_app/engines/people/test/people_test.rb +7 -0
- data/test/test_app/engines/people/test/test_helper.rb +15 -0
- data/test/test_app/gems/authorization/Gemfile +14 -0
- data/test/test_app/gems/authorization/Gemfile.lock +81 -0
- data/test/test_app/gems/authorization/MIT-LICENSE +20 -0
- data/test/test_app/gems/authorization/README.rdoc +3 -0
- data/test/test_app/gems/authorization/Rakefile +32 -0
- data/test/test_app/gems/authorization/authorization.gemspec +22 -0
- data/test/test_app/gems/authorization/lib/authorization.rb +4 -0
- data/test/test_app/gems/authorization/lib/authorization/people/v1/user.rb +90 -0
- data/test/test_app/gems/authorization/lib/authorization/version.rb +3 -0
- data/test/test_app/gems/authorization/lib/tasks/authorization_tasks.rake +4 -0
- data/test/test_app/gems/authorization/test/authorization_test.rb +7 -0
- data/test/test_app/gems/authorization/test/dummy/README.rdoc +28 -0
- data/test/test_app/gems/authorization/test/dummy/Rakefile +6 -0
- data/test/test_app/gems/authorization/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/test_app/gems/authorization/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/test_app/gems/authorization/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/test_app/gems/authorization/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/test_app/gems/authorization/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/test_app/gems/authorization/test/dummy/bin/bundle +3 -0
- data/test/test_app/gems/authorization/test/dummy/bin/rails +4 -0
- data/test/test_app/gems/authorization/test/dummy/bin/rake +4 -0
- data/test/test_app/gems/authorization/test/dummy/config.ru +4 -0
- data/test/test_app/gems/authorization/test/dummy/config/application.rb +23 -0
- data/test/test_app/gems/authorization/test/dummy/config/boot.rb +5 -0
- data/test/test_app/gems/authorization/test/dummy/config/database.yml +25 -0
- data/test/test_app/gems/authorization/test/dummy/config/environment.rb +5 -0
- data/test/test_app/gems/authorization/test/dummy/config/environments/development.rb +29 -0
- data/test/test_app/gems/authorization/test/dummy/config/environments/production.rb +80 -0
- data/test/test_app/gems/authorization/test/dummy/config/environments/test.rb +36 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/test_app/gems/authorization/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/test_app/gems/authorization/test/dummy/config/locales/en.yml +23 -0
- data/test/test_app/gems/authorization/test/dummy/config/routes.rb +56 -0
- data/test/test_app/gems/authorization/test/dummy/public/404.html +58 -0
- data/test/test_app/gems/authorization/test/dummy/public/422.html +58 -0
- data/test/test_app/gems/authorization/test/dummy/public/500.html +57 -0
- data/test/test_app/gems/authorization/test/dummy/public/favicon.ico +0 -0
- data/test/test_app/gems/authorization/test/test_helper.rb +15 -0
- data/test/test_app/log/development.log +79 -0
- data/test/test_app/log/production.log +12 -0
- data/test/test_app/log/test.log +13884 -0
- data/test/test_app/public/404.html +58 -0
- data/test/test_app/public/422.html +58 -0
- data/test/test_app/public/500.html +57 -0
- data/test/test_app/public/favicon.ico +0 -0
- data/test/test_app/public/robots.txt +5 -0
- data/test/test_app/spec/controllers/app_index_controller_spec.rb +12 -0
- data/test/test_app/spec/engines/people/api/v1/models/user_spec.rb +61 -0
- data/test/test_app/spec/engines/people/api/v1/requests/user_spec.rb +244 -0
- data/test/test_app/spec/engines/people/api/v1/routing/user_spec.rb +91 -0
- data/test/test_app/spec/factories/people_user_1_factory.rb +14 -0
- data/test/test_app/spec/rails_helper.rb +47 -0
- data/test/test_app/spec/spec_helper.rb +78 -0
- data/test/test_app/spec/support/factory_girl.rb +16 -0
- data/test/test_app/spec/support/request_helpers.rb +7 -0
- metadata +381 -2
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe ::People::V1::User, '.username', :type => :model do
|
4
|
+
it "does not save when nil" do
|
5
|
+
user = FactoryGirl.build(:people_user_1, :username => nil)
|
6
|
+
expect(user.save).to equal(false)
|
7
|
+
end
|
8
|
+
it "does not save with invalid characters" do
|
9
|
+
#user = FactoryGirl.build(:people_user_1, :username => "!@#$%)")
|
10
|
+
#expect(user.save).to equal(false)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
RSpec.describe ::People::V1::User, '.email', :type => :model do
|
14
|
+
it "does not save when nil" do
|
15
|
+
user = FactoryGirl.build(:people_user_1, :email => nil)
|
16
|
+
expect(user.save).to equal(false)
|
17
|
+
end
|
18
|
+
it "does not save with invalid characters" do
|
19
|
+
#user = FactoryGirl.build(:people_user_1, :email => "!@#$%)")
|
20
|
+
#expect(user.save).to equal(false)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
RSpec.describe ::People::V1::User, '.password_digest', :type => :model do
|
24
|
+
it "does not save when nil" do
|
25
|
+
user = FactoryGirl.build(:people_user_1, :password => nil, :password_confirmation => nil)
|
26
|
+
expect(user.save).to equal(false)
|
27
|
+
end
|
28
|
+
it "does not save when not a match" do
|
29
|
+
user = FactoryGirl.build(:people_user_1, :password => "firstAttempt", :password_confirmation => "secondAttempt")
|
30
|
+
expect(user.save).to equal(false)
|
31
|
+
end
|
32
|
+
it "saves with a matching password and password_confirmation" do
|
33
|
+
user = FactoryGirl.build(:people_user_1, :password => "good_password", :password_confirmation => "good_password")
|
34
|
+
expect(user.save).to equal(true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
RSpec.describe ::People::V1::User, :type => :model do
|
38
|
+
describe "dependencies" do
|
39
|
+
before(:example) do
|
40
|
+
@user = FactoryGirl.create(:people_user_1)
|
41
|
+
end
|
42
|
+
it "deletes ... when deleted" do
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
RSpec.describe ::People::V1::User, :type => :model do
|
48
|
+
describe "callbacks" do
|
49
|
+
before(:example) do
|
50
|
+
@user = FactoryGirl.create(:people_user_1)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "creates an authentication token" do
|
54
|
+
expect(@user.tokens.any?).to equal(true)
|
55
|
+
end
|
56
|
+
it "does not create an empty auth token" do
|
57
|
+
expect(@user.tokens[0].auth_token.nil?).to equal(false)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
#-#-#-#-#REST#-#-#-#-#
|
4
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
5
|
+
describe "Index" do
|
6
|
+
before(:example) do
|
7
|
+
@user = FactoryGirl.create(:people_user_1)
|
8
|
+
token = @user.tokens[0].auth_token
|
9
|
+
@header = {"Auth-Token" => token, "Email" => @user.email}
|
10
|
+
end
|
11
|
+
# get /api/1/users
|
12
|
+
it "checks index json response" do
|
13
|
+
FactoryGirl.create_list(:people_user_1, 10)
|
14
|
+
get 'api/1/users', nil, @header
|
15
|
+
expect(response.status).to eq(200) #ok
|
16
|
+
expect(json["users"]).to_not eq(nil)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
21
|
+
describe "Show" do
|
22
|
+
before(:example) do
|
23
|
+
@user = FactoryGirl.create(:people_user_1)
|
24
|
+
token = @user.tokens[0].auth_token
|
25
|
+
@header = {"Auth-Token" => token, "Email" => @user.email}
|
26
|
+
end
|
27
|
+
# get /api/1/users/1
|
28
|
+
it "checks show json response" do
|
29
|
+
get 'api/1/users/1', nil, @header
|
30
|
+
expect(response.status).to eq(200) #ok
|
31
|
+
expect(json["user"]["id"]).to eq(1)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
36
|
+
describe "Update" do
|
37
|
+
before(:example) do
|
38
|
+
@user = FactoryGirl.create(:people_user_1)
|
39
|
+
token = @user.tokens[0].auth_token
|
40
|
+
@header = {"Auth-Token" => token, "Email" => @user.email}
|
41
|
+
end
|
42
|
+
# put /api/1/users/1
|
43
|
+
it "checks update json response" do
|
44
|
+
attrs = FactoryGirl.attributes_for(:people_user_1)
|
45
|
+
attrs["email"] = "Cole@LaunchU.com"
|
46
|
+
hash = {"user" => attrs}
|
47
|
+
#This uses users 1 header
|
48
|
+
put 'api/1/users/1', hash, @header
|
49
|
+
expect(response.status).to eq(200) #ok
|
50
|
+
expect(json["user"]["email"]).to eq("cole@launchu.com")
|
51
|
+
end
|
52
|
+
it "makes sure a user cannot alter another users information" do
|
53
|
+
FactoryGirl.create(:people_user_1)
|
54
|
+
attrs = FactoryGirl.attributes_for(:people_user_1)
|
55
|
+
attrs["email"] = "Cole@LaunchU.com"
|
56
|
+
hash = {"user" => attrs}
|
57
|
+
#This uses users 2 header
|
58
|
+
put 'api/1/users/2', hash, @header
|
59
|
+
expect(response.status).to eq(403) #forbidden
|
60
|
+
end
|
61
|
+
it "makes sure a user can't update to bad values" do
|
62
|
+
attrs = FactoryGirl.attributes_for(:people_user_1)
|
63
|
+
attrs["email"] = ""
|
64
|
+
hash = {"user" => attrs}
|
65
|
+
#This uses users 1 header
|
66
|
+
put 'api/1/users/1', hash, @header
|
67
|
+
expect(response.status).to eq(422) #ok
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
#-#-#-#-#Collection Routes#-#-#-#-#
|
72
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
73
|
+
describe "Register" do
|
74
|
+
before(:example) do
|
75
|
+
@attrs = FactoryGirl.attributes_for(:people_user_1)
|
76
|
+
end
|
77
|
+
# post /api/1/users/register
|
78
|
+
it "checks response of a register request with a valid user object" do
|
79
|
+
post 'api/1/users/register', :user => @attrs
|
80
|
+
expect(response.status).to eq(200) #ok
|
81
|
+
expect(::People::V1::User.all.count).to eq(1)
|
82
|
+
#A valid token needs to be returned
|
83
|
+
expect(json["token"]["auth_token"]).to_not eq(nil)
|
84
|
+
token = ::People::V1::User.find(1).tokens[0]
|
85
|
+
expect(json["token"]["auth_token"]).to eq(token.auth_token)
|
86
|
+
end
|
87
|
+
# post /api/1/users/register
|
88
|
+
it "checks response of a register request with mismatched passwords" do
|
89
|
+
@attrs["password"] = "password1"
|
90
|
+
@attrs["password_confirmation"] = "password2"
|
91
|
+
post 'api/1/users/register', :user => @attrs
|
92
|
+
expect(response.status).to eq(422) #invalid_resource
|
93
|
+
expect(::People::V1::User.all.count).to eq(0)
|
94
|
+
#Errors need to be returned
|
95
|
+
expect(json["errors"]).to_not eq(nil)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
100
|
+
describe "Login" do
|
101
|
+
before(:example) do
|
102
|
+
@attrs = FactoryGirl.attributes_for(:people_user_1)
|
103
|
+
end
|
104
|
+
# post /api/1/users/login
|
105
|
+
it "checks response of a valid login request" do
|
106
|
+
@attrs["password"] = "password123"
|
107
|
+
@attrs["password_confirmation"] = "password123"
|
108
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
109
|
+
old_auth_token = user.tokens[0].auth_token
|
110
|
+
#It needs to send an email and password
|
111
|
+
hash = {"user" => @attrs}
|
112
|
+
post 'api/1/users/login', hash
|
113
|
+
expect(response.status).to eq(200) #ok
|
114
|
+
#A valid and new token need to be returned
|
115
|
+
expect(json["token"]["auth_token"]).to_not eq(old_auth_token)
|
116
|
+
#This token should be the newest token in the database
|
117
|
+
new_auth_token = ::People::V1::User.find(1).tokens.order("created_at").last.auth_token
|
118
|
+
expect(json["token"]["auth_token"]).to eq(new_auth_token)
|
119
|
+
end
|
120
|
+
# post /api/1/users/login
|
121
|
+
it "checks response of an invalid login request with an invalid password" do
|
122
|
+
@attrs["password"] = "password123"
|
123
|
+
@attrs["password_confirmation"] = "password123"
|
124
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
125
|
+
#The password needs to be invalid
|
126
|
+
@attrs["password"] = "wrongPassword"
|
127
|
+
hash = {"user" => @attrs}
|
128
|
+
#It needs to send an email and password
|
129
|
+
post 'api/1/users/login', hash
|
130
|
+
expect(response.status).to eq(401) #unauthorized
|
131
|
+
#Errors need to be returned
|
132
|
+
expect(json["errors"]).to_not eq(nil)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
137
|
+
describe "Logout" do
|
138
|
+
before(:example) do
|
139
|
+
@attrs = FactoryGirl.attributes_for(:people_user_1)
|
140
|
+
end
|
141
|
+
# get /api/1/users/1/logout
|
142
|
+
it "checks logout response and makes sure token is deleted" do
|
143
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
144
|
+
token = user.tokens[0].auth_token
|
145
|
+
header = {"Auth-Token" => token, "Email" => user.email}
|
146
|
+
post 'api/1/users/logout', nil, header
|
147
|
+
expect(::People::V1::User.count).to eq(1)
|
148
|
+
expect(response.status).to eq(200) #ok
|
149
|
+
expect(::Arcadex::Token.count).to eq(0)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
154
|
+
describe "Authenticate" do
|
155
|
+
before(:example) do
|
156
|
+
@attrs = FactoryGirl.attributes_for(:people_user_1)
|
157
|
+
end
|
158
|
+
# post /api/1/users/authenticate
|
159
|
+
it "checks a valid authenticate request" do
|
160
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
161
|
+
token = user.tokens[0].auth_token
|
162
|
+
header = {"Auth-Token" => token, "Email" => user.email}
|
163
|
+
hash = {"user" => @attrs}
|
164
|
+
post "api/1/users/authenticate/#{user.id}", hash, header
|
165
|
+
expect(response.status).to eq(200) #ok
|
166
|
+
end
|
167
|
+
# post /api/1/users/authenticate
|
168
|
+
it "checks an invalid authenticate request" do
|
169
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
170
|
+
token = user.tokens[0].auth_token
|
171
|
+
header = {"Auth-Token" => token, "Email" => user.email}
|
172
|
+
@attrs["password"] = "false_password"
|
173
|
+
hash = {"user" => @attrs}
|
174
|
+
post "api/1/users/authenticate/#{user.id}", hash, header
|
175
|
+
expect(response.status).to eq(401) #unauthorized
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
180
|
+
describe "Login_Status" do
|
181
|
+
before(:example) do
|
182
|
+
@attrs = FactoryGirl.attributes_for(:people_user_1)
|
183
|
+
end
|
184
|
+
# get /api/1/users/login_status
|
185
|
+
it "returns 200 okay if token is valid" do
|
186
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
187
|
+
token = user.tokens[0].auth_token
|
188
|
+
header = {"Auth-Token" => token, "Email" => user.email}
|
189
|
+
get "api/1/users/login_status", nil, header
|
190
|
+
expect(response.status).to eq(200) #ok
|
191
|
+
end
|
192
|
+
# get /api/1/users/login_status
|
193
|
+
it "returns a 401 if token is not valid" do
|
194
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
195
|
+
token = user.tokens[0].auth_token + "not_valid"
|
196
|
+
header = {"Auth-Token" => token, "Email" => user.email}
|
197
|
+
get "api/1/users/login_status", nil, header
|
198
|
+
expect(response.status).to eq(401) #unauthorized
|
199
|
+
end
|
200
|
+
# get /api/1/users/login_status
|
201
|
+
it "returns a 401 if token does not exist" do
|
202
|
+
user = FactoryGirl.create(:people_user_1,@attrs)
|
203
|
+
token = user.tokens[0].auth_token
|
204
|
+
header = {"Email" => user.email}
|
205
|
+
get "api/1/users/login_status", nil, header
|
206
|
+
expect(response.status).to eq(401) #unauthorized
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
#-#-#-#-#Serialization#-#-#-#-#
|
211
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
212
|
+
describe "Serialization" do
|
213
|
+
before(:example) do
|
214
|
+
@user = FactoryGirl.create(:people_user_1)
|
215
|
+
token = @user.tokens[0].auth_token
|
216
|
+
@header = {"Auth-Token" => token, "Email" => @user.email}
|
217
|
+
end
|
218
|
+
# get /api/1/users
|
219
|
+
it "checks only appropriate attributes are sent back for index" do
|
220
|
+
FactoryGirl.create_list(:people_user_1, 10)
|
221
|
+
get 'api/1/users', nil, @header
|
222
|
+
expect(response.status).to eq(200) #ok
|
223
|
+
expect(::People::V1::User.count).to eq(11)
|
224
|
+
expect(::Arcadex::Token.count).to eq(11)
|
225
|
+
expect(json["users"][0]["password_digest"]).to eq(nil)
|
226
|
+
expect(json["users"][0]["created_at"]).to_not eq(nil)
|
227
|
+
expect(json["users"][0]["updated_at"]).to_not eq(nil)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
#-#-#-#-#Errors#-#-#-#-#
|
232
|
+
RSpec.describe ::People::V1::User, :type => :request do
|
233
|
+
describe "Authorization" do
|
234
|
+
before(:example) do
|
235
|
+
@user = FactoryGirl.create(:people_user_1)
|
236
|
+
token = @user.tokens[0].auth_token
|
237
|
+
@header = {"Auth-Token" => token, "Email" => @user.email}
|
238
|
+
end
|
239
|
+
it "checks for 404 response" do
|
240
|
+
get 'api/1/users/20', nil, @header
|
241
|
+
expect(response.status).to eq(404) #not_found
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|