2020-01-03 02:44:06 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ProfileStories
|
|
|
|
attr_reader :bob, :alice, :alice_bio
|
|
|
|
|
|
|
|
def as_a_registered_user
|
|
|
|
@bob = Fabricate(
|
|
|
|
:user,
|
|
|
|
email: email, password: password, confirmed_at: confirmed_at,
|
|
|
|
account: Fabricate(:account, username: 'bob')
|
|
|
|
)
|
2023-07-28 23:09:49 +02:00
|
|
|
|
2024-01-30 16:38:33 +01:00
|
|
|
Web::Setting.where(user: bob).first_or_initialize(user: bob).update!(data: { introductionVersion: 2018_12_16_044202 }) if finished_onboarding
|
2020-01-03 02:44:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def as_a_logged_in_user
|
|
|
|
as_a_registered_user
|
|
|
|
visit new_user_session_path
|
|
|
|
fill_in 'user_email', with: email
|
|
|
|
fill_in 'user_password', with: password
|
2024-01-04 10:20:32 +01:00
|
|
|
click_on I18n.t('auth.login')
|
2020-01-03 02:44:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def with_alice_as_local_user
|
2023-02-17 22:56:20 +01:00
|
|
|
@alice_bio = '@alice and @bob are fictional characters commonly used as' \
|
|
|
|
'placeholder names in #cryptology, as well as #science and' \
|
2022-03-06 22:51:40 +01:00
|
|
|
'engineering 📖 literature. Not affiliated with @pepe.'
|
2020-01-03 02:44:06 +01:00
|
|
|
|
|
|
|
@alice = Fabricate(
|
|
|
|
:user,
|
|
|
|
email: 'alice@example.com', password: password, confirmed_at: confirmed_at,
|
|
|
|
account: Fabricate(:account, username: 'alice', note: @alice_bio)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def confirmed_at
|
|
|
|
@confirmed_at ||= Time.zone.now
|
|
|
|
end
|
|
|
|
|
|
|
|
def email
|
|
|
|
@email ||= 'test@example.com'
|
|
|
|
end
|
|
|
|
|
|
|
|
def password
|
|
|
|
@password ||= 'password'
|
|
|
|
end
|
2023-07-28 23:09:49 +02:00
|
|
|
|
|
|
|
def finished_onboarding
|
|
|
|
@finished_onboarding || false
|
|
|
|
end
|
2020-01-03 02:44:06 +01:00
|
|
|
end
|