Skip to content

Commit

Permalink
feat: add seed_db: true to most tests
Browse files Browse the repository at this point in the history
Not mailers though, those work already
On some tests we have to drop back to seeding on :each
  • Loading branch information
elasticspoon committed Apr 13, 2024
1 parent e65c76c commit e877802
Show file tree
Hide file tree
Showing 221 changed files with 280 additions and 263 deletions.
2 changes: 1 addition & 1 deletion spec/controllers/admins_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=begin
require "rails_helper"
RSpec.describe AdminsController, type: :controller do
RSpec.describe AdminsController, type: :controller, seed_db: true do
let(:default_params) do
{ organization_id: @organization.id }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe ApplicationController do
RSpec.describe ApplicationController, seed_db: true do
describe "current_organization" do
before(:each) do
allow(controller).to receive(:current_user).and_return(user)
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/distributions_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe DistributionsController, type: :controller do
RSpec.describe DistributionsController, type: :controller, seed_db: true do
let(:default_params) do
{ organization_name: @organization.to_param }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/donation_sites_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe DonationSitesController, type: :controller do
RSpec.describe DonationSitesController, type: :controller, seed_db: true do
let(:default_params) do
{ organization_name: @organization.to_param }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/donations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe DonationsController, type: :controller do
RSpec.describe DonationsController, type: :controller, seed_db: true do
let(:default_params) do
{ organization_name: @organization.to_param }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/help_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe HelpController, type: :controller do
RSpec.describe HelpController, type: :controller, seed_db: true do
let(:default_params) do
{ organization_name: @organization.to_param }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/items_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe ItemsController, type: :controller do
RSpec.describe ItemsController, type: :controller, seed_db: true do
let(:default_params) do
{ organization_name: @organization.to_param }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/transfers_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe TransfersController, type: :controller do
RSpec.describe TransfersController, type: :controller, seed_db: true do
context "While signed in" do
before do
sign_in(@user)
Expand Down
2 changes: 1 addition & 1 deletion spec/events/event_differ_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe EventDiffer do
RSpec.describe EventDiffer, seed_db: true do
let(:organization) { create(:organization) }
let(:storage_location1) { create(:storage_location, organization: organization) }
let(:storage_location2) { create(:storage_location, organization: organization) }
Expand Down
2 changes: 1 addition & 1 deletion spec/events/inventory_aggregate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe InventoryAggregate do
RSpec.describe InventoryAggregate, seed_db: true do
let(:organization) { FactoryBot.create(:organization) }
let(:storage_location1) { FactoryBot.create(:storage_location, organization: organization) }
let(:storage_location2) { FactoryBot.create(:storage_location, organization: organization) }
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe ApplicationHelper, type: :helper do
RSpec.describe ApplicationHelper, type: :helper, seed_db: true do
describe "default_title_content" do
helper do
def current_organization; end
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/dashboard_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe DashboardHelper, type: :helper do
RSpec.describe DashboardHelper, type: :helper, seed_db: true do
describe "#recently_added_user_display_text" do
context "when the user has a name" do
it "returns the user's display name" do
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/historical_trends_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rspec"

RSpec.describe HistoricalTrendsHelper do
RSpec.describe HistoricalTrendsHelper, seed_db: true do
describe "#last_12_months" do
it "returns the last 12 months starting from July when the current month is June" do
allow_any_instance_of(Time).to receive(:month).and_return(6)
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/product_drive_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe ProductDriveHelper, type: :helper do
RSpec.describe ProductDriveHelper, type: :helper, seed_db: true do
describe '#is_virtual' do
context 'when the product drive was held virtually' do
let(:product_drive) { build(:product_drive, virtual: true) }
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/purchases_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe PurchasesHelper, type: :helper do
RSpec.describe PurchasesHelper, type: :helper, seed_db: true do
describe "#new_purchase_default_location" do
helper do
def current_organization
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/ui_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe UiHelper, type: :helper do
RSpec.describe UiHelper, type: :helper, seed_db: true do
describe 'optional_data_text' do
subject { helper.optional_data_text(field) }

Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/historical_data_cache_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe HistoricalDataCacheJob, type: :job do
RSpec.describe HistoricalDataCacheJob, type: :job, seed_db: true do
include ActiveJob::TestHelper

