2016-02-08 18:16:18 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Invite do
|
|
|
|
describe 'an email can be used for multiple dossier' do
|
|
|
|
let(:email1) { 'plop@octo.com' }
|
|
|
|
|
|
|
|
let!(:dossier1) { create(:dossier) }
|
|
|
|
let!(:dossier2) { create(:dossier) }
|
|
|
|
|
|
|
|
context 'when an email is invite on two dossier' do
|
|
|
|
subject do
|
|
|
|
create(:invite, email: email1, dossier: dossier1)
|
|
|
|
create(:invite, email: email1, dossier: dossier2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect{ subject }.to change(Invite, :count).by(2) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when an email is invite twice on a dossier' do
|
|
|
|
subject do
|
|
|
|
create(:invite, email: email1, dossier: dossier1)
|
|
|
|
create(:invite, email: email1, dossier: dossier1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid }
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|