Skip to content

Commit

Permalink
refactor(tests): use metadata
Browse files Browse the repository at this point in the history
Turns out you can use metadata.
  • Loading branch information
elasticspoon committed Apr 15, 2024
1 parent 33c8895 commit 4ed91bc
Show file tree
Hide file tree
Showing 229 changed files with 237 additions and 233 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, seed_db: true do
RSpec.describe AdminsController, type: :controller 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, seed_db: true do
RSpec.describe ApplicationController 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, seed_db: true do
RSpec.describe DistributionsController, type: :controller 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, seed_db: true do
RSpec.describe DonationSitesController, type: :controller 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, seed_db: true do
RSpec.describe DonationsController, type: :controller 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, seed_db: true do
RSpec.describe HelpController, type: :controller 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, seed_db: true do
RSpec.describe ItemsController, type: :controller 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, seed_db: true do
RSpec.describe TransfersController, type: :controller 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, seed_db: true do
RSpec.describe EventDiffer 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, seed_db: true do
RSpec.describe InventoryAggregate 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, seed_db: true do
RSpec.describe ApplicationHelper, type: :helper 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, seed_db: true do
RSpec.describe DashboardHelper, type: :helper 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, seed_db: true do
RSpec.describe HistoricalTrendsHelper 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, seed_db: true do
RSpec.describe ProductDriveHelper, type: :helper 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, seed_db: true do
RSpec.describe PurchasesHelper, type: :helper 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, seed_db: true do
RSpec.describe UiHelper, type: :helper 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, seed_db: true do
RSpec.describe HistoricalDataCacheJob, type: :job 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, seed_db: true do
RSpec.describe NotifyPartnerJob, job: 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, seed_db: true do
RSpec.describe PartnerMailerJob, type: :job 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, seed_db: true do
RSpec.describe ReminderDeadlineJob, type: :job 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, seed_db: true do
RSpec.describe DispersedPastDatesGenerator 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/mailers/account_request_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe AccountRequestMailer, type: :mailer do
RSpec.describe AccountRequestMailer, type: :mailer, skip_seed: true do
describe '#confirmation' do
let(:mail) { AccountRequestMailer.confirmation(account_request_id: account_request_id) }
let(:account_request_id) { account_request.id }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/custom_devise_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe CustomDeviseMailer, type: :mailer do
RSpec.describe CustomDeviseMailer, type: :mailer, skip_seed: true do
describe "#invitation_instructions" do
let(:user) { create(:partner_user) }
let(:mail) { described_class.invitation_instructions(user, SecureRandom.uuid) }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/distribution_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe DistributionMailer, type: :mailer do
RSpec.describe DistributionMailer, type: :mailer, skip_seed: true do
let(:organization) { create(:organization, skip_items: true, name: "TEST ORG") }
let(:user) { create(:user, organization: organization) }
let(:partner) { create(:partner, name: 'PARTNER', organization_id: organization.id) }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/organization_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe OrganizationMailer, type: :mailer do
RSpec.describe OrganizationMailer, type: :mailer, skip_seed: true do
describe "#partner_approval_request" do
subject { described_class.partner_approval_request(organization: organization, partner: partner) }
let(:organization) { create(:organization, skip_items: true) }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/partner_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe PartnerMailer, type: :mailer do
RSpec.describe PartnerMailer, type: :mailer, skip_seed: true do
describe "#recertification_request" do
subject { PartnerMailer.recertification_request(partner: partner) }
let(:partner) { create(:partner) }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/request_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe RequestMailer, type: :mailer do
RSpec.describe RequestMailer, type: :mailer, skip_seed: true do
describe "#request_cancel_partner_notification" do
subject { described_class.request_cancel_partner_notification(request_id: request.id) }
let(:request) { create(:request) }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/requests_confirmation_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe RequestsConfirmationMailer, type: :mailer do
RSpec.describe RequestsConfirmationMailer, type: :mailer, skip_seed: true do
let(:organization) { create(:organization, :with_items) }
let(:request) { create(:request, organization: organization) }
let(:mail) { RequestsConfirmationMailer.confirmation_email(request) }
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/user_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe User, type: :mailer do
RSpec.describe User, type: :mailer, skip_seed: true do
describe "#role_added" do
let(:user) { create(:user, email: "[email protected]") }
let(:partner) { create(:partner, name: "Partner 1") }
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, seed_db: true do
RSpec.describe AccountRequest, type: :model 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, seed_db: true do
RSpec.describe Adjustment, type: :model 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, seed_db: true do
RSpec.describe Audit, type: :model 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, seed_db: true do
RSpec.describe BarcodeItem, type: :model 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, seed_db: true do
RSpec.describe BaseItem, type: :model 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, seed_db: true do
RSpec.describe BroadcastAnnouncement, type: :model 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, seed_db: true do
RSpec.describe Deadlinable, type: :model 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, seed_db: true do
RSpec.describe County, type: :model 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, seed_db: true do
RSpec.describe Distribution, type: :model 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, seed_db: true do
RSpec.describe DonationSite, type: :model 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, seed_db: true do
RSpec.describe Donation, type: :model 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, seed_db: true do
RSpec.describe Event, type: :model 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, seed_db: true do
RSpec.describe InventoryItem, type: :model 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, seed_db: true do
RSpec.describe ItemCategory, type: :model 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, seed_db: true do
RSpec.describe Item, type: :model 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, seed_db: true do
RSpec.describe KitAllocation, type: :model 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, seed_db: true do
RSpec.describe Kit, type: :model 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, seed_db: true do
RSpec.describe LineItem, type: :model 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, seed_db: true do
RSpec.describe Manufacturer, type: :model 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, seed_db: true do
RSpec.describe NDBNMember, type: :model 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, seed_db: true do
RSpec.describe Organization, type: :model 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, seed_db: true do
RSpec.describe OrganizationStats, type: :model do
let(:partners) { [] }
let(:storage_locations) { [] }
let(:donation_sites) { [] }
Expand Down
Loading

0 comments on commit 4ed91bc

Please sign in to comment.