Permalink
Browse files

Add changed_by method to Audit model for incapsulation user association

  • Loading branch information...
1 parent 79e0bdf commit e9a23805011cce2b989d80898bf9d504e8e9d5b3 @zuf committed Mar 28, 2012
Showing with 9 additions and 0 deletions.
  1. +8 −0 lib/auditable/audit.rb
  2. +1 −0 spec/lib/auditable_spec.rb
View
@@ -62,5 +62,13 @@ def diff_since(time)
other_audit = self.class.where("created_at < ?", time).order("created_at DESC").limit(1).first
diff(other_audit)
end
+
+ # Returns user object
+ #
+ # Use same method name like in update_attributes:
+ #
+ def changed_by
+ user
+ end
end
end
@@ -77,6 +77,7 @@
it "should set changed_by" do
survey.update_attributes(:title => "another title", :changed_by => user)
survey.audits.last.user.should == user
+ survey.audits.last.changed_by.should == user
end
it "should set audit_action" do

0 comments on commit e9a2380

Please sign in to comment.