Skip to content

Commit 375bb1b

Browse files
4217 eliminate checking factory items (#5234)
* Removed non required fields from Organization factory * Updated tests that relied on non required fields from factory to set these fields themselves * Fixed various specs counting the ActiveStorage::AnalyzeJob job created when the organization was created with a logo image * Removed unused transient * Removed non-necessary fields from storage_location and updated tests that relied on those fields or factory values * Updated item_request to specify its values shouldn't be tested against and updated tests that relied on those factory values * Updated line_item to specify its values shouldn't be tested against and updated tests that relied on those factory values * Updated product_drive to specify its values shouldn't be tested against and updated tests that relied on those factory values * Removed non-necessary fields from purchase and updated tests that relied on those fields or factory values * Removed non-necessary fields from product_drive_participant, added trait to explicitly nil contact_name and email, and updated tests that relied on those fields or factory values * Removed non-necessary fields from global_barcode_item and barcode_item, and updated tests that relied on those fields or factory values * Removed non-necessary field from partner_profile, set no_social_media_presence to false to avoid various validations failing, and updated tests that relied on those fields or factory values * Removed non-necessary field from donation * Updated tests that relied on removed fields of donation and storage_location * Updated tests that relied on removed fields of donation, line_item, and product_drive_participant * Removed non-necessary fields from counties and updated tests that relied on those fields or factory values * Removed non-necessary fields from various factories that did not break any tests * Changes made by linter * Added default, catch-all stup to Geocoder lookup so specific addresses don't need to be used * Removed apostrophes from default names to not break tests that compare raw strings to encoded HTML * Removed factory comment added by other branch * Removed outdated comment
1 parent e3acbe0 commit 375bb1b

File tree

63 files changed

+196
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+196
-190
lines changed

spec/controllers/distributions_controller_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@
243243
end
244244
it "should schedule the reminder email" do
245245
subject
246-
expect(enqueued_jobs[2]["arguments"][1]).to eq("reminder_email")
246+
expect(enqueued_jobs[1]["arguments"][1]).to eq("reminder_email")
247247
end
248248

249249
it "should not schedule a reminder for a date in the past" do
250250
params[:distribution][:issued_at] = Date.yesterday
251251
subject
252-
expect(enqueued_jobs.size).to eq(2)
252+
expect(enqueued_jobs.size).to eq(1)
253253
end
254254
end
255255

@@ -258,7 +258,7 @@
258258

259259
it "should not schedule an email reminder for a partner that disabled reminders" do
260260
subject
261-
expect(enqueued_jobs.size).to eq(1)
261+
expect(enqueued_jobs.size).to eq(0)
262262
end
263263
end
264264
end
@@ -419,13 +419,13 @@
419419
end
420420
it "should schedule the reminder email" do
421421
subject
422-
expect(enqueued_jobs[1]["arguments"][1]).to eq("reminder_email")
422+
expect(enqueued_jobs.first["arguments"][1]).to eq("reminder_email")
423423
end
424424

425425
it "should not schedule a reminder for a date in the past" do
426426
params[:distribution][:issued_at] = Date.yesterday
427427
subject
428-
expect(enqueued_jobs.size).to eq(1)
428+
expect(enqueued_jobs.size).to eq(0)
429429
end
430430
end
431431

@@ -434,7 +434,7 @@
434434

435435
it "should not schedule an email reminder for a partner that disabled reminders" do
436436
subject
437-
expect(enqueued_jobs.size).to eq(1)
437+
expect(enqueued_jobs.size).to eq(0)
438438
end
439439
end
440440
end

spec/factories/adjustments.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
factory :adjustment do
1616
organization { Organization.try(:first) || create(:organization) }
1717
storage_location
18-
comment { "A comment" }
1918
user { organization.users.try(:first) || create(:user, organization_id: organization.id) }
2019

2120
trait :with_items do

spec/factories/audits.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
user { nil }
1919
storage_location { nil }
2020
adjustment { nil }
21-
status { :in_progress }
2221

2322
after(:build) do |instance, evaluator|
2423
instance.storage_location = evaluator.storage_location || create(:storage_location, organization: instance.organization)

spec/factories/barcode_items.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
FactoryBot.define do
1616
factory :global_barcode_item, class: "BarcodeItem" do
1717
sequence(:value) { (SecureRandom.random_number * (10**12)).to_i } # 037000863427
18-
quantity { 50 }
18+
quantity { 999 } # Don't test this number
1919
barcodeable { BaseItem.all.sample || create(:base_item) }
20-
barcodeable_type { "BaseItem" }
2120
end
2221

2322
factory :barcode_item, class: "BarcodeItem" do
2423
organization { Organization.try(:first) || create(:organization) }
2524
sequence(:value) { (SecureRandom.random_number * (10**12)).to_i } # 037000863427
26-
quantity { 50 }
25+
quantity { 999 } # Don't test this number
2726
barcodeable { nil }
2827

2928
after(:build) do |instance, evaluator|

spec/factories/base_items.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
FactoryBot.define do
1818
factory :base_item do
19-
sequence(:name) { |size| "#{size}T Diapers" }
19+
sequence(:name) { |size| "#{size}Dont test this" }
2020
size { nil }
21-
sequence(:partner_key) { |n| "#{n}t_diapers" }
21+
sequence(:partner_key) { |n| "#{n}dont_test_this" }
2222
end
2323
end

spec/factories/broadcast_announcements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
factory :broadcast_announcement do
1616
user
1717
organization
18-
message { "test" }
18+
message { "Dont test this" }
1919
end
2020
end

spec/factories/counties.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#
1212
FactoryBot.define do
1313
factory :county do
14-
sequence(:name) { |n| "County #{n}" }
1514
region { Faker::Address.state }
16-
category { "US_County" }
1715
end
1816
end

spec/factories/donation_sites.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
factory :donation_site do
2020
organization { Organization.try(:first) || create(:organization) }
2121
name { Faker::Company.name.tr(",", ";") }
22-
address { "1500 Remount Road, Front Royal, VA 22630" }
22+
address { "Dont test this" }
2323
active { true }
2424
contact_name { Faker::Name.name }
2525
email { Faker::Internet.email }

spec/factories/donations.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
FactoryBot.define do
2121
factory :donation do
2222
source { Donation::SOURCES[:misc] }
23-
comment { "It's a fine day for diapers." }
2423
storage_location
2524
organization { Organization.try(:first) || create(:organization) }
2625
issued_at { Time.current }

spec/factories/inventory_items.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
FactoryBot.define do
1414
factory :inventory_item do
15-
quantity { 300 }
1615
item
1716
storage_location
1817
end

0 commit comments

Comments
 (0)