Sha256: bcc7aade5080466ee0b194cb122502ebde6d4f05854b28f12f7b479a8afb99b9
Contents?: true
Size: 1.24 KB
Versions: 9
Compression:
Stored size: 1.24 KB
Contents
describe Spotlight::ContactEmail, type: :model do let(:exhibit) { FactoryBot.build_stubbed(:exhibit) } subject { described_class.new(exhibit: exhibit) } it { is_expected.not_to be_valid } describe 'with an invalid email set' do before { subject.email = '@-foo' } it 'does not be valid' do expect(subject).to_not be_valid expect(subject.errors[:email]).to eq ['is not valid'] end end describe 'with a valid email set' do before { subject.email = 'foo@example.com' } it { is_expected.to be_valid } describe '#send_devise_notification' do it 'sends stuff' do expect do subject.send(:send_devise_notification, :confirmation_instructions, 'Q7PEPdLVxymsQL2_s_Rg', {}) end.to change { ActionMailer::Base.deliveries.count }.by(1) end end end describe '.confirmed' do it 'scopes contacts to only confirmed contacts' do a = exhibit.contact_emails.create(email: 'a@example.com') if a.respond_to? :confirm a.confirm else a.confirm! end b = exhibit.contact_emails.create(email: 'b@example.com') expect(described_class.confirmed.to_a).to include a expect(described_class.confirmed.to_a).to_not include b end end end
Version data entries
9 entries across 9 versions & 1 rubygems