nyauth 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -6
  3. data/app/controllers/concerns/nyauth/application_concern.rb +10 -0
  4. data/app/controllers/concerns/nyauth/client_concern.rb +31 -0
  5. data/app/controllers/nyauth/confirmation_requests_controller.rb +10 -8
  6. data/app/controllers/nyauth/confirmations_controller.rb +8 -6
  7. data/app/controllers/nyauth/new_password_requests_controller.rb +10 -8
  8. data/app/controllers/nyauth/new_passwords_controller.rb +10 -8
  9. data/app/controllers/nyauth/passwords_controller.rb +11 -9
  10. data/app/controllers/nyauth/registrations_controller.rb +10 -8
  11. data/app/controllers/nyauth/sessions_controller.rb +6 -4
  12. data/app/helpers/nyauth/application_helper.rb +38 -1
  13. data/app/mailers/nyauth/request_mailer.rb +15 -0
  14. data/app/views/nyauth/confirmation_requests/new.html.slim +1 -1
  15. data/app/views/nyauth/confirmations/edit.html.slim +2 -2
  16. data/app/views/nyauth/new_password_requests/new.html.slim +1 -1
  17. data/app/views/nyauth/new_passwords/edit.html.slim +3 -3
  18. data/app/views/nyauth/passwords/edit.html.slim +3 -3
  19. data/app/views/nyauth/registrations/new.html.slim +3 -3
  20. data/app/views/nyauth/request_mailer/request_confirmation.html.slim +2 -0
  21. data/app/views/nyauth/request_mailer/request_confirmation.text.erb +3 -0
  22. data/app/views/nyauth/request_mailer/request_new_password.html.slim +2 -0
  23. data/app/views/nyauth/request_mailer/request_new_password.text.erb +3 -0
  24. data/app/views/nyauth/sessions/new.html.slim +1 -5
  25. data/config/routes.rb +1 -1
  26. data/lib/generators/nyauth/install_generator.rb +11 -0
  27. data/lib/generators/nyauth/templates/nyauth_install_initializer.rb +7 -0
  28. data/lib/nyauth/configuration.rb +40 -0
  29. data/lib/nyauth/engine.rb +2 -0
  30. data/lib/nyauth/version.rb +1 -1
  31. data/lib/nyauth.rb +10 -0
  32. data/spec/dummy/app/controllers/pages_controller.rb +4 -0
  33. data/spec/dummy/app/controllers/posts_controller.rb +5 -0
  34. data/spec/dummy/app/models/admin.rb +3 -0
  35. data/spec/dummy/app/views/layouts/application.html.erb +2 -1
  36. data/spec/dummy/config/routes.rb +7 -1
  37. data/spec/dummy/db/development.sqlite3 +0 -0
  38. data/spec/dummy/db/migrate/20150317141956_create_admins.rb +12 -0
  39. data/spec/dummy/db/schema.rb +11 -1
  40. data/spec/dummy/db/test.sqlite3 +0 -0
  41. data/spec/dummy/log/development.log +1662 -0
  42. data/spec/dummy/log/test.log +36831 -0
  43. data/spec/dummy/tmp/capybara/capybara-201503142131285774508896.html +1 -0
  44. data/spec/dummy/tmp/capybara/capybara-201503142131502672526321.html +1 -0
  45. data/spec/dummy/tmp/capybara/capybara-201503142132597161072575.html +16 -0
  46. data/spec/dummy/tmp/capybara/capybara-201503142147454003977122.html +16 -0
  47. data/spec/dummy/tmp/capybara/capybara-201503150030597512321952.html +1 -0
  48. data/spec/dummy/tmp/capybara/capybara-201503172332094559831059.html +15 -0
  49. data/spec/dummy/tmp/capybara/capybara-201503172332489943616503.html +15 -0
  50. data/spec/dummy/tmp/capybara/capybara-201503172333245353296202.html +15 -0
  51. data/spec/dummy/tmp/capybara/capybara-201503172335156567049015.html +15 -0
  52. data/spec/dummy/tmp/capybara/capybara-201503172339176031196898.html +15 -0
  53. data/spec/dummy/tmp/capybara/capybara-201503172340144947026095.html +15 -0
  54. data/spec/dummy/tmp/capybara/capybara-201503172341585213923875.html +15 -0
  55. data/spec/dummy/tmp/capybara/capybara-201503172342188836603353.html +15 -0
  56. data/spec/dummy/tmp/capybara/capybara-201503172344586782457691.html +15 -0
  57. data/spec/dummy/tmp/capybara/capybara-201503172346495241516033.html +15 -0
  58. data/spec/dummy/tmp/capybara/capybara-201503172354248621830336.html +15 -0
  59. data/spec/dummy/tmp/capybara/capybara-20150623002226753539811.html +15 -0
  60. data/spec/dummy/tmp/pids/server.pid +1 -0
  61. data/spec/factories/admins.rb +6 -0
  62. data/spec/featrues/nyauth/registrations_spec.rb +1 -0
  63. data/spec/featrues/nyauth/sessions_spec.rb +54 -19
  64. data/spec/featrues/url_helper_on_application_spec.rb +10 -0
  65. data/spec/helpers/nyauth/application_helper_spec.rb +145 -0
  66. data/spec/lib/generators/nyauth/install_generator_spec.rb +19 -0
  67. data/spec/lib/generators/nyauth/tmp/config/initializers/nyauth.rb +7 -0
  68. data/spec/lib/nyauth/configuration_spec.rb +23 -0
  69. data/spec/mailers/nyauth/{user_mailer_spec.rb → request_mailer_spec.rb} +3 -3
  70. metadata +72 -13
  71. data/app/controllers/nyauth/base_controller.rb +0 -5
  72. data/app/mailers/nyauth/user_mailer.rb +0 -15
  73. data/app/views/nyauth/group_requests/new.html.slim +0 -14
  74. data/app/views/nyauth/groups/show.html.slim +0 -0
  75. data/app/views/nyauth/user_mailer/request_confirmation.html.slim +0 -2
  76. data/app/views/nyauth/user_mailer/request_confirmation.text.erb +0 -3
  77. data/app/views/nyauth/user_mailer/request_new_password.html.slim +0 -2
  78. data/app/views/nyauth/user_mailer/request_new_password.text.erb +0 -3
  79. /data/{app/views/nyauth/group_requests/edit.html.slim → spec/dummy/app/views/pages/index.html.slim} +0 -0
@@ -0,0 +1 @@
1
+ <form class="pure-form" id="new_session_service" action="/session" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign in</legend><input placeholder="Email" type="email" name="session_service[email]" id="session_service_email" /><input placeholder="Password" type="password" name="session_service[password]" id="session_service_password" /><input type="submit" name="commit" value="Sign in" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form><ul><li><a href="/registration/new">sign up</a></li><li><a href="/new_password_requests/new">request new password</a></li></ul>
@@ -0,0 +1 @@
1
+ <form class="pure-form" id="new_session_service" action="/session" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign in</legend><input placeholder="Email" type="email" name="session_service[email]" id="session_service_email" /><input placeholder="Password" type="password" name="session_service[password]" id="session_service_password" /><input type="submit" name="commit" value="Sign in" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form><ul><li><a href="/registration/new">sign up</a></li><li><a href="/new_password_requests/new">request new password</a></li></ul>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+
12
+ registration success
13
+
14
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
15
+ </body>
16
+ </html>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form" id="new_session_service" action="/session" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign in</legend><input placeholder="Email" type="email" name="session_service[email]" id="session_service_email" /><input placeholder="Password" type="password" name="session_service[password]" id="session_service_password" /><input type="submit" name="commit" value="Sign in" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form><ul><li><a href="/registration/new">sign up</a></li><li><a href="/new_password_requests/new">request new password</a></li></ul>
12
+ updated password
13
+
14
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
15
+ </body>
16
+ </html>
@@ -0,0 +1 @@
1
+ <form class="pure-form pure-form-stacked" id="edit_user_205" action="/new_passwords/49791165ece3a672817872e6b29d027de63de1331ec260a680c315a6fc6738ef" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="_method" value="patch" /><fieldset><legend></legend><h2>errors</h2><ul class="errors"><li>New password key translation missing: en.activerecord.errors.models.user.attributes.new_password_key.expired</li></ul><input placeholder="Password" type="password" name="user[password]" id="user_password" /><input placeholder="Confirmation" type="password" name="user[password_confirmation]" id="user_password_confirmation" /><input type="submit" name="commit" value="Update" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/admin/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/admin/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/admin/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/admin/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_user" action="/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="user[email]" id="user_email" /><input placeholder="Password" type="password" name="user[password]" id="user_password" /><input placeholder="Confirmation" type="password" name="user[password_confirmation]" id="user_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_user" action="/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="user[email]" id="user_email" /><input placeholder="Password" type="password" name="user[password]" id="user_password" /><input placeholder="Confirmation" type="password" name="user[password_confirmation]" id="user_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_user" action="/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="user[email]" id="user_email" /><input placeholder="Password" type="password" name="user[password]" id="user_password" /><input placeholder="Confirmation" type="password" name="user[password_confirmation]" id="user_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_user" action="/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="user[email]" id="user_email" /><input placeholder="Password" type="password" name="user[password]" id="user_password" /><input placeholder="Confirmation" type="password" name="user[password_confirmation]" id="user_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_user" action="/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="user[email]" id="user_email" /><input placeholder="Password" type="password" name="user[password]" id="user_password" /><input placeholder="Confirmation" type="password" name="user[password_confirmation]" id="user_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/admin/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/admin/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/admin/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/admin/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/admin/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/admin/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/admin/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/admin/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <link rel="stylesheet" media="all" href="/assets/application.css" data-turbolinks-track="true" />
6
+ <script src="/assets/application.js" data-turbolinks-track="true"></script>
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <form class="pure-form pure-form-stacked" id="new_admin" action="/registration" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><fieldset><legend>Sign up</legend><input placeholder="Email" type="text" name="admin[email]" id="admin_email" /><input placeholder="Password" type="password" name="admin[password]" id="admin_password" /><input placeholder="Confirmation" type="password" name="admin[password_confirmation]" id="admin_password_confirmation" /><input type="submit" name="commit" value="Sign up" data-disable-with="..." class="pure-button pure-button-primary" /></fieldset></form>
12
+ <a href="/posts">URL helper on application</a>
13
+ <a class="pure-menu-link" rel="nofollow" data-method="delete" href="/session">Sign out</a>
14
+ </body>
15
+ </html>
@@ -0,0 +1 @@
1
+ 62060
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :admin, class: 'Admin' do
3
+ sequence(:email) { |n| "admin#{n}@example.com" }
4
+ password { 'password' }
5
+ end
6
+ end
@@ -13,6 +13,7 @@ RSpec.describe 'Nyauth::Registrations' do
13
13
  click_button('Sign up')
14
14
 
15
15
  expect(page).to have_content('registration success')
16
+ expect(User.last.email).to eq user.email
16
17
  end
17
18
 
18
19
  scenario "can't create user" do
@@ -1,36 +1,71 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  RSpec.describe 'Nyauth::Sessions' do
4
- let(:user) { create(:user) }
4
+ context 'user' do
5
+ let(:user) { create(:user) }
6
+ feature 'sign in' do
7
+ background { visit nyauth.new_session_path }
5
8
 
6
- feature 'sign in' do
7
- background { visit nyauth.new_session_path }
9
+ scenario 'sign in user' do
10
+ fill_in('session_service_email', with: user.email)
11
+ fill_in('session_service_password', with: user.password)
12
+ click_button('Sign in')
8
13
 
9
- scenario 'sign in user' do
10
- fill_in('session_service_email', with: user.email)
11
- fill_in('session_service_password', with: user.password)
12
- click_button('Sign in')
14
+ expect(page).to have_content('sign in success')
15
+ end
13
16
 
14
- expect(page).to have_content('sign in success')
15
- end
17
+ scenario "can't sign in user" do
18
+ click_button('Sign in')
16
19
 
17
- scenario "can't sign in user" do
18
- click_button('Sign in')
20
+ expect(page).to have_content('invalid')
21
+ end
19
22
 
20
- expect(page).to have_content('invalid')
21
23
  end
22
24
 
25
+ feature 'sign out' do
26
+ background do
27
+ sign_in(user)
28
+ end
29
+
30
+ scenario 'sign out user' do
31
+ visit root_path
32
+ click_link('Sign out')
33
+ expect(page).to have_content('sign out')
34
+ end
35
+ end
23
36
  end
24
37
 
25
- feature 'sign out' do
26
- background do
27
- sign_in(user)
38
+ context 'admin' do
39
+ let(:admin) { create(:admin) }
40
+ feature 'sign in' do
41
+ background { visit new_admin_session_path }
42
+
43
+ scenario 'sign in admin' do
44
+ fill_in('session_service_email', with: admin.email)
45
+ fill_in('session_service_password', with: admin.password)
46
+ click_button('Sign in')
47
+
48
+ expect(page).to have_content('sign in success')
49
+ end
50
+
51
+ scenario "can't sign in admin" do
52
+ click_button('Sign in')
53
+
54
+ expect(page).to have_content('invalid')
55
+ end
56
+
28
57
  end
