audited 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.travis.yml +13 -0
- data/.yardopts +3 -0
- data/Appraisals +11 -0
- data/CHANGELOG +34 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +206 -0
- data/Rakefile +24 -0
- data/audited-activerecord.gemspec +19 -0
- data/audited-mongo_mapper.gemspec +19 -0
- data/audited.gemspec +25 -0
- data/gemfiles/rails30.gemfile +7 -0
- data/gemfiles/rails31.gemfile +7 -0
- data/gemfiles/rails32.gemfile +7 -0
- data/lib/audited.rb +11 -0
- data/lib/audited/audit.rb +105 -0
- data/lib/audited/auditor.rb +272 -0
- data/lib/audited/sweeper.rb +45 -0
- data/spec/audited_spec_helpers.rb +31 -0
- data/spec/rails_app/config/application.rb +5 -0
- data/spec/rails_app/config/database.yml +24 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +19 -0
- data/spec/rails_app/config/environments/production.rb +33 -0
- data/spec/rails_app/config/environments/test.rb +33 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/inflections.rb +2 -0
- data/spec/rails_app/config/initializers/secret_token.rb +2 -0
- data/spec/rails_app/config/routes.rb +6 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/active_record/models.rb +84 -0
- data/spec/support/active_record/schema.rb +54 -0
- data/spec/support/mongo_mapper/connection.rb +4 -0
- data/spec/support/mongo_mapper/models.rb +174 -0
- data/test/db/version_1.rb +17 -0
- data/test/db/version_2.rb +18 -0
- data/test/db/version_3.rb +19 -0
- data/test/db/version_4.rb +20 -0
- data/test/db/version_5.rb +18 -0
- data/test/install_generator_test.rb +17 -0
- data/test/test_helper.rb +19 -0
- data/test/upgrade_generator_test.rb +65 -0
- metadata +220 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
create_table :audits, :force => true do |t|
|
3
|
+
t.column :auditable_id, :integer
|
4
|
+
t.column :auditable_type, :string
|
5
|
+
t.column :user_id, :integer
|
6
|
+
t.column :user_type, :string
|
7
|
+
t.column :username, :string
|
8
|
+
t.column :action, :string
|
9
|
+
t.column :audited_changes, :text
|
10
|
+
t.column :version, :integer, :default => 0
|
11
|
+
t.column :comment, :string
|
12
|
+
t.column :created_at, :datetime
|
13
|
+
t.column :remote_address, :string
|
14
|
+
t.column :association_id, :integer
|
15
|
+
t.column :association_type, :string
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'generators/audited/install_generator'
|
4
|
+
|
5
|
+
class InstallGeneratorTest < Rails::Generators::TestCase
|
6
|
+
destination File.expand_path('../../tmp', __FILE__)
|
7
|
+
setup :prepare_destination
|
8
|
+
tests Audited::Generators::InstallGenerator
|
9
|
+
|
10
|
+
test "should generate a migration" do
|
11
|
+
run_generator %w(install)
|
12
|
+
|
13
|
+
assert_migration "db/migrate/install_audited.rb" do |content|
|
14
|
+
assert_match /class InstallAudited/, content
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
|
3
|
+
$:.unshift File.dirname(__FILE__)
|
4
|
+
|
5
|
+
require File.expand_path('../../spec/rails_app/config/environment', __FILE__)
|
6
|
+
require 'rails/test_help'
|
7
|
+
|
8
|
+
require 'audited'
|
9
|
+
|
10
|
+
class ActiveSupport::TestCase
|
11
|
+
|
12
|
+
setup do
|
13
|
+
ActiveRecord::Migration.verbose = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_schema( version )
|
17
|
+
load File.dirname(__FILE__) + "/db/version_#{version}.rb"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'generators/audited/upgrade_generator'
|
4
|
+
|
5
|
+
class UpgradeGeneratorTest < Rails::Generators::TestCase
|
6
|
+
destination File.expand_path('../../tmp', __FILE__)
|
7
|
+
setup :prepare_destination
|
8
|
+
tests Audited::Generators::UpgradeGenerator
|
9
|
+
|
10
|
+
test "should add 'comment' to audits table" do
|
11
|
+
load_schema 1
|
12
|
+
|
13
|
+
run_generator %w(upgrade)
|
14
|
+
|
15
|
+
assert_migration "db/migrate/add_comment_to_audits.rb" do |content|
|
16
|
+
assert_match /add_column :audits, :comment, :string/, content
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_migration "db/migrate/rename_changes_to_audited_changes.rb"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "should rename 'changes' to 'audited_changes'" do
|
23
|
+
load_schema 2
|
24
|
+
|
25
|
+
run_generator %w(upgrade)
|
26
|
+
|
27
|
+
assert_no_migration "db/migrate/add_comment_to_audits.rb"
|
28
|
+
|
29
|
+
assert_migration "db/migrate/rename_changes_to_audited_changes.rb" do |content|
|
30
|
+
assert_match /rename_column :audits, :changes, :audited_changes/, content
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
test "should add a 'remote_address' to audits table" do
|
35
|
+
load_schema 3
|
36
|
+
|
37
|
+
run_generator %w(upgrade)
|
38
|
+
|
39
|
+
assert_migration "db/migrate/add_remote_address_to_audits.rb" do |content|
|
40
|
+
assert_match /add_column :audits, :remote_address, :string/, content
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
test "should add 'association_id' and 'association_type' to audits table" do
|
45
|
+
load_schema 4
|
46
|
+
|
47
|
+
run_generator %w(upgrade)
|
48
|
+
|
49
|
+
assert_migration "db/migrate/add_association_to_audits.rb" do |content|
|
50
|
+
assert_match /add_column :audits, :association_id, :integer/, content
|
51
|
+
assert_match /add_column :audits, :association_type, :string/, content
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
test "should rename 'association_id' to 'associated_id' and 'association_type' to 'associated_type'" do
|
56
|
+
load_schema 5
|
57
|
+
|
58
|
+
run_generator %w(upgrade)
|
59
|
+
|
60
|
+
assert_migration "db/migrate/rename_association_to_associated.rb" do |content|
|
61
|
+
assert_match /rename_column :audits, :association_id, :associated_id/, content
|
62
|
+
assert_match /rename_column :audits, :association_type, :associated_type/, content
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: audited
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0.rc1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brandon Keepers
|
9
|
+
- Kenneth Kalmer
|
10
|
+
- Daniel Morrison
|
11
|
+
- Brian Ryckbost
|
12
|
+
- Steve Richert
|
13
|
+
- Ryan Glover
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
date: 2012-04-25 00:00:00.000000000 Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: activerecord
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
type: :development
|
28
|
+
prerelease: false
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.0'
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: appraisal
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.4'
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ~>
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0.4'
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: bson_ext
|
53
|
+
requirement: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '1.6'
|
59
|
+
type: :development
|
60
|
+
prerelease: false
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.6'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: mongo_mapper
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.11'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.11'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '3.0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rspec-rails
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ~>
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '2.0'
|
107
|
+
type: :development
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ~>
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '2.0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: sqlite3
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '1.0'
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ~>
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.0'
|
131
|
+
description: Log all changes to your models
|
132
|
+
email: info@collectiveidea.com
|
133
|
+
executables: []
|
134
|
+
extensions: []
|
135
|
+
extra_rdoc_files: []
|
136
|
+
files:
|
137
|
+
- .gitignore
|
138
|
+
- .travis.yml
|
139
|
+
- .yardopts
|
140
|
+
- Appraisals
|
141
|
+
- CHANGELOG
|
142
|
+
- Gemfile
|
143
|
+
- LICENSE
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- audited-activerecord.gemspec
|
147
|
+
- audited-mongo_mapper.gemspec
|
148
|
+
- audited.gemspec
|
149
|
+
- gemfiles/rails30.gemfile
|
150
|
+
- gemfiles/rails31.gemfile
|
151
|
+
- gemfiles/rails32.gemfile
|
152
|
+
- lib/audited.rb
|
153
|
+
- lib/audited/audit.rb
|
154
|
+
- lib/audited/auditor.rb
|
155
|
+
- lib/audited/sweeper.rb
|
156
|
+
- spec/audited_spec_helpers.rb
|
157
|
+
- spec/rails_app/config/application.rb
|
158
|
+
- spec/rails_app/config/database.yml
|
159
|
+
- spec/rails_app/config/environment.rb
|
160
|
+
- spec/rails_app/config/environments/development.rb
|
161
|
+
- spec/rails_app/config/environments/production.rb
|
162
|
+
- spec/rails_app/config/environments/test.rb
|
163
|
+
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
164
|
+
- spec/rails_app/config/initializers/inflections.rb
|
165
|
+
- spec/rails_app/config/initializers/secret_token.rb
|
166
|
+
- spec/rails_app/config/routes.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
- spec/support/active_record/models.rb
|
169
|
+
- spec/support/active_record/schema.rb
|
170
|
+
- spec/support/mongo_mapper/connection.rb
|
171
|
+
- spec/support/mongo_mapper/models.rb
|
172
|
+
- test/db/version_1.rb
|
173
|
+
- test/db/version_2.rb
|
174
|
+
- test/db/version_3.rb
|
175
|
+
- test/db/version_4.rb
|
176
|
+
- test/db/version_5.rb
|
177
|
+
- test/install_generator_test.rb
|
178
|
+
- test/test_helper.rb
|
179
|
+
- test/upgrade_generator_test.rb
|
180
|
+
homepage: https://github.com/collectiveidea/audited
|
181
|
+
licenses: []
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ! '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>'
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 1.3.1
|
198
|
+
requirements: []
|
199
|
+
rubyforge_project:
|
200
|
+
rubygems_version: 1.8.21
|
201
|
+
signing_key:
|
202
|
+
specification_version: 3
|
203
|
+
summary: Log all changes to your models
|
204
|
+
test_files:
|
205
|
+
- spec/audited_spec_helpers.rb
|
206
|
+
- spec/rails_app/config/application.rb
|
207
|
+
- spec/rails_app/config/database.yml
|
208
|
+
- spec/rails_app/config/environment.rb
|
209
|
+
- spec/rails_app/config/environments/development.rb
|
210
|
+
- spec/rails_app/config/environments/production.rb
|
211
|
+
- spec/rails_app/config/environments/test.rb
|
212
|
+
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
213
|
+
- spec/rails_app/config/initializers/inflections.rb
|
214
|
+
- spec/rails_app/config/initializers/secret_token.rb
|
215
|
+
- spec/rails_app/config/routes.rb
|
216
|
+
- spec/spec_helper.rb
|
217
|
+
- spec/support/active_record/models.rb
|
218
|
+
- spec/support/active_record/schema.rb
|
219
|
+
- spec/support/mongo_mapper/connection.rb
|
220
|
+
- spec/support/mongo_mapper/models.rb
|