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 end
it 'attempts to make a slug copy and returns the proper errors' do 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 = { input = {
nonprofit: { name: 'n', state_code: 'WI', city: 'appleton', zip_code: 54_915 }, nonprofit: { name: 'n', state_code: 'WI', city: 'appleton', zip_code: 54_915 },
user: { name: 'Name', email: 'em@em.com', password: '12345678', password_confirmation: '12345678' } user: { name: 'Name', email: 'em@em.com', password: '12345678', password_confirmation: '12345678' }
@ -140,7 +140,7 @@ describe Houdini::V1::Nonprofit, type: :request do
end end
it 'succeeds' do 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 = { input = {
nonprofit: { name: 'n', state_code: 'WI', city: 'appleton', zip_code: 54_915, url: 'www.cs.c', website: 'www.cs.c' }, 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' } 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 describe 'index' do
render_views 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)} let(:campaign) { force_create(:campaign, nonprofit: nonprofit, name: "simplename", goal_amount: 444)}
before(:each) do before(:each) do
@ -85,7 +85,7 @@ describe CampaignsController, type: :controller do
name: 'simplename', name: 'simplename',
total_raised: 0, total_raised: 0,
goal_amount: 444, goal_amount: 444,
url: "///sluggy-sluggo/campaigns/slug_#{campaign.id}" url: "/nm/albuquerque/new_mexican_equality/campaigns/slug_#{campaign.id}"
}]}.with_indifferent_access) }]}.with_indifferent_access)
end end
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@ describe CancelBillingSubscription do
before(:each) do before(:each) do
StripeMock.start StripeMock.start
@card_token = StripeMock.generate_card_token(last4: '9191', exp_year: 2011) @card_token = StripeMock.generate_card_token(last4: '9191', exp_year: 2011)
@np = force_create(:nonprofit) @np = force_create(:nm_justice)
end end
after { StripeMock.stop } after { StripeMock.stop }
@ -26,9 +26,6 @@ describe CancelBillingSubscription do
end end
context 'with db' do context 'with db' do
before(:each) do
@np = create(:nonprofit)
end
it 'nonprofit valid but no card or billing_subscription' do it 'nonprofit valid but no card or billing_subscription' do
result = CancelBillingSubscription.with_stripe(@np) 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 describe 'donation and campaign gift option exist so we validate the details' do
let(:profile) { force_create(:profile, user: force_create(:user)) } 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(:campaign) { force_create(:campaign, profile: profile, nonprofit: nonprofit) }
let(:bad_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 CreatePeerToPeerCampaign do
describe '.create' do describe '.create' do
let!(:profile) { force_create(:profile, user: force_create(:user)) } 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 context 'on success' do
it 'returns a hash' do it 'returns a hash' do

View file

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

View file

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

View file

@ -13,7 +13,7 @@ describe ExportSupporterNotes do
CHUNKED_UPLOADER.clear CHUNKED_UPLOADER.clear
end end
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
let(:supporter1) { force_create(:supporter, nonprofit: nonprofit) } let(:supporter1) { force_create(:supporter, nonprofit: nonprofit) }
let(:supporter2) { 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 describe ExportSupporters do
before(:each) do before(:each) do
stub_const('CHUNKED_UPLOADER', TestChunkedUploader) stub_const('CHUNKED_UPLOADER', TestChunkedUploader)
@nonprofit = force_create(:nonprofit) @nonprofit = force_create(:nm_justice)
@email = 'example@example.com' @email = 'example@example.com'
@user = force_create(:user, email: @email) @user = force_create(:user, email: @email)
@supporters = 2.times { force_create(:supporter, nonprofit: @nonprofit) } @supporters = 2.times { force_create(:supporter, nonprofit: @nonprofit) }

View file

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

View file

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

View file

@ -22,7 +22,7 @@ describe InsertCard do
} }
end end
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
let(:user) do let(:user) do
user = force_create(:user) user = force_create(:user)
force_create(:role, name: :nonprofit_admin, host: nonprofit, user: user) force_create(:role, name: :nonprofit_admin, host: nonprofit, user: user)
@ -396,7 +396,7 @@ describe InsertCard do
end end
it 'should return proper error when event doesnt match the supporters nonprofit' do 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) 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}" }) 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 end

View file

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

View file

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

View file

@ -52,7 +52,7 @@ describe InsertPayout do
end end
it 'handles no charges to payout' do 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 { 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).to be_a ArgumentError
expect(error.message).to eq 'No payments are available for disbursal on this account.' 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 context 'no date provided' do
include_context 'payments for a payout' 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(:date_for_marking) { Time.now }
let(:ba) do let(:ba) do
InsertBankAccount.with_stripe(np, user, stripe_bank_account_token: StripeMock.generate_bank_token, name: bank_name) 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 context 'previous date provided' do
include_context 'payments for a payout' 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(: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) } let(:ba) { InsertBankAccount.with_stripe(np, user, stripe_bank_account_token: StripeMock.generate_bank_token, name: bank_name) }
end end

View file

@ -160,7 +160,7 @@ describe InsertRecurringDonation do
describe 'wonderful testing Eric' do describe 'wonderful testing Eric' do
before(:each) { Timecop.freeze(2020, 4, 29) } before(:each) { Timecop.freeze(2020, 4, 29) }
after(:each) { Timecop.return } 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(:profile) { force_create(:profile, user: force_create(:user)) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) } let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:card) { force_create(:card, holder: supporter) } let(:card) { force_create(:card, holder: supporter) }
@ -224,7 +224,7 @@ describe InsertRecurringDonation do
describe 'test for earlier in the month' do describe 'test for earlier in the month' do
before(:each) { Timecop.freeze(2020, 4, 5) } before(:each) { Timecop.freeze(2020, 4, 5) }
after(:each) { Timecop.return } 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(:profile) { force_create(:profile, user: force_create(:user)) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) } let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:card) { force_create(:card, holder: supporter) } let(:card) { force_create(:card, holder: supporter) }

View file

@ -21,7 +21,7 @@ describe 'InsertTagJoins.in_bulk' do
end end
context 'requiring db' do context 'requiring db' do
before do before do
@nonprofit = force_create(:nonprofit) @nonprofit = force_create(:nm_justice)
@profile = force_create(:profile) @profile = force_create(:profile)
end end
@ -46,12 +46,12 @@ describe 'InsertTagJoins.in_bulk' do
context 'supporters tags' do context 'supporters tags' do
before(:each) do before(:each) do
@nonprofit = force_create(:nonprofit) @nonprofit = force_create(:nm_justice)
@profile = force_create(:profile) @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] @delete_tags = [20, 40, 60]
@add_tags = [25, 35] @add_tags = [25, 35]

View file

@ -10,7 +10,7 @@ describe Mailchimp do
{ id: 'on_mailchimp', email_address: 'on_mailchimp@email.com' }] { id: 'on_mailchimp', email_address: 'on_mailchimp@email.com' }]
end end
let(:np) { force_create(:nonprofit) } let(:np) { force_create(:nm_justice) }
let(:tag_master) { force_create(:tag_master, nonprofit: np) } 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(: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') } 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 unique custom field on 2
# one common field on both and keep the value of the most common # 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_supporter1) { force_create(:supporter, nonprofit: np) }
let(:old_supporter2) { force_create(:supporter, nonprofit: np) } let(:old_supporter2) { force_create(:supporter, nonprofit: np) }
let(:new_supporter) { 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_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_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(: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 describe 'events' do
let(:event) { force_create(:event, name: @name, nonprofit: nonprofit) } let(:event) { force_create(:event, name: @name, nonprofit: nonprofit) }

View file

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

View file

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

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe QueryCampaignMetrics do describe QueryCampaignMetrics do
describe 'calculates your metrics plus children' 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) { 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) } 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 QueryDonations do
describe 'campaign_export' do describe 'campaign_export' do
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
let(:supporter) { force_create(:supporter) } let(:supporter) { force_create(:supporter) }
let(:profile_email) { 'something@profile_email.com' } let(:profile_email) { 'something@profile_email.com' }

View file

@ -6,7 +6,7 @@ require 'support/payments_for_a_payout'
describe QueryPayments do describe QueryPayments do
before :each 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), @supporters = [force_create(:supporter, name: 'supporter-0', nonprofit: @nonprofit),
force_create(:supporter, name: 'supporter-1', nonprofit: @nonprofit)] force_create(:supporter, name: 'supporter-1', nonprofit: @nonprofit)]

View file

@ -30,7 +30,7 @@ describe QueryRecurringDonations do
end end
describe '.is_due?' do describe '.is_due?' do
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
let(:supporter) { force_create(:supporter, nonprofit: nonprofit) } let(:supporter) { force_create(:supporter, nonprofit: nonprofit) }
let(:donation) do let(:donation) do
force_create(:donation, amount: 1000, supporter: supporter, recurring: true, nonprofit: nonprofit) force_create(:donation, amount: 1000, supporter: supporter, recurring: true, nonprofit: nonprofit)
@ -156,7 +156,7 @@ describe QueryRecurringDonations do
describe '.for_export_enumerable' do describe '.for_export_enumerable' do
before :each 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), @supporters = [force_create(:supporter, name: 'supporter-0', nonprofit: @nonprofit),
force_create(:supporter, name: 'supporter-1', 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(:expired_uuid) { '061124ca-05f1-11e8-8730-57558ad1064d' }
let(:overused_uuid) { '0ac67006-05f1-11e8-902c-035df51dbc79' } 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(:event) { force_create(:event, nonprofit: nonprofit) }
let(:user) do let(:user) do
u = force_create(:user) u = force_create(:user)

View file

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

View file

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

View file

@ -21,7 +21,7 @@ describe SlugCopyNamingAlgorithm do
let(:short_slug_copy_today_plus_1) { 'slug_name_copy_01' } let(:short_slug_copy_today_plus_1) { 'slug_name_copy_01' }
let(:copy_base) { 'slug_name_copy' } let(:copy_base) { 'slug_name_copy' }
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
describe 'events' do describe 'events' do
let(:event) { force_create(:event, slug: @name, nonprofit: nonprofit) } 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' } let(:not_our_city_slug) { 'not_our_city_slug' }
describe 'nonprofits' do describe 'nonprofits' do
let(:nonprofit) { force_create(:nonprofit, slug: @name, state_code_slug: 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(:nonprofit, slug: @name2, 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(:nonprofit, slug: @name, state_code_slug: state_slug, city_slug: not_our_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(:nonprofit, slug: @name, state_code_slug: not_our_state_slug, city_slug: city_slug) } 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 let(:nonprofit_at_max_copies) do
(0..99).collect do |i| (0..99).collect do |i|
force_create(:nonprofit, slug: "#{@copy_base}-#{format('%02d', i)}", state_code_slug: state_slug, city_slug: city_slug) 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(:short_slug_copy_today_plus_1) { 'slug_name_001' }
let(:copy_base) { 'slug_name' } let(:copy_base) { 'slug_name' }
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
describe 'campaigns' do describe 'campaigns' do
let(:campaign) { force_create(:campaign, slug: @name, nonprofit: nonprofit, deleted: true) } 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 } let(:stripe_helper) { StripeMock.create_test_helper }
before(:each) { StripeMock.start } before(:each) { StripeMock.start }
after(:each) { StripeMock.stop } after(:each) { StripeMock.stop }
let(:nonprofit) { force_create(:nonprofit) } let(:nonprofit) { force_create(:nm_justice) }
describe '.find_or_create' do describe '.find_or_create' do
describe 'param validation' do describe 'param validation' do

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe AdminMailer, type: :mailer do RSpec.describe AdminMailer, type: :mailer do
describe 'notify_failed_gift' 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!(:s) { force_create(:supporter, email: 'supporter.email@mail.teha') }
let!(:oldcard) { force_create(:card) } let!(:oldcard) { force_create(:card) }
let!(:donation) { force_create(:donation, nonprofit_id: np.id, supporter_id: s.id, card_id: oldcard.id, amount: 999) } 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 RSpec.describe DonationMailer, type: :mailer do
describe 'donor_recurring_donation_change_amount' 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(:s) { force_create(:supporter, email: 'supporter.email@mail.teha') }
let(:oldcard) { force_create(:card) } let(:oldcard) { force_create(:card) }
let(:donation) { create(:donation, nonprofit_id: np.id, supporter_id: s.id, card_id: oldcard.id, amount: 999) } 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 RSpec.describe Campaign, type: :model do
describe 'sends correct email based on type of campaign' 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(:parent_campaign) { force_create(:campaign, name: 'Parent campaign', nonprofit: nonprofit) }
let(:child_campaign) do let(:child_campaign) do
force_create(:campaign, force_create(:campaign,

View file

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

View file

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

View file

@ -86,7 +86,7 @@ shared_context 'payments for a payout' do
end end
let(:other_np_payment) do 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') create_charge(payment: p, amount: 2000, fee: -400, status: 'available')
return p return p
end end