notifiably_audited 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Appraisals +11 -0
- data/CHANGELOG +34 -0
- data/LICENSE +19 -0
- data/audited-activerecord.gemspec +21 -0
- data/audited-mongo_mapper.gemspec +21 -0
- data/audited.gemspec +26 -0
- data/gemfiles/rails30.gemfile +7 -0
- data/gemfiles/rails31.gemfile +7 -0
- data/gemfiles/rails32.gemfile +7 -0
- data/lib/audited.rb +15 -0
- data/lib/audited/audit.rb +102 -0
- data/lib/audited/auditor.rb +270 -0
- data/lib/audited/rspec_matchers.rb +173 -0
- data/lib/audited/sweeper.rb +51 -0
- data/notifiably_audited.gemspec +11 -18
- 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 +210 -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 +56 -2
@@ -0,0 +1,20 @@
|
|
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
|
+
end
|
15
|
+
|
16
|
+
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
17
|
+
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
18
|
+
add_index :audits, :created_at
|
19
|
+
end
|
20
|
+
|
@@ -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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifiably_audited
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
@@ -120,13 +120,51 @@ extensions: []
|
|
120
120
|
extra_rdoc_files: []
|
121
121
|
files:
|
122
122
|
- .gitignore
|
123
|
+
- Appraisals
|
124
|
+
- CHANGELOG
|
123
125
|
- Gemfile
|
126
|
+
- LICENSE
|
124
127
|
- LICENSE.txt
|
125
128
|
- README.md
|
126
129
|
- Rakefile
|
130
|
+
- audited-activerecord.gemspec
|
131
|
+
- audited-mongo_mapper.gemspec
|
132
|
+
- audited.gemspec
|
133
|
+
- gemfiles/rails30.gemfile
|
134
|
+
- gemfiles/rails31.gemfile
|
135
|
+
- gemfiles/rails32.gemfile
|
136
|
+
- lib/audited.rb
|
137
|
+
- lib/audited/audit.rb
|
138
|
+
- lib/audited/auditor.rb
|
139
|
+
- lib/audited/rspec_matchers.rb
|
140
|
+
- lib/audited/sweeper.rb
|
127
141
|
- lib/notifiably_audited.rb
|
128
142
|
- lib/notifiably_audited/version.rb
|
129
143
|
- notifiably_audited.gemspec
|
144
|
+
- spec/audited_spec_helpers.rb
|
145
|
+
- spec/rails_app/config/application.rb
|
146
|
+
- spec/rails_app/config/database.yml
|
147
|
+
- spec/rails_app/config/environment.rb
|
148
|
+
- spec/rails_app/config/environments/development.rb
|
149
|
+
- spec/rails_app/config/environments/production.rb
|
150
|
+
- spec/rails_app/config/environments/test.rb
|
151
|
+
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
152
|
+
- spec/rails_app/config/initializers/inflections.rb
|
153
|
+
- spec/rails_app/config/initializers/secret_token.rb
|
154
|
+
- spec/rails_app/config/routes.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/support/active_record/models.rb
|
157
|
+
- spec/support/active_record/schema.rb
|
158
|
+
- spec/support/mongo_mapper/connection.rb
|
159
|
+
- spec/support/mongo_mapper/models.rb
|
160
|
+
- test/db/version_1.rb
|
161
|
+
- test/db/version_2.rb
|
162
|
+
- test/db/version_3.rb
|
163
|
+
- test/db/version_4.rb
|
164
|
+
- test/db/version_5.rb
|
165
|
+
- test/install_generator_test.rb
|
166
|
+
- test/test_helper.rb
|
167
|
+
- test/upgrade_generator_test.rb
|
130
168
|
homepage: https://github.com/collectiveidea/audited
|
131
169
|
licenses:
|
132
170
|
- MIT
|
@@ -151,5 +189,21 @@ rubygems_version: 2.2.2
|
|
151
189
|
signing_key:
|
152
190
|
specification_version: 4
|
153
191
|
summary: Log all changes to your models
|
154
|
-
test_files:
|
192
|
+
test_files:
|
193
|
+
- spec/audited_spec_helpers.rb
|
194
|
+
- spec/rails_app/config/application.rb
|
195
|
+
- spec/rails_app/config/database.yml
|
196
|
+
- spec/rails_app/config/environment.rb
|
197
|
+
- spec/rails_app/config/environments/development.rb
|
198
|
+
- spec/rails_app/config/environments/production.rb
|
199
|
+
- spec/rails_app/config/environments/test.rb
|
200
|
+
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
201
|
+
- spec/rails_app/config/initializers/inflections.rb
|
202
|
+
- spec/rails_app/config/initializers/secret_token.rb
|
203
|
+
- spec/rails_app/config/routes.rb
|
204
|
+
- spec/spec_helper.rb
|
205
|
+
- spec/support/active_record/models.rb
|
206
|
+
- spec/support/active_record/schema.rb
|
207
|
+
- spec/support/mongo_mapper/connection.rb
|
208
|
+
- spec/support/mongo_mapper/models.rb
|
155
209
|
has_rdoc:
|