Cleanup of nonprofit factories

This commit is contained in:
Eric Schultz 2020-04-17 14:02:07 -05:00
parent 5b5b6fa330
commit 5a5a657b58
48 changed files with 100 additions and 104 deletions

View file

@ -99,7 +99,7 @@ describe Houdini::V1::Nonprofit, type: :request do
end
it 'attempts to make a slug copy and returns the proper errors' do
force_create(:nonprofit, slug: 'n', state_code_slug: 'wi', city_slug: 'appleton')
force_create(:nm_justice, slug: 'n', state_code_slug: 'wi', city_slug: 'appleton')
input = {
nonprofit: { name: 'n', state_code: 'WI', city: 'appleton', zip_code: 54_915 },
user: { name: 'Name', email: 'em@em.com', password: '12345678', password_confirmation: '12345678' }
@ -140,7 +140,7 @@ describe Houdini::V1::Nonprofit, type: :request do
end
it 'succeeds' do
force_create(:nonprofit, slug: 'n', state_code_slug: 'wi', city_slug: 'appleton')
force_create(:nm_justice, slug: 'n', state_code_slug: 'wi', city_slug: 'appleton')
input = {
nonprofit: { name: 'n', state_code: 'WI', city: 'appleton', zip_code: 54_915, url: 'www.cs.c', website: 'www.cs.c' },
user: { name: 'Name', email: 'em@em.com', password: '12345678', password_confirmation: '12345678' }

View file

@ -67,7 +67,7 @@ describe CampaignsController, type: :controller do
describe 'index' do
render_views
let(:nonprofit) { force_create(:nonprofit, published: true)}
let(:nonprofit) { force_create(:nm_justice, published: true)}
let(:campaign) { force_create(:campaign, nonprofit: nonprofit, name: "simplename", goal_amount: 444)}
before(:each) do
@ -85,7 +85,7 @@ describe CampaignsController, type: :controller do
name: 'simplename',
total_raised: 0,
goal_amount: 444,
url: "///sluggy-sluggo/campaigns/slug_#{campaign.id}"
url: "/nm/albuquerque/new_mexican_equality/campaigns/slug_#{campaign.id}"
}]}.with_indifferent_access)
end
end

View file

@ -3,8 +3,8 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
RSpec.shared_context :shared_user_context do
let(:nonprofit) { force_create(:nonprofit, published: true) }
let(:other_nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice, published: true) }
let(:other_nonprofit) { force_create(:fv_poverty) }
let(:user_as_np_admin) do
__create_admin(nonprofit)

View file

@ -4,7 +4,7 @@
FactoryBot.define do
factory :campaign do
profile
nonprofit
nonprofit_id { 55352 }
sequence(:name) { |i| "name #{i}" }
sequence(:slug) { |i| "slug_#{i}" }
end

View file

@ -10,7 +10,7 @@ FactoryBot.define do
city { 'Appleton' }
state_code { 'WI' }
slug { 'event-of-wonders' }
nonprofit
nonprofit_id { 55352 }
profile
end
end

View file

@ -2,24 +2,28 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
FactoryBot.define do
factory :nonprofit do
name { 'spec_nonprofit_full' }
factory :nm_justice, class: Nonprofit do
id { 55352 }
name { 'New Mexico Justice' }
city { 'Albuquerque' }
state_code { 'NM' }
zip_code { 55_555 }
email { 'example@email.com' }
slug { 'sluggy-sluggo' }
email { 'nmj@gmail.com' }
slug { 'new_mexican_equality' }
state_code_slug { 'nm'}
city_slug { 'albuquerque'}
end
factory :nonprofit_with_cards do
after(:create) do |nonprofit, _evaluator|
create(:active_card_1, holder: nonprofit)
create(:active_card_2, holder: nonprofit)
create(:inactive_card, holder: nonprofit)
end
end
after(:create) do |nonprofit, _evaluator|
create(:supporter, nonprofit: nonprofit)
end
factory :fv_poverty, class: Nonprofit do
id { 22352 }
name { 'Ending Poverty in the Fox Valley Inc.' }
city { 'Appleton' }
state_code { 'WI' }
zip_code { 54915 }
email { 'contact@endpovertyinthefoxvalleyinc.org' }
website {'https://endpovertyinthefoxvalleyinc.org'}
slug { 'end_poverty_in_the_fox_valley_inc' }
state_code_slug { 'wi'}
city_slug { 'appleton'}
end
end

View file

@ -4,8 +4,7 @@
FactoryBot.define do
factory :supporter do
name { 'Fake Supporter Name' }
nonprofit
nonprofit_id { 55352 }
trait :has_a_card do
after(:create) do |supporter|
create(:active_card_1, holder: supporter)

View file

@ -9,7 +9,7 @@ describe CancelBillingSubscription do
before(:each) do
StripeMock.start
@card_token = StripeMock.generate_card_token(last4: '9191', exp_year: 2011)
@np = force_create(:nonprofit)
@np = force_create(:nm_justice)
end
after { StripeMock.stop }
@ -26,9 +26,6 @@ describe CancelBillingSubscription do
end
context 'with db' do
before(:each) do
@np = create(:nonprofit)
end
it 'nonprofit valid but no card or billing_subscription' do
result = CancelBillingSubscription.with_stripe(@np)

View file

@ -47,7 +47,7 @@ describe CreateCampaignGift do
describe 'donation and campaign gift option exist so we validate the details' do
let(:profile) { force_create(:profile, user: force_create(:user)) }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:campaign) { force_create(:campaign, profile: profile, nonprofit: nonprofit) }
let(:bad_campaign) { force_create(:campaign, profile: profile, nonprofit: nonprofit) }

View file

@ -6,7 +6,7 @@ require 'rails_helper'
describe CreatePeerToPeerCampaign do
describe '.create' do
let!(:profile) { force_create(:profile, user: force_create(:user)) }
let!(:parent_campaign) { force_create(:campaign, name: 'Parent campaign') }
let!(:parent_campaign) { force_create(:campaign, name: 'Parent campaign', nonprofit: force_create(:nm_justice)) }
context 'on success' do
it 'returns a hash' do

View file

@ -13,7 +13,7 @@ describe ExportPayments do
let(:email) { 'example@example.com' }
let(:user) { force_create(:user, email: email) }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:supporters) do
[force_create(:supporter, name: 'supporter-0', nonprofit: nonprofit),
force_create(:supporter, name: 'supporter-1', nonprofit: nonprofit)]

View file

@ -9,7 +9,7 @@ describe ExportRecurringDonations do
stub_const('CHUNKED_UPLOADER', TestChunkedUploader)
@email = 'example@example.com'
@user = force_create(:user, email: @email)
@nonprofit = force_create(:nonprofit)
@nonprofit = force_create(:nm_justice)
@supporters = [force_create(:supporter, name: 'supporter-0', nonprofit: @nonprofit),
force_create(:supporter, name: 'supporter-1', nonprofit: @nonprofit)]
@donations = [force_create(:donation, nonprofit: @nonprofit, supporter: @supporters[0]),

View file

@ -13,7 +13,7 @@ describe ExportSupporterNotes do
CHUNKED_UPLOADER.clear
end
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:supporter1) { force_create(:supporter, nonprofit: nonprofit) }
let(:supporter2) { force_create(:supporter, nonprofit: nonprofit) }

View file

@ -7,7 +7,7 @@ require 'support/test_chunked_uploader'
describe ExportSupporters do
before(:each) do
stub_const('CHUNKED_UPLOADER', TestChunkedUploader)
@nonprofit = force_create(:nonprofit)
@nonprofit = force_create(:nm_justice)
@email = 'example@example.com'
@user = force_create(:user, email: @email)
@supporters = 2.times { force_create(:supporter, nonprofit: @nonprofit) }

View file

@ -24,7 +24,7 @@ describe FetchMiscellaneousNpInfo do
describe 'with valid nonprofit' do
before(:each) do
@np = force_create(:nonprofit)
@np = force_create(:nm_justice)
end
it 'returns hash with empty misc settings' do

View file

@ -14,7 +14,7 @@ describe InsertBankAccount do
Timecop.return
end
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:user) { force_create(:user, email: 'x@example.com') }
describe '.with_stripe' do

View file

@ -22,7 +22,7 @@ describe InsertCard do
}
end
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:user) do
user = force_create(:user)
force_create(:role, name: :nonprofit_admin, host: nonprofit, user: user)
@ -396,7 +396,7 @@ describe InsertCard do
end
it 'should return proper error when event doesnt match the supporters nonprofit' do
supporter2 = force_create(:supporter)
supporter2 = force_create(:supporter, nonprofit: force_create(:fv_poverty))
ret = InsertCard.with_stripe({ holder_id: supporter2.id, holder_type: 'Supporter', stripe_card_id: 'card_fafjeht', stripe_card_token: stripe_card_token, name: 'name' }, nil, event.id, user_not_from_nonprofit)
expect(ret).to eq(status: :unprocessable_entity, json: { error: "Oops! There was an error: Event #{event.id} is not for the same nonprofit as supporter #{supporter2.id}" })
end

View file

@ -5,8 +5,8 @@ require 'rails_helper'
describe InsertCustomFieldJoins do
describe '.find_or_create' do
let(:nonprofit) { force_create(:nonprofit) }
let(:other_nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:other_nonprofit) { force_create(:fv_poverty) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:other_supporter) { force_create(:supporter, nonprofit: other_nonprofit) }
@ -95,8 +95,8 @@ describe InsertCustomFieldJoins do
end
context 'requiring db' do
before(:each) do
@nonprofit = force_create(:nonprofit)
@bad_nonprofit = force_create(:nonprofit, id: 50)
@nonprofit = force_create(:nm_justice)
@bad_nonprofit = force_create(:fv_poverty, id: 50)
end
it 'nonprofit must be valid' do
response = InsertCustomFieldJoins.in_bulk(@nonprofit.id + 1, [], [])
@ -118,11 +118,11 @@ describe InsertCustomFieldJoins do
context 'main testing' do
before(:each) do
@nonprofit = force_create(:nonprofit)
@nonprofit = force_create(:nm_justice)
@other_nonprofit = force_create(:fv_poverty)
@random_supporter = create(:supporter, nonprofit: @other_nonprofit)
@random_supporter = create(:supporter)
@other_nonprofit = force_create(:nonprofit)
@delete_cfm = [20, 40, 60]
@add_cfm = [25, 35]

View file

@ -11,7 +11,7 @@ describe InsertDuplicate do
after(:all) do
Timecop.return
end
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:profile) { force_create(:profile) }
let(:dates) do
{

View file

@ -52,7 +52,7 @@ describe InsertPayout do
end
it 'handles no charges to payout' do
np = force_create(:nonprofit)
np = force_create(:nm_justice)
expect { InsertPayout.with_stripe(np.id, { stripe_account_id: 'valid', email: 'valid', user_ip: 'valid', bank_name: 'valid' }, nil) }.to(raise_error do |error|
expect(error).to be_a ArgumentError
expect(error.message).to eq 'No payments are available for disbursal on this account.'
@ -73,7 +73,7 @@ describe InsertPayout do
context 'no date provided' do
include_context 'payments for a payout' do
let(:np) { force_create(:nonprofit, stripe_account_id: Stripe::Account.create['id'], vetted: true) }
let(:np) { force_create(:nm_justice, stripe_account_id: Stripe::Account.create['id'], vetted: true) }
let(:date_for_marking) { Time.now }
let(:ba) do
InsertBankAccount.with_stripe(np, user, stripe_bank_account_token: StripeMock.generate_bank_token, name: bank_name)
@ -204,7 +204,7 @@ describe InsertPayout do
context 'previous date provided' do
include_context 'payments for a payout' do
let(:np) { force_create(:nonprofit, stripe_account_id: Stripe::Account.create['id'], vetted: true) }
let(:np) { force_create(:nm_justice, stripe_account_id: Stripe::Account.create['id'], vetted: true) }
let(:date_for_marking) { Time.now - 1.day }
let(:ba) { InsertBankAccount.with_stripe(np, user, stripe_bank_account_token: StripeMock.generate_bank_token, name: bank_name) }
end

View file

@ -160,7 +160,7 @@ describe InsertRecurringDonation do
describe 'wonderful testing Eric' do
before(:each) { Timecop.freeze(2020, 4, 29) }
after(:each) { Timecop.return }
let(:nonprofit) { force_create(:nonprofit, state_code_slug: 'wi', city_slug: 'city', slug: 'sluggster') }
let(:nonprofit) { force_create(:nm_justice, state_code_slug: 'wi', city_slug: 'city', slug: 'sluggster') }
let(:profile) { force_create(:profile, user: force_create(:user)) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:card) { force_create(:card, holder: supporter) }
@ -224,7 +224,7 @@ describe InsertRecurringDonation do
describe 'test for earlier in the month' do
before(:each) { Timecop.freeze(2020, 4, 5) }
after(:each) { Timecop.return }
let(:nonprofit) { force_create(:nonprofit, state_code_slug: 'wi', city_slug: 'city', slug: 'sluggster') }
let(:nonprofit) { force_create(:nm_justice, state_code_slug: 'wi', city_slug: 'city', slug: 'sluggster') }
let(:profile) { force_create(:profile, user: force_create(:user)) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:card) { force_create(:card, holder: supporter) }

View file

@ -21,7 +21,7 @@ describe 'InsertTagJoins.in_bulk' do
end
context 'requiring db' do
before do
@nonprofit = force_create(:nonprofit)
@nonprofit = force_create(:nm_justice)
@profile = force_create(:profile)
end
@ -46,12 +46,12 @@ describe 'InsertTagJoins.in_bulk' do
context 'supporters tags' do
before(:each) do
@nonprofit = force_create(:nonprofit)
@nonprofit = force_create(:nm_justice)
@profile = force_create(:profile)
@other_nonprofit = force_create(:fv_poverty)
@random_supporter = create(:supporter, nonprofit: @other_nonprofit)
@random_supporter = create(:supporter)
@other_nonprofit = force_create(:nonprofit)
@delete_tags = [20, 40, 60]
@add_tags = [25, 35]

View file

@ -10,7 +10,7 @@ describe Mailchimp do
{ id: 'on_mailchimp', email_address: 'on_mailchimp@email.com' }]
end
let(:np) { force_create(:nonprofit) }
let(:np) { force_create(:nm_justice) }
let(:tag_master) { force_create(:tag_master, nonprofit: np) }
let(:email_list) { force_create(:email_list, mailchimp_list_id: 'list_id', tag_master: tag_master, nonprofit: np, list_name: 'temp') }
let(:supporter_on_both) { force_create(:supporter, nonprofit: np, email: 'on_BOTH@email.com') }

View file

@ -17,7 +17,7 @@ describe MergeSupporters do
# one unique custom field on 2
# one common field on both and keep the value of the most common
let(:np) { force_create(:nonprofit) }
let(:np) { force_create(:nm_justice) }
let(:old_supporter1) { force_create(:supporter, nonprofit: np) }
let(:old_supporter2) { force_create(:supporter, nonprofit: np) }
let(:new_supporter) { force_create(:supporter, nonprofit: np) }

View file

@ -27,7 +27,7 @@ describe NameCopyNamingAlgorithm do
let(:long_name_copy_today_plus_1) { "#{long_name_copy_today_base} 01" }
let(:long_name_copy_yesterday) { 'campaign_name is so long that it must b (2020-05-03 copy) 00' }
let(:long_name_copy_today_base) { 'campaign_name is so long that it must b (2020-05-04 copy)' }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
describe 'events' do
let(:event) { force_create(:event, name: @name, nonprofit: nonprofit) }

View file

@ -10,7 +10,7 @@ describe BillingPlans do
end
let(:nonprofit) do
force_create(:nonprofit)
force_create(:nm_justice)
end
describe '.get_percentage_fee' do

View file

@ -8,7 +8,7 @@ describe QueryCampaignGifts do
GIFT_LEVEL_RECURRING = 5585
GIFT_LEVEL_CHANGED_RECURRING = 5512
CAMPAIGN_GIFT_OPTION_NAME = 'theowthoinv'
let(:np) { force_create(:nonprofit) }
let(:np) { force_create(:nm_justice) }
let(:supporter1) { force_create(:supporter, nonprofit: np) }
let(:supporter2) { force_create(:supporter, nonprofit: np) }
let(:campaign) { force_create(:campaign, nonprofit: np, slug: 'slug stuff') }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe QueryCampaignMetrics do
describe 'calculates your metrics plus children' do
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:campaign) { force_create(:campaign, nonprofit: nonprofit, show_total_count: false, show_total_raised: false, goal_amount: 16_000) }
let(:campaign_child) { force_create(:campaign, nonprofit: nonprofit, parent_campaign: campaign, show_total_count: true, show_total_raised: true, goal_amount: 8000) }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe QueryDonations do
describe 'campaign_export' do
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:supporter) { force_create(:supporter) }
let(:profile_email) { 'something@profile_email.com' }

View file

@ -6,7 +6,7 @@ require 'support/payments_for_a_payout'
describe QueryPayments do
before :each do
@nonprofit = force_create(:nonprofit, name: 'npo1')
@nonprofit = force_create(:nm_justice, name: 'npo1', id: 515152)
@supporters = [force_create(:supporter, name: 'supporter-0', nonprofit: @nonprofit),
force_create(:supporter, name: 'supporter-1', nonprofit: @nonprofit)]

View file

@ -30,7 +30,7 @@ describe QueryRecurringDonations do
end
describe '.is_due?' do
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:donation) do
force_create(:donation, amount: 1000, supporter: supporter, recurring: true, nonprofit: nonprofit)
@ -156,7 +156,7 @@ describe QueryRecurringDonations do
describe '.for_export_enumerable' do
before :each do
@nonprofit = force_create(:nonprofit, name: 'npo1')
@nonprofit = force_create(:nm_justice, name: 'npo1')
@supporters = [force_create(:supporter, name: 'supporter-0', nonprofit: @nonprofit),
force_create(:supporter, name: 'supporter-1', nonprofit: @nonprofit)]

View file

@ -11,7 +11,7 @@ describe QuerySourceToken do
let(:expired_uuid) { '061124ca-05f1-11e8-8730-57558ad1064d' }
let(:overused_uuid) { '0ac67006-05f1-11e8-902c-035df51dbc79' }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:event) { force_create(:event, nonprofit: nonprofit) }
let(:user) do
u = force_create(:user)

View file

@ -9,7 +9,7 @@ describe QuerySupporters do
let(:gift_level_changed_recurring) { 5512 }
let(:campaign_gift_option_name) { 'theowthoinv' }
let(:np) { force_create(:nonprofit) }
let(:np) { force_create(:nm_justice) }
let(:supporter1) { force_create(:supporter, nonprofit: np) }
let(:supporter2) { force_create(:supporter, nonprofit: np) }
let(:campaign) { force_create(:campaign, nonprofit: np, slug: 'slug stuff') }

View file

@ -6,7 +6,7 @@ require 'rails_helper'
describe RetrieveActiveRecordItems do
describe '.retrieve' do
let(:item) { force_create(:supporter) }
let(:item2) { force_create(:nonprofit) }
let(:item2) { force_create(:nm_justice) }
it 'raises if not a class for key' do
expect { RetrieveActiveRecordItems.retrieve('item' => 1) }.to raise_error(ArgumentError)
end
@ -41,7 +41,7 @@ describe RetrieveActiveRecordItems do
describe '.retrieve_from_keys' do
let(:item) { force_create(:supporter) }
let(:item2) { force_create(:nonprofit) }
let(:item2) { force_create(:nm_justice) }
it 'raises if not a class for key' do
expect { RetrieveActiveRecordItems.retrieve_from_keys({}, 'item' => 1) }.to raise_error(ArgumentError)
end

View file

@ -21,7 +21,7 @@ describe SlugCopyNamingAlgorithm do
let(:short_slug_copy_today_plus_1) { 'slug_name_copy_01' }
let(:copy_base) { 'slug_name_copy' }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
describe 'events' do
let(:event) { force_create(:event, slug: @name, nonprofit: nonprofit) }

View file

@ -27,10 +27,10 @@ describe SlugNonprofitNamingAlgorithm do
let(:not_our_city_slug) { 'not_our_city_slug' }
describe 'nonprofits' do
let(:nonprofit) { force_create(:nonprofit, slug: @name, state_code_slug: state_slug, city_slug: city_slug) }
let(:nonprofit2) { force_create(:nonprofit, slug: @name2, state_code_slug: state_slug, city_slug: city_slug) }
let(:nonprofit_in_other_city) { force_create(:nonprofit, slug: @name, state_code_slug: state_slug, city_slug: not_our_city_slug) }
let(:nonprofit_in_other_state) { force_create(:nonprofit, slug: @name, state_code_slug: not_our_state_slug, city_slug: city_slug) }
let(:nonprofit) { force_create(:nm_justice, slug: @name, state_code_slug: state_slug, city_slug: city_slug) }
let(:nonprofit2) { force_create(:fv_poverty, slug: @name2, state_code_slug: state_slug, city_slug: city_slug) }
let(:nonprofit_in_other_city) { force_create(:nm_justice, slug: @name, state_code_slug: state_slug, city_slug: not_our_city_slug, id: 523950250) }
let(:nonprofit_in_other_state) { force_create(:fv_poverty, slug: @name, state_code_slug: not_our_state_slug, city_slug: city_slug, id: 5239502) }
let(:nonprofit_at_max_copies) do
(0..99).collect do |i|
force_create(:nonprofit, slug: "#{@copy_base}-#{format('%02d', i)}", state_code_slug: state_slug, city_slug: city_slug)

View file

@ -21,7 +21,7 @@ describe SlugP2pCampaignNamingAlgorithm do
let(:short_slug_copy_today_plus_1) { 'slug_name_001' }
let(:copy_base) { 'slug_name' }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
describe 'campaigns' do
let(:campaign) { force_create(:campaign, slug: @name, nonprofit: nonprofit, deleted: true) }

View file

@ -9,7 +9,7 @@ describe StripeAccount do
let(:stripe_helper) { StripeMock.create_test_helper }
before(:each) { StripeMock.start }
after(:each) { StripeMock.stop }
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
describe '.find_or_create' do
describe 'param validation' do

View file

@ -11,8 +11,8 @@ describe UpdateDonation do
after do
Timecop.return
end
let(:np) { force_create(:nonprofit) }
let(:supporter) { force_create(:supporter, nonprofit: np) }
let(:np) { force_create(:nm_justice) }
let(:supporter) { force_create(:supporter) }
let(:donation) do
force_create(:donation, nonprofit: np,
dedication: initial_dedication,
@ -48,10 +48,10 @@ describe UpdateDonation do
fee_total: initial_fee,
net_amount: initial_amount - initial_fee)
end
let(:campaign) { force_create(:campaign, nonprofit: np) }
let(:event) { force_create(:event, nonprofit: np) }
let(:other_campaign) { force_create(:campaign) }
let(:other_event) { force_create(:event) }
let(:campaign) { force_create(:campaign) }
let(:event) { force_create(:event) }
let(:other_campaign) { force_create(:campaign, nonprofit: force_create(:fv_poverty)) }
let(:other_event) { force_create(:event, nonprofit: force_create(:fv_poverty)) }
let(:initial_date) { Date.new(2020, 4, 5).to_time }
let(:initial_dedication) { 'initial dedication' }

View file

@ -25,7 +25,7 @@ describe UpdateMiscellaneousNpInfo do
end
describe 'main' do
let!(:np) { force_create(:nonprofit) }
let!(:np) { force_create(:nm_justice) }
let (:working_message) { '<p>working message</p>' }
it 'sets change_amount_message to nil if empty tags' do
expect(MiscellaneousNpInfo.count).to eq 0

View file

@ -49,7 +49,7 @@ describe UpdatePayouts do
let!(:refunds) { [force_create(:refund, charge: charges.last, payment: reverse_payment_for_refund, disbursed: true)] }
let(:np) { force_create(:nonprofit) }
let(:np) { force_create(:nm_justice) }
let!(:bank_account) { force_create(:bank_account, nonprofit: np) }
let!(:payout) do
force_create(:payout, status: 'paid', failure_message: 'all good',

View file

@ -6,10 +6,8 @@ require 'rails_helper'
describe UpdateRecurringDonations do
# deactivate a recurring donation
describe '.cancel' do
before(:each) do
end
let(:np) { force_create(:nonprofit) }
let(:np) { force_create(:nm_justice) }
let(:s) { force_create(:supporter) }
let(:donation) { force_create(:donation, nonprofit_id: np.id, supporter_id: s.id) }
let(:email) { 'test@test.com' }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe AdminMailer, type: :mailer do
describe 'notify_failed_gift' do
let!(:np) { force_create(:nonprofit, name: 'nonprofit', email: 'blah', timezone: 'UTC') }
let!(:np) { force_create(:nm_justice, name: 'nonprofit', email: 'blah', timezone: 'UTC') }
let!(:s) { force_create(:supporter, email: 'supporter.email@mail.teha') }
let!(:oldcard) { force_create(:card) }
let!(:donation) { force_create(:donation, nonprofit_id: np.id, supporter_id: s.id, card_id: oldcard.id, amount: 999) }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe DonationMailer, type: :mailer do
describe 'donor_recurring_donation_change_amount' do
let(:np) { force_create(:nonprofit, name: 'nonprofit', email: 'blah') }
let(:np) { force_create(:nm_justice, name: 'nonprofit', email: 'blah') }
let(:s) { force_create(:supporter, email: 'supporter.email@mail.teha') }
let(:oldcard) { force_create(:card) }
let(:donation) { create(:donation, nonprofit_id: np.id, supporter_id: s.id, card_id: oldcard.id, amount: 999) }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Campaign, type: :model do
describe 'sends correct email based on type of campaign' do
let(:nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice) }
let(:parent_campaign) { force_create(:campaign, name: 'Parent campaign', nonprofit: nonprofit) }
let(:child_campaign) do
force_create(:campaign,

View file

@ -6,13 +6,11 @@ require 'rails_helper'
RSpec.describe Nonprofit, type: :model do
describe 'with cards' do
before(:each) do
@nonprofit = create(:nonprofit_with_cards)
end
before (:each) do
cards = @nonprofit.cards.to_ary
@card1 = cards.first { |i| i.name == 'card1' }
@card2 = cards.first { |i| i.name == 'card2' }
@card3 = cards.first { |i| i.name == 'card3' }
@nonprofit = create(:nm_justice)
@card1 = create(:card, holder: @nonprofit, name: 'card1')
@card2 = create(:card, holder: @nonprofit, name: 'card2')
@card3 = create(:card, holder: @nonprofit, name: 'card3', inactive:true)
end
describe '.active_cards' do
it 'should return all cards' do
@ -38,7 +36,7 @@ RSpec.describe Nonprofit, type: :model do
end
describe '.currency_symbol' do
let(:nonprofit) { force_create(:nonprofit, currency: 'eur') }
let(:nonprofit) { force_create(:nm_justice, currency: 'eur') }
let(:euro) { '€' }
it 'finds correct currency symbol for nonprofit' do

View file

@ -4,8 +4,8 @@
require 'stripe_mock'
RSpec.shared_context :shared_donation_charge_context do
let(:nonprofit) { force_create(:nonprofit, name: 'nonprofit name', slug: 'nonprofit_nameo') }
let(:other_nonprofit) { force_create(:nonprofit) }
let(:nonprofit) { force_create(:nm_justice, name: 'nonprofit name', slug: 'nonprofit_nameo') }
let(:other_nonprofit) { force_create(:fv_poverty) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit, locale: 'locale_one') }
let(:other_nonprofit_supporter) { force_create(:supporter, nonprofit: other_nonprofit, locale: 'locale_two') }
let(:card) { force_create(:card, holder: supporter) }

View file

@ -86,7 +86,7 @@ shared_context 'payments for a payout' do
end
let(:other_np_payment) do
p = create_payment(nonprofit: force_create(:nonprofit))
p = create_payment(nonprofit: force_create(:fv_poverty))
create_charge(payment: p, amount: 2000, fee: -400, status: 'available')
return p
end