mysociety/alaveteli

View on GitHub
spec/views/notification_mailer/info_requests/messages/_overdue.text.erb_spec.rb

Summary

Maintainability
A
3 hrs
Test Coverage
# -*- encoding : utf-8 -*-
require 'spec_helper'

describe("notification_mailer/info_requests/messages/_overdue.text.erb") do
  let!(:public_body) { FactoryGirl.create(:public_body, name: "One & Two") }
  let!(:info_request) do
    FactoryGirl.create(:overdue_request, public_body: public_body)
  end
  let!(:info_request_event) do
    FactoryGirl.create(:overdue_event, info_request: info_request)
  end
  let!(:notification) do
    FactoryGirl.create(:daily_notification,
                       info_request_event: info_request_event)
  end
  let(:template) do
    "notification_mailer/info_requests/messages/overdue"
  end

  before do
    allow(info_request).to receive(:law_used_human).and_return("FOI & EIR")
    render partial: template, locals: { info_request: info_request }
  end

  it "doesn't escape HTMLEntities in the public_body name" do
    expect(response).to include("One & Two")
    expect(response).not_to include("One & Two")
  end

  it "doesn't escape HTMLEntities in the law used" do
    expect(response).to include("FOI & EIR")
    expect(response).not_to include("FOI & EIR")
  end

  it "prints a link for the request" do
    target = respond_to_last_path(info_request, anchor: 'followup')
    expected_url = signin_url(r: target)
    expect(response).to have_text(expected_url)
  end
end