Commit 475ab94e authored by James Lopez's avatar James Lopez

add more license specs

parent 0ad7f5db
......@@ -93,6 +93,19 @@ module EE
)
end
def entity_audit_events_enabled?
@entity.respond_to?(:feature_available?) && @entity.feature_available?(:audit_events)
end
def audit_events_enabled?
# Always log auth events. Log all other events if `extended_audit_events` is enabled
@details[:with] || License.feature_available?(:extended_audit_events)
end
def admin_audit_log_enabled?
License.feature_available?(:admin_audit_log)
end
def method_missing(method_sym, *arguments, &block)
super(method_sym, *arguments, &block) unless respond_to?(method_sym)
......@@ -150,18 +163,5 @@ module EE
@details.merge!(ip_address: ip_address,
entity_path: @entity.full_path)
end
def entity_audit_events_enabled?
@entity.respond_to?(:feature_available?) && @entity.feature_available?(:audit_events)
end
def audit_events_enabled?
# Always log auth events. Log all other events if `extended_audit_events` is enabled
@details[:with] || License.feature_available?(:extended_audit_events)
end
def admin_audit_log_enabled?
License.feature_available?(:admin_audit_log)
end
end
end
......@@ -56,20 +56,20 @@ describe AuditEventService do
end
end
describe '#audit_events_enabled?' do
describe '#entity_audit_events_enabled??' do
context 'entity is a project' do
let(:service) { described_class.new(user, project, { action: :destroy }) }
it 'returns false when project is unlicensed' do
stub_licensed_features(audit_events: false)
expect(service.audit_events_enabled?).to be_falsy
expect(service.entity_audit_events_enabled?).to be_falsy
end
it 'returns true when project is licensed' do
stub_licensed_features(audit_events: true)
expect(service.audit_events_enabled?).to be_truthy
expect(service.entity_audit_events_enabled?).to be_truthy
end
end
......@@ -80,19 +80,35 @@ describe AuditEventService do
it 'returns false when group is unlicensed' do
stub_licensed_features(audit_events: false)
expect(service.audit_events_enabled?).to be_falsy
expect(service.entity_audit_events_enabled?).to be_falsy
end
it 'returns true when group is licensed' do
stub_licensed_features(audit_events: true)
expect(service.audit_events_enabled?).to be_truthy
expect(service.entity_audit_events_enabled?).to be_truthy
end
end
context 'entity is a user' do
let(:service) { described_class.new(user, user, { action: :destroy }) }
it 'returns false when unlicensed' do
stub_licensed_features(audit_events: false, admin_audit_log: false)
expect(service.audit_events_enabled?).to be_falsey
end
it 'returns true when licensed with extended events' do
stub_licensed_features(extended_audit_events: true)
expect(service.audit_events_enabled?).to be_truthy
end
end
context 'auth event' do
let(:service) { described_class.new(user, user, { with: 'auth' }) }
it 'returns true when unlicensed' do
stub_licensed_features(audit_events: false, admin_audit_log: false)
......
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