Permalink
Browse files

Rename all non-file-related instances of "acts_as_audited" with "audi…

…ted"
  • Loading branch information...
1 parent bd40873 commit 9cc692691c71fd246d24a9b3321984856dc1305e @laserlemon laserlemon committed Apr 24, 2012
View
2 CHANGELOG
@@ -1,4 +1,4 @@
-acts_as_audited ChangeLog
+Audited ChangeLog
-------------------------------------------------------------------------------
* 2012-04-10 - Add Audit scopes for creates, updates and destroys [chriswfx]
* 2011-10-25 - Made ignored_attributes configurable [senny]
View
42 README.textile
@@ -1,30 +1,30 @@
-h1. acts_as_audited !https://secure.travis-ci.org/collectiveidea/acts_as_audited.png?branch=master(Build Status)!:http://travis-ci.org/collectiveidea/acts_as_audited !https://gemnasium.com/collectiveidea/acts_as_audited.png(Dependency Status)!:https://gemnasium.com/collectiveidea/acts_as_audited
+h1. Audited !https://secure.travis-ci.org/collectiveidea/audited.png?branch=master(Build Status)!:http://travis-ci.org/collectiveidea/audited !https://gemnasium.com/collectiveidea/audited.png(Dependency Status)!:https://gemnasium.com/collectiveidea/audited
-+acts_as_audited+ is an ActiveRecord extension that logs all changes to your
-models in an audits table, with optional revision comments. +acts_as_audited+
+Audited is an ActiveRecord extension that logs all changes to your
+models in an audits table, with optional revision comments. Audited
has been updated to work with Rails 3, to use it with older version of Rails,
please see the <tt>1.1-stable</tt> branch.
h2. Installation
In <tt>Gemfile</tt>:
-@gem "acts_as_audited", "2.0.0"@
+@gem "audited-activerecord", "2.0.0"@
In your application root, run:
@$ bundle install@
Generate the migration:
-* If installing without a previous version of +acts_as_audited+ or you do not mind overwriting your audits table:
+* If installing without a previous version of Audited (or acts_as_audited) or you do not mind overwriting your audits table:
-@$ rails g acts_as_audited:install@
+@$ rails g audited:install@
-* If upgrading from a previous version of +acts_as_audited+ you might need some alterations to the audits table:
+* If upgrading from a previous version of Audited (or acts_as_audited) you might need some alterations to the audits table:
-@$ rails g acts_as_audited:upgrade@
+@$ rails g audited:upgrade@
* After running one of the generators:
@@ -40,30 +40,30 @@ I'm well aware of the fact, and working towards a solution. The issue has also b
h2. Upgrading
-Upgrading to Rails 3, or even between point releases of +acts_as_audited+, might require alterations to the audits table. After every upgrade please run the following generator:
+Upgrading to Rails 3, or even between point releases of Audited, might require alterations to the audits table. After every upgrade please run the following generator:
-@$ rails g acts_as_audited:upgrade@
+@$ rails g audited:upgrade@
The upgrade generator will only generate migrations that are missing, or no migrations at all if you are up to date.
h2. Usage
-Declare +acts_as_audited+ on your models:
+Declare +audited+ on your models:
<pre><code>class User < ActiveRecord::Base
- acts_as_audited :except => [:password, :mistress]
+ audited :except => [:password, :mistress]
end
</code></pre>
Within a web request, will automatically record the user that made the change if your controller has a +current_user+ method. Comments can be added to an audit by setting <tt>model.audit_comment</tt>
-before create/update/destroy. If the <tt>:comment_required</tt> option is given to +acts_as_audited+,
+before create/update/destroy. If the <tt>:comment_required</tt> option is given to +audited+,
the save/update/destroy action will fail with add an error on <tt>model.audit_comment</tt> and triggering a
transaction rollback if <tt>model.audit_comment</tt> is nil.
To record an audit for an associated model, use the <tt>:associated_with</tt> option.
<pre><code>class User < ActiveRecord::Base
- acts_as_audited :associated_with => :company
+ audited :associated_with => :company
end
</code></pre>
@@ -84,23 +84,23 @@ end
h2. Caveats
-If your model declares +attr_accessible+ after +acts_as_audited+, you need to set <tt>:protect</tt> to false. acts_as_audited uses +attr_protected+ internally to prevent malicious users from unassociating your audits, and Rails does not allow both +attr_protected+ and +attr_accessible+. It will default to false if +attr_accessible+ is called before +acts_as_audited+, but needs to be explicitly set if it is called after.
+If your model declares +attr_accessible+ after +audited+, you need to set <tt>:protect</tt> to false. Audited uses +attr_protected+ internally to prevent malicious users from unassociating your audits, and Rails does not allow both +attr_protected+ and +attr_accessible+. It will default to false if +attr_accessible+ is called before +audited+, but needs to be explicitly set if it is called after.
<pre><code>class User < ActiveRecord::Base
- acts_as_audited :protect => false
+ audited :protect => false
attr_accessible :name
end
</code></pre>
-Another caveat is documented in "issue 26":https://github.com/collectiveidea/acts_as_audited/issues#issue/26, where an audit created on the first request to the server does not have a user. Please review the Github issue for more details on how to fix this. It does not appear to affect Rails 3.
+Another caveat is documented in "issue 26":https://github.com/collectiveidea/audited/issues#issue/26, where an audit created on the first request to the server does not have a user. Please review the Github issue for more details on how to fix this. It does not appear to affect Rails 3.
h2. Compatability
-+acts_as_audited+ works with Rails 3.0+. For older versions of Rails, please see the <tt>1.1-stable</tt> branch.
+Audited works with Rails 3.0+. For older versions of Rails, please see the <tt>1.1-stable</tt> branch.
h2. Getting Help
-Review the documentation at "http://rdoc.info/github/collectiveidea/acts_as_audited":http://rdoc.info/github/collectiveidea/acts_as_audited
+Review the documentation at "http://rdoc.info/github/collectiveidea/audited":http://rdoc.info/github/collectiveidea/audited
Join "the mailing list":http://groups.google.com/group/acts_as_audited for getting help or offering suggestions.
@@ -121,12 +121,12 @@ Here are some ways *you* can contribute:
* writing specifications
* writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
* refactoring code
-* closing "issues":https://github.com/collectiveidea/acts_as_audited/issues
+* closing "issues":https://github.com/collectiveidea/audited/issues
* reviewing patches
h2. Submitting an Issue
-We use the "GitHub issue tracker":https://github.com/collectiveidea/acts_as_audited/issues to track bugs
+We use the "GitHub issue tracker":https://github.com/collectiveidea/audited/issues to track bugs
and features. Before submitting a bug report or feature request, check to make sure it hasn't already
been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
bug report, please include a "Gist":https://gist.github.com/ that includes a stack trace and any
View
4 acts_as_audited.gemspec
@@ -1,14 +1,14 @@
# encoding: utf-8
Gem::Specification.new do |gem|
- gem.name = 'acts_as_audited'
+ gem.name = 'audited'
gem.version = '2.1.0'
gem.authors = ['Brandon Keepers', 'Kenneth Kalmer', 'Daniel Morrison', 'Brian Ryckbost', 'Steve Richert', 'Ryan Glover']
gem.email = 'info@collectiveidea.com'
gem.description = 'Log all changes to your models'
gem.summary = gem.description
- gem.homepage = 'https://github.com/collectiveidea/acts_as_audited'
+ gem.homepage = 'https://github.com/collectiveidea/audited'
gem.add_development_dependency 'appraisal', '~> 0.4'
gem.add_development_dependency 'bson_ext', '~> 1.6'
View
6 lib/acts_as_audited/adapters/base/audit.rb
@@ -28,11 +28,11 @@ def audited_classes
# by +user+. This method is hopefully threadsafe, making it ideal
# for background operations that require audit information.
def as_user(user, &block)
- Thread.current[:acts_as_audited_user] = user
+ Thread.current[:audited_user] = user
yieldval = yield
- Thread.current[:acts_as_audited_user] = nil
+ Thread.current[:audited_user] = nil
yieldval
end
@@ -98,7 +98,7 @@ def set_version_number
end
def set_audit_user
- self.user = Thread.current[:acts_as_audited_user] if Thread.current[:acts_as_audited_user]
+ self.user = Thread.current[:audited_user] if Thread.current[:audited_user]
nil # prevent stopping callback chains
end
end
View
14 lib/acts_as_audited/auditor.rb
@@ -3,13 +3,13 @@ module Audited
# audit table. This assumes there is an audits table ready.
#
# class User < ActiveRecord::Base
- # acts_as_audited
+ # audited
# end
#
# To store an audit comment set model.audit_comment to your comment before
# a create, update or destroy operation.
#
- # See <tt>Audited::Adapters::ActiveRecord::Auditor::ClassMethods#acts_as_audited</tt>
+ # See <tt>Audited::Adapters::ActiveRecord::Auditor::ClassMethods#audited</tt>
# for configuration options
module Auditor #:nodoc:
extend ActiveSupport::Concern
@@ -22,28 +22,28 @@ module ClassMethods
#
# * +only+ - Only audit the given attributes
# * +except+ - Excludes fields from being saved in the audit log.
- # By default, acts_as_audited will audit all but these fields:
+ # By default, Audited will audit all but these fields:
#
# [self.primary_key, inheritance_column, 'lock_version', 'created_at', 'updated_at']
# You can add to those by passing one or an array of fields to skip.
#
# class User < ActiveRecord::Base
- # acts_as_audited :except => :password
+ # audited :except => :password
# end
# * +protect+ - If your model uses +attr_protected+, set this to false to prevent Rails from
- # raising an error. If you declare +attr_accessible+ before calling +acts_as_audited+, it
+ # raising an error. If you declare +attr_accessible+ before calling +audited+, it
# will automatically default to false. You only need to explicitly set this if you are
# calling +attr_accessible+ after.
#
# * +require_comment+ - Ensures that audit_comment is supplied before
# any create, update or destroy operation.
#
# class User < ActiveRecord::Base
- # acts_as_audited :protect => false
+ # audited :protect => false
# attr_accessible :name
# end
#
- def acts_as_audited(options = {})
+ def audited(options = {})
# don't allow multiple calls
return if self.included_modules.include?(Audited::Auditor::AuditedInstanceMethods)
View
2 lib/acts_as_audited/sweeper.rb
@@ -29,7 +29,7 @@ def add_observer!(klass)
def define_callback(klass)
observer = self
- callback_meth = :"_notify_acts_as_audited_sweeper"
+ callback_meth = :"_notify_audited_sweeper"
klass.send(:define_method, callback_meth) do
observer.update(:before_create, self)
end
View
2 spec/acts_as_audited/adapters/active_record/audit_spec.rb
@@ -102,7 +102,7 @@
class Models::ActiveRecord::CustomUser < ::ActiveRecord::Base
end
class Models::ActiveRecord::CustomUserSubclass < Models::ActiveRecord::CustomUser
- acts_as_audited
+ audited
end
it "should include audited classes" do
View
4 spec/acts_as_audited/adapters/active_record/auditor_spec.rb
@@ -20,7 +20,7 @@
it "should be configurable which attributes are not audited" do
Audited.ignored_attributes = ['delta', 'top_secret', 'created_at']
class Secret < ::ActiveRecord::Base
- acts_as_audited
+ audited
end
Secret.non_audited_columns.should include('delta', 'top_secret', 'created_at')
@@ -463,7 +463,7 @@ class Secret < ::ActiveRecord::Base
}.to_not raise_error
end
- it "should not rause an error when attr_accessible is declared before acts_as_audited" do
+ it "should not rause an error when attr_accessible is declared before audited" do
expect {
Models::ActiveRecord::AccessibleUser.new(:name => 'No fail!')
}.to_not raise_error
View
2 spec/acts_as_audited/adapters/mongo_mapper/audit_spec.rb
@@ -109,7 +109,7 @@ class Models::MongoMapper::CustomUser
include ::MongoMapper::Document
end
class Models::MongoMapper::CustomUserSubclass < Models::MongoMapper::CustomUser
- acts_as_audited
+ audited
end
it "should include audited classes" do
View
4 spec/acts_as_audited/adapters/mongo_mapper/auditor_spec.rb
@@ -21,7 +21,7 @@
Audited.ignored_attributes = ['delta', 'top_secret', 'created_at']
class Secret
include MongoMapper::Document
- acts_as_audited
+ audited
end
Secret.non_audited_columns.should include('delta', 'top_secret', 'created_at')
@@ -465,7 +465,7 @@ class Secret
}.to_not raise_error
end
- it "should not rause an error when attr_accessible is declared before acts_as_audited" do
+ it "should not rause an error when attr_accessible is declared before audited" do
expect {
Models::MongoMapper::AccessibleUser.new(:name => 'No fail!')
}.to_not raise_error
View
6 spec/rails_app/config/database.yml
@@ -4,21 +4,21 @@ sqlite3mem: &SQLITE3MEM
sqlite3: &SQLITE
adapter: sqlite3
- database: acts_as_audited_plugin.sqlite3.db
+ database: audited_test.sqlite3.db
postgresql: &POSTGRES
adapter: postgresql
username: postgres
password: postgres
- database: acts_as_audited_plugin_test
+ database: audited_test
min_messages: ERROR
mysql: &MYSQL
adapter: mysql
host: localhost
username: root
password:
- database: acts_as_audited_plugin_test
+ database: audited_test
test:
<<: *<%= ENV['DB'] || 'SQLITE3MEM' %>
View
24 spec/support/active_record/models.rb
@@ -4,7 +4,7 @@
module Models
module ActiveRecord
class User < ::ActiveRecord::Base
- acts_as_audited :except => :password
+ audited :except => :password
attr_protected :logins
@@ -15,29 +15,29 @@ def name=(val)
class CommentRequiredUser < ::ActiveRecord::Base
self.table_name = :users
- acts_as_audited :comment_required => true
+ audited :comment_required => true
end
class UnprotectedUser < ::ActiveRecord::Base
self.table_name = :users
- acts_as_audited :protect => false
+ audited :protect => false
attr_accessible :name, :username, :password
end
class AccessibleUser < ::ActiveRecord::Base
self.table_name = :users
attr_accessible :name, :username, :password # declare attr_accessible before calling aaa
- acts_as_audited
+ audited
end
class NoAttributeProtectionUser < ::ActiveRecord::Base
self.table_name = :users
- acts_as_audited
+ audited
end
class UserWithAfterAudit < ::ActiveRecord::Base
self.table_name = :users
- acts_as_audited
+ audited
attr_accessor :bogus_attr
def after_audit
@@ -46,7 +46,7 @@ def after_audit
end
class Company < ::ActiveRecord::Base
- acts_as_audited
+ audited
end
class Owner < ::ActiveRecord::Base
@@ -58,27 +58,27 @@ class OwnedCompany < ::ActiveRecord::Base
self.table_name = 'companies'
belongs_to :owner, :class_name => "Owner"
attr_accessible :name, :owner # declare attr_accessible before calling aaa
- acts_as_audited :associated_with => :owner
+ audited :associated_with => :owner
end
class OnUpdateDestroy < ::ActiveRecord::Base
self.table_name = 'companies'
- acts_as_audited :on => [:update, :destroy]
+ audited :on => [:update, :destroy]
end
class OnCreateDestroy < ::ActiveRecord::Base
self.table_name = 'companies'
- acts_as_audited :on => [:create, :destroy]
+ audited :on => [:create, :destroy]
end
class OnCreateDestroyExceptName < ::ActiveRecord::Base
self.table_name = 'companies'
- acts_as_audited :except => :name, :on => [:create, :destroy]
+ audited :except => :name, :on => [:create, :destroy]
end
class OnCreateUpdate < ::ActiveRecord::Base
self.table_name = 'companies'
- acts_as_audited :on => [:create, :update]
+ audited :on => [:create, :update]
end
end
end
View
2 spec/support/mongo_mapper/connection.rb
@@ -1,4 +1,4 @@
require 'mongo_mapper'
MongoMapper.connection = Mongo::Connection.new
-MongoMapper.database = 'acts_as_audited'
+MongoMapper.database = 'audited_test'
View
24 spec/support/mongo_mapper/models.rb
@@ -15,7 +15,7 @@ class User
key :logins, Integer, :default => 0
timestamps!
- acts_as_audited :except => :password
+ audited :except => :password
attr_protected :logins
@@ -35,7 +35,7 @@ class CommentRequiredUser
key :logins, Integer, :default => 0
timestamps!
- acts_as_audited :comment_required => true
+ audited :comment_required => true
end
class UnprotectedUser
@@ -49,7 +49,7 @@ class UnprotectedUser
key :logins, Integer, :default => 0
timestamps!
- acts_as_audited :protect => false
+ audited :protect => false
attr_accessible :name, :username, :password
end
@@ -65,7 +65,7 @@ class AccessibleUser
timestamps!
attr_accessible :name, :username, :password # declare attr_accessible before calling aaa
- acts_as_audited
+ audited
end
class NoAttributeProtectionUser
@@ -79,7 +79,7 @@ class NoAttributeProtectionUser
key :logins, Integer, :default => 0
timestamps!
- acts_as_audited
+ audited
end
class UserWithAfterAudit
@@ -93,7 +93,7 @@ class UserWithAfterAudit
key :logins, Integer, :default => 0
timestamps!
- acts_as_audited
+ audited
attr_accessor :bogus_attr
def after_audit
@@ -107,7 +107,7 @@ class Company
key :name, String
key :owner_id, ObjectId
- acts_as_audited
+ audited
end
class Owner
@@ -132,7 +132,7 @@ class OwnedCompany
belongs_to :owner, :class_name => "Owner"
attr_accessible :name, :owner # declare attr_accessible before calling aaa
- acts_as_audited :associated_with => :owner
+ audited :associated_with => :owner
end
class OnUpdateDestroy
@@ -141,7 +141,7 @@ class OnUpdateDestroy
key :name, String
key :owner_id, ObjectId
- acts_as_audited :on => [:update, :destroy]
+ audited :on => [:update, :destroy]
end
class OnCreateDestroy
@@ -150,7 +150,7 @@ class OnCreateDestroy
key :name, String
key :owner_id, ObjectId
- acts_as_audited :on => [:create, :destroy]
+ audited :on => [:create, :destroy]
end
class OnCreateDestroyExceptName
@@ -159,7 +159,7 @@ class OnCreateDestroyExceptName
key :name, String
key :owner_id, ObjectId
- acts_as_audited :except => :name, :on => [:create, :destroy]
+ audited :except => :name, :on => [:create, :destroy]
end
class OnCreateUpdate
@@ -168,7 +168,7 @@ class OnCreateUpdate
key :name, String
key :owner_id, ObjectId
- acts_as_audited :on => [:create, :update]
+ audited :on => [:create, :update]
end
end
end

0 comments on commit 9cc6926

Please sign in to comment.