gitlab-org--gitlab-foss/spec/services/emails/create_service_spec.rb

22 lines
529 B
Ruby
Raw Normal View History

2017-06-16 12:07:56 +00:00
require 'spec_helper'
describe Emails::CreateService do
2017-06-16 12:07:56 +00:00
let(:user) { create(:user) }
let(:opts) { { email: 'new@email.com' } }
2017-09-20 11:36:00 +00:00
subject(:service) { described_class.new(user, user, opts) }
2017-06-16 12:07:56 +00:00
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