Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #22054 - Audit resources which lack auditing #5105

Merged
merged 1 commit into from Dec 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/http_proxy.rb
Expand Up @@ -3,6 +3,8 @@ class HttpProxy < ApplicationRecord
include Taxonomix
include Encryptable

audited

extend FriendlyId

encrypts :password
Expand Down
2 changes: 2 additions & 0 deletions app/models/model.rb
Expand Up @@ -4,6 +4,8 @@ class Model < ApplicationRecord
friendly_id :name
include Parameterizable::ByIdName

audited

before_destroy EnsureNotUsedBy.new(:hosts)
has_many_hosts
has_many :trends, :as => :trendable, :class_name => "ForemanTrend"
Expand Down
10 changes: 10 additions & 0 deletions test/models/model_test.rb
Expand Up @@ -23,4 +23,14 @@ class ModelTest < ActiveSupport::TestCase
assert_equal 1, m.reload.hosts.size
assert !m.destroy
end

context 'is audited' do
test 'on creation on of a new model' do
model = FactoryBot.build(:model, :with_auditing)

assert_difference 'model.audits.count' do
model.save!
end
end
end
end
10 changes: 10 additions & 0 deletions test/unit/http_proxy_test.rb
Expand Up @@ -15,4 +15,14 @@ class HttpProxyTest < ActiveSupport::TestCase
test 'search by name' do
assert_equal 1, HttpProxy.search_for("name = #{http_proxy.name}").count
end

context 'is audited' do
test 'on creation on of a new http_proxy' do
http_proxy = FactoryBot.build(:http_proxy, :with_auditing)

assert_difference 'http_proxy.audits.count' do
http_proxy.save!
end
end
end
end