Commit 31655a5b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '6517-extract-ee-specific-files-lines-for-spec-services-emails' into 'master'

Resolve "Extract EE specific files/lines for spec/services/emails"

Closes #6517

See merge request gitlab-org/gitlab-ee!10345
parents 89ee1191 53907f24
# frozen_string_literal: true
require 'spec_helper'
describe Emails::CreateService do
let(:user) { create(:user) }
let(:opts) { { email: 'new@email.com', user: user } }
subject(:service) { described_class.new(user, opts) }
describe '#execute' do
it 'registers a security event' do
stub_licensed_features(extended_audit_events: true)
expect { service.execute }.to change { SecurityEvent.count }.by(1)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Emails::DestroyService do
let!(:user) { create(:user) }
let!(:email) { create(:email, user: user) }
subject(:service) { described_class.new(user, user: user) }
describe '#execute' do
it 'registers a security event' do
stub_licensed_features(extended_audit_events: true)
expect { service.execute(email) }.to change { SecurityEvent.count }.by(1)
end
end
end
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe Emails::CreateService do describe Emails::CreateService do
...@@ -7,10 +9,6 @@ describe Emails::CreateService do ...@@ -7,10 +9,6 @@ describe Emails::CreateService do
subject(:service) { described_class.new(user, opts) } subject(:service) { described_class.new(user, opts) }
describe '#execute' do describe '#execute' do
before do
stub_licensed_features(extended_audit_events: true)
end
it 'creates an email with valid attributes' do it 'creates an email with valid attributes' do
expect { service.execute }.to change { Email.count }.by(1) expect { service.execute }.to change { Email.count }.by(1)
expect(Email.where(opts)).not_to be_empty expect(Email.where(opts)).not_to be_empty
...@@ -26,9 +24,5 @@ describe Emails::CreateService do ...@@ -26,9 +24,5 @@ describe Emails::CreateService do
expect(user.emails).to eq(Email.where(opts)) expect(user.emails).to eq(Email.where(opts))
end end
it 'registers a security event' do
expect { service.execute }.to change { SecurityEvent.count }.by(1)
end
end end
end end
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe Emails::DestroyService do describe Emails::DestroyService do
...@@ -6,17 +8,9 @@ describe Emails::DestroyService do ...@@ -6,17 +8,9 @@ describe Emails::DestroyService do
subject(:service) { described_class.new(user, user: user) } subject(:service) { described_class.new(user, user: user) }
before do
stub_licensed_features(extended_audit_events: true)
end
describe '#execute' do describe '#execute' do
it 'removes an email' do it 'removes an email' do
expect { service.execute(email) }.to change { user.emails.count }.by(-1) expect { service.execute(email) }.to change { user.emails.count }.by(-1)
end end
it 'registers a security event' do
expect { service.execute(email) }.to change { SecurityEvent.count }.by(1)
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment