require "spec_helper"

describe FeedbackRequestMailer do

  let(:email) { ActionMailer::Base.deliveries.last }
  let(:session) { Fabricate(:sessions, title: "HTML & CSS") }
  let(:member) { Fabricate(:member) }
  let(:feedback_request) { Fabricate(:feedback_request, sessions: session, member: member) }

  it "#request_feedback" do
    email_subject = "Feedback for #{session.title} by Codebar - #{I18n.l(session.date_and_time, format: :email_title)}"

    FeedbackRequestMailer.request_feedback(session, member, feedback_request).deliver

    expect(email.subject).to eq(email_subject)
  end
end
require "spec_helper"

describe FeedbackRequestMailer do

  let(:email) { ActionMailer::Base.deliveries.last }
  let(:session) { Fabricate(:sessions, title: "HTML & CSS") }
  let(:member) { Fabricate(:member) }
  let(:feedback_request) { Fabricate(:feedback_request, sessions: session, member: member) }

  it "#request_feedback" do
    email_subject = "Feedback for #{session.title} by Codebar - #{I18n.l(session.date_and_time, format: :email_title)}"

    FeedbackRequestMailer.request_feedback(session, member, feedback_request).deliver

    expect(email.subject).to eq(email_subject)
    expect(email.parts.first.body.raw_source).to include feedback_url(feedback_request.token)
  end
end
Improve Feedback request mailer spec
Improve Feedback request mailer spec
