hello-rails 0.0.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +97 -0
- data/Rakefile +23 -0
- data/app/controllers/hello/application_controller.rb +27 -0
- data/app/controllers/hello/authentication/sessions_controller.rb +81 -0
- data/app/controllers/hello/authentication/sign_in_controller.rb +39 -0
- data/app/controllers/hello/authentication/sudo_mode_controller.rb +40 -0
- data/app/controllers/hello/concerns/authentication/sign_in.rb +44 -0
- data/app/controllers/hello/concerns/management/forgot_password.rb +45 -0
- data/app/controllers/hello/concerns/management/reset_password.rb +33 -0
- data/app/controllers/hello/concerns/registration/sign_up.rb +64 -0
- data/app/controllers/hello/internationalization/locale_controller.rb +28 -0
- data/app/controllers/hello/management/accesses_controller.rb +29 -0
- data/app/controllers/hello/management/confirm_emails_controller.rb +41 -0
- data/app/controllers/hello/management/emails_controller.rb +67 -0
- data/app/controllers/hello/management/forgot_password_controller.rb +41 -0
- data/app/controllers/hello/management/passwords_controller.rb +57 -0
- data/app/controllers/hello/management/profiles_controller.rb +71 -0
- data/app/controllers/hello/management/reset_password_controller.rb +53 -0
- data/app/controllers/hello/registration/sign_up_controller.rb +63 -0
- data/app/helpers/hello/application_helper.rb +5 -0
- data/app/mailers/hello/mailer.rb +26 -0
- data/app/models/access.rb +2 -0
- data/app/models/credential.rb +2 -0
- data/app/models/email_credential.rb +2 -0
- data/app/models/password_credential.rb +2 -0
- data/app/models/user.rb +2 -0
- data/app/views/hello/authentication/_sign_in.html.erb +64 -0
- data/app/views/hello/authentication/new_session.html.erb +4 -0
- data/app/views/hello/authentication/sessions.html.erb +36 -0
- data/app/views/hello/authentication/sign_in.html.erb +3 -0
- data/app/views/hello/authentication/sudo_mode.html.erb +37 -0
- data/app/views/hello/internationalization/locales.html.erb +7 -0
- data/app/views/hello/mailer/confirm_email.html.erb +12 -0
- data/app/views/hello/mailer/forgot_password.html.erb +12 -0
- data/app/views/hello/mailer/welcome.html.erb +11 -0
- data/app/views/hello/management/accesses.html.erb +47 -0
- data/app/views/hello/management/cancel.html.erb +14 -0
- data/app/views/hello/management/email_credentials/expired_confirmation_token.html.erb +1 -0
- data/app/views/hello/management/email_credentials/index.html.erb +84 -0
- data/app/views/hello/management/password_credentials/_forgot_form.html.erb +17 -0
- data/app/views/hello/management/password_credentials/_reset_form.html.erb +39 -0
- data/app/views/hello/management/password_credentials/forgot.html.erb +10 -0
- data/app/views/hello/management/password_credentials/forgot_success.html.erb +26 -0
- data/app/views/hello/management/password_credentials/reset.html.erb +3 -0
- data/app/views/hello/management/password_credentials/show.html.erb +25 -0
- data/app/views/hello/management/user.html.erb +73 -0
- data/app/views/hello/registration/_sign_up.html.erb +86 -0
- data/app/views/hello/registration/sign_up.html.erb +3 -0
- data/app/views/hello/registration/sign_up_widget.html.erb +3 -0
- data/app/views/hello/shared/_errors.html.erb +11 -0
- data/app/views/hello/shared/_flash.html.erb +8 -0
- data/app/views/hello/shared/_nav_pills.html.erb +15 -0
- data/app/views/hello/shared/_session_expiration.html.erb +15 -0
- data/app/views/hello/shared/_settings.html.erb +41 -0
- data/config/locales/hello.en.yml +69 -0
- data/config/locales/hello.es.yml +71 -0
- data/config/locales/hello.fr.yml +71 -0
- data/config/locales/hello.pl.yml +71 -0
- data/config/locales/hello.pt-BR.yml +71 -0
- data/config/locales/hello.zh-CN.yml +71 -0
- data/config/locales/hello.zh-TW.yml +71 -0
- data/config/routes.rb +74 -0
- data/db/migrate/1_create_credentials.rb +17 -0
- data/db/migrate/2_create_accesses.rb +15 -0
- data/db/migrate/3_create_users.rb +23 -0
- data/lib/generators/hello/concerns/USAGE +8 -0
- data/lib/generators/hello/concerns/concerns_generator.rb +10 -0
- data/lib/generators/hello/from_devise/USAGE +8 -0
- data/lib/generators/hello/from_devise/from_devise_generator.rb +13 -0
- data/lib/generators/hello/from_devise/templates/from_devise.migration.rb +39 -0
- data/lib/generators/hello/install/USAGE +8 -0
- data/lib/generators/hello/install/install_generator.rb +94 -0
- data/lib/generators/hello/install/templates/application.html.erb +35 -0
- data/lib/generators/hello/install/templates/hello_helper.rb +16 -0
- data/lib/generators/hello/install/templates/initializer.rb +24 -0
- data/lib/generators/hello/install/templates/models/concerns/user/authorization.rb +21 -0
- data/lib/generators/hello/install/templates/models/user.rb +9 -0
- data/lib/generators/hello/install/templates/onboarding/index.html.erb +5 -0
- data/lib/generators/hello/install/templates/onboarding/onboarding_controller.rb +33 -0
- data/lib/generators/hello/install/templates/root/index.html.erb +7 -0
- data/lib/generators/hello/install/templates/root/root_controller.rb +6 -0
- data/lib/generators/hello/install/templates/users/controllers/users_controller.rb +71 -0
- data/lib/generators/hello/install/templates/users/views/users/index.html.erb +29 -0
- data/lib/generators/hello/install/templates/users/views/users/list.html.erb +35 -0
- data/lib/generators/hello/install/templates/users/views/users/new.html.erb +60 -0
- data/lib/generators/hello/install/templates/users/views/users/show.html.erb +74 -0
- data/lib/generators/hello/locales/USAGE +12 -0
- data/lib/generators/hello/locales/locales_generator.rb +64 -0
- data/lib/generators/hello/views/USAGE +8 -0
- data/lib/generators/hello/views/views_generator.rb +9 -0
- data/lib/hello-rails.rb +1 -0
- data/lib/hello.rb +36 -0
- data/lib/hello/CHANGES.md +26 -0
- data/lib/hello/business.rb +47 -0
- data/lib/hello/business/authentication/sign_in.rb +92 -0
- data/lib/hello/business/authentication/sign_out.rb +8 -0
- data/lib/hello/business/authentication/sudo_mode_authentication.rb +25 -0
- data/lib/hello/business/authentication/sudo_mode_expiration.rb +17 -0
- data/lib/hello/business/base.rb +33 -0
- data/lib/hello/business/internationalization/update_locale.rb +33 -0
- data/lib/hello/business/management/add_email.rb +19 -0
- data/lib/hello/business/management/cancel_account.rb +22 -0
- data/lib/hello/business/management/confirm_email.rb +36 -0
- data/lib/hello/business/management/forgot_password.rb +47 -0
- data/lib/hello/business/management/remove_email.rb +19 -0
- data/lib/hello/business/management/reset_password.rb +34 -0
- data/lib/hello/business/management/send_confirmation_email.rb +40 -0
- data/lib/hello/business/management/unlink_access.rb +8 -0
- data/lib/hello/business/management/update_profile.rb +44 -0
- data/lib/hello/business/registration/sign_up.rb +159 -0
- data/lib/hello/configuration.rb +12 -0
- data/lib/hello/encryptors.rb +6 -0
- data/lib/hello/encryptors/complex.rb +25 -0
- data/lib/hello/encryptors/simple.rb +27 -0
- data/lib/hello/engine.rb +23 -0
- data/lib/hello/errors.rb +12 -0
- data/lib/hello/locales.rb +238 -0
- data/lib/hello/middleware.rb +13 -0
- data/lib/hello/rails_active_record.rb +10 -0
- data/lib/hello/rails_active_record/access.rb +65 -0
- data/lib/hello/rails_active_record/credential.rb +51 -0
- data/lib/hello/rails_active_record/email_credential.rb +60 -0
- data/lib/hello/rails_active_record/password_credential.rb +70 -0
- data/lib/hello/rails_active_record/user.rb +99 -0
- data/lib/hello/rails_controller.rb +124 -0
- data/lib/hello/rails_controller/restrict_by_role.rb +79 -0
- data/lib/hello/rails_helper.rb +35 -0
- data/lib/hello/request_manager.rb +14 -0
- data/lib/hello/request_manager/abstract.rb +77 -0
- data/lib/hello/request_manager/factory.rb +32 -0
- data/lib/hello/request_manager/stateful.rb +53 -0
- data/lib/hello/request_manager/stateful/finder.rb +58 -0
- data/lib/hello/request_manager/stateful/session_wrapper.rb +37 -0
- data/lib/hello/request_manager/stateless.rb +35 -0
- data/lib/hello/time_zones.rb +7 -0
- data/lib/hello/utils.rb +11 -0
- data/lib/hello/utils/device_name.rb +34 -0
- data/lib/hello/version.rb +4 -0
- data/lib/tasks/hello_tasks.rake +4 -0
- data/spec/bdd/hello/authentication/authorization/authorization_role_restriction_spec.rb +291 -0
- data/spec/bdd/hello/authentication/authorization/authorization_router_constraints_spec.rb +41 -0
- data/spec/bdd/hello/authentication/authorization/authorization_sensitive_restriction_spec.rb +84 -0
- data/spec/bdd/hello/authentication/authorization/bdd.yml +1 -0
- data/spec/bdd/hello/authentication/bdd.yml +1 -0
- data/spec/bdd/hello/authentication/classic_sign_in_spec.rb +264 -0
- data/spec/bdd/hello/authentication/manage_sessions_spec.rb +292 -0
- data/spec/bdd/hello/authentication/sign_out_spec.rb +159 -0
- data/spec/bdd/hello/bdd.yml +1 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/bdd.yml +1 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_locale_page_spec.rb +90 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_profile_page_spec.rb +64 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_in_form_spec.rb +31 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_up_form_spec.rb +34 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/bdd.yml +1 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_profile_page_spec.rb +14 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_sign_in_form_spec.rb +14 -0
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_timezone/change_timezone_on_the_sign_up_form_spec.rb +14 -0
- data/spec/bdd/hello/internalionalization/bdd.yml +1 -0
- data/spec/bdd/hello/management/bdd.yml +1 -0
- data/spec/bdd/hello/management/cancel_account_spec.rb +128 -0
- data/spec/bdd/hello/management/manage_email_credentials/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_api_spec.rb +7 -0
- data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_page_spec.rb +252 -0
- data/spec/bdd/hello/management/manage_password_credentials/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_forgot_password_spec.rb +68 -0
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_page_spec.rb +60 -0
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_reset_password_spec.rb +145 -0
- data/spec/bdd/hello/management/manage_profile/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_profile/manage_profile_api_spec.rb +7 -0
- data/spec/bdd/hello/management/manage_profile/manage_profile_page_spec.rb +65 -0
- data/spec/bdd/hello/management/manage_social_credentials/bdd.yml +1 -0
- data/spec/bdd/hello/management/manage_social_credentials/manage_social_credentials_pending_spec.rb +7 -0
- data/spec/bdd/hello/management/unlink_sessions_spec.rb +59 -0
- data/spec/bdd/hello/other/bdd.yml +1 -0
- data/spec/bdd/hello/other/create_user_spec.rb +70 -0
- data/spec/bdd/hello/other/impersonate_user_spec.rb +58 -0
- data/spec/bdd/hello/other/list_users_spec.rb +86 -0
- data/spec/bdd/hello/registration/bdd.yml +1 -0
- data/spec/bdd/hello/registration/classic_sign_up_spec.rb +228 -0
- data/spec/bdd/hello/registration/onboarding_process_spec.rb +101 -0
- data/spec/bdd/hello/support.rb +62 -0
- data/spec/business/hello/authentication/sign_in_spec.rb +72 -0
- data/spec/business/hello/registration/sign_up_spec.rb +258 -0
- data/spec/controllers/authentication_spec.rb +97 -0
- data/spec/controllers/localization_spec.rb +65 -0
- data/spec/controllers/request_can_carry_an_access_token_spec.rb +223 -0
- data/spec/fixtures/hello/password_mailer/confirmation +3 -0
- data/spec/fixtures/hello/password_mailer/forgot +3 -0
- data/spec/fixtures/hello/password_mailer/sign_up +3 -0
- data/spec/mailers/hello/mailer_spec.rb +53 -0
- data/spec/models/access_spec.rb +19 -0
- data/spec/models/credential_spec.rb +9 -0
- data/spec/models/email_credential_spec.rb +163 -0
- data/spec/models/hello/sign_up_model_spec.rb +64 -0
- data/spec/models/password_credential_spec.rb +75 -0
- data/spec/models/user_spec.rb +93 -0
- data/spec/others/configuration_spec.rb +25 -0
- data/spec/others/encryptors/complex_spec.rb +26 -0
- data/spec/others/encryptors/simple_spec.rb +21 -0
- data/spec/others/helper_spec.rb +10 -0
- data/spec/others/localization_consistency_spec.rb +73 -0
- data/spec/requests/forgot_password_spec.rb +36 -0
- data/spec/requests/reset_password_spec.rb +7 -0
- data/spec/requests/security/user_spec.rb +19 -0
- data/spec/routing/hello/accesses_routing_spec.rb +17 -0
- data/spec/routing/hello/emails_routing_spec.rb +37 -0
- data/spec/routing/hello/locale_routing_spec.rb +17 -0
- data/spec/routing/hello/profile_routing_spec.rb +29 -0
- data/spec/routing/hello/registration_routing_spec.rb +23 -0
- data/spec/routing/hello/sign_out_routing_spec.rb +11 -0
- data/spec/routing/hello/sudo_mode_routing_spec.rb +23 -0
- data/spec/routing/hello/users_routing_spec.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/spec_helper/codeclimate.rb +2 -0
- data/spec/spec_helper/configure_rspec.rb +23 -0
- data/spec/spec_helper/create_database.rb +5 -0
- data/spec/spec_helper/dummy_and_test_dependencies.rb +17 -0
- data/spec/spec_helper/support.rb +1 -0
- data/spec/support/factories.rb +60 -0
- data/spec/support/feature_injection.rb +118 -0
- data/spec/support/features/feature_support_given.rb +46 -0
- data/spec/support/features/feature_support_then.rb +43 -0
- data/spec/support/helpers/aliases.rb +76 -0
- data/spec/support/helpers/configuration.rb +6 -0
- data/spec/support/helpers/current.rb +16 -0
- data/spec/support/helpers/expect.rb +61 -0
- data/spec/support/helpers/given.rb +49 -0
- data/spec/support/helpers/shortcuts.rb +24 -0
- data/spec/support/helpers/then.rb +29 -0
- data/spec/support/helpers/when.rb +108 -0
- data/spec/support/requests/request_support.rb +8 -0
- data/spec/utils/device_name_spec.rb +228 -0
- metadata +562 -11
@@ -0,0 +1 @@
|
|
1
|
+
capability: Manage Email Credentials
|
data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_page_spec.rb
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "Emails Page" do
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def self._before__given_I_am_on_the_emails_page
|
8
|
+
before do
|
9
|
+
Given "I am fully authorized on the Email Management Page" do
|
10
|
+
given_I_have_signed_in_with_sudo_mode
|
11
|
+
click_link "Settings"
|
12
|
+
click_link "Emails"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
story "Add" do
|
20
|
+
_before__given_I_am_on_the_emails_page
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
def _when_I_submit(text, email)
|
25
|
+
When "I submit #{text} email" do
|
26
|
+
fill_in 'email_credential_email', with: (@new_email = email)
|
27
|
+
click_button 'Add'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
scenario "Valid" do
|
34
|
+
_when_I_submit "a valid", "newemail@provider.com"
|
35
|
+
|
36
|
+
Then "I should see a confirmation message" do
|
37
|
+
expect_flash_notice "newemail@provider.com was successfully added"
|
38
|
+
end
|
39
|
+
|
40
|
+
Then "and I should see the newly included unconfirmed email on the list" do
|
41
|
+
within all("table tr")[1] do
|
42
|
+
expect_to_see @new_email
|
43
|
+
expect_to_see "Confirmation never sent"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
scenario "Blank" do
|
51
|
+
_when_I_submit "a blank", ""
|
52
|
+
|
53
|
+
Then "I should see an alert message" do
|
54
|
+
expect_flash_alert "Email can't be blank"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
scenario "Malformed" do
|
61
|
+
_when_I_submit "a malformed", "a@a"
|
62
|
+
|
63
|
+
Then "I should see an alert message" do
|
64
|
+
expect_flash_alert "Email is too short (minimum is 4 characters)"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
scenario "Taken" do
|
71
|
+
_when_I_submit "a malformed", USER_TEST_EMAIL
|
72
|
+
|
73
|
+
Then "I should see an alert message" do
|
74
|
+
expect_flash_alert "Email has already been taken"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
story "Remove" do
|
82
|
+
_before__given_I_am_on_the_emails_page
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
scenario "Cannot remove single email" do
|
87
|
+
But "I only have 1 email" do
|
88
|
+
# empty
|
89
|
+
end
|
90
|
+
|
91
|
+
When "I attempt to remove that email" do
|
92
|
+
click_on "Remove"
|
93
|
+
end
|
94
|
+
|
95
|
+
Then "I should see an alert message" do
|
96
|
+
expect_flash_alert "must have at least one credential"
|
97
|
+
end
|
98
|
+
|
99
|
+
Then "and I should still see that email on the list" do
|
100
|
+
within all("table tr")[0] do
|
101
|
+
expect_to_see USER_TEST_EMAIL
|
102
|
+
expect_to_see "Confirmation never sent"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
scenario "Can remove a second email" do
|
110
|
+
And "I have a second email" do
|
111
|
+
@new_email = "newemail@provider.com"
|
112
|
+
create(:email_credential, user: User.last, email: @new_email)
|
113
|
+
page_reload
|
114
|
+
end
|
115
|
+
|
116
|
+
When "I attempt to remove that email" do
|
117
|
+
click_nth_button("Remove", 1)
|
118
|
+
end
|
119
|
+
|
120
|
+
Then "I should see a confirmation message" do
|
121
|
+
expect_flash_notice "newemail@provider.com was successfully removed"
|
122
|
+
end
|
123
|
+
|
124
|
+
Then "and I should no longer see that email on the list" do
|
125
|
+
within all("table tr")[1] do
|
126
|
+
expect_not_to_see @new_email
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Then "nor in the database" do
|
131
|
+
expect(EmailCredential.pluck(:email)).not_to include @new_email
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
story "Send Confirmation" do
|
139
|
+
_before__given_I_am_on_the_emails_page
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
scenario "Success" do
|
144
|
+
|
145
|
+
expect_any_instance_of(Hello::Business::Management::SendConfirmationEmail).to receive(:deliver).and_call_original
|
146
|
+
|
147
|
+
When "I click the confirm button" do
|
148
|
+
click_button "Confirm"
|
149
|
+
end
|
150
|
+
|
151
|
+
Then "I should see a confirmation message" do
|
152
|
+
expect_flash_notice "We have sent a confirmation email to #{USER_TEST_EMAIL}"
|
153
|
+
end
|
154
|
+
|
155
|
+
Then "and I should see the confirmation button" do
|
156
|
+
expect(page).to have_button("Confirm")
|
157
|
+
end
|
158
|
+
|
159
|
+
Then "and I should see the confirmation email was recently sent" do
|
160
|
+
expect_to_see "less than a minute ago"
|
161
|
+
end
|
162
|
+
|
163
|
+
Then "and an email should be sent" do
|
164
|
+
# empty
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
story "Confirm" do
|
173
|
+
context "Who: As a User" do
|
174
|
+
scenario "Invalid Link" do
|
175
|
+
given_I_have_signed_in
|
176
|
+
_when_visit_invalid
|
177
|
+
_then_error_message_and_signed_out
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
scenario "Valid Link" do
|
183
|
+
given_I_have_signed_in
|
184
|
+
_when_visit_valid
|
185
|
+
_then_confirmed_and_signed_in
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
context "Who: As a Guest" do
|
192
|
+
scenario "Invalid Link" do
|
193
|
+
given_I_have_not_signed_in
|
194
|
+
_when_visit_invalid
|
195
|
+
_then_error_message_and_signed_out
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
scenario "Valid Link" do
|
201
|
+
given_I_have_not_signed_in
|
202
|
+
_when_visit_valid
|
203
|
+
_then_confirmed_and_signed_in
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
def the_url(id, token)
|
213
|
+
"http://host.com/hello/emails/#{id}/confirm/#{token}"
|
214
|
+
end
|
215
|
+
|
216
|
+
def _when_visit_invalid
|
217
|
+
When "I visit an invalid token URL" do
|
218
|
+
visit the_url(0, '1234')
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def _when_visit_valid
|
223
|
+
When "I visit a valid token URL" do
|
224
|
+
@credential = create(:email_credential)
|
225
|
+
token = @credential.reset_verifying_token!
|
226
|
+
visit the_url(@credential.id, token)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def _then_error_message_and_signed_out
|
231
|
+
Then "I should see the link has expired" do
|
232
|
+
expect_flash_alert "This link has expired, please ask for a new link"
|
233
|
+
end
|
234
|
+
|
235
|
+
then_I_expect_to_be_signed_out
|
236
|
+
end
|
237
|
+
|
238
|
+
def _then_confirmed_and_signed_in
|
239
|
+
Then "I should see a confirmation message" do
|
240
|
+
expect_flash_notice "#{@credential.email} has been confirmed successfully."
|
241
|
+
end
|
242
|
+
|
243
|
+
then_I_expect_to_be_signed_in_with_id(@credential.user_id)
|
244
|
+
|
245
|
+
Then "I expect to see the email was confirmed" do
|
246
|
+
expect(@credential.reload.email_confirmed?).to eq(true)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
capability: Manage Password
|
data/spec/bdd/hello/management/manage_password_credentials/manage_password_forgot_password_spec.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "Forgot Password" do
|
4
|
+
|
5
|
+
story "-" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
given_I_have_an_email_credential
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
context "Credentials Found" do
|
14
|
+
|
15
|
+
scenario 'Username' do
|
16
|
+
When "I submit a valid username" do
|
17
|
+
when_I_ask_to_reset_my_password
|
18
|
+
end
|
19
|
+
|
20
|
+
Then "I should see a confirmation message" do
|
21
|
+
expect_to_see "To get back into your account, follow the instructions we've sent to your \"foobar\" email address."
|
22
|
+
expect(current_path).to eq hello.forgot_passwords_path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
scenario 'Email' do
|
27
|
+
When "I submit a valid email" do
|
28
|
+
when_I_ask_to_reset_my_password('foo@bar.com')
|
29
|
+
end
|
30
|
+
|
31
|
+
Then "I should see a confirmation message" do
|
32
|
+
expect_to_see "To get back into your account, follow the instructions we've sent to your \"foo@bar.com\" email address."
|
33
|
+
expect(current_path).to eq hello.forgot_passwords_path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Then "and I should receive an email with a password reset URL" do
|
40
|
+
regexp = Regexp.new(/example.com\/hello\/passwords\/(\d*)\/reset\/(\d*)\/\w*/)
|
41
|
+
expect(open_last_email.to_s).to match regexp
|
42
|
+
# TODO: test this for a valid route
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
scenario "Credentials Not Found" do
|
49
|
+
When "I submit an invalid email" do
|
50
|
+
when_I_ask_to_reset_my_password('wrong')
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
Then "I should see an alert message" do
|
56
|
+
expect_error_message "1 error was found while locating your credentials"
|
57
|
+
expect(current_path).to eq hello.forgot_passwords_path
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
after do
|
65
|
+
then_I_expect_to_be_signed_out
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "Password Page" do
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def self._before__given_I_am_on_the_password_page
|
8
|
+
before do
|
9
|
+
Given "I am on the Password Management Page" do
|
10
|
+
given_I_have_signed_in_with_sudo_mode
|
11
|
+
click_link "Settings"
|
12
|
+
click_link "Password"
|
13
|
+
expect(current_path).to eq hello.password_path(PasswordCredential.last)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
story "Update Password" do
|
21
|
+
_before__given_I_am_on_the_password_page
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
scenario "Valid" do
|
26
|
+
When "I submit a new valid password" do
|
27
|
+
fill_in 'password_credential_password', with: (@new_password = 'newpassword')
|
28
|
+
click_button 'Update'
|
29
|
+
end
|
30
|
+
|
31
|
+
Then "I should see a confirmation message" do
|
32
|
+
expect_flash_notice "You have updated your profile successfully"
|
33
|
+
end
|
34
|
+
|
35
|
+
then_I_expect_to_be_signed_in
|
36
|
+
|
37
|
+
Then "and I should be able to sign in with the new password" do
|
38
|
+
click_link "Sign Out"
|
39
|
+
then_I_expect_to_be_signed_out
|
40
|
+
|
41
|
+
when_sign_in_with_standard_data(password: @new_password)
|
42
|
+
then_I_expect_to_be_signed_in
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
scenario "Invalid" do
|
49
|
+
When "I submit an invalid password" do
|
50
|
+
fill_in 'password_credential_password', with: ''
|
51
|
+
click_button 'Update'
|
52
|
+
end
|
53
|
+
|
54
|
+
Then "I should see an alert message" do
|
55
|
+
expect_error_message "1 error was found while updating your profile"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/spec/bdd/hello/management/manage_password_credentials/manage_password_reset_password_spec.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "Reset Password" do
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def _when_I_visit_with_an_invalid_token_then
|
8
|
+
When "I visit with an invalid token" do
|
9
|
+
visit hello.reset_password_path(999, 999, 'wrong')
|
10
|
+
end
|
11
|
+
_then_I_should_see_a_token_invalid_message
|
12
|
+
end
|
13
|
+
|
14
|
+
def _I_visit_with_a_valid_token
|
15
|
+
@reset_token ||= given_I_have_an_email_credential_and_forgot_my_password
|
16
|
+
p = PasswordCredential.last
|
17
|
+
visit hello.reset_password_path(p.id, p.user_id, @reset_token)
|
18
|
+
end
|
19
|
+
|
20
|
+
def _then_I_should_see_a_token_invalid_message
|
21
|
+
Then "I expect to see an alert message" do
|
22
|
+
expect_flash_alert "This link has expired, please ask for a new link"
|
23
|
+
expect(current_path).to eq hello.forgot_passwords_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
story "With roles" do
|
30
|
+
scenario "As a Guest" do
|
31
|
+
given_I_have_not_signed_in
|
32
|
+
_when_I_visit_with_an_invalid_token_then
|
33
|
+
then_I_expect_to_be_signed_out
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
scenario "As an Onboarding" do
|
39
|
+
given_I_have_signed_in_as_an_onboarding
|
40
|
+
_when_I_visit_with_an_invalid_token_then
|
41
|
+
then_I_expect_to_be_signed_out
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
scenario "As a User" do
|
47
|
+
given_I_have_signed_in
|
48
|
+
_when_I_visit_with_an_invalid_token_then
|
49
|
+
then_I_expect_to_be_signed_out
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
scenario "As a Webmaster" do
|
55
|
+
given_I_have_signed_in_as_a_webmaster
|
56
|
+
_when_I_visit_with_an_invalid_token_then
|
57
|
+
then_I_expect_to_be_signed_out
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
story "Open Page" do
|
64
|
+
scenario "Valid Token" do
|
65
|
+
When "I visit with a valid token" do
|
66
|
+
_I_visit_with_a_valid_token
|
67
|
+
end
|
68
|
+
|
69
|
+
Then "I should not see an alert message" do
|
70
|
+
expect_flash_alert_blank
|
71
|
+
end
|
72
|
+
|
73
|
+
then_I_expect_to_be_signed_out
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
scenario "Invalid Token" do
|
79
|
+
_when_I_visit_with_an_invalid_token_then
|
80
|
+
|
81
|
+
Then "I should see an alert message" do
|
82
|
+
expect_flash_alert "This link has expired, please ask for a new link"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
story "Update Password" do
|
90
|
+
before do
|
91
|
+
Given "I visit with a valid token" do
|
92
|
+
_I_visit_with_a_valid_token
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
scenario "Valid Password" do
|
99
|
+
When "I submit a new valid password" do
|
100
|
+
_I_submit @new_password = "123456"
|
101
|
+
end
|
102
|
+
|
103
|
+
Then "I should see a confirmation message" do
|
104
|
+
expect_flash_notice "You have reset your password successfully"
|
105
|
+
end
|
106
|
+
|
107
|
+
then_I_expect_to_be_signed_in
|
108
|
+
|
109
|
+
Then "and I should be able to sign in with the new password" do
|
110
|
+
click_link "Sign Out"
|
111
|
+
then_I_expect_to_be_signed_out
|
112
|
+
|
113
|
+
when_sign_in_with_standard_data(password: @new_password)
|
114
|
+
then_I_expect_to_be_signed_in
|
115
|
+
end
|
116
|
+
|
117
|
+
Then "the token should no longer be valid" do
|
118
|
+
_I_visit_with_a_valid_token
|
119
|
+
_then_I_should_see_a_token_invalid_message
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
scenario "Invalid Password" do
|
126
|
+
When "I submit a new valid password" do
|
127
|
+
_I_submit ""
|
128
|
+
end
|
129
|
+
|
130
|
+
Then "I should see an alert message" do
|
131
|
+
expect_to_see "1 error was found while resetting your password"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
def _I_submit(password)
|
139
|
+
within("form") do
|
140
|
+
fill_in 'reset_password_password', with: password
|
141
|
+
click_button 'Save'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|