acts_as_audited 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -7,4 +7,5 @@ pkg
7
7
  .bundle
8
8
  tmp/*
9
9
  .yardoc
10
- .rvmrc
10
+ .rvmrc
11
+ Gemfile.lock
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
data/CHANGELOG CHANGED
@@ -1,6 +1,7 @@
1
1
  acts_as_audited ChangeLog
2
2
  -------------------------------------------------------------------------------
3
-
3
+ * 2012-04-10 - Add Audit scopes for creates, updates and destroys [chriswfx]
4
+ * 2011-10-25 - Made ignored_attributes configurable [senny]
4
5
  * 2011-09-09 - Rails 3.x support
5
6
  Support for associated audits
6
7
  Support for remote IP address storage
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem "rails", ">= 3.0.3"
3
+ gemspec
4
+
4
5
  gem "sqlite3"
5
- gem "rspec-rails", "~> 2.4.0"
6
- gem "rcov"
7
- gem "yard"
6
+ gem "rspec-rails", "~> 2.0"
7
+ gem "simplecov"
@@ -1,4 +1,5 @@
1
- h1. acts_as_audited
1
+ 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
2
+
2
3
 
3
4
  +acts_as_audited+ is an ActiveRecord extension that logs all changes to your
4
5
  models in an audits table, with optional revision comments. +acts_as_audited+
@@ -95,7 +96,7 @@ Another caveat is documented in "issue 26":https://github.com/collectiveidea/act
95
96
 
96
97
  h2. Compatability
97
98
 
98
- +acts_as_audited+ works with Rails 3.0.3 – 3.1.0. For older versions of Rails, please see the <tt>1.1-stable</tt> branch.
99
+ +acts_as_audited+ works with Rails 3.0+. For older versions of Rails, please see the <tt>1.1-stable</tt> branch.
99
100
 
100
101
  h2. Getting Help
101
102
 
@@ -1,18 +1,18 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.add_runtime_dependency(%q<rails>, [">= 3.0.3"])
4
+ gem.add_runtime_dependency "rails", "~> 3.0", ">= 3.0.3"
5
5
 
6
- gem.authors = ["Brandon Keepers", "Kenneth Kalmer"]
7
- gem.email = 'brandon@opensoul.org'
6
+ gem.authors = ["Brandon Keepers", "Kenneth Kalmer", "Daniel Morrison", "Brian Ryckbost"]
7
+ gem.email = 'daniel@collectiveidea.com '
8
8
  gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
9
9
  gem.files = `git ls-files`.split("\n")
10
- gem.homepage = %q{http://github.com/collectiveidea/acts_as_audited}
10
+ gem.homepage = %q{https://github.com/collectiveidea/acts_as_audited}
11
11
  gem.rdoc_options = ["--main", "README.rdoc", "--line-numbers", "--inline-source"]
12
12
  gem.require_paths = ["lib"]
13
13
  gem.name = 'acts_as_audited'
14
14
  gem.summary = %q{ActiveRecord extension that logs all changes to your models in an audits table}
15
15
  gem.test_files = `git ls-files -- spec/* test/*`.split("\n")
16
- gem.version = "2.0.0"
16
+ gem.version = "2.1.0"
17
17
  end
18
18
 
@@ -1 +1 @@
1
- Autotest.add_discovery { "rspec2" }
1
+ Autotest.add_discovery { "rspec2" }
@@ -19,17 +19,23 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- require 'active_support/core_ext/module'
23
22
  require 'active_record'
24
23
 
25
24
  # To get started, please review ActsAsAudited::Auditor::ClassMethods#acts_as_audited
26
25
  module ActsAsAudited
27
- VERSION = '2.0.0'
26
+ VERSION = '2.1.0'
28
27
 
29
- mattr_accessor :current_user_method
30
- # The method to be called to return the current user for logging in the audits.
31
- @@current_user_method = :current_user
28
+ class << self
29
+ attr_accessor :ignored_attributes, :current_user_method
30
+ end
31
+ @ignored_attributes ||= ['lock_version',
32
+ 'created_at',
33
+ 'updated_at',
34
+ 'created_on',
35
+ 'updated_on']
32
36
 
37
+ # The method to be called to return the current user for logging in the audits.
38
+ @current_user_method = :current_user
33
39
  end
34
40
 
35
41
  require 'acts_as_audited/auditor'
@@ -25,6 +25,10 @@ class Audit < ActiveRecord::Base
25
25
  default_scope order(:version)
26
26
  scope :descending, reorder("version DESC")
27
27
 
28
+ scope :creates, :conditions => {:action => 'create'}
29
+ scope :updates, :conditions => {:action => 'update'}
30
+ scope :destroys, :conditions => {:action => 'destroy'}
31
+
28
32
  class << self
29
33
 
30
34
  # Returns the list of classes that are being audited
@@ -34,7 +34,7 @@ module ActsAsAudited
34
34
  # acts_as_audited :except => :password
35
35
  # end
36
36
  # * +protect+ - If your model uses +attr_protected+, set this to false to prevent Rails from
37
- # raising an error. If you declare +attr_accessibe+ before calling +acts_as_audited+, it
37
+ # raising an error. If you declare +attr_accessible+ before calling +acts_as_audited+, it
38
38
  # will automatically default to false. You only need to explicitly set this if you are
39
39
  # calling +attr_accessible+ after.
40
40
  #
@@ -59,8 +59,7 @@ module ActsAsAudited
59
59
  if options[:only]
60
60
  except = self.column_names - options[:only].flatten.map(&:to_s)
61
61
  else
62
- except = [self.primary_key, inheritance_column, 'lock_version',
63
- 'created_at', 'updated_at', 'created_on', 'updated_on']
62
+ except = [self.primary_key, inheritance_column] + ActsAsAudited.ignored_attributes
64
63
  except |= Array(options[:except]).collect(&:to_s) if options[:except]
65
64
  end
66
65
  self.non_audited_columns = except
@@ -17,6 +17,15 @@ describe ActsAsAudited::Auditor do
17
17
  end
18
18
  end
19
19
 
20
+ it "should be configurable which attributes are not audited" do
21
+ ActsAsAudited.ignored_attributes = ['delta', 'top_secret', 'created_at']
22
+ class Secret < ActiveRecord::Base
23
+ acts_as_audited
24
+ end
25
+
26
+ Secret.non_audited_columns.should include('delta', 'top_secret', 'created_at')
27
+ end
28
+
20
29
  it "should not save non-audited columns" do
21
30
  create_user.audits.first.audited_changes.keys.any? { |col| ['created_at', 'updated_at', 'password'].include?( col ) }.should be_false
22
31
  end
@@ -57,6 +66,10 @@ describe ActsAsAudited::Auditor do
57
66
 
58
67
  it "should set the action to create" do
59
68
  user.audits.first.action.should == 'create'
69
+ Audit.creates.reorder(:id).last.should == user.audits.first
70
+ user.audits.creates.count.should == 1
71
+ user.audits.updates.count.should == 0
72
+ user.audits.destroys.count.should == 0
60
73
  end
61
74
 
62
75
  it "should store all the audited attributes" do
@@ -102,6 +115,8 @@ describe ActsAsAudited::Auditor do
102
115
  it "should set the action to 'update'" do
103
116
  @user.update_attributes :name => 'Changed'
104
117
  @user.audits.last.action.should == 'update'
118
+ Audit.updates.reorder(:id).last.should == @user.audits.last
119
+ @user.audits.updates.last.should == @user.audits.last
105
120
  end
106
121
 
107
122
  it "should store the changed attributes" do
@@ -145,6 +160,8 @@ describe ActsAsAudited::Auditor do
145
160
  @user.destroy
146
161
 
147
162
  @user.audits.last.action.should == 'destroy'
163
+ Audit.destroys.reorder(:id).last.should == @user.audits.last
164
+ @user.audits.destroys.last.should == @user.audits.last
148
165
  end
149
166
 
150
167
  it "should store all of the audited attributes" do
@@ -4,7 +4,6 @@ require "rails/all"
4
4
 
5
5
  Bundler.require :default
6
6
 
7
-
8
7
  module RailsApp
9
8
  class Application < Rails::Application
10
9
  # Ensure the root is correct
@@ -10,4 +10,4 @@ rescue LoadError
10
10
  Bundler.setup :default, DEVISE_ORM
11
11
  end
12
12
 
13
- $:.unshift File.expand_path('../../../../lib', __FILE__)
13
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,2 +1,2 @@
1
1
  Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
2
- Rails.application.config.session_store :cookie_store, :key => "_my_app"
2
+ Rails.application.config.session_store :cookie_store, :key => "_my_app"
@@ -4,9 +4,7 @@ $:.unshift File.dirname(__FILE__)
4
4
 
5
5
  require 'rails_app/config/environment'
6
6
  require 'rspec/rails'
7
-
8
7
  require 'acts_as_audited'
9
-
10
8
  require 'audited_spec_helpers'
11
9
 
12
10
  RSpec.configure do |c|
@@ -11,24 +11,24 @@ class User < ActiveRecord::Base
11
11
  end
12
12
 
13
13
  class CommentRequiredUser < ActiveRecord::Base
14
- set_table_name :users
14
+ self.table_name = :users
15
15
  acts_as_audited :comment_required => true
16
16
  end
17
17
 
18
18
  class UnprotectedUser < ActiveRecord::Base
19
- set_table_name :users
19
+ self.table_name = :users
20
20
  acts_as_audited :protect => false
21
21
  attr_accessible :name, :username, :password
22
22
  end
23
23
 
24
24
  class AccessibleUser < ActiveRecord::Base
25
- set_table_name :users
25
+ self.table_name = :users
26
26
  attr_accessible :name, :username, :password # declare attr_accessible before calling aaa
27
27
  acts_as_audited
28
28
  end
29
29
 
30
30
  class NoAttributeProtectionUser < ActiveRecord::Base
31
- set_table_name :users
31
+ self.table_name = :users
32
32
  acts_as_audited
33
33
  end
34
34
 
@@ -37,34 +37,34 @@ class Company < ActiveRecord::Base
37
37
  end
38
38
 
39
39
  class Owner < ActiveRecord::Base
40
- set_table_name 'users'
40
+ self.table_name = 'users'
41
41
  has_associated_audits
42
42
  end
43
43
 
44
44
  class OwnedCompany < ActiveRecord::Base
45
- set_table_name 'companies'
45
+ self.table_name = 'companies'
46
46
  belongs_to :owner, :class_name => "Owner"
47
47
  attr_accessible :name, :owner # declare attr_accessible before calling aaa
48
48
  acts_as_audited :associated_with => :owner
49
49
  end
50
50
 
51
51
  class OnUpdateDestroy < ActiveRecord::Base
52
- set_table_name 'companies'
52
+ self.table_name = 'companies'
53
53
  acts_as_audited :on => [:update, :destroy]
54
54
  end
55
55
 
56
56
  class OnCreateDestroy < ActiveRecord::Base
57
- set_table_name 'companies'
57
+ self.table_name = 'companies'
58
58
  acts_as_audited :on => [:create, :destroy]
59
59
  end
60
60
 
61
61
  class OnCreateDestroyExceptName < ActiveRecord::Base
62
- set_table_name 'companies'
62
+ self.table_name = 'companies'
63
63
  acts_as_audited :except => :name, :on => [:create, :destroy]
64
64
  end
65
65
 
66
66
  class OnCreateUpdate < ActiveRecord::Base
67
- set_table_name 'companies'
67
+ self.table_name = 'companies'
68
68
  acts_as_audited :on => [:create, :update]
69
69
  end
70
70
 
metadata CHANGED
@@ -1,39 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_audited
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brandon Keepers
9
9
  - Kenneth Kalmer
10
+ - Daniel Morrison
11
+ - Brian Ryckbost
10
12
  autorequire:
11
13
  bindir: bin
12
14
  cert_chain: []
13
- date: 2011-09-12 00:00:00.000000000Z
15
+ date: 2012-04-11 00:00:00.000000000 Z
14
16
  dependencies:
15
17
  - !ruby/object:Gem::Dependency
16
18
  name: rails
17
- requirement: &70322406432300 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
18
20
  none: false
19
21
  requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '3.0'
20
25
  - - ! '>='
21
26
  - !ruby/object:Gem::Version
22
27
  version: 3.0.3
23
28
  type: :runtime
24
29
  prerelease: false
25
- version_requirements: *70322406432300
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '3.0'
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 3.0.3
26
39
  description:
27
- email: brandon@opensoul.org
40
+ email: ! 'daniel@collectiveidea.com '
28
41
  executables: []
29
42
  extensions: []
30
43
  extra_rdoc_files: []
31
44
  files:
32
45
  - .gitignore
46
+ - .travis.yml
33
47
  - .yardopts
34
48
  - CHANGELOG
35
49
  - Gemfile
36
- - Gemfile.lock
37
50
  - LICENSE
38
51
  - README.textile
39
52
  - Rakefile
@@ -78,7 +91,7 @@ files:
78
91
  - test/install_generator_test.rb
79
92
  - test/test_helper.rb
80
93
  - test/upgrade_generator_test.rb
81
- homepage: http://github.com/collectiveidea/acts_as_audited
94
+ homepage: https://github.com/collectiveidea/acts_as_audited
82
95
  licenses: []
83
96
  post_install_message:
84
97
  rdoc_options:
@@ -102,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
115
  version: 1.3.6
103
116
  requirements: []
104
117
  rubyforge_project:
105
- rubygems_version: 1.8.6
118
+ rubygems_version: 1.8.21
106
119
  signing_key:
107
120
  specification_version: 3
108
121
  summary: ActiveRecord extension that logs all changes to your models in an audits
@@ -134,3 +147,4 @@ test_files:
134
147
  - test/install_generator_test.rb
135
148
  - test/test_helper.rb
136
149
  - test/upgrade_generator_test.rb
150
+ has_rdoc:
@@ -1,108 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- actionmailer (3.1.0)
5
- actionpack (= 3.1.0)
6
- mail (~> 2.3.0)
7
- actionpack (3.1.0)
8
- activemodel (= 3.1.0)
9
- activesupport (= 3.1.0)
10
- builder (~> 3.0.0)
11
- erubis (~> 2.7.0)
12
- i18n (~> 0.6)
13
- rack (~> 1.3.2)
14
- rack-cache (~> 1.0.3)
15
- rack-mount (~> 0.8.2)
16
- rack-test (~> 0.6.1)
17
- sprockets (~> 2.0.0)
18
- activemodel (3.1.0)
19
- activesupport (= 3.1.0)
20
- bcrypt-ruby (~> 3.0.0)
21
- builder (~> 3.0.0)
22
- i18n (~> 0.6)
23
- activerecord (3.1.0)
24
- activemodel (= 3.1.0)
25
- activesupport (= 3.1.0)
26
- arel (~> 2.2.1)
27
- tzinfo (~> 0.3.29)
28
- activeresource (3.1.0)
29
- activemodel (= 3.1.0)
30
- activesupport (= 3.1.0)
31
- activesupport (3.1.0)
32
- multi_json (~> 1.0)
33
- arel (2.2.1)
34
- bcrypt-ruby (3.0.0)
35
- builder (3.0.0)
36
- diff-lcs (1.1.3)
37
- erubis (2.7.0)
38
- hike (1.2.1)
39
- i18n (0.6.0)
40
- mail (2.3.0)
41
- i18n (>= 0.4.0)
42
- mime-types (~> 1.16)
43
- treetop (~> 1.4.8)
44
- mime-types (1.16)
45
- multi_json (1.0.3)
46
- polyglot (0.3.2)
47
- rack (1.3.2)
48
- rack-cache (1.0.3)
49
- rack (>= 0.4)
50
- rack-mount (0.8.3)
51
- rack (>= 1.0.0)
52
- rack-ssl (1.3.2)
53
- rack
54
- rack-test (0.6.1)
55
- rack (>= 1.0)
56
- rails (3.1.0)
57
- actionmailer (= 3.1.0)
58
- actionpack (= 3.1.0)
59
- activerecord (= 3.1.0)
60
- activeresource (= 3.1.0)
61
- activesupport (= 3.1.0)
62
- bundler (~> 1.0)
63
- railties (= 3.1.0)
64
- railties (3.1.0)
65
- actionpack (= 3.1.0)
66
- activesupport (= 3.1.0)
67
- rack-ssl (~> 1.3.2)
68
- rake (>= 0.8.7)
69
- rdoc (~> 3.4)
70
- thor (~> 0.14.6)
71
- rake (0.9.2)
72
- rcov (0.9.10)
73
- rdoc (3.9.4)
74
- rspec (2.4.0)
75
- rspec-core (~> 2.4.0)
76
- rspec-expectations (~> 2.4.0)
77
- rspec-mocks (~> 2.4.0)
78
- rspec-core (2.4.0)
79
- rspec-expectations (2.4.0)
80
- diff-lcs (~> 1.1.2)
81
- rspec-mocks (2.4.0)
82
- rspec-rails (2.4.1)
83
- actionpack (~> 3.0)
84
- activesupport (~> 3.0)
85
- railties (~> 3.0)
86
- rspec (~> 2.4.0)
87
- sprockets (2.0.0)
88
- hike (~> 1.2)
89
- rack (~> 1.0)
90
- tilt (!= 1.3.0, ~> 1.1)
91
- sqlite3 (1.3.4)
92
- thor (0.14.6)
93
- tilt (1.3.3)
94
- treetop (1.4.10)
95
- polyglot
96
- polyglot (>= 0.3.1)
97
- tzinfo (0.3.29)
98
- yard (0.7.2)
99
-
100
- PLATFORMS
101
- ruby
102
-
103
- DEPENDENCIES
104
- rails (>= 3.0.3)
105
- rcov
106
- rspec-rails (~> 2.4.0)
107
- sqlite3
108
- yard