notifiably_audited 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/audited/adapters/active_record/audit.rb +69 -0
- data/lib/audited/adapters/active_record.rb +15 -0
- data/lib/audited-activerecord.rb +2 -0
- data/lib/generators/audited/install_generator.rb +28 -0
- data/lib/generators/audited/templates/add_association_to_audits.rb +11 -0
- data/lib/generators/audited/templates/add_comment_to_audits.rb +9 -0
- data/lib/generators/audited/templates/add_remote_address_to_audits.rb +10 -0
- data/lib/generators/audited/templates/install.rb +35 -0
- data/lib/generators/audited/templates/rename_association_to_associated.rb +23 -0
- data/lib/generators/audited/templates/rename_changes_to_audited_changes.rb +9 -0
- data/lib/generators/audited/templates/rename_parent_to_association.rb +11 -0
- data/lib/generators/audited/upgrade_generator.rb +63 -0
- metadata +24 -157
- data/.gitignore +0 -17
- data/Appraisals +0 -11
- data/CHANGELOG +0 -34
- data/Gemfile +0 -3
- data/LICENSE.txt +0 -22
- data/README.md +0 -234
- data/Rakefile +0 -24
- data/audited-activerecord.gemspec +0 -21
- data/audited-mongo_mapper.gemspec +0 -21
- data/audited.gemspec +0 -27
- data/gemfiles/rails30.gemfile +0 -7
- data/gemfiles/rails31.gemfile +0 -7
- data/gemfiles/rails32.gemfile +0 -7
- data/lib/audited/audit.rb +0 -115
- data/lib/audited/auditor.rb +0 -449
- data/lib/audited/rspec_matchers.rb +0 -173
- data/lib/audited/sweeper.rb +0 -51
- data/lib/audited.rb +0 -15
- data/lib/notifiably_audited/version.rb +0 -3
- data/lib/notifiably_audited.rb +0 -15
- data/notifiably_audited.gemspec +0 -23
- data/spec/audited_spec_helpers.rb +0 -31
- data/spec/rails_app/config/application.rb +0 -5
- data/spec/rails_app/config/database.yml +0 -24
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/development.rb +0 -19
- data/spec/rails_app/config/environments/production.rb +0 -33
- data/spec/rails_app/config/environments/test.rb +0 -33
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/inflections.rb +0 -2
- data/spec/rails_app/config/initializers/secret_token.rb +0 -2
- data/spec/rails_app/config/routes.rb +0 -6
- data/spec/spec_helper.rb +0 -23
- data/spec/support/active_record/models.rb +0 -84
- data/spec/support/active_record/schema.rb +0 -54
- data/spec/support/mongo_mapper/connection.rb +0 -4
- data/spec/support/mongo_mapper/models.rb +0 -210
- data/test/db/version_1.rb +0 -17
- data/test/db/version_2.rb +0 -18
- data/test/db/version_3.rb +0 -19
- data/test/db/version_4.rb +0 -20
- data/test/db/version_5.rb +0 -18
- data/test/install_generator_test.rb +0 -17
- data/test/test_helper.rb +0 -19
- data/test/upgrade_generator_test.rb +0 -65
data/lib/notifiably_audited.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Audited
|
2
|
-
VERSION = '3.0.0'
|
3
|
-
|
4
|
-
class << self
|
5
|
-
attr_accessor :ignored_attributes, :current_user_method, :audit_class
|
6
|
-
|
7
|
-
def store
|
8
|
-
Thread.current[:audited_store] ||= {}
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
@ignored_attributes = %w(lock_version created_at updated_at created_on updated_on)
|
13
|
-
|
14
|
-
@current_user_method = :current_user
|
15
|
-
end
|
data/notifiably_audited.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'notifiably_audited/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "notifiably_audited"
|
8
|
-
spec.version = NotifiablyAudited::VERSION
|
9
|
-
spec.authors = ["TODO: Write your name"]
|
10
|
-
spec.email = ["TODO: Write your email address"]
|
11
|
-
spec.summary = %q{TODO: Write a short summary. Required.}
|
12
|
-
spec.description = %q{TODO: Write a longer description. Optional.}
|
13
|
-
spec.homepage = ""
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module AuditedSpecHelpers
|
2
|
-
|
3
|
-
def create_user(use_mongo = false, attrs = {})
|
4
|
-
klass = use_mongo ? Models::MongoMapper::User : Models::ActiveRecord::User
|
5
|
-
klass.create({:name => 'Brandon', :username => 'brandon', :password => 'password'}.merge(attrs))
|
6
|
-
end
|
7
|
-
|
8
|
-
def create_versions(n = 2, use_mongo = false)
|
9
|
-
klass = use_mongo ? Models::MongoMapper::User : Models::ActiveRecord::User
|
10
|
-
|
11
|
-
klass.create(:name => 'Foobar 1').tap do |u|
|
12
|
-
(n - 1).times do |i|
|
13
|
-
u.update_attribute :name, "Foobar #{i + 2}"
|
14
|
-
end
|
15
|
-
u.reload
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_active_record_user(attrs = {})
|
20
|
-
create_user(false, attrs)
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_mongo_user(attrs = {})
|
24
|
-
create_user(true, attrs)
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_mongo_versions(n = 2)
|
28
|
-
create_versions(n, true)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
sqlite3mem: &SQLITE3MEM
|
2
|
-
adapter: sqlite3
|
3
|
-
database: ":memory:"
|
4
|
-
|
5
|
-
sqlite3: &SQLITE
|
6
|
-
adapter: sqlite3
|
7
|
-
database: audited_test.sqlite3.db
|
8
|
-
|
9
|
-
postgresql: &POSTGRES
|
10
|
-
adapter: postgresql
|
11
|
-
username: postgres
|
12
|
-
password: postgres
|
13
|
-
database: audited_test
|
14
|
-
min_messages: ERROR
|
15
|
-
|
16
|
-
mysql: &MYSQL
|
17
|
-
adapter: mysql
|
18
|
-
host: localhost
|
19
|
-
username: root
|
20
|
-
password:
|
21
|
-
database: audited_test
|
22
|
-
|
23
|
-
test:
|
24
|
-
<<: *<%= ENV['DB'] || 'SQLITE3MEM' %>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
RailsApp::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the webserver when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
|
-
# Show full error reports and disable caching
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
|
-
config.action_controller.perform_caching = false
|
16
|
-
|
17
|
-
# Don't care if the mailer can't send
|
18
|
-
config.action_mailer.raise_delivery_errors = false
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
RailsApp::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
-
|
4
|
-
# The production environment is meant for finished, "live" apps.
|
5
|
-
# Code is not reloaded between requests
|
6
|
-
config.cache_classes = true
|
7
|
-
|
8
|
-
# Full error reports are disabled and caching is turned on
|
9
|
-
config.consider_all_requests_local = false
|
10
|
-
config.action_controller.perform_caching = true
|
11
|
-
|
12
|
-
# See everything in the log (default is :info)
|
13
|
-
# config.log_level = :debug
|
14
|
-
|
15
|
-
# Use a different logger for distributed setups
|
16
|
-
# config.logger = SyslogLogger.new
|
17
|
-
|
18
|
-
# Use a different cache store in production
|
19
|
-
# config.cache_store = :mem_cache_store
|
20
|
-
|
21
|
-
# Disable Rails's static asset server
|
22
|
-
# In production, Apache or nginx will already do this
|
23
|
-
config.serve_static_assets = false
|
24
|
-
|
25
|
-
# Enable serving of images, stylesheets, and javascripts from an asset server
|
26
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
27
|
-
|
28
|
-
# Disable delivery errors, bad email addresses will be ignored
|
29
|
-
# config.action_mailer.raise_delivery_errors = false
|
30
|
-
|
31
|
-
# Enable threaded mode
|
32
|
-
# config.threadsafe!
|
33
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
RailsApp::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
-
|
4
|
-
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
8
|
-
config.cache_classes = true
|
9
|
-
|
10
|
-
# Log error messages when you accidentally call methods on nil.
|
11
|
-
config.whiny_nils = true
|
12
|
-
|
13
|
-
# Show full error reports and disable caching
|
14
|
-
config.consider_all_requests_local = true
|
15
|
-
config.action_controller.perform_caching = false
|
16
|
-
|
17
|
-
# Disable request forgery protection in test environment
|
18
|
-
config.action_controller.allow_forgery_protection = false
|
19
|
-
|
20
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
21
|
-
# The :test delivery method accumulates sent emails in the
|
22
|
-
# ActionMailer::Base.deliveries array.
|
23
|
-
config.action_mailer.delivery_method = :test
|
24
|
-
|
25
|
-
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
26
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
27
|
-
# like if you have constraints or database-specific column types
|
28
|
-
# config.active_record.schema_format = :sql
|
29
|
-
|
30
|
-
config.action_dispatch.show_exceptions = false
|
31
|
-
|
32
|
-
config.active_support.deprecation = :stderr
|
33
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
-
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
-
|
6
|
-
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
-
Rails.backtrace_cleaner.remove_silencers!
|
@@ -1,6 +0,0 @@
|
|
1
|
-
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
4
|
-
# Note: This route will make all actions in every controller accessible via GET requests.
|
5
|
-
match ':controller(/:action(/:id(.:format)))'
|
6
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] = 'test'
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
require 'rails_app/config/environment'
|
5
|
-
require 'rspec/rails'
|
6
|
-
require 'audited'
|
7
|
-
require 'audited_spec_helpers'
|
8
|
-
|
9
|
-
SPEC_ROOT = Pathname.new(File.expand_path('../', __FILE__))
|
10
|
-
|
11
|
-
Dir[SPEC_ROOT.join('support/*.rb')].each{|f| require f }
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.include AuditedSpecHelpers
|
15
|
-
|
16
|
-
config.before(:each, :adapter => :active_record) do
|
17
|
-
Audited.audit_class = Audited::Adapters::ActiveRecord::Audit
|
18
|
-
end
|
19
|
-
|
20
|
-
config.before(:each, :adapter => :mongo_mapper) do
|
21
|
-
Audited.audit_class = Audited::Adapters::MongoMapper::Audit
|
22
|
-
end
|
23
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require File.expand_path('../schema', __FILE__)
|
3
|
-
|
4
|
-
module Models
|
5
|
-
module ActiveRecord
|
6
|
-
class User < ::ActiveRecord::Base
|
7
|
-
audited :allow_mass_assignment => true, :except => :password
|
8
|
-
|
9
|
-
attr_protected :logins
|
10
|
-
|
11
|
-
def name=(val)
|
12
|
-
write_attribute(:name, CGI.escapeHTML(val))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class CommentRequiredUser < ::ActiveRecord::Base
|
17
|
-
self.table_name = :users
|
18
|
-
audited :comment_required => true
|
19
|
-
end
|
20
|
-
|
21
|
-
class AccessibleAfterDeclarationUser < ::ActiveRecord::Base
|
22
|
-
self.table_name = :users
|
23
|
-
audited
|
24
|
-
attr_accessible :name, :username, :password
|
25
|
-
end
|
26
|
-
|
27
|
-
class AccessibleBeforeDeclarationUser < ::ActiveRecord::Base
|
28
|
-
self.table_name = :users
|
29
|
-
attr_accessible :name, :username, :password # declare attr_accessible before calling aaa
|
30
|
-
audited
|
31
|
-
end
|
32
|
-
|
33
|
-
class NoAttributeProtectionUser < ::ActiveRecord::Base
|
34
|
-
self.table_name = :users
|
35
|
-
audited :allow_mass_assignment => true
|
36
|
-
end
|
37
|
-
|
38
|
-
class UserWithAfterAudit < ::ActiveRecord::Base
|
39
|
-
self.table_name = :users
|
40
|
-
audited
|
41
|
-
attr_accessor :bogus_attr
|
42
|
-
|
43
|
-
def after_audit
|
44
|
-
self.bogus_attr = "do something"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class Company < ::ActiveRecord::Base
|
49
|
-
audited
|
50
|
-
end
|
51
|
-
|
52
|
-
class Owner < ::ActiveRecord::Base
|
53
|
-
self.table_name = 'users'
|
54
|
-
has_associated_audits
|
55
|
-
end
|
56
|
-
|
57
|
-
class OwnedCompany < ::ActiveRecord::Base
|
58
|
-
self.table_name = 'companies'
|
59
|
-
belongs_to :owner, :class_name => "Owner"
|
60
|
-
attr_accessible :name, :owner # declare attr_accessible before calling aaa
|
61
|
-
audited :associated_with => :owner
|
62
|
-
end
|
63
|
-
|
64
|
-
class OnUpdateDestroy < ::ActiveRecord::Base
|
65
|
-
self.table_name = 'companies'
|
66
|
-
audited :on => [:update, :destroy]
|
67
|
-
end
|
68
|
-
|
69
|
-
class OnCreateDestroy < ::ActiveRecord::Base
|
70
|
-
self.table_name = 'companies'
|
71
|
-
audited :on => [:create, :destroy]
|
72
|
-
end
|
73
|
-
|
74
|
-
class OnCreateDestroyExceptName < ::ActiveRecord::Base
|
75
|
-
self.table_name = 'companies'
|
76
|
-
audited :except => :name, :on => [:create, :destroy]
|
77
|
-
end
|
78
|
-
|
79
|
-
class OnCreateUpdate < ::ActiveRecord::Base
|
80
|
-
self.table_name = 'companies'
|
81
|
-
audited :on => [:create, :update]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
require 'logger'
|
3
|
-
|
4
|
-
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
5
|
-
ActiveRecord::Base.logger = Logger.new(SPEC_ROOT.join('debug.log'))
|
6
|
-
ActiveRecord::Migration.verbose = false
|
7
|
-
|
8
|
-
ActiveRecord::Schema.define do
|
9
|
-
create_table :users, :force => true do |t|
|
10
|
-
t.column :name, :string
|
11
|
-
t.column :username, :string
|
12
|
-
t.column :password, :string
|
13
|
-
t.column :activated, :boolean
|
14
|
-
t.column :suspended_at, :datetime
|
15
|
-
t.column :logins, :integer, :default => 0
|
16
|
-
t.column :created_at, :datetime
|
17
|
-
t.column :updated_at, :datetime
|
18
|
-
end
|
19
|
-
|
20
|
-
create_table :companies, :force => true do |t|
|
21
|
-
t.column :name, :string
|
22
|
-
t.column :owner_id, :integer
|
23
|
-
end
|
24
|
-
|
25
|
-
create_table :authors, :force => true do |t|
|
26
|
-
t.column :name, :string
|
27
|
-
end
|
28
|
-
|
29
|
-
create_table :books, :force => true do |t|
|
30
|
-
t.column :authord_id, :integer
|
31
|
-
t.column :title, :string
|
32
|
-
end
|
33
|
-
|
34
|
-
create_table :audits, :force => true do |t|
|
35
|
-
t.column :auditable_id, :integer
|
36
|
-
t.column :auditable_type, :string
|
37
|
-
t.column :associated_id, :integer
|
38
|
-
t.column :associated_type, :string
|
39
|
-
t.column :user_id, :integer
|
40
|
-
t.column :user_type, :string
|
41
|
-
t.column :username, :string
|
42
|
-
t.column :action, :string
|
43
|
-
t.column :audited_changes, :text
|
44
|
-
t.column :version, :integer, :default => 0
|
45
|
-
t.column :comment, :string
|
46
|
-
t.column :remote_address, :string
|
47
|
-
t.column :created_at, :datetime
|
48
|
-
end
|
49
|
-
|
50
|
-
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
51
|
-
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
|
52
|
-
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
53
|
-
add_index :audits, :created_at
|
54
|
-
end
|
@@ -1,210 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'mongo_mapper'
|
3
|
-
require File.expand_path('../connection', __FILE__)
|
4
|
-
|
5
|
-
module Models
|
6
|
-
module MongoMapper
|
7
|
-
class User
|
8
|
-
include ::MongoMapper::Document
|
9
|
-
|
10
|
-
key :name, String
|
11
|
-
key :username, String
|
12
|
-
key :password, String
|
13
|
-
key :activated, Boolean
|
14
|
-
key :suspended_at, Time
|
15
|
-
key :logins, Integer, :default => 0
|
16
|
-
timestamps!
|
17
|
-
|
18
|
-
audited :allow_mass_assignment => true, :except => :password
|
19
|
-
|
20
|
-
attr_protected :logins
|
21
|
-
|
22
|
-
def name=(val)
|
23
|
-
write_attribute(:name, CGI.escapeHTML(val))
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class CommentRequiredUser
|
28
|
-
include ::MongoMapper::Document
|
29
|
-
|
30
|
-
key :name, String
|
31
|
-
key :username, String
|
32
|
-
key :password, String
|
33
|
-
key :activated, Boolean
|
34
|
-
key :suspended_at, Time
|
35
|
-
key :logins, Integer, :default => 0
|
36
|
-
timestamps!
|
37
|
-
|
38
|
-
audited :comment_required => true
|
39
|
-
end
|
40
|
-
|
41
|
-
class AccessibleAfterDeclarationUser
|
42
|
-
include ::MongoMapper::Document
|
43
|
-
|
44
|
-
key :name, String
|
45
|
-
key :username, String
|
46
|
-
key :password, String
|
47
|
-
key :activated, Boolean
|
48
|
-
key :suspended_at, Time
|
49
|
-
key :logins, Integer, :default => 0
|
50
|
-
timestamps!
|
51
|
-
|
52
|
-
audited
|
53
|
-
attr_accessible :name, :username, :password
|
54
|
-
end
|
55
|
-
|
56
|
-
class AccessibleBeforeDeclarationUser
|
57
|
-
include ::MongoMapper::Document
|
58
|
-
|
59
|
-
key :name, String
|
60
|
-
key :username, String
|
61
|
-
key :password, String
|
62
|
-
key :activated, Boolean
|
63
|
-
key :suspended_at, Time
|
64
|
-
key :logins, Integer, :default => 0
|
65
|
-
timestamps!
|
66
|
-
|
67
|
-
attr_accessible :name, :username, :password # declare attr_accessible before calling aaa
|
68
|
-
audited
|
69
|
-
end
|
70
|
-
|
71
|
-
class NoAttributeProtectionUser
|
72
|
-
include ::MongoMapper::Document
|
73
|
-
|
74
|
-
key :name, String
|
75
|
-
key :username, String
|
76
|
-
key :password, String
|
77
|
-
key :activated, Boolean
|
78
|
-
key :suspended_at, Time
|
79
|
-
key :logins, Integer, :default => 0
|
80
|
-
timestamps!
|
81
|
-
|
82
|
-
audited :allow_mass_assignment => true
|
83
|
-
end
|
84
|
-
|
85
|
-
class UserWithAfterAudit
|
86
|
-
include ::MongoMapper::Document
|
87
|
-
|
88
|
-
key :name, String
|
89
|
-
key :username, String
|
90
|
-
key :password, String
|
91
|
-
key :activated, Boolean
|
92
|
-
key :suspended_at, Time
|
93
|
-
key :logins, Integer, :default => 0
|
94
|
-
timestamps!
|
95
|
-
|
96
|
-
audited
|
97
|
-
attr_accessor :bogus_attr
|
98
|
-
|
99
|
-
def after_audit
|
100
|
-
self.bogus_attr = "do something"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
class Company
|
105
|
-
include ::MongoMapper::Document
|
106
|
-
|
107
|
-
key :name, String
|
108
|
-
key :owner_id, ObjectId
|
109
|
-
|
110
|
-
audited
|
111
|
-
end
|
112
|
-
|
113
|
-
class Owner
|
114
|
-
include ::MongoMapper::Document
|
115
|
-
|
116
|
-
key :name, String
|
117
|
-
key :username, String
|
118
|
-
key :password, String
|
119
|
-
key :activated, Boolean
|
120
|
-
key :suspended_at, Time
|
121
|
-
key :logins, Integer, :default => 0
|
122
|
-
timestamps!
|
123
|
-
|
124
|
-
has_associated_audits
|
125
|
-
end
|
126
|
-
|
127
|
-
class OwnedCompany
|
128
|
-
include ::MongoMapper::Document
|
129
|
-
|
130
|
-
key :name, String
|
131
|
-
key :owner_id, ObjectId
|
132
|
-
|
133
|
-
belongs_to :owner, :class_name => "Owner"
|
134
|
-
attr_accessible :name, :owner # declare attr_accessible before calling aaa
|
135
|
-
audited :associated_with => :owner
|
136
|
-
end
|
137
|
-
|
138
|
-
class OnUpdateDestroy
|
139
|
-
include ::MongoMapper::Document
|
140
|
-
|
141
|
-
key :name, String
|
142
|
-
key :owner_id, ObjectId
|
143
|
-
|
144
|
-
audited :on => [:update, :destroy]
|
145
|
-
end
|
146
|
-
|
147
|
-
class OnCreateDestroy
|
148
|
-
include ::MongoMapper::Document
|
149
|
-
|
150
|
-
key :name, String
|
151
|
-
key :owner_id, ObjectId
|
152
|
-
|
153
|
-
audited :on => [:create, :destroy]
|
154
|
-
end
|
155
|
-
|
156
|
-
class OnCreateDestroyExceptName
|
157
|
-
include ::MongoMapper::Document
|
158
|
-
|
159
|
-
key :name, String
|
160
|
-
key :owner_id, ObjectId
|
161
|
-
|
162
|
-
audited :except => :name, :on => [:create, :destroy]
|
163
|
-
end
|
164
|
-
|
165
|
-
class OnCreateUpdate
|
166
|
-
include ::MongoMapper::Document
|
167
|
-
|
168
|
-
key :name, String
|
169
|
-
key :owner_id, ObjectId
|
170
|
-
|
171
|
-
audited :on => [:create, :update]
|
172
|
-
end
|
173
|
-
|
174
|
-
class RichObjectUser
|
175
|
-
include ::MongoMapper::Document
|
176
|
-
|
177
|
-
class Name
|
178
|
-
attr_accessor :first_name, :last_name
|
179
|
-
|
180
|
-
def self.from_mongo(value)
|
181
|
-
case value
|
182
|
-
when String then new(*value.split)
|
183
|
-
when self then value
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
def self.to_mongo(value)
|
188
|
-
case value
|
189
|
-
when String then value
|
190
|
-
when self then value.to_s
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def initialize(first_name, last_name)
|
195
|
-
self.first_name, self.last_name = first_name, last_name
|
196
|
-
end
|
197
|
-
|
198
|
-
def to_s
|
199
|
-
[first_name, last_name].compact.join(' ')
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
key :name, Name
|
204
|
-
|
205
|
-
attr_accessible :name
|
206
|
-
|
207
|
-
audited
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
data/test/db/version_1.rb
DELETED
@@ -1,17 +0,0 @@
|
|
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 :changes, :text
|
10
|
-
t.column :version, :integer, :default => 0
|
11
|
-
t.column :created_at, :datetime
|
12
|
-
end
|
13
|
-
|
14
|
-
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
15
|
-
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
16
|
-
add_index :audits, :created_at
|
17
|
-
end
|
data/test/db/version_2.rb
DELETED
@@ -1,18 +0,0 @@
|
|
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 :changes, :text
|
10
|
-
t.column :version, :integer, :default => 0
|
11
|
-
t.column :comment, :string
|
12
|
-
t.column :created_at, :datetime
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
16
|
-
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
17
|
-
add_index :audits, :created_at
|
18
|
-
end
|
data/test/db/version_3.rb
DELETED
@@ -1,19 +0,0 @@
|
|
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
|
-
end
|
14
|
-
|
15
|
-
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
|
16
|
-
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
17
|
-
add_index :audits, :created_at
|
18
|
-
end
|
19
|
-
|
data/test/db/version_4.rb
DELETED
@@ -1,20 +0,0 @@
|
|
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
|
-
|