29
58
 
30
- scenario 'sign out user' do
31
- visit nyauth.root_path
32
- click_link('Sign out')
33
- expect(page).to have_content('sign out')
59
+ feature 'sign out' do
60
+ background do
61
+ sign_in(admin)
62
+ end
63
+
64
+ scenario 'sign out admin' do
65
+ visit root_path
66
+ click_link('Sign out')
67
+ expect(page).to have_content('sign out')
68
+ end
34
69
  end
35
70
  end
36
71
  end
@@ -0,0 +1,10 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe 'URL helper on Application' do
4
+ feature 'get path on engine' do
5
+ scenario 'can use URL helper on application' do
6
+ visit nyauth.new_session_path
7
+ expect(page).to have_link('URL helper on application')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,145 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Nyauth::ApplicationHelper do
4
+ describe '#session_path_for' do
5
+ subject { helper.session_path_for(client_name) }
6
+
7
+ context 'when client_name is admin' do
8
+ let(:client_name) { :admin }
9
+ it { is_expected.to eq '/admin/session' }
10
+ end
11
+
12
+ context 'when client_name is user' do
13
+ let(:client_name) { :user }
14
+ it { is_expected.to eq '/session' }
15
+ end
16
+ end
17
+
18
+ describe '#new_session_path_for' do
19
+ subject { helper.new_session_path_for(client_name) }
20
+
21
+ context 'when client_name is admin' do
22
+ let(:client_name) { :admin }
23
+ it { is_expected.to eq '/admin/session/new' }
24
+ end
25
+
26
+ context 'when client_name is user' do
27
+ let(:client_name) { :user }
28
+ it { is_expected.to eq '/session/new' }
29
+ end
30
+ end
31
+
32
+ describe '#registration_path_for' do
33
+ subject { helper.registration_path_for(client_name) }
34
+
35
+ context 'when client_name is admin' do
36
+ let(:client_name) { :admin }
37
+ it { is_expected.to eq nil }
38
+ end
39
+
40
+ context 'when client_name is user' do
41
+ let(:client_name) { :user }
42
+ it { is_expected.to eq '/registration' }
43
+ end
44
+ end
45
+
46
+ describe '#new_registration_path_for' do
47
+ subject { helper.new_registration_path_for(client_name) }
48
+
49
+ context 'when client_name is admin' do
50
+ let(:client_name) { :admin }
51
+ it { is_expected.to eq nil }
52
+ end
53
+
54
+ context 'when client_name is user' do
55
+ let(:client_name) { :user }
56
+ it { is_expected.to eq '/registration/new' }
57
+ end
58
+ end
59
+
60
+ describe '#password_path_for' do
61
+ subject { helper.password_path_for(client_name) }
62
+
63
+ context 'when client_name is admin' do
64
+ let(:client_name) { :admin }
65
+ it { is_expected.to eq nil }
66
+ end
67
+
68
+ context 'when client_name is user' do
69
+ let(:client_name) { :user }
70
+ it { is_expected.to eq "/password" }
71
+ end
72
+ end
73
+
74
+ describe '#new_confirmation_request_path_for' do
75
+ subject { helper.new_confirmation_request_path_for(client_name) }
76
+
77
+ context 'when client_name is admin' do
78
+ let(:client_name) { :admin }
79
+ it { is_expected.to eq nil }
80
+ end
81
+
82
+ context 'when client_name is user' do
83
+ let(:client_name) { :user }
84
+ it { is_expected.to eq "/confirmation_requests/new" }
85
+ end
86
+ end
87
+
88
+ describe '#confirmation_path_for(:confirmation_key)' do
89
+ subject { helper.confirmation_path_for(client_name, confirmation_key) }
90
+ let(:confirmation_key) { 'hogehoge' }
91
+
92
+ context 'when client_name is admin' do
93
+ let(:client_name) { :admin }
94
+ it { is_expected.to eq nil }
95
+ end
96
+
97
+ context 'when client_name is user' do
98
+ let(:client_name) { :user }
99
+ it { is_expected.to eq "/confirmations/#{confirmation_key}" }
100
+ end
101
+ end
102
+
103
+ describe '#new_password_requests_path_for' do
104
+ subject { helper.new_password_requests_path_for(client_name) }
105
+
106
+ context 'when client_name is admin' do
107
+ let(:client_name) { :admin }
108
+ it { is_expected.to eq nil }
109
+ end
110
+
111
+ context 'when client_name is user' do
112
+ let(:client_name) { :user }
113
+ it { is_expected.to eq "/new_password_requests" }
114
+ end
115
+ end
116
+
117
+ describe '#new_new_password_request_path_for' do
118
+ subject { helper.new_new_password_request_path_for(client_name) }
119
+
120
+ context 'when client_name is admin' do
121
+ let(:client_name) { :admin }
122
+ it { is_expected.to eq nil }
123
+ end
124
+
125
+ context 'when client_name is user' do
126
+ let(:client_name) { :user }
127
+ it { is_expected.to eq "/new_password_requests/new" }
128
+ end
129
+ end
130
+
131
+ describe '#new_password_path_for(:new_password_key)' do
132
+ subject { helper.new_password_path_for(client_name, new_password_key) }
133
+ let(:new_password_key) { 'hogehoge' }
134
+
135
+ context 'when client_name is admin' do
136
+ let(:client_name) { :admin }
137
+ it { is_expected.to eq nil }
138
+ end
139
+
140
+ context 'when client_name is user' do
141
+ let(:client_name) { :user }
142
+ it { is_expected.to eq "/new_passwords/#{new_password_key}" }
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,19 @@
1
+ require 'rails_helper'
2
+ require 'generators/nyauth/install_generator'
3
+
4
+ describe Nyauth::InstallGenerator, type: :generator do
5
+ destination ::File.expand_path('../tmp/', __FILE__)
6
+
7
+ before do
8
+ prepare_destination
9
+ run_generator
10
+ end
11
+
12
+ describe 'rails g nyauth:install' do
13
+ it 'creates a test initializer' do
14
+ assert_file 'config/initializers/nyauth.rb', /config.redirect_path_after_sign_in/
15
+ assert_file 'config/initializers/nyauth.rb', /config.redirect_path_after_sign_out/
16
+ assert_file 'config/initializers/nyauth.rb', /config.redirect_path do |urls|/
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ Nyauth.configure do |config|
2
+ config.redirect_path do |urls|
3
+ # config.redirect_path_after_sign_in = urls.admin_secret_notes_path
4
+ # config.redirect_path_after_sign_out = urls.root_path
5
+ # config.redirect_path_after_registration = urls.root_path
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Nyauth::Configuration do
4
+ describe '#configure' do
5
+ let(:redirect_path_after_sign_in) { '/posts' }
6
+ before do
7
+ # applicationの
8
+ # config/initializers/nyauth.rb
9
+ Nyauth.configure do |config|
10
+ config.redirect_path do |urls|
11
+ config.redirect_path_after_sign_in = redirect_path_after_sign_in
12
+ end
13
+ end
14
+ # nyauthの
15
+ # config/rotues.rbから呼ばれる
16
+ Nyauth.configuration.setup_redirect_path
17
+ end
18
+
19
+ subject { Nyauth.configuration.redirect_path_after_sign_in }
20
+
21
+ it { is_expected.to eq redirect_path_after_sign_in }
22
+ end
23
+ end
@@ -1,15 +1,15 @@
1
1
  require "rails_helper"
2
2
 
3
- RSpec.describe Nyauth::UserMailer do
3
+ RSpec.describe Nyauth::RequestMailer do
4
4
  describe '#request_confirmation' do
5
5
  let(:user) { create(:user, :requested_confirmation) }
6
- subject(:mail) { Nyauth::UserMailer.request_confirmation(user) }
6
+ subject(:mail) { Nyauth::RequestMailer.request_confirmation(user) }
7
7
  it { expect(mail).to have_body_text 'Plese confirm your email' }
8
8
  end
9
9
 
10
10
  describe '#request_new_password' do
11
11
  let(:user) { create(:user, :requested_new_password) }
12
- subject(:mail) { Nyauth::UserMailer.request_new_password(user) }
12
+ subject(:mail) { Nyauth::RequestMailer.request_new_password(user) }
13
13
  it { expect(mail).to have_body_text 'Plese set your new password' }
14
14
  end
15
15
  end