-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add factory bot and tests for complete profile endpoint
- Loading branch information
1 parent
b52363e
commit 7ca939a
Showing
10 changed files
with
154 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
require: | ||
- rubocop-factory_bot | ||
- rubocop-minitest | ||
- rubocop-performance | ||
- rubocop-rake | ||
- rubocop-sequel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class Account < Sequel::Model | ||
many_to_one :account_status, key: :status_id | ||
one_to_one :account_password_hash | ||
one_to_one :account_information | ||
end | ||
|
||
FactoryBot.define do | ||
factory :account do | ||
transient do | ||
password { "password" } | ||
account_information { {} } | ||
end | ||
email { Faker::Internet.email } | ||
account_status { AccountStatus.verified } | ||
after(:create) do |account, evaluator| | ||
create(:account_password_hash, account:, password: evaluator.password) | ||
create(:account_information, account:, **evaluator.account_information) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountInformation < Sequel::Model | ||
many_to_one :account | ||
end | ||
FactoryBot.define do | ||
factory :account_information do | ||
account | ||
about_me { Faker::Lorem.paragraph } | ||
birth_date { Date.new(1985, 8, 5) } | ||
genders { %w[questioning man] } | ||
orientations { %w[bisexual fluid] } | ||
languages { %w[eng por spa] } | ||
relationship_status { "partnered" } | ||
relationship_type { "non_monogamous" } | ||
tobacco { "never" } | ||
marijuana { "sometimes" } | ||
alcohol { "sometimes" } | ||
other_recreational_drugs { "sometimes" } | ||
pets { "have" } | ||
wants_pets { "maybe" } | ||
kids { "have_not" } | ||
wants_kids { "do_not_want_any" } | ||
religion { "atheism" } | ||
religion_importance { "not_important" } | ||
display_name { Faker::Twitter.screen_name } | ||
created_at { Time.now } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountPasswordHash < Sequel::Model | ||
many_to_one :account, key: :id | ||
end | ||
|
||
FactoryBot.define do | ||
factory :account_password_hash do | ||
transient do | ||
password { "password" } | ||
end | ||
account | ||
password_hash { puts password; BCrypt::Password.create(password, cost: BCrypt::Engine::MIN_COST) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountStatus < Sequel::Model | ||
class << self | ||
def verified | ||
@verified ||= AccountStatus.where(name: "Verified").first | ||
end | ||
end | ||
end | ||
|
||
FactoryBot.define do | ||
factory :account_status do | ||
name { "status" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters