* set up refactored onboarding * create onboarding page * add in first slide and change slide functionality * fix test suite * profile refactor * profile refactor * refactor to api * add checkbox fields * add checkbox fields * remove puts * add basic css * add styling * add redirect * hide back and next at first and last slides * test refactored onboarding * test refactored onboarding * remove article edits * Fix schema * Add deleted file back in * Add default value for checked_t&c column * Adjust HTML structure to keep nav buttons in place * Fix ESLint issues on Onboarding.jsx file * Handling for undefined or empty followedTags on getUserTags * Fix codeclimate issues * Fix codeclimate issues * Fix more codeclimate issues * Fix more codeclimate issues * Update Onboarding snapshots * Uncheck the CoC and T&C checkboxes on render * Update snapshots * Return false instead of raising error * Update spec to use new onboarding * Redirect to onboarding if haven't seen it yet * Prevent redirect to onboarding from /signout_confirm * Use assign_attributes instead of saving twice * Move COC and T&C checkbox page to second slide * Add 'go back to original page' functionality * Reuse ready prototype logic * Keep track of the last visited onboarding page * Fix email subscription bug * Fix overflow issue for tags page * Remove height to prevent page container scrolling * Check for CoC and T&C for displaying onboarding * Add InstantClick redirect and preserve referrer in client * Fix async update + check by using localStorage * Turn off onboarding for tests * Finalize design for onboarding * Finalize design for onboarding * Make bulk follows during onboarding * Fix bulk follow test
105 lines
3 KiB
Ruby
105 lines
3 KiB
Ruby
FactoryBot.define do
|
|
sequence(:email) { |n| "person#{n}@example.com" }
|
|
sequence(:username) { |n| "username#{n}" }
|
|
sequence(:twitter_username) { |n| "twitter#{n}" }
|
|
sequence(:github_username) { |n| "github#{n}" }
|
|
|
|
image = Rack::Test::UploadedFile.new(
|
|
Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg"),
|
|
"image/jpeg",
|
|
)
|
|
|
|
factory :user do
|
|
name { Faker::Name.name }
|
|
email { generate :email }
|
|
username { generate :username }
|
|
profile_image { image }
|
|
twitter_username { generate :twitter_username }
|
|
github_username { generate :github_username }
|
|
summary { Faker::Lorem.paragraph[0..rand(190)] }
|
|
website_url { Faker::Internet.url }
|
|
confirmed_at { Time.current }
|
|
saw_onboarding { true }
|
|
checked_code_of_conduct { true }
|
|
checked_terms_and_conditions { true }
|
|
signup_cta_variant { "navbar_basic" }
|
|
email_digest_periodic { false }
|
|
|
|
after(:create) do |user|
|
|
create(:identity, user_id: user.id)
|
|
end
|
|
|
|
trait :two_identities do
|
|
after(:create) { |user| create(:identity, user_id: user.id, provider: "twitter") }
|
|
end
|
|
|
|
trait :super_admin do
|
|
after(:build) { |user| user.add_role(:super_admin) }
|
|
end
|
|
|
|
trait :admin do
|
|
after(:build) { |user| user.add_role(:admin) }
|
|
end
|
|
|
|
trait :trusted do
|
|
after(:build) { |user| user.add_role(:trusted) }
|
|
end
|
|
|
|
trait :banned do
|
|
after(:build) { |user| user.add_role(:banned) }
|
|
end
|
|
|
|
trait :video_permission do
|
|
after(:build) { |user| user.created_at = 3.weeks.ago }
|
|
end
|
|
|
|
trait :ignore_after_callback do
|
|
after(:build) do |user|
|
|
user.define_singleton_method(:subscribe_to_mailchimp_newsletter) {}
|
|
# user.class.skip_callback(:validates, :after_create)
|
|
end
|
|
end
|
|
|
|
trait :pro do
|
|
after(:build) { |user| user.add_role :pro }
|
|
end
|
|
|
|
trait :org_member do
|
|
after(:create) do |user|
|
|
org = create(:organization)
|
|
create(:organization_membership, user_id: user.id, organization_id: org.id, type_of_user: "member")
|
|
end
|
|
end
|
|
|
|
trait :org_admin do
|
|
after(:create) do |user|
|
|
org = create(:organization)
|
|
create(:organization_membership, user_id: user.id, organization_id: org.id, type_of_user: "admin")
|
|
end
|
|
end
|
|
|
|
trait :with_article do
|
|
after(:create) do |user|
|
|
create(:article, user_id: user.id)
|
|
user.update(articles_count: 1)
|
|
end
|
|
end
|
|
|
|
trait :with_only_comment do
|
|
after(:create) do |user|
|
|
other_user = create(:user)
|
|
article = create(:article, user_id: other_user.id)
|
|
create(:comment, user_id: user.id, commentable_id: article.id)
|
|
user.update(comments_count: 1)
|
|
end
|
|
end
|
|
|
|
trait :with_article_and_comment do
|
|
after(:create) do |user|
|
|
article = create(:article, user_id: user.id)
|
|
create(:comment, user_id: user.id, commentable_id: article.id)
|
|
user.update(articles_count: 1, comments_count: 1)
|
|
end
|
|
end
|
|
end
|
|
end
|