Sha256: 59639fa143dccd0756689efed8cee9e0bdab6e5da9d5cfb86201f0683ec16986
Contents?: true
Size: 1.64 KB
Versions: 47
Compression:
Stored size: 1.64 KB
Contents
require 'rails_helper' module Cmor::Contact RSpec.describe ContactRequest, type: :model do it { expect(subject).to validate_presence_of(:name) } it { expect(subject).to validate_presence_of(:email) } it { expect(subject).to validate_presence_of(:phone) } it { expect(subject).to validate_presence_of(:ip_address) } it { expect(subject).to validate_presence_of(:message) } describe 'spam protection' do it { expect(subject).to respond_to(:nickname) } describe 'when is spam' do subject { build(:cmor_contact_contact_request) } before(:each) { subject.nickname = 'Evil Spammer' } it { expect(subject).to be_valid } it { expect(subject.save).to be_truthy } it { subject.valid?; expect(subject.errors.full_messages).to eq([])} it { expect{ subject.save }.not_to change{ described_class.count } } end describe 'when it is not spam' do subject { build(:cmor_contact_contact_request) } before(:each) { subject.nickname = nil } it { expect(subject).to be_valid } it { expect(subject.save).to be_truthy } it { subject.valid?; expect(subject.errors.full_messages).to eq([])} it { expect{ subject.save }.to change{ described_class.count }.from(0).to(1) } end end describe 'notification' do let(:contact_request) { build(:cmor_contact_contact_request) } before(:each) do allow(Cmor::Contact::NotifyNewContactRequestJob).to receive(:perform_later) contact_request.save end it { expect(Cmor::Contact::NotifyNewContactRequestJob).to have_received(:perform_later).once } end end end
Version data entries
47 entries across 47 versions & 1 rubygems