spec/audited/audit_spec.rb in audited-4.7.1 vs spec/audited/audit_spec.rb in audited-4.8.0

- old
+ new

@@ -211,9 +211,28 @@ expect(audit.user).to eq(user) end end end + it "should support nested as_user" do + Audited::Audit.as_user("sidekiq") do + company = Models::ActiveRecord::Company.create name: "The auditors" + company.name = "The Auditors, Inc" + company.save + expect(company.audits[-1].user).to eq("sidekiq") + + Audited::Audit.as_user(user) do + company.name = "NEW Auditors, Inc" + company.save + expect(company.audits[-1].user).to eq(user) + end + + company.name = "LAST Auditors, Inc" + company.save + expect(company.audits[-1].user).to eq("sidekiq") + end + end + it "should record usernames" do Audited::Audit.as_user(user.name) do company = Models::ActiveRecord::Company.create name: "The auditors" company.name = "The Auditors, Inc" company.save