Commit 9cc7764a authored by James Lopez's avatar James Lopez

refactor and fix spec

parent 15df6af2
...@@ -7,24 +7,23 @@ describe EE::Audit::Changes do ...@@ -7,24 +7,23 @@ describe EE::Audit::Changes do
before do before do
foo_instance.instance_variable_set(:@current_user, user) foo_instance.instance_variable_set(:@current_user, user)
foo_instance.instance_variable_set(:@user, user)
allow(foo_instance).to receive(:model).and_return(user) allow(foo_instance).to receive(:model).and_return(user)
end end
describe 'non audit changes' do describe 'non audit changes' do
it 'does not call the audit event service' do it 'does not call the audit event service' do
expect_any_instance_of(AuditEventService).not_to receive(:security_event)
user.update!(name: 'new name') user.update!(name: 'new name')
foo_instance.audit_changes(:email)
expect{ foo_instance.audit_changes(:email) }.not_to change { SecurityEvent.count }
end end
end end
describe 'audit changes' do describe 'audit changes' do
it 'calls the audit event service' do it 'calls the audit event service' do
expect_any_instance_of(AuditEventService).to receive(:security_event)
user.update!(name: 'new name') user.update!(name: 'new name')
foo_instance.audit_changes(:name)
expect{ foo_instance.audit_changes(:name) }.to change { SecurityEvent.count }.by(1)
end 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