From adeb9c46cbe4aba9081d0b48a66e66d0af25c188 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Mon, 11 Feb 2019 14:00:32 -0600 Subject: [PATCH 1/3] Fix bug where the federated p2p creators location was mangled --- .../fundraising_pages/_campaigner_profile.html.erb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/components/fundraising_pages/_campaigner_profile.html.erb b/app/views/components/fundraising_pages/_campaigner_profile.html.erb index bfe48bca..d7bf54bc 100644 --- a/app/views/components/fundraising_pages/_campaigner_profile.html.erb +++ b/app/views/components/fundraising_pages/_campaigner_profile.html.erb @@ -1,12 +1,12 @@ +<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%> +<%- @location_array = [] + @location_array.push(profile.city) if profile.city.present? + @location_array.push(profile.state_code) if profile.state_code.present? +-%>
-

<%= profile.name %> <% if profile.state_code || profile.city -%> - (<% if profile.state_code && profile.city -%><%= profile.city %>, <%= profile.state_code -%> -<% elsif profile.city -%> -<%= profile.city -%> -<% else -%> -<%= profile.state_code -%> -<% end -%>)<% end -%> +

<%= profile.name %><%- if @location_array.any? -%> + (<%= @location_array.join(', ') %>)<%- end -%>

"<%= reason_for_supporting %>"

From 0916fe74c09453278efbf774e30c527df4923c0e Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Mon, 11 Feb 2019 16:10:57 -0600 Subject: [PATCH 2/3] Add a federated P2P creation email --- app/mailers/campaign_mailer.rb | 6 ++++ app/models/campaign.rb | 7 ++++- .../federated_creation_followup.html.erb | 31 +++++++++++++++++++ spec/models/campaign_spec.rb | 26 ++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 app/views/campaign_mailer/federated_creation_followup.html.erb create mode 100644 spec/models/campaign_spec.rb diff --git a/app/mailers/campaign_mailer.rb b/app/mailers/campaign_mailer.rb index c18aca9b..6919bef2 100644 --- a/app/mailers/campaign_mailer.rb +++ b/app/mailers/campaign_mailer.rb @@ -6,4 +6,10 @@ class CampaignMailer < BaseMailer @campaign = campaign mail(:to => @creator_profile.user.email, :subject => "Get your new campaign rolling! (via #{Settings.general.name})") end + + def federated_creation_followup(campaign) + @creator_profile = campaign.profile + @campaign = campaign + mail(:to => @creator_profile.user.email, :subject => "Get your new campaign rolling! (via #{Settings.general.name})") + end end diff --git a/app/models/campaign.rb b/app/models/campaign.rb index f0d62fcc..d4037873 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -101,7 +101,12 @@ class Campaign < ActiveRecord::Base after_create do user = self.profile.user Role.create(name: :campaign_editor, user_id: user.id, host: self) - CampaignMailer.delay.creation_followup(self) + if child_campaign? + CampaignMailer.delay.federated_creation_followup(self) + else + CampaignMailer.delay.creation_followup(self) + end + NonprofitAdminMailer.delay.supporter_fundraiser(self) unless QueryRoles.is_nonprofit_user?(user.id, self.nonprofit_id) self end diff --git a/app/views/campaign_mailer/federated_creation_followup.html.erb b/app/views/campaign_mailer/federated_creation_followup.html.erb new file mode 100644 index 00000000..8191ae0d --- /dev/null +++ b/app/views/campaign_mailer/federated_creation_followup.html.erb @@ -0,0 +1,31 @@ +<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%> +<% campaign_url = Format::Url.concat(root_url, @campaign.url) %> + +

Dear <%= @creator_profile.name.blank? ? @creator_profile.user.email : @creator_profile.name %>,

+
+ +

Congratulations on creating your campaign to support <%= @campaign.nonprofit.name %>!

+
+ +

You can visit it here: <%= campaign_url %>.

+
+ +

Before you share your campaign with the world, we recommend you personalize + your campaign by including a testimonial in your words about why + you launched your campaign. You can also set a goal amount to inspire you and your donors. + To edit your campaign, ">visit your fundraisers (you may be asked to login) + and select <%= @campaign.name%>.

+
+

Make sure to tell your friends and family why they should support your cause and how their contributions will make a difference. Your words and your passion can make a big difference. + Share your fundraiser on:

+ + +

If you need some help getting your campaign up and running, don't hesitate to contact <%= Settings.devise.mailer_sender %>.

+ +<%= render 'emails/sig' %> diff --git a/spec/models/campaign_spec.rb b/spec/models/campaign_spec.rb new file mode 100644 index 00000000..db5b4adb --- /dev/null +++ b/spec/models/campaign_spec.rb @@ -0,0 +1,26 @@ +# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later +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(:parent_campaign) { force_create(:campaign, name: 'Parent campaign', nonprofit: nonprofit) } + let(:child_campaign) do + force_create(:campaign, + name: 'Child campaign', + parent_campaign_id: parent_campaign.id, + slug: "twehotiheiotheiofnieoth", + goal_amount_dollars: "1000", nonprofit: nonprofit ) + end + + it 'parent campaign sends out general campaign email' do + expect { parent_campaign }.to change { ActionMailer::Base.deliveries.count }.by(1) + expect(ActionMailer::Base.deliveries.last.body.include?("Create one-time or recurring")).to be_truthy + end + + it 'child campaign sends out federated campaign email' do + expect { child_campaign}.to change { ActionMailer::Base.deliveries.count }.by(2) + expect(ActionMailer::Base.deliveries.last.body.include?("including a testimonial")).to be_truthy + end + end +end From 1e592ed74fbc9e717b3135bed760caca28e8089a Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Mon, 11 Feb 2019 16:16:32 -0600 Subject: [PATCH 3/3] Correct some language in federated P2P creation email --- app/views/campaign_mailer/federated_creation_followup.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/campaign_mailer/federated_creation_followup.html.erb b/app/views/campaign_mailer/federated_creation_followup.html.erb index 8191ae0d..846363b8 100644 --- a/app/views/campaign_mailer/federated_creation_followup.html.erb +++ b/app/views/campaign_mailer/federated_creation_followup.html.erb @@ -13,7 +13,7 @@

Before you share your campaign with the world, we recommend you personalize your campaign by including a testimonial in your words about why you launched your campaign. You can also set a goal amount to inspire you and your donors. - To edit your campaign, ">visit your fundraisers (you may be asked to login) + To edit your campaign, ">visit your fundraisers dashboard (you may be asked to login) and select <%= @campaign.name%>.


Make sure to tell your friends and family why they should support your cause and how their contributions will make a difference. Your words and your passion can make a big difference.