let(:organization) { create(:organization) }
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/notify_partner_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe NotifyPartnerJob, job: true do
RSpec.describe NotifyPartnerJob, job: true, seed_db: true do
describe "#perform" do
let(:request) { create(:request) }
let(:mailer) { double(:mailer) }
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/partner_mailer_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe PartnerMailerJob, type: :job do
RSpec.describe PartnerMailerJob, type: :job, seed_db: true do
describe "conditionally sending the emails" do
let(:organization) { create :organization }
let(:mailer_subject) { 'PartnerMailerJob subject' }
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/reminder_deadline_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe ReminderDeadlineJob, type: :job do
RSpec.describe ReminderDeadlineJob, type: :job, seed_db: true do
describe '#perform' do
subject { -> { described_class.perform_now } }
let(:partner) { create(:partner) }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dispersed_past_dates_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load "lib/dispersed_past_dates_generator.rb"

RSpec.describe DispersedPastDatesGenerator do
RSpec.describe DispersedPastDatesGenerator, seed_db: true do
describe "constants" do
it "has 4 day ranges for generation of past dates" do
expect(described_class::DAYS_RANGES).to eq([0..6, 7..30, 31..300, 350..700])
Expand Down
2 changes: 1 addition & 1 deletion spec/models/account_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
require 'rails_helper'

RSpec.describe AccountRequest, type: :model do
RSpec.describe AccountRequest, type: :model, seed_db: true do
let(:account_request) { FactoryBot.create(:account_request) }

describe 'associations' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# user_id :bigint
#

RSpec.describe Adjustment, type: :model do
RSpec.describe Adjustment, type: :model, seed_db: true do
it_behaves_like "itemizable"
# This mixes feature specs with model specs... idealy we do not want to do this
# it_behaves_like "pagination"
Expand Down
2 changes: 1 addition & 1 deletion spec/models/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

require 'rails_helper'

RSpec.describe Audit, type: :model do
RSpec.describe Audit, type: :model, seed_db: true do
it_behaves_like "itemizable"

context "Validations >" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/barcode_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end
end

RSpec.describe BarcodeItem, type: :model do
RSpec.describe BarcodeItem, type: :model, seed_db: true do
context "Barcodes of BaseItems ('Global')" do
let(:base_item) { create(:base_item) }
let(:global_barcode_item) { create(:global_barcode_item, barcodeable: base_item) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/base_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

require "rails_helper"

RSpec.describe BaseItem, type: :model do
RSpec.describe BaseItem, type: :model, seed_db: true do
describe "Validations >" do
it "is invalid without a name" do
expect(build(:base_item, name: nil)).not_to be_valid
Expand Down
2 changes: 1 addition & 1 deletion spec/models/broadcast_announcement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
require "rails_helper"

RSpec.describe BroadcastAnnouncement, type: :model do
RSpec.describe BroadcastAnnouncement, type: :model, seed_db: true do
it { should belong_to(:organization).optional }
it { should belong_to(:user) }
it { should validate_presence_of(:message) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/concerns/deadlinable_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe Deadlinable, type: :model do
RSpec.describe Deadlinable, type: :model, seed_db: true do
let(:dummy_class) do
Class.new do
def self.name
Expand Down
2 changes: 1 addition & 1 deletion spec/models/county_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
require "rails_helper"

RSpec.describe County, type: :model do
RSpec.describe County, type: :model, seed_db: true do
it { should have_many(:served_areas) }

describe "versioning" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/distribution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# storage_location_id :integer
#

RSpec.describe Distribution, type: :model do
RSpec.describe Distribution, type: :model, seed_db: true do
it_behaves_like "itemizable"

context "Validations >" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/donation_site_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# organization_id :integer
#

RSpec.describe DonationSite, type: :model do
RSpec.describe DonationSite, type: :model, seed_db: true do
context "Validations >" do
it "must belong to an organization" do
expect(build(:donation_site, organization_id: nil)).not_to be_valid
Expand Down
2 changes: 1 addition & 1 deletion spec/models/donation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# storage_location_id :integer
#

RSpec.describe Donation, type: :model do
RSpec.describe Donation, type: :model, seed_db: true do
it_behaves_like "itemizable"
# This mixes feature specs with model specs... idealy we do not want to do this
# it_behaves_like "pagination"
Expand Down
2 changes: 1 addition & 1 deletion spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# organization_id :bigint
# user_id :bigint
#
RSpec.describe Event, type: :model do
RSpec.describe Event, type: :model, seed_db: true do
let(:organization) { FactoryBot.create(:organization) }
describe "#most_recent_snapshot" do
let(:eventable) { FactoryBot.create(:distribution, organization_id: organization.id) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/inventory_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# storage_location_id :integer
#

RSpec.describe InventoryItem, type: :model do
RSpec.describe InventoryItem, type: :model, seed_db: true do
context "Validations >" do
describe "quantity >" do
it "is required" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/item_category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
require 'rails_helper'

RSpec.describe ItemCategory, type: :model do
RSpec.describe ItemCategory, type: :model, seed_db: true do
describe 'validations' do
subject { build(:item_category) }

Expand Down
2 changes: 1 addition & 1 deletion spec/models/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# organization_id :integer
#

RSpec.describe Item, type: :model do
RSpec.describe Item, type: :model, seed_db: true do
describe 'Assocations >' do
it { should belong_to(:item_category).optional }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/kit_allocation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
require "rails_helper"

RSpec.describe KitAllocation, type: :model do
RSpec.describe KitAllocation, type: :model, seed_db: true do
pending "add some examples to (or delete) #{__FILE__}"

describe "versioning" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/kit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
require 'rails_helper'

RSpec.describe Kit, type: :model do
RSpec.describe Kit, type: :model, seed_db: true do
let(:kit) { build(:kit, name: "Test Kit") }

context "Validations >" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/line_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# itemizable_id :integer
#

RSpec.describe LineItem, type: :model do
RSpec.describe LineItem, type: :model, seed_db: true do
let(:line_item) { build :line_item }

context "Validations >" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/manufacturer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

require "rails_helper"

RSpec.describe Manufacturer, type: :model do
RSpec.describe Manufacturer, type: :model, seed_db: true do
context "Validations" do
it "must belong to an organization" do
expect(build(:manufacturer, organization: nil)).not_to be_valid
Expand Down
2 changes: 1 addition & 1 deletion spec/models/ndbn_member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
require "rails_helper"

RSpec.describe NDBNMember, type: :model do
RSpec.describe NDBNMember, type: :model, seed_db: true do
describe "validations" do
subject { build(:ndbn_member) }
it { should validate_presence_of(:ndbn_member_id) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ndbn_member_id :bigint
#

RSpec.describe Organization, type: :model do
RSpec.describe Organization, type: :model, seed_db: true do
let(:organization) { create(:organization) }
describe "validations" do
it "validates that attachments are png or jpgs" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/organization_stats_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# == No Schema Information
#

RSpec.describe OrganizationStats, type: :model do
RSpec.describe OrganizationStats, type: :model, seed_db: true do
let(:partners) { [] }
let(:storage_locations) { [] }
let(:donation_sites) { [] }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partner_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# updated_at :datetime not null
# organization_id :bigint
#
RSpec.describe PartnerGroup, type: :model do
RSpec.describe PartnerGroup, type: :model, seed_db: true do
describe 'associations' do
it { should belong_to(:organization) }
it { should have_many(:partners) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# partner_group_id :bigint
#

RSpec.describe Partner, type: :model do
RSpec.describe Partner, type: :model, seed_db: true do
describe 'associations' do
it { should belong_to(:organization) }
it { should belong_to(:partner_group).optional }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/authorized_family_member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
require "rails_helper"

RSpec.describe Partners::AuthorizedFamilyMember, type: :model do
RSpec.describe Partners::AuthorizedFamilyMember, type: :model, seed_db: true do
describe 'associations' do
it { should belong_to(:family) }
it { should have_many(:child_item_requests).dependent(:nullify) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/child_item_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
require 'rails_helper'

RSpec.describe Partners::ChildItemRequest, type: :model do
RSpec.describe Partners::ChildItemRequest, type: :model, seed_db: true do
describe 'associations' do
it { should belong_to(:item_request) }
it { should belong_to(:child) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/child_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
require "rails_helper"

RSpec.describe Partners::Child, type: :model do
RSpec.describe Partners::Child, type: :model, seed_db: true do
describe 'associations' do
it { should belong_to(:family) }
it { should have_many(:child_item_requests).dependent(:destroy) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/family_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe Partners::FamilyRequest do
RSpec.describe Partners::FamilyRequest, seed_db: true do
describe "Partners::FamilyRequest.new_with_attrs" do
it "creates a new FamilyRequest with attributes" do
attributes = [{item_id: 1, person_count: 3}]
Expand Down
Loading

0 comments on commit e877802

Please sign in to comment.