Skip to content

Instantly share code, notes, and snippets.

@dan-palmer
Last active August 29, 2015 14:11
Show Gist options
  • Save dan-palmer/36fad9d0128fd37cc8a4 to your computer and use it in GitHub Desktop.
Save dan-palmer/36fad9d0128fd37cc8a4 to your computer and use it in GitHub Desktop.
require 'rails_helper'
feature 'Confirmation Group Payment With Remission', type: :feature do
attr_reader :claim, :recipients, :email, :body
before :all do
@claim = create :claim, :group_payment_with_remission
@recipients = ["me@example.com"]
@email = BaseMailer.confirmation_email(claim, recipients).deliver_now
@body = email.parts.first.body.raw_source
end
include_context "a Confirmation Email"
it "has a greeting" do
greeting = "Thank you for submitting your claim to an employment tribunal."
expect(body).to have_text greeting
end
describe "what happens next" do
it "has 'apply for fee remission' text" do
content = <<-eos
You have said you want to apply for fee
remission. You must apply within 7 days,
or your claim may be rejected.
eos
expect(body).to have_text content
end
it "has an 'apply for fee remisison' button" do
expect(body).to have_link "Apply for fee remission"
end
it "has 'apply for fee remission' text" do
content = <<-eos
We’ll review your claim for remission and
contact you to explain the next steps.
eos
expect(body).to have_text content
end
end
describe "submission details" do
it "has a 'Claim completed' section" do
expect(body).to have_text "Claim completedSee attached PDF"
end
it "has a 'Claim submitted' section" do
expect(body).to have_text "Claim submittedSubmitted #{Time.now.strftime '%d %B %Y'}"
end
it "has an 'Attachments submitted' section" do
expect(body).to have_text "Attachments submittedfile.rtffile.csv"
end
it "has an 'Issue fee paid' section" do
expect(body).to have_text "Issue fee paid£250.00"
end
end
describe "further information" do
it "has contact details" do
expect(body).to have_text "England & Wales: 0300 123 1024"
expect(body).to have_text "Scotland: 0141 354 8574"
end
end
end
RSpec.shared_examples 'a Confirmation Email' do
describe "common properties" do
it "has been delivered" do
expect(ActionMailer::Base.deliveries).to be_present
end
it 'has a PDF attachment' do
expect(email.attachments.size).to eq 1
expect(email.attachments.first.filename).to eq "et1_barrington_wrigglesworth.pdf"
end
it "has a subject" do
expect(email.subject).to eq "Employment tribunal: claim submitted"
end
it 'has recipients' do
expect(email.to).to eq recipients
end
it "has a title" do
bold_heading = "font-family:arial; font-size:40px; font-weight:bold;\">Claim submitted"
expect(body).to include bold_heading
end
it 'has a claim reference in the body' do
expect(body).to have_text claim.reference
end
it "has a salutation" do
name = "#{claim.primary_claimant.first_name} #{claim.primary_claimant.last_name}"
expect(body).to have_text name
end
it "has a feedback link" do
expect(body).to have_link "Your feedback"
end
it "has a diversity monitoring questionnaire link" do
expect(body).to have_link "diversity monitoring questionnaire"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment