hello-rails 0.0.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,159 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.capability 'I can Sign Out' do
|
4
|
+
|
5
|
+
role 'User' do
|
6
|
+
Given 'I am a User' do
|
7
|
+
sign_in_as_a('user')
|
8
|
+
expect(Access.count).to eq(1)
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'Components', type: :feature do
|
12
|
+
|
13
|
+
uic 'Sign Out Button' do
|
14
|
+
|
15
|
+
scenario 'One Account' do
|
16
|
+
|
17
|
+
Given 'I am signed in with a single account' do
|
18
|
+
# intentionally left blank
|
19
|
+
end
|
20
|
+
|
21
|
+
When 'I attempt to sign out' do
|
22
|
+
click_link 'Sign Out'
|
23
|
+
end
|
24
|
+
|
25
|
+
Then 'I should see a confirmation message' do
|
26
|
+
expect_flash_notice 'You have signed out!'
|
27
|
+
end
|
28
|
+
|
29
|
+
Then 'and I should be signed out' do
|
30
|
+
then_I_expect_to_be_signed_out
|
31
|
+
end
|
32
|
+
|
33
|
+
Then 'Database now has 0 Access' do
|
34
|
+
expect(Access.count).to eq(0)
|
35
|
+
end
|
36
|
+
|
37
|
+
end # scenario
|
38
|
+
|
39
|
+
scenario 'Two Accounts' do
|
40
|
+
|
41
|
+
Given 'I sign in as a second user' do
|
42
|
+
u = create(:user_user, username: 'foobar')
|
43
|
+
sign_in_with(u.username)
|
44
|
+
expect(Access.count).to eq(2)
|
45
|
+
end
|
46
|
+
|
47
|
+
When 'I attempt to sign out' do
|
48
|
+
click_link 'Sign Out'
|
49
|
+
end
|
50
|
+
|
51
|
+
Then 'I should see a confirmation message' do
|
52
|
+
expect_flash_notice 'You have signed out!'
|
53
|
+
end
|
54
|
+
|
55
|
+
Then 'and I should be signed in' do
|
56
|
+
then_I_expect_to_be_signed_in
|
57
|
+
end
|
58
|
+
|
59
|
+
Then 'Database now has 1 Access' do
|
60
|
+
expect(Access.count).to eq(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
end # scenario
|
64
|
+
|
65
|
+
end # uic
|
66
|
+
|
67
|
+
end # context
|
68
|
+
|
69
|
+
context 'Features', type: :feature do
|
70
|
+
|
71
|
+
feature 'Token Expiration' do
|
72
|
+
|
73
|
+
scenario 'Does not renew after 09 minutes' do
|
74
|
+
|
75
|
+
When 'I visit the home page after 09 minutes' do
|
76
|
+
visit_path_after(root_path, 9.minutes)
|
77
|
+
end
|
78
|
+
|
79
|
+
Then 'I should be signed in' do
|
80
|
+
then_I_expect_to_be_signed_in
|
81
|
+
end
|
82
|
+
|
83
|
+
Then 'My access should expire in less than 29 minutes' do
|
84
|
+
expect(current_access.reload.expires_at).not_to be > 29.minutes.from_now
|
85
|
+
end
|
86
|
+
|
87
|
+
end # scenario
|
88
|
+
|
89
|
+
scenario 'Renews after 11 minutes' do
|
90
|
+
|
91
|
+
When 'I visit the home page after 11 minutes' do
|
92
|
+
visit_path_after(root_path, 11.minutes)
|
93
|
+
end
|
94
|
+
|
95
|
+
Then 'I should be signed in' do
|
96
|
+
then_I_expect_to_be_signed_in
|
97
|
+
end
|
98
|
+
|
99
|
+
Then 'My access should expire in more than 29 minutes' do
|
100
|
+
expect(current_access.reload.expires_at).to be > 29.minutes.from_now
|
101
|
+
end
|
102
|
+
|
103
|
+
end # scenario
|
104
|
+
|
105
|
+
scenario 'Expires after 31 minutes' do
|
106
|
+
|
107
|
+
When 'I visit the home page after 31 minutes' do
|
108
|
+
visit_path_after(root_path, 31.minutes)
|
109
|
+
end
|
110
|
+
|
111
|
+
Then 'I should be signed out' do
|
112
|
+
then_I_expect_to_be_signed_out
|
113
|
+
end
|
114
|
+
|
115
|
+
Then 'My access should have expired' do
|
116
|
+
expect(Access.count).to eq(0)
|
117
|
+
end
|
118
|
+
|
119
|
+
end # scenario
|
120
|
+
|
121
|
+
end # feature
|
122
|
+
|
123
|
+
feature 'Unlinked', type: :feature do
|
124
|
+
|
125
|
+
scenario 'One Access' do
|
126
|
+
|
127
|
+
Given 'I should be signed in' do
|
128
|
+
visit '/'
|
129
|
+
then_I_expect_to_be_signed_in
|
130
|
+
end
|
131
|
+
|
132
|
+
When 'I get unlinked' do
|
133
|
+
Access.destroy_all
|
134
|
+
visit hello.profile_path
|
135
|
+
end
|
136
|
+
|
137
|
+
Then 'I should be signed out' do
|
138
|
+
then_I_expect_to_be_signed_out
|
139
|
+
end
|
140
|
+
|
141
|
+
Then 'I should be sent to the sign in page' do
|
142
|
+
expect_to_be_on hello.sign_in_path
|
143
|
+
end
|
144
|
+
|
145
|
+
end # scenario
|
146
|
+
|
147
|
+
end # feature
|
148
|
+
|
149
|
+
end # context
|
150
|
+
|
151
|
+
api 'API', type: :request do
|
152
|
+
|
153
|
+
skip 'TODO: write API features here too'
|
154
|
+
|
155
|
+
end # api
|
156
|
+
|
157
|
+
end # role
|
158
|
+
|
159
|
+
end # capability
|
@@ -0,0 +1 @@
|
|
1
|
+
vision: Hello Gem
|
@@ -0,0 +1 @@
|
|
1
|
+
capability: Anyone Can Change Their Locale
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "On The Sign In Form" do
|
4
|
+
|
5
|
+
# ACCEPTANCE CRITERIA
|
6
|
+
# -
|
7
|
+
|
8
|
+
story "As a Guest" do
|
9
|
+
scenario "Success" do
|
10
|
+
Given "the Browser's locale is set to 'Portuguese (Brazil)'" do
|
11
|
+
_set_the_locale_to 'Portuguese (Brazil)'
|
12
|
+
end
|
13
|
+
|
14
|
+
Then "I expect to a confirmation message in 'pt-BR'" do
|
15
|
+
expect_flash_notice "Seu idioma foi atualizado com sucesso. 'Português (Brasil)'"
|
16
|
+
end
|
17
|
+
|
18
|
+
_then_the_browser_locale_should_be('pt-BR')
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
When "I set the locale to 'English'" do
|
23
|
+
_set_the_locale_to 'English'
|
24
|
+
end
|
25
|
+
|
26
|
+
Then "I expect to a confirmation message in 'en'" do
|
27
|
+
expect_flash_notice "Your current language has been applied successfully. 'English'"
|
28
|
+
end
|
29
|
+
|
30
|
+
_then_the_browser_locale_should_be('en')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
story "As a User" do
|
37
|
+
scenario "Success" do
|
38
|
+
given_I_have_signed_in
|
39
|
+
|
40
|
+
_then_the_database_locale_should_be('en')
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
When "the Browser's locale is set to 'Portuguese (Brazil)'" do
|
45
|
+
_set_the_locale_to 'Portuguese (Brazil)'
|
46
|
+
end
|
47
|
+
|
48
|
+
Then "I expect to a confirmation message in 'pt-BR'" do
|
49
|
+
expect_flash_notice "Seu idioma foi atualizado com sucesso. 'Português (Brasil)'"
|
50
|
+
end
|
51
|
+
|
52
|
+
_then_the_browser_locale_should_be('pt-BR')
|
53
|
+
|
54
|
+
_then_the_database_locale_should_be('pt-BR')
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
When "I set the locale to 'Spanish'" do
|
59
|
+
_set_the_locale_to 'Spanish'
|
60
|
+
end
|
61
|
+
|
62
|
+
Then "I expect to a confirmation message in 'es'" do
|
63
|
+
expect_flash_notice "Su idioma ha sido configurado exitosamente. 'Español'"
|
64
|
+
end
|
65
|
+
|
66
|
+
_then_the_browser_locale_should_be('es')
|
67
|
+
|
68
|
+
_then_the_database_locale_should_be('es')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
def _set_the_locale_to(string)
|
75
|
+
visit hello.locale_path
|
76
|
+
click_button string
|
77
|
+
end
|
78
|
+
|
79
|
+
def _then_the_browser_locale_should_be(string)
|
80
|
+
Then "the Browser's locale should be #{string}" do
|
81
|
+
expect_to_see "dummy-locale: #{string}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def _then_the_database_locale_should_be(string)
|
86
|
+
Then "the Database's locale should be '#{string}'" do
|
87
|
+
expect(User.last.locale).to eq string
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "On The Profile Page" do
|
4
|
+
|
5
|
+
# ACCEPTANCE CRITERIA
|
6
|
+
# -
|
7
|
+
|
8
|
+
story "As a User" do
|
9
|
+
scenario "Success" do
|
10
|
+
given_I_have_signed_in
|
11
|
+
|
12
|
+
_then_the_database_locale_should_be('en')
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
_when_I_update_my_locale_to('Portuguese (Brazil)')
|
17
|
+
|
18
|
+
Then "I expect to a confirmation message in 'pt-BR'" do
|
19
|
+
expect_flash_notice "Você atualizou seu perfil com sucesso"
|
20
|
+
end
|
21
|
+
|
22
|
+
_then_the_browser_locale_should_be('pt-BR')
|
23
|
+
|
24
|
+
_then_the_database_locale_should_be('pt-BR')
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
_when_I_update_my_locale_to('Spanish')
|
29
|
+
|
30
|
+
Then "I expect to a confirmation message in 'es'" do
|
31
|
+
expect_flash_notice "Su perfil ha sido actualizado exitosamente"
|
32
|
+
end
|
33
|
+
|
34
|
+
_then_the_browser_locale_should_be('es')
|
35
|
+
|
36
|
+
_then_the_database_locale_should_be('es')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
def _when_I_update_my_locale_to(string)
|
43
|
+
When "I update my locale to '#{string}'" do
|
44
|
+
visit hello.profile_path
|
45
|
+
|
46
|
+
within("form") do
|
47
|
+
find("#user_locale").select(string)
|
48
|
+
click_button "Update"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def _then_the_browser_locale_should_be(string)
|
54
|
+
Then "the Browser's locale should be #{string}" do
|
55
|
+
expect_to_see "dummy-locale: #{string}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def _then_the_database_locale_should_be(string)
|
60
|
+
Then "the Database's locale should be '#{string}'" do
|
61
|
+
expect(User.last.locale).to eq string
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "On The Sign In Form" do
|
4
|
+
|
5
|
+
# ACCEPTANCE CRITERIA
|
6
|
+
# - My browser learns my account’s locale
|
7
|
+
|
8
|
+
story "As a Guest" do
|
9
|
+
scenario "Success" do
|
10
|
+
Given "The browser's locale is set to 'English'" do
|
11
|
+
visit '/'
|
12
|
+
expect_to_see "dummy-locale: en"
|
13
|
+
end
|
14
|
+
|
15
|
+
When "I sign in to a 'pt-BR' user" do
|
16
|
+
user = given_I_have_an_email_credential.user
|
17
|
+
user.update! locale: 'pt-BR'
|
18
|
+
when_sign_in_with_standard_data(skip_expire: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
Then "I expect to a confirmation message in 'en'" do
|
22
|
+
expect_flash_notice "You have signed in successfully"
|
23
|
+
end
|
24
|
+
|
25
|
+
Then "the Browser's locale should be 'pt-BR'" do
|
26
|
+
expect_to_see "dummy-locale: pt-BR"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.uic "On The Sign Up Form" do
|
4
|
+
|
5
|
+
# ACCEPTANCE CRITERIA
|
6
|
+
# - My account learns my browser’s locale
|
7
|
+
|
8
|
+
story "As a Guest" do
|
9
|
+
scenario "Success" do
|
10
|
+
Given "I set the browser's locale to 'Portuguese (Brazil)'" do
|
11
|
+
visit hello.locale_path
|
12
|
+
click_button 'Portuguese (Brazil)'
|
13
|
+
expect_flash_notice "Seu idioma foi atualizado com sucesso. 'Português (Brasil)'"
|
14
|
+
end
|
15
|
+
|
16
|
+
When "I sign up" do
|
17
|
+
when_sign_up_as_an_onboarding(skip_expire: true, expect_welcome_mailer: true)
|
18
|
+
end
|
19
|
+
|
20
|
+
Then "I expect to a confirmation message in 'pt-BR'" do
|
21
|
+
expect_flash_notice "Você se cadastrou com sucesso"
|
22
|
+
end
|
23
|
+
|
24
|
+
Then "the Browser's locale should be 'pt-BR'" do
|
25
|
+
expect_to_see "dummy-locale: pt-BR"
|
26
|
+
end
|
27
|
+
|
28
|
+
Then "the Database's locale should be 'pt-BR'" do
|
29
|
+
expect(User.last.locale).to eq('pt-BR')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
capability: Anyone Can Change Their Timezone
|
@@ -0,0 +1 @@
|
|
1
|
+
goal: Internationalization
|
@@ -0,0 +1 @@
|
|
1
|
+
goal: Management
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.bdd.capability "I can Cancel my Account" do
|
4
|
+
|
5
|
+
# TODO: test with onboarding too
|
6
|
+
|
7
|
+
%w[user webmaster].each do |role_string|
|
8
|
+
role role_string.titleize do
|
9
|
+
context "Components", type: :feature do
|
10
|
+
|
11
|
+
Given "I am a #{role_string.titleize}" do
|
12
|
+
sign_in_as_a(role_string)
|
13
|
+
end
|
14
|
+
|
15
|
+
uic "Cancel Account Page" do
|
16
|
+
|
17
|
+
Given "I visit the Cancel Account Page" do
|
18
|
+
visit '/'
|
19
|
+
click_link 'Settings'
|
20
|
+
click_link 'Cancel Account'
|
21
|
+
end
|
22
|
+
|
23
|
+
Given 'I go through sudo mode' do
|
24
|
+
fill_in 'user_password', with: '1234'
|
25
|
+
click_button 'Confirm'
|
26
|
+
end
|
27
|
+
|
28
|
+
story "Valid" do
|
29
|
+
|
30
|
+
scenario "Success" do
|
31
|
+
|
32
|
+
And "User has no dependent children" do
|
33
|
+
end
|
34
|
+
|
35
|
+
When 'I attempt to cancel my account' do
|
36
|
+
click_button 'Cancel'
|
37
|
+
end
|
38
|
+
|
39
|
+
Then "I should be on the home page" do
|
40
|
+
expect_to_be_on '/'
|
41
|
+
end
|
42
|
+
|
43
|
+
Then "I should see a confirmation message" do
|
44
|
+
expect_flash_notice "You have deactivated your account successfully"
|
45
|
+
end
|
46
|
+
|
47
|
+
Then "and I should be signed out" do
|
48
|
+
then_I_expect_to_be_signed_out
|
49
|
+
end
|
50
|
+
|
51
|
+
Then "and my data should be removed from the database" do
|
52
|
+
expect(User.count).to eq(0)
|
53
|
+
expect(Credential.count).to eq(0)
|
54
|
+
expect(Access.count).to eq(0)
|
55
|
+
end
|
56
|
+
|
57
|
+
end # scenario
|
58
|
+
|
59
|
+
end # story
|
60
|
+
|
61
|
+
story "Invalid" do
|
62
|
+
|
63
|
+
scenario "User has dependent children" do
|
64
|
+
But "User has dependent children" do
|
65
|
+
User.last.addresses.create! text: "foo"
|
66
|
+
end
|
67
|
+
|
68
|
+
When 'I attempt to cancel my account' do
|
69
|
+
click_button 'Cancel'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
scenario "User has dependent grandchildren" do
|
74
|
+
But "User has dependent grandchildren" do
|
75
|
+
EmailCredential.last.some_credential_data.create! text: "foo"
|
76
|
+
end
|
77
|
+
|
78
|
+
When 'I attempt to cancel my account' do
|
79
|
+
click_button 'Cancel'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
scenario "Some other reason" do
|
84
|
+
But "an exception" do
|
85
|
+
expect_any_instance_of(::User).to receive(:destroy!).and_raise(ActiveRecord::RecordNotDestroyed.new("mock!", ::User.new))
|
86
|
+
end
|
87
|
+
|
88
|
+
When 'I attempt to cancel my account' do
|
89
|
+
click_button 'Cancel'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
Then "I should be back on the Cancel Account page" do
|
95
|
+
expect_to_see 'Are you sure you want to cancel your account?'
|
96
|
+
end
|
97
|
+
|
98
|
+
Then "I should see an error message" do
|
99
|
+
expect_flash_alert "Terminating your account would cause other users to experience errors while using our website. Please contact any of our staff members and ask to have your account removed manually."
|
100
|
+
end
|
101
|
+
|
102
|
+
Then "and I should be signed in" do
|
103
|
+
then_I_expect_to_be_signed_in
|
104
|
+
end
|
105
|
+
|
106
|
+
Then "and my data should not be removed from the database" do
|
107
|
+
expect(User.count).to eq(1)
|
108
|
+
expect(EmailCredential.count).to eq(1)
|
109
|
+
expect(PasswordCredential.count).to eq(1)
|
110
|
+
expect(Access.count).to eq(1)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end # uic
|
116
|
+
end # context
|
117
|
+
|
118
|
+
|
119
|
+
context "API", type: :request do
|
120
|
+
api "API" do
|
121
|
+
skip "ToDo: write API features here too"
|
122
|
+
end
|
123
|
+
end # context
|
124
|
+
|
125
|
+
end # role
|
126
|
+
end
|
127
|
+
|
128
|
+
end # capability
|