diff options
author | James Lopez <james@jameslopez.es> | 2017-06-16 14:07:56 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-06-23 11:41:42 +0200 |
commit | 3798e894594c6056df5bea2daa65f10bc19843d0 (patch) | |
tree | f077f78e161d3149d25422f514d87889d8fd095b /spec | |
parent | 158550cf37cc2db9590f0212962f10ecc73082de (diff) | |
download | gitlab-ce-3798e894594c6056df5bea2daa65f10bc19843d0.tar.gz |
add emails service specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/emails/create_service_spec.rb | 21 | ||||
-rw-r--r-- | spec/services/emails/destroy_service_spec.rb | 14 |
2 files changed, 35 insertions, 0 deletions
diff --git a/spec/services/emails/create_service_spec.rb b/spec/services/emails/create_service_spec.rb new file mode 100644 index 00000000000..c1f477f551e --- /dev/null +++ b/spec/services/emails/create_service_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Emails::CreateService, services: true do + let(:user) { create(:user) } + let(:opts) { { email: 'new@email.com' } } + + subject(:service) { described_class.new(user, opts) } + + describe '#execute' do + it 'creates an email with valid attributes' do + expect { service.execute }.to change { Email.count }.by(1) + expect(Email.where(opts)).not_to be_empty + end + + it 'has the right user association' do + service.execute + + expect(user.emails).to eq(Email.where(opts)) + end + end +end diff --git a/spec/services/emails/destroy_service_spec.rb b/spec/services/emails/destroy_service_spec.rb new file mode 100644 index 00000000000..0778b3f50da --- /dev/null +++ b/spec/services/emails/destroy_service_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Emails::DestroyService, services: true do + let!(:user) { create(:user) } + let!(:email) { create(:email, user: user) } + + subject(:service) { described_class.new(user, opts) } + + describe '#execute' do + it 'creates an email with valid attributes' do + expect { service.execute }.to change { user.emails.count }.by(-1) + end + end +end |