Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup factories and annotate them, drop partner users table #4536

Merged
merged 7 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions db/migrate/20240718010905_drop_partner_users_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class DropPartnerUsersTable < ActiveRecord::Migration[7.1]
def up
drop_table :partner_users

end
def down
fail ActiveRecord::IrreversibleMigration
end
end
34 changes: 1 addition & 33 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_07_11_020808) do
ActiveRecord::Schema[7.1].define(version: 2024_07_18_010905) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -631,38 +631,6 @@
t.index ["partner_profile_id"], name: "index_partner_served_areas_on_partner_profile_id"
end

create_table "partner_users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at", precision: nil
t.datetime "remember_created_at", precision: nil
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at", precision: nil
t.datetime "last_sign_in_at", precision: nil
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.string "invitation_token"
t.datetime "invitation_created_at", precision: nil
t.datetime "invitation_sent_at", precision: nil
t.datetime "invitation_accepted_at", precision: nil
t.integer "invitation_limit"
t.string "invited_by_type"
t.bigint "invited_by_id"
t.integer "invitations_count", default: 0
t.bigint "partner_id"
t.string "name"
t.index ["email"], name: "index_partner_users_on_email", unique: true
t.index ["invitation_token"], name: "index_partner_users_on_invitation_token", unique: true
t.index ["invitations_count"], name: "index_partner_users_on_invitations_count"
t.index ["invited_by_id"], name: "index_partner_users_on_invited_by_id"
t.index ["invited_by_type", "invited_by_id"], name: "index_partner_users_on_invited_by"
t.index ["partner_id"], name: "index_partner_users_on_partner_id"
t.index ["reset_password_token"], name: "index_partner_users_on_reset_password_token", unique: true
end

create_table "partners", id: :serial, force: :cascade do |t|
t.string "name"
t.string "email"
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

context "As a partner user" do
let(:user) { create(:partners_user) }
let(:user) { create(:partner_user) }
it "should return nil" do
expect(controller.current_organization).to eq(nil)
end
Expand Down Expand Up @@ -52,7 +52,7 @@
context "As a partner user" do
let(:partner) { create(:partner, organization: organization) }
let(:partner2) { create(:partner, organization: organization) }
let(:user) { create(:partners_user, partner: partner) }
let(:user) { create(:partner_user, partner: partner) }
before(:each) do
user.add_role(Role::PARTNER, partner2) # add a second role
end
Expand Down
11 changes: 0 additions & 11 deletions spec/factories/donation_site.rb

This file was deleted.

28 changes: 28 additions & 0 deletions spec/factories/donation_sites.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# == Schema Information
#
# Table name: donation_sites
#
# id :integer not null, primary key
# active :boolean default(TRUE)
# address :string
# contact_name :string
# email :string
# latitude :float
# longitude :float
# name :string
# phone :string
# created_at :datetime not null
# updated_at :datetime not null
# organization_id :integer
#
FactoryBot.define do
factory :donation_site do
organization { Organization.try(:first) || create(:organization) }
name { Faker::Company.name }
address { "1500 Remount Road, Front Royal, VA 22630" }
active { true }
contact_name { Faker::Name.name }
email { Faker::Internet.email }
phone { Faker::PhoneNumber.phone_number }
end
end
16 changes: 0 additions & 16 deletions spec/factories/partner_user.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/factories/partners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

# Create associated records
create(:partner_profile, partner_id: partner.id)
create(:partners_user, email: partner.email, name: partner.name, partner: partner)
create(:partner_user, email: partner.email, name: partner.name, partner: partner)
end
end
end
14 changes: 0 additions & 14 deletions spec/factories/partners/child.rb

This file was deleted.

35 changes: 35 additions & 0 deletions spec/factories/partners/children.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# == Schema Information
#
# Table name: children
#
# id :bigint not null, primary key
# active :boolean default(TRUE)
# archived :boolean
# child_lives_with :jsonb
# comments :text
# date_of_birth :date
# first_name :string
# gender :string
# health_insurance :jsonb
# item_needed_diaperid :integer
# last_name :string
# race :jsonb
# created_at :datetime not null
# updated_at :datetime not null
# agency_child_id :string
# family_id :bigint
#
FactoryBot.define do
factory :partners_child, class: Partners::Child do
association :family, factory: :partners_family

active { true }
archived { false }
comments { "Comments " }
date_of_birth { Time.zone.today - 5.years }
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
gender { Faker::Gender.binary_type }
requested_item_ids { [create(:item, organization: family.partner.organization).id] }
end
end
49 changes: 49 additions & 0 deletions spec/factories/partners/families.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# == Schema Information
#
# Table name: families
#
# id :bigint not null, primary key
# archived :boolean default(FALSE)
# case_manager :string
# comments :text
# guardian_county :string
# guardian_employed :boolean
# guardian_employment_type :jsonb
# guardian_first_name :string
# guardian_health_insurance :jsonb
# guardian_last_name :string
# guardian_monthly_pay :decimal(, )
# guardian_phone :string
# guardian_zip_code :string
# home_adult_count :integer
# home_child_count :integer
# home_young_child_count :integer
# military :boolean default(FALSE)
# sources_of_income :jsonb
# created_at :datetime not null
# updated_at :datetime not null
# old_partner_id :bigint
# partner_id :bigint
#
FactoryBot.define do
factory :partners_family, class: Partners::Family do
association :partner

comments { Faker::Lorem.paragraph }
# Faker doesn't have county, community is same flavour, we don't use it, and it is not country.
guardian_county { Faker::Address.community }
guardian_employed { false }
guardian_employment_type { nil }
guardian_first_name { Faker::Name.first_name }
guardian_health_insurance { nil }
guardian_last_name { Faker::Name.last_name }
guardian_monthly_pay { rand(500.0..2000.0).round(2) }
guardian_phone { Faker::PhoneNumber.phone_number_with_country_code }
guardian_zip_code { Faker::Address.zip }
home_adult_count { rand(1..5) }
home_child_count { rand(0..5) }
home_young_child_count { rand(0..5) }
military { false }
archived { false }
end
end
22 changes: 0 additions & 22 deletions spec/factories/partners/family.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/factories/partners/item_request.rb

This file was deleted.

24 changes: 24 additions & 0 deletions spec/factories/partners/item_requests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# == Schema Information
#
# Table name: item_requests
#
# id :bigint not null, primary key
# name :string
# partner_key :string
# quantity :string
# request_unit :string
# created_at :datetime not null
# updated_at :datetime not null
# item_id :integer
# old_partner_request_id :integer
# partner_request_id :bigint
#
FactoryBot.define do
factory :item_request, class: Partners::ItemRequest do
item
request { build(:request, organization: item.organization) }
quantity { 5 }
sequence(:name) { |n| "Item Request #{n}" }
sequence(:partner_key) { |n| "partner_key#{n}" }
end
end
9 changes: 0 additions & 9 deletions spec/factories/partners/profile.rb

This file was deleted.

Loading