2016-12-13 03:28:10 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-06 16:15:18 +00:00
|
|
|
|
2016-10-13 07:39:13 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe MapMailer, type: :mailer do
|
2017-02-09 21:53:19 +00:00
|
|
|
describe 'access_request' do
|
2016-10-17 14:53:53 +00:00
|
|
|
let(:map) { create(:map) }
|
2016-12-13 03:28:10 +00:00
|
|
|
let(:request) { create(:access_request, map: map) }
|
2017-02-09 21:53:19 +00:00
|
|
|
let(:mail) { described_class.access_request(request) }
|
2016-10-17 14:53:53 +00:00
|
|
|
|
|
|
|
it { expect(mail.from).to eq ['team@metamaps.cc'] }
|
|
|
|
it { expect(mail.to).to eq [map.user.email] }
|
|
|
|
it { expect(mail.subject).to match map.name }
|
|
|
|
it { expect(mail.body.encoded).to match map.name }
|
|
|
|
it { expect(mail.body.encoded).to match request.user.name }
|
2016-11-07 19:56:35 +00:00
|
|
|
it { expect(mail.body.encoded).to match 'Allow' }
|
|
|
|
it { expect(mail.body.encoded).to match 'Decline' }
|
2016-10-17 14:53:53 +00:00
|
|
|
end
|
|
|
|
|
2017-02-09 21:53:19 +00:00
|
|
|
describe 'invite_to_edit' do
|
2016-10-17 14:53:53 +00:00
|
|
|
let(:inviter) { create(:user) }
|
2017-02-09 21:53:19 +00:00
|
|
|
let(:map) { create(:map, user: inviter) }
|
|
|
|
let(:invited) { create(:user) }
|
|
|
|
let(:user_map) { create(:user_map, map: map, user: invited) }
|
|
|
|
let(:mail) { described_class.invite_to_edit(user_map) }
|
2016-10-13 07:39:13 +00:00
|
|
|
|
|
|
|
it { expect(mail.from).to eq ['team@metamaps.cc'] }
|
2017-02-09 21:53:19 +00:00
|
|
|
it { expect(mail.to).to eq [invited.email] }
|
2016-10-13 07:39:13 +00:00
|
|
|
it { expect(mail.subject).to match map.name }
|
|
|
|
it { expect(mail.body.encoded).to match inviter.name }
|
|
|
|
it { expect(mail.body.encoded).to match map.name }
|
|
|
|
end
|
|
|
|
end
|