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
|
+
Dir[SPEC_ROOT.join('support/**/*.rb')].each { |f| require f }
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
# https://github.com/thoughtbot/factory_girl/blob/webmaster/GETTING_STARTED.md
|
3
|
+
|
4
|
+
# https://github.com/stympy/faker#usage
|
5
|
+
|
6
|
+
FactoryGirl.define do
|
7
|
+
factory :user do
|
8
|
+
name { Faker::Name.name }
|
9
|
+
city { Faker::Address.city } # for dummy's customized sign up
|
10
|
+
locale 'en'
|
11
|
+
time_zone Time.zone.name
|
12
|
+
role 'user'
|
13
|
+
|
14
|
+
username { Faker::Internet.user_name(name, %w(-_)) }
|
15
|
+
|
16
|
+
# TODO: improve this
|
17
|
+
after(:build) { |user| build(:password_credential, user: user) }
|
18
|
+
after(:create) { |user| create(:password_credential, user: user) }
|
19
|
+
|
20
|
+
factory :webmaster_user do
|
21
|
+
name 'Admin'
|
22
|
+
role 'webmaster'
|
23
|
+
username 'webmaster'
|
24
|
+
factory :user_webmaster do
|
25
|
+
name 'Webmaster'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
factory :user_onboarding do
|
30
|
+
name 'Onboarding'
|
31
|
+
role 'onboarding'
|
32
|
+
username 'onboarding'
|
33
|
+
end
|
34
|
+
|
35
|
+
factory :user_user do
|
36
|
+
name 'User'
|
37
|
+
role 'user'
|
38
|
+
username 'user'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
factory :email_credential do
|
43
|
+
user
|
44
|
+
email { Faker::Internet.email }
|
45
|
+
end
|
46
|
+
|
47
|
+
factory :password_credential do
|
48
|
+
user
|
49
|
+
after(:build) { |pc| pc.password = '1234' }
|
50
|
+
end
|
51
|
+
|
52
|
+
factory :access do
|
53
|
+
user
|
54
|
+
expires_at nil
|
55
|
+
user_agent_string 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36'
|
56
|
+
factory :valid_access do
|
57
|
+
expires_at { 30.minutes.from_now }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module RSpec
|
2
|
+
def self.bdd
|
3
|
+
Bdd::FeatureInjection.instance
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Bdd
|
8
|
+
class FeatureInjection
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
def capability(s, *metadata, &example_group_block)
|
12
|
+
data = get_data(*metadata, &example_group_block)
|
13
|
+
s_vision = format('Vision', data['vision'])
|
14
|
+
RSpec.describe(s_vision, *metadata) do
|
15
|
+
goal data['goal'] do
|
16
|
+
capability s, type: :feature, &example_group_block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def uic(s, *metadata, &example_group_block)
|
22
|
+
data = get_data(*metadata, &example_group_block)
|
23
|
+
s_vision = format('Vision', data['vision'])
|
24
|
+
RSpec.describe(s_vision, *metadata) do
|
25
|
+
goal data['goal'] do
|
26
|
+
capability data['capability'] do
|
27
|
+
uic s, type: :feature, &example_group_block
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def api(s, *metadata, &example_group_block)
|
34
|
+
data = get_data(*metadata, &example_group_block)
|
35
|
+
s_vision = format('Vision', data['vision'])
|
36
|
+
RSpec.describe(s_vision, *metadata) do
|
37
|
+
goal data['goal'] do
|
38
|
+
capability data['capability'] do
|
39
|
+
api s, type: :request, &example_group_block
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_data(*_metadata, &example_group_block)
|
46
|
+
data = Hash.new('-')
|
47
|
+
|
48
|
+
# data = LOAD bdd.yml files from parent folders into
|
49
|
+
p = Pathname(example_group_block.source_location.first)
|
50
|
+
# data['feature'] = s
|
51
|
+
loop do
|
52
|
+
break if p.to_s.ends_with? '/spec'
|
53
|
+
r = p.join('bdd.yml')
|
54
|
+
data.reverse_merge!(YAML.load_file(r)) if r.exist?
|
55
|
+
p = p.parent
|
56
|
+
xxx = p.join('support.rb')
|
57
|
+
xxx.exist? && load(xxx)
|
58
|
+
end
|
59
|
+
data
|
60
|
+
end
|
61
|
+
|
62
|
+
def format(s1, s2)
|
63
|
+
[s1.underline.light_white, s2].join(': ')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
module RSpec
|
68
|
+
module ExampleGroups
|
69
|
+
def dig_context(k, v, *args, &b)
|
70
|
+
context(::RSpec.bdd.format(k, v), *args, &b)
|
71
|
+
end
|
72
|
+
|
73
|
+
def the_context(s, *args, &b)
|
74
|
+
context(::RSpec.bdd.format('Context', s), *args, &b)
|
75
|
+
end
|
76
|
+
|
77
|
+
def vision(s, *args, &b)
|
78
|
+
context(::RSpec.bdd.format('Vision', s), *args, &b)
|
79
|
+
end
|
80
|
+
|
81
|
+
def goal(s, *args, &b)
|
82
|
+
context(::RSpec.bdd.format('Goal', s), *args, &b)
|
83
|
+
end
|
84
|
+
|
85
|
+
def capability(s, *args, &b)
|
86
|
+
context(::RSpec.bdd.format('Capability', s), *args, &b)
|
87
|
+
end
|
88
|
+
|
89
|
+
def feature(s, *args, &b)
|
90
|
+
context(::RSpec.bdd.format('Feature', s), *args, &b)
|
91
|
+
end
|
92
|
+
|
93
|
+
def api(s, *args, &b)
|
94
|
+
context(::RSpec.bdd.format('Interface', s), *args, &b)
|
95
|
+
end
|
96
|
+
|
97
|
+
def uic(s, *args, &b)
|
98
|
+
context(::RSpec.bdd.format('Component', s), *args, &b)
|
99
|
+
end
|
100
|
+
|
101
|
+
def role(s, *args, &b)
|
102
|
+
context(::RSpec.bdd.format('Role', s), *args, &b)
|
103
|
+
end
|
104
|
+
|
105
|
+
def story(s, *args, &b)
|
106
|
+
context(::RSpec.bdd.format('Story', s), *args, &b)
|
107
|
+
end
|
108
|
+
|
109
|
+
def scenario(s, *args, &b)
|
110
|
+
super(::RSpec.bdd.format('Scenario', s), *args, &b)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
RSpec.configure do |config|
|
117
|
+
config.extend Bdd::RSpec::ExampleGroups
|
118
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Hello::FeatureSupportGiven
|
2
|
+
def given_I_have_not_signed_in
|
3
|
+
Given('I have not signed in') {}
|
4
|
+
end
|
5
|
+
|
6
|
+
def given_I_have_signed_in
|
7
|
+
Given 'I have signed in' do
|
8
|
+
given_I_am_logged_in
|
9
|
+
# @current_user = User.last
|
10
|
+
# @current_credential = Credential.last
|
11
|
+
# @current_access = Access.last
|
12
|
+
then_I_expect_to_be_signed_in_with_role('user')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def given_I_have_signed_in_with_sudo_mode
|
17
|
+
Given 'I have signed in with sudo mode' do
|
18
|
+
given_I_have_signed_in
|
19
|
+
then_I_expect_not_to_be_on_sudo_mode
|
20
|
+
visit '/hello/emails'
|
21
|
+
when_I_confirm_sudo_mode
|
22
|
+
then_I_expect_to_be_on_sudo_mode
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def given_I_have_signed_in_as_an_onboarding
|
27
|
+
Given 'I have signed in as an onboarding' do
|
28
|
+
sign_up_as_an_onboarding
|
29
|
+
then_I_expect_to_be_signed_in_with_role('onboarding')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def given_I_have_signed_in_as_a_user
|
34
|
+
Given 'I have signed in as a user' do
|
35
|
+
given_I_have_signed_in
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def given_I_have_signed_in_as_a_webmaster
|
40
|
+
Given 'I have signed in as a webmaster' do
|
41
|
+
given_I_have_a_webmaster_password_credential
|
42
|
+
when_sign_in_with_webmaster_data
|
43
|
+
then_I_expect_to_be_signed_in_with_role('webmaster')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Hello::FeatureSupportGiven
|
2
|
+
def then_I_expect_to_be_signed_out
|
3
|
+
Then 'I should be signed out' do
|
4
|
+
then_I_should_see 'dummy-logged-out'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def then_I_expect_to_be_signed_in
|
9
|
+
Then 'I should be signed in' do
|
10
|
+
then_I_should_see 'dummy-logged-in'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def then_I_expect_to_be_signed_in_with_role(role = 'user')
|
15
|
+
Then "I should be signed in as a #{role.capitalize}" do
|
16
|
+
then_I_should_see "dummy-logged-in-role-#{role}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def then_I_expect_to_be_signed_in_with_id(user_id)
|
21
|
+
Then 'I should be signed in as a specific user' do
|
22
|
+
then_I_should_see "dummy-logged-in-User##{user_id}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def then_I_expect_to_be_signed_in_with_sudo_mode
|
27
|
+
Then 'I should be signed in with Sudo Mode' do
|
28
|
+
then_I_should_see 'dummy-logged-in-with-sudo-mode'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def then_I_expect_to_be_on_sudo_mode
|
33
|
+
Then 'I should be on Sudo Mode' do
|
34
|
+
then_I_should_see 'dummy-logged-in-with-sudo-mode'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def then_I_expect_not_to_be_on_sudo_mode
|
39
|
+
Then 'I should not be on Sudo Mode' do
|
40
|
+
then_I_should_see 'dummy-logged-in-without-sudo-mode'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
# STORY CARD
|
3
|
+
|
4
|
+
def story_card(options = {})
|
5
|
+
before(:all) do
|
6
|
+
array = []
|
7
|
+
array << ['|', ' Who'.bold, options[:who].white].join(' ')
|
8
|
+
array << ['|', ' What'.bold, options[:what].white].join(' ')
|
9
|
+
array << ['|', ' Why'.bold, options[:why].white].join(' ')
|
10
|
+
|
11
|
+
x = array.max(&:length).uncolorize.length
|
12
|
+
s = '+' + ('-' * x)
|
13
|
+
t = 'STORY CARD:'.light_blue
|
14
|
+
puts nil, t, s, array, s, nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# FEATURE TERMS
|
19
|
+
|
20
|
+
def feature_set(*args, &b)
|
21
|
+
describe(*args, &b)
|
22
|
+
end
|
23
|
+
|
24
|
+
# AGILE TERMS
|
25
|
+
|
26
|
+
# def epic(*args, &b)
|
27
|
+
# describe(*args, &b)
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# def story(*args, &b)
|
31
|
+
# describe(*args, &b)
|
32
|
+
# end
|
33
|
+
|
34
|
+
# WWW
|
35
|
+
|
36
|
+
def feature_www(s, options = {}, &b)
|
37
|
+
s = ['Feature:', s, www(options)]
|
38
|
+
feature(s, &b)
|
39
|
+
end
|
40
|
+
|
41
|
+
def www(options = {})
|
42
|
+
r = []
|
43
|
+
r << "\n Who....: #{options[:who].light_black}" if options[:who]
|
44
|
+
r << "\n What...: #{options[:what].light_black}" if options[:what]
|
45
|
+
r << "\n Why....: #{options[:why].light_black}" if options[:why]
|
46
|
+
r << "\n Where..: #{options[:where].light_black}" if options[:where]
|
47
|
+
r.join('')
|
48
|
+
end
|
49
|
+
|
50
|
+
# WWW GROUPING
|
51
|
+
|
52
|
+
def who(s, &b)
|
53
|
+
describe('Who:', s.light_black, &b)
|
54
|
+
end
|
55
|
+
|
56
|
+
def what(s, &b)
|
57
|
+
describe('What:', s.light_black, &b)
|
58
|
+
end
|
59
|
+
|
60
|
+
# def why(s, &b)
|
61
|
+
# describe("Why:", s.light_black, &b)
|
62
|
+
# end
|
63
|
+
|
64
|
+
# WWW SCENARIOS
|
65
|
+
|
66
|
+
# def who_scenario(s, &b)
|
67
|
+
# scenario(s, &b)
|
68
|
+
# end
|
69
|
+
|
70
|
+
# def what_scenario(s, &b)
|
71
|
+
# scenario(s, &b)
|
72
|
+
# end
|
73
|
+
|
74
|
+
# def why_scenario(s, &b)
|
75
|
+
# scenario(s, &b)
|
76
|
+
# end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
def expect_flash_notice(text)
|
3
|
+
expect(page).to have_selector '.alert-success', text: text
|
4
|
+
end
|
5
|
+
|
6
|
+
def expect_flash_alert(text)
|
7
|
+
expect(page).to have_selector '.alert-warning', text: text
|
8
|
+
end
|
9
|
+
|
10
|
+
def expect_flash_info(text)
|
11
|
+
expect(page).to have_selector '.alert-info', text: text
|
12
|
+
end
|
13
|
+
|
14
|
+
def expect_flash_info_blank
|
15
|
+
expect(page).not_to have_selector '.alert-info'
|
16
|
+
end
|
17
|
+
|
18
|
+
def expect_flash_alert_blank
|
19
|
+
expect(page).not_to have_selector '.alert-warning'
|
20
|
+
end
|
21
|
+
|
22
|
+
def expect_error_message(text)
|
23
|
+
expect(page).to have_selector 'form h2.errors', text: text
|
24
|
+
end
|
25
|
+
|
26
|
+
def expect_to_see(text)
|
27
|
+
expect(page.text).to include text
|
28
|
+
end
|
29
|
+
|
30
|
+
def expect_not_to_see(text)
|
31
|
+
expect(page.text).not_to include text
|
32
|
+
end
|
33
|
+
|
34
|
+
def expect_to_have_a_layout
|
35
|
+
expect_to_see('dummy')
|
36
|
+
end
|
37
|
+
|
38
|
+
def expect_not_to_have_a_layout
|
39
|
+
expect_not_to_see('dummy')
|
40
|
+
end
|
41
|
+
|
42
|
+
def expect_to_be_on(path)
|
43
|
+
expect(current_path).to eq path
|
44
|
+
end
|
45
|
+
|
46
|
+
def expect_flash_notice_signed_in
|
47
|
+
expect_flash_notice 'You have signed in successfully'
|
48
|
+
end
|
49
|
+
|
50
|
+
def expect_flash_auth(situation)
|
51
|
+
case situation
|
52
|
+
when nil then expect_flash_alert_blank
|
53
|
+
when :must_be_authenticated then expect_flash_alert 'You must sign in to continue.'
|
54
|
+
when :cannot_be_a_authenticated then expect_flash_alert 'You have already signed in.'
|
55
|
+
when :must_be_an_onboarding then expect_flash_alert 'You have already completed your registration.'
|
56
|
+
when :cannot_be_an_onboarding then expect_flash_alert 'Please complete your registration.'
|
57
|
+
when :must_be_a_master then expect_flash_alert 'This section of website is restricted to admins.'
|
58
|
+
else fail("unknown auth_situation '#{situation}'")
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
USER_TEST_EMAIL = 'foo@bar.com'.freeze
|
4
|
+
USER_TEST_USERNAME = 'foobar'.freeze
|
5
|
+
|
6
|
+
def given_I_have_a_classic_access_token
|
7
|
+
user = create(:user, name: 'James Pinto', username: USER_TEST_USERNAME, city: 'Brasilia')
|
8
|
+
create(:email_credential, user: user, email: USER_TEST_EMAIL)
|
9
|
+
Access.create!(user: user, user_agent_string: 'testing', expires_at: 24.hours.from_now)
|
10
|
+
end
|
11
|
+
|
12
|
+
def given_I_have_an_email_credential
|
13
|
+
user = create(:user, name: 'James Pinto', username: USER_TEST_USERNAME, city: 'Brasilia')
|
14
|
+
create(:email_credential, user: user, email: USER_TEST_EMAIL)
|
15
|
+
end
|
16
|
+
|
17
|
+
def given_I_have_an_onboarding_password_credential
|
18
|
+
user = create(:onboarding)
|
19
|
+
create(:email_credential, user: user, email: USER_TEST_EMAIL)
|
20
|
+
end
|
21
|
+
|
22
|
+
def given_I_have_a_webmaster_password_credential
|
23
|
+
user = create(:webmaster_user)
|
24
|
+
create(:email_credential, user: user, email: 'webmaster@bar.com')
|
25
|
+
end
|
26
|
+
|
27
|
+
def given_I_have_an_email_credential_and_forgot_my_password
|
28
|
+
credential = given_I_have_an_email_credential
|
29
|
+
unencrypted_token = credential.user.password_credential.reset_verifying_token!
|
30
|
+
end
|
31
|
+
|
32
|
+
def given_I_am_logged_in_with_a_classic_credential
|
33
|
+
# when_sign_up_with_standard_data(expect_welcome_mailer: true)
|
34
|
+
given_I_have_an_email_credential
|
35
|
+
when_sign_in_with_standard_data
|
36
|
+
then_I_should_be_logged_in
|
37
|
+
end
|
38
|
+
|
39
|
+
def given_I_am_logged_in
|
40
|
+
given_I_am_logged_in_with_a_classic_credential
|
41
|
+
end
|
42
|
+
|
43
|
+
def given_I_am_logged_in_with_two_accounts
|
44
|
+
given_I_have_signed_in
|
45
|
+
given_I_have_a_webmaster_password_credential
|
46
|
+
when_sign_in_with_webmaster_data
|
47
|
+
then_I_expect_to_be_signed_in_with_role('webmaster')
|
48
|
+
expect_to_see 'dummy-accounts-2'
|
49
|
+
end
|