forked from theforeman/foreman
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes theforeman#8428 - Connecting audits to existing users
- Loading branch information
Showing
5 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveAuditUserFk < ActiveRecord::Migration | ||
def change | ||
remove_foreign_key(:audits, :user) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :audit do | ||
sequence(:version) {|n| "#{n}" } | ||
auditable_type "test" | ||
action "update" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'test_helper' | ||
|
||
class AuditExtensionsTest < ActiveSupport::TestCase | ||
|
||
def setup | ||
@user = users :admin | ||
end | ||
|
||
test "should be connected to current user" do | ||
audit = as_admin do | ||
FactoryGirl.create(:audit) | ||
end | ||
|
||
assert_equal audit.user_id, @user.id | ||
assert_equal audit.username, @user.name | ||
end | ||
end |