Commit d6e5b443 authored by Rajendra Kadam's avatar Rajendra Kadam

Fix rubocop offense and use attr_accessor

parent 56b93d1c
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module Keys module Keys
class CreateService < ::Keys::BaseService class CreateService < ::Keys::BaseService
attr_accessor :current_user
def initialize(current_user, params = {}) def initialize(current_user, params = {})
@current_user, @params = current_user, params @current_user, @params = current_user, params
@ip_address = @params.delete(:ip_address) @ip_address = @params.delete(:ip_address)
......
...@@ -14,7 +14,7 @@ module EE ...@@ -14,7 +14,7 @@ module EE
end end
def audit_event_service def audit_event_service
::AuditEventService.new(@current_user, ::AuditEventService.new(current_user,
user, user,
action: :custom, action: :custom,
custom_message: 'Added SSH key', custom_message: 'Added SSH key',
......
...@@ -3,18 +3,20 @@ ...@@ -3,18 +3,20 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Keys::CreateService do RSpec.describe Keys::CreateService do
let(:admin_user) { create(:admin)} let(:admin) { create(:admin) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:params) { attributes_for(:key).merge(user: user) } let(:params) { attributes_for(:key).merge(user: user) }
subject { described_class.new(admin_user, params) } subject { described_class.new(admin, params) }
it 'creates' do it 'creates' do
stub_licensed_features(extended_audit_events: true) stub_licensed_features(extended_audit_events: true)
expect { subject.execute }.to change { SecurityEvent.count }.by(1) expect { subject.execute }.to change { SecurityEvent.count }.by(1)
event = SecurityEvent.last event = SecurityEvent.last
expect(event.author_name).to eq(admin_user.name)
expect(event.author_name).to eq(admin.name)
expect(event.entity_id).to eq(user.id) expect(event.entity_id).to eq(user.id)
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