-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix payment mailer specs, add eald spec
- Loading branch information
Showing
15 changed files
with
98 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
--color | ||
--order rand | ||
--profile 5 | ||
--require spec_helper | ||
--require rails_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
require 'newrelic_rpm' | ||
require 'singleton' | ||
|
||
module FnF | ||
class EventReporter | ||
class << self | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationMailer < ActionMailer::Base | ||
DEFAULT_SENDER_EMAIL = '[email protected]' | ||
DEFAULT_REPLY_TO_EMAIL = '[email protected]' | ||
|
||
layout 'email' | ||
|
||
abstract! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class EaldPaymentMailer < ActionMailer::Base | ||
DEFAULT_SENDER_EMAIL = '[email protected]' | ||
DEFAULT_REPLY_TO_EMAIL = '[email protected]' | ||
|
||
helper PaymentsHelper | ||
|
||
layout 'email' | ||
|
||
def eald_payment_received(eald_payment) | ||
@eald_payment = eald_payment | ||
@event = @eald_payment.event | ||
mail to: "#{@eald_payment.name} <#{@eald_payment.email}>", | ||
class EaldPaymentMailer < PaymentReceivedMailer | ||
def eald_payment_received(payment) | ||
@payment = payment | ||
@event = @payment.event | ||
mail to: "#{@payment.name} <#{@payment.email}>", | ||
from: from_email, | ||
reply_to: reply_to_email, | ||
subject: "Your payment for #{@event.name} Early Arrival/Late Departure passes has been received" | ||
end | ||
|
||
private | ||
|
||
def from_email | ||
"#{@event.name} <#{DEFAULT_SENDER_EMAIL}>" | ||
end | ||
|
||
def reply_to_email | ||
"#{@event.name} Ticketing <#{DEFAULT_REPLY_TO_EMAIL}>" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class PaymentMailer < ActionMailer::Base | ||
DEFAULT_SENDER_EMAIL = '[email protected]' | ||
DEFAULT_REPLY_TO_EMAIL = '[email protected]' | ||
|
||
helper PaymentsHelper | ||
|
||
layout 'email' | ||
|
||
class PaymentReceivedMailer < ApplicationMailer | ||
def payment_received(payment) | ||
@payment = payment | ||
@ticket_request = @payment.ticket_request | ||
@event = @ticket_request.event | ||
@user = @ticket_request.user | ||
self.payment = payment | ||
|
||
mail to: "#{@user.name} <#{@user.email}>", | ||
from: from_email, | ||
reply_to: reply_to_email, | ||
|
@@ -28,4 +19,11 @@ def from_email | |
def reply_to_email | ||
"#{@event.name} Ticketing <#{DEFAULT_REPLY_TO_EMAIL}>" | ||
end | ||
|
||
def payment=(payment) | ||
@payment = payment | ||
@ticket_request = @payment.ticket_request | ||
@event = @ticket_request&.event | ||
@user = @ticket_request&.user | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,6 @@ | |
require 'awesome_print' | ||
|
||
class TicketRequestMailer < ActionMailer::Base | ||
DEFAULT_SENDER_EMAIL = '[email protected]' | ||
DEFAULT_REPLY_TO_EMAIL = '[email protected]' | ||
|
||
layout 'email' | ||
|
||
def request_received(ticket_request) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :eald_payment do | ||
event | ||
name { Faker::Name.name } | ||
early_arrival_passes { 10 } | ||
amount_charged_cents { 1000 } | ||
late_departure_passes { 5 } | ||
email { Faker::Internet.email } | ||
stripe_charge_id { Faker::Alphanumeric.alphanumeric(number: 10) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe EaldPaymentMailer do | ||
let(:payment) { create(:eald_payment) } | ||
let(:event) { payment.event } | ||
|
||
describe '#eald_payment_received' do | ||
subject(:mail) { described_class.eald_payment_received(payment) } | ||
|
||
let(:expected_subject) { "Your payment for #{event.name} Early Arrival/Late Departure passes has been received" } | ||
|
||
its(:subject) { is_expected.to eql(expected_subject) } | ||
|
||
its(:to) { is_expected.to eql([payment.email]) } | ||
|
||
its('body.encoded') { is_expected.to match(event.name) } | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe PaymentReceivedMailer do | ||
let(:ticket_request) { create(:ticket_request) } | ||
let(:user) { ticket_request.user } | ||
let(:event) { ticket_request.event } | ||
let(:payment) { create(:payment, ticket_request:) } | ||
|
||
describe '#payment_received' do | ||
subject(:mail) { described_class.payment_received(payment) } | ||
|
||
let(:expected_subject) { "Your payment for #{event.name} has been received" } | ||
|
||
its(:subject) { is_expected.to eql(expected_subject) } | ||
|
||
its(:to) { is_expected.to eql([user.email]) } | ||
|
||
its('body.encoded') { is_expected.to match(user.first_name) } | ||
|
||
its('body.encoded') { is_expected.to match(event.name) } | ||
end | ||
end |