Skip to content

Commit

Permalink
add test for set_sql.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshimizu-oc committed Dec 15, 2023
1 parent e70b4d7 commit 4b195bc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion spec/audited/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ class Models::ActiveRecord::CustomUserSubclass < Models::ActiveRecord::CustomUse

describe "as_audit_application" do
it "should set audit_application string" do
Audited::Audit.as_audit_application("test-app") do
Audited::Audit.as_audit_application("test-app")
Audited::Audit.as_user(user) do
company = Models::ActiveRecord::Company.create name: "The auditors"
company.name = "The Auditors, Inc"
company.save
Expand All @@ -368,4 +369,20 @@ class Models::ActiveRecord::CustomUserSubclass < Models::ActiveRecord::CustomUse
end
end
end

describe "set_sql" do
it 'should set sql query' do
Audited.sql_log_enabled = true
Audited::Audit.as_user(user) do
company = Models::ActiveRecord::Company.create name: "The auditors"
company.name = "The Auditors, Inc"
company.save

company.audits.each do |audit|
expect(audit.sql).not_to be_nil
end
end
Audited.sql_log_enabled = false
end
end
end

0 comments on commit 4b195bc

Please sign in to comment.