audited 4.2.0 → 4.3.0

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +11 -9
  3. data/Appraisals +10 -3
  4. data/Gemfile +1 -1
  5. data/README.md +57 -44
  6. data/Rakefile +3 -18
  7. data/gemfiles/rails40.gemfile +1 -1
  8. data/gemfiles/rails41.gemfile +1 -1
  9. data/gemfiles/rails42.gemfile +1 -1
  10. data/gemfiles/rails50.gemfile +8 -0
  11. data/lib/audited/audit.rb +97 -57
  12. data/lib/audited/auditor.rb +86 -43
  13. data/lib/audited/rspec_matchers.rb +6 -2
  14. data/lib/audited/sweeper.rb +10 -19
  15. data/lib/audited/version.rb +1 -1
  16. data/lib/audited-rspec.rb +4 -0
  17. data/lib/audited.rb +15 -2
  18. data/lib/generators/audited/install_generator.rb +20 -0
  19. data/lib/generators/audited/migration.rb +15 -0
  20. data/lib/generators/audited/templates/add_association_to_audits.rb +11 -0
  21. data/lib/generators/audited/templates/add_comment_to_audits.rb +9 -0
  22. data/lib/generators/audited/templates/add_remote_address_to_audits.rb +10 -0
  23. data/lib/generators/audited/templates/add_request_uuid_to_audits.rb +10 -0
  24. data/lib/generators/audited/templates/install.rb +30 -0
  25. data/lib/generators/audited/templates/rename_association_to_associated.rb +23 -0
  26. data/lib/generators/audited/templates/rename_changes_to_audited_changes.rb +9 -0
  27. data/lib/generators/audited/templates/rename_parent_to_association.rb +11 -0
  28. data/lib/generators/audited/upgrade_generator.rb +57 -0
  29. data/spec/audited/audit_spec.rb +199 -0
  30. data/spec/audited/auditor_spec.rb +607 -0
  31. data/spec/audited/sweeper_spec.rb +106 -0
  32. data/spec/audited_spec_helpers.rb +6 -22
  33. data/spec/rails_app/config/environments/test.rb +7 -4
  34. data/spec/rails_app/config/initializers/secret_token.rb +1 -1
  35. data/spec/rails_app/config/routes.rb +1 -4
  36. data/spec/spec_helper.rb +7 -9
  37. data/spec/support/active_record/models.rb +23 -13
  38. data/spec/support/active_record/schema.rb +37 -12
  39. data/test/db/version_1.rb +4 -4
  40. data/test/db/version_2.rb +4 -4
  41. data/test/db/version_3.rb +4 -4
  42. data/test/db/version_4.rb +4 -4
  43. data/test/db/version_5.rb +2 -2
  44. data/test/db/version_6.rb +2 -2
  45. data/test/install_generator_test.rb +1 -1
  46. data/test/upgrade_generator_test.rb +10 -10
  47. metadata +56 -76
  48. data/lib/audited/active_record/version.rb +0 -5
  49. data/lib/audited/mongo_mapper/version.rb +0 -5
  50. data/spec/support/mongo_mapper/connection.rb +0 -4
  51. data/spec/support/mongo_mapper/models.rb +0 -214
@@ -1,19 +1,15 @@
1
1
  module AuditedSpecHelpers
2
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))
3
+ def create_user(attrs = {})
4
+ Models::ActiveRecord::User.create({name: 'Brandon', username: 'brandon', password: 'password'}.merge(attrs))
6
5
  end
7
6
 
8
- def build_user(use_mongo = false, attrs = {})
9
- klass = use_mongo ? Models::MongoMapper::User : Models::ActiveRecord::User
10
- klass.new({:name => 'darth', :username => 'darth', :password => 'noooooooo'}.merge(attrs))
7
+ def build_user(attrs = {})
8
+ Models::ActiveRecord::User.new({name: 'darth', username: 'darth', password: 'noooooooo'}.merge(attrs))
11
9
  end
12
10
 
13
- def create_versions(n = 2, use_mongo = false)
14
- klass = use_mongo ? Models::MongoMapper::User : Models::ActiveRecord::User
15
-
16
- klass.create(:name => 'Foobar 1').tap do |u|
11
+ def create_versions(n = 2)
12
+ Models::ActiveRecord::User.create(name: 'Foobar 1').tap do |u|
17
13
  (n - 1).times do |i|
18
14
  u.update_attribute :name, "Foobar #{i + 2}"
19
15
  end
@@ -21,16 +17,4 @@ module AuditedSpecHelpers
21
17
  end
22
18
  end
23
19
 
24
- def create_active_record_user(attrs = {})
25
- create_user(false, attrs)
26
- end
27
-
28
- def create_mongo_user(attrs = {})
29
- create_user(true, attrs)
30
- end
31
-
32
- def create_mongo_versions(n = 2)
33
- create_versions(n, true)
34
- end
35
-
36
20
  end
@@ -12,11 +12,14 @@ RailsApp::Application.configure do
12
12
  # preloads Rails for running tests, you may have to set it to true.
13
13
  config.eager_load = false
14
14
 
15
- # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
17
15
  # Configure static file server for tests with Cache-Control for performance.
18
- config.serve_static_files = true
19
- config.static_cache_control = 'public, max-age=3600'
16
+ if config.respond_to?(:public_file_server)
17
+ config.public_file_server.enabled = true
18
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
19
+ else
20
+ config.static_cache_control = 'public, max-age=3600'
21
+ config.serve_static_files = true
22
+ end
20
23
 
21
24
  # Show full error reports and disable caching.
22
25
  config.consider_all_requests_local = true
@@ -1,3 +1,3 @@
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"
3
3
  Rails.application.config.secret_key_base = 'secret value'
@@ -1,6 +1,3 @@
1
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)))', via: [:get, :post, :put, :delete]
2
+ resources :audits
6
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  ENV['RAILS_ENV'] = 'test'
2
2
 
3
- require 'protected_attributes'
3
+ if Bundler.definition.dependencies.map(&:name).include?('protected_attributes')
4
+ require 'protected_attributes'
5
+ end
4
6
  require 'rails_app/config/environment'
5
7
  require 'rspec/rails'
6
8
  require 'audited'
7
9
  require 'audited_spec_helpers'
10
+ require 'support/active_record/models'
11
+ load "audited/sweeper.rb" # force to reload sweeper
8
12
 
9
13
  SPEC_ROOT = Pathname.new(File.expand_path('../', __FILE__))
10
14
 
@@ -12,12 +16,6 @@ Dir[SPEC_ROOT.join('support/*.rb')].each{|f| require f }
12
16
 
13
17
  RSpec.configure do |config|
14
18
  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
19
+ config.use_transactional_fixtures = false if Rails.version.start_with?('4.')
20
+ config.use_transactional_tests = false if config.respond_to?(:use_transactional_tests=)
23
21
  end
@@ -4,35 +4,40 @@ require File.expand_path('../schema', __FILE__)
4
4
  module Models
5
5
  module ActiveRecord
6
6
  class User < ::ActiveRecord::Base
7
- audited :allow_mass_assignment => true, :except => :password
7
+ audited allow_mass_assignment: true, except: :password
8
8
 
9
- attr_protected :logins
9
+ attr_protected :logins if respond_to?(:attr_protected)
10
10
 
11
11
  def name=(val)
12
12
  write_attribute(:name, CGI.escapeHTML(val))
13
13
  end
14
14
  end
15
15
 
16
+ class UserOnlyPassword < ::ActiveRecord::Base
17
+ self.table_name = :users
18
+ audited allow_mass_assignment: true, only: :password
19
+ end
20
+
16
21
  class CommentRequiredUser < ::ActiveRecord::Base
17
22
  self.table_name = :users
18
- audited :comment_required => true
23
+ audited comment_required: true
19
24
  end
20
25
 
21
26
  class AccessibleAfterDeclarationUser < ::ActiveRecord::Base
22
27
  self.table_name = :users
23
28
  audited
24
- attr_accessible :name, :username, :password
29
+ attr_accessible :name, :username, :password if respond_to?(:attr_accessible)
25
30
  end
26
31
 
27
32
  class AccessibleBeforeDeclarationUser < ::ActiveRecord::Base
28
33
  self.table_name = :users
29
- attr_accessible :name, :username, :password # declare attr_accessible before calling aaa
34
+ attr_accessible :name, :username, :password if respond_to?(:attr_accessible) # declare attr_accessible before calling aaa
30
35
  audited
31
36
  end
32
37
 
33
38
  class NoAttributeProtectionUser < ::ActiveRecord::Base
34
39
  self.table_name = :users
35
- audited :allow_mass_assignment => true
40
+ audited allow_mass_assignment: true
36
41
  end
37
42
 
38
43
  class UserWithAfterAudit < ::ActiveRecord::Base
@@ -40,6 +45,8 @@ module Models
40
45
  audited
41
46
  attr_accessor :bogus_attr, :around_attr
42
47
 
48
+ private
49
+
43
50
  def after_audit
44
51
  self.bogus_attr = "do something"
45
52
  end
@@ -53,6 +60,9 @@ module Models
53
60
  audited
54
61
  end
55
62
 
63
+ class Company::STICompany < Company
64
+ end
65
+
56
66
  class Owner < ::ActiveRecord::Base
57
67
  self.table_name = 'users'
58
68
  has_associated_audits
@@ -61,29 +71,29 @@ module Models
61
71
 
62
72
  class OwnedCompany < ::ActiveRecord::Base
63
73
  self.table_name = 'companies'
64
- belongs_to :owner, :class_name => "Owner"
65
- attr_accessible :name, :owner # declare attr_accessible before calling aaa
66
- audited :associated_with => :owner
74
+ belongs_to :owner, class_name: "Owner"
75
+ attr_accessible :name, :owner if respond_to?(:attr_accessible) # declare attr_accessible before calling aaa
76
+ audited associated_with: :owner
67
77
  end
68
78
 
69
79
  class OnUpdateDestroy < ::ActiveRecord::Base
70
80
  self.table_name = 'companies'
71
- audited :on => [:update, :destroy]
81
+ audited on: [:update, :destroy]
72
82
  end
73
83
 
74
84
  class OnCreateDestroy < ::ActiveRecord::Base
75
85
  self.table_name = 'companies'
76
- audited :on => [:create, :destroy]
86
+ audited on: [:create, :destroy]
77
87
  end
78
88
 
79
89
  class OnCreateDestroyExceptName < ::ActiveRecord::Base
80
90
  self.table_name = 'companies'
81
- audited :except => :name, :on => [:create, :destroy]
91
+ audited except: :name, on: [:create, :destroy]
82
92
  end
83
93
 
84
94
  class OnCreateUpdate < ::ActiveRecord::Base
85
95
  self.table_name = 'companies'
86
- audited :on => [:create, :update]
96
+ audited on: [:create, :update]
87
97
  end
88
98
  end
89
99
  end
@@ -1,37 +1,62 @@
1
1
  require 'active_record'
2
2
  require 'logger'
3
3
 
4
- ActiveRecord::Base.establish_connection
5
- ActiveRecord::Base.logger = Logger.new(SPEC_ROOT.join('debug.log'))
4
+ begin
5
+ db_config = ActiveRecord::Base.configurations[Rails.env].clone
6
+ db_type = db_config['adapter']
7
+ db_name = db_config.delete('database')
8
+ raise Exception.new('No database name specified.') if db_name.blank?
9
+ if db_type == 'sqlite3'
10
+ db_file = Pathname.new(__FILE__).dirname.join(db_name)
11
+ db_file.unlink if db_file.file?
12
+ else
13
+ if defined?(JRUBY_VERSION)
14
+ db_config.symbolize_keys!
15
+ db_config[:configure_connection] = false
16
+ end
17
+ adapter = ActiveRecord::Base.send("#{db_type}_connection", db_config)
18
+ adapter.recreate_database db_name
19
+ adapter.disconnect!
20
+ end
21
+ rescue Exception => e
22
+ Kernel.warn e
23
+ end
24
+
25
+ logfile = Pathname.new(__FILE__).dirname.join('debug.log')
26
+ logfile.unlink if logfile.file?
27
+ ActiveRecord::Base.logger = Logger.new(logfile)
28
+
6
29
  ActiveRecord::Migration.verbose = false
30
+ ActiveRecord::Base.establish_connection
7
31
 
8
32
  ActiveRecord::Schema.define do
9
- create_table :users, :force => true do |t|
33
+ create_table :users do |t|
10
34
  t.column :name, :string
11
35
  t.column :username, :string
12
36
  t.column :password, :string
13
37
  t.column :activated, :boolean
14
38
  t.column :suspended_at, :datetime
15
- t.column :logins, :integer, :default => 0
39
+ t.column :logins, :integer, default: 0
16
40
  t.column :created_at, :datetime
17
41
  t.column :updated_at, :datetime
18
42
  end
19
43
 
20
- create_table :companies, :force => true do |t|
44
+ create_table :companies do |t|
21
45
  t.column :name, :string
22
46
  t.column :owner_id, :integer
47
+ t.column :type, :string
23
48
  end
24
49
 
25
- create_table :authors, :force => true do |t|
50
+ create_table :authors do |t|
26
51
  t.column :name, :string
27
52
  end
28
53
 
29
- create_table :books, :force => true do |t|
54
+ create_table :books do |t|
30
55
  t.column :authord_id, :integer
31
56
  t.column :title, :string
32
57
  end
33
58
 
34
- create_table :audits, :force => true do |t|
59
+ create_table :audits do |t|
35
60
  t.column :auditable_id, :integer
36
61
  t.column :auditable_type, :string
37
62
  t.column :associated_id, :integer
@@ -41,16 +66,16 @@ ActiveRecord::Schema.define do
41
66
  t.column :username, :string
42
67
  t.column :action, :string
43
68
  t.column :audited_changes, :text
44
- t.column :version, :integer, :default => 0
69
+ t.column :version, :integer, default: 0
45
70
  t.column :comment, :string
46
71
  t.column :remote_address, :string
47
72
  t.column :request_uuid, :string
48
73
  t.column :created_at, :datetime
49
74
  end
50
75
 
51
- add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
52
- add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
53
- add_index :audits, [:user_id, :user_type], :name => 'user_index'
76
+ add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
77
+ add_index :audits, [:associated_id, :associated_type], name: 'associated_index'
78
+ add_index :audits, [:user_id, :user_type], name: 'user_index'
54
79
  add_index :audits, :request_uuid
55
80
  add_index :audits, :created_at
56
81
  end
data/test/db/version_1.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ActiveRecord::Schema.define do
2
- create_table :audits, :force => true do |t|
2
+ create_table :audits, force: true do |t|
3
3
  t.column :auditable_id, :integer
4
4
  t.column :auditable_type, :string
5
5
  t.column :user_id, :integer
@@ -7,11 +7,11 @@ ActiveRecord::Schema.define do
7
7
  t.column :username, :string
8
8
  t.column :action, :string
9
9
  t.column :changes, :text
10
- t.column :version, :integer, :default => 0
10
+ t.column :version, :integer, default: 0
11
11
  t.column :created_at, :datetime
12
12
  end
13
13
 
14
- add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
15
- add_index :audits, [:user_id, :user_type], :name => 'user_index'
14
+ add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
15
+ add_index :audits, [:user_id, :user_type], name: 'user_index'
16
16
  add_index :audits, :created_at
17
17
  end
data/test/db/version_2.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ActiveRecord::Schema.define do
2
- create_table :audits, :force => true do |t|
2
+ create_table :audits, force: true do |t|
3
3
  t.column :auditable_id, :integer
4
4
  t.column :auditable_type, :string
5
5
  t.column :user_id, :integer
@@ -7,12 +7,12 @@ ActiveRecord::Schema.define do
7
7
  t.column :username, :string
8
8
  t.column :action, :string
9
9
  t.column :changes, :text
10
- t.column :version, :integer, :default => 0
10
+ t.column :version, :integer, default: 0
11
11
  t.column :comment, :string
12
12
  t.column :created_at, :datetime
13
13
  end
14
14
 
15
- add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
16
- add_index :audits, [:user_id, :user_type], :name => 'user_index'
15
+ add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
16
+ add_index :audits, [:user_id, :user_type], name: 'user_index'
17
17
  add_index :audits, :created_at
18
18
  end
data/test/db/version_3.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ActiveRecord::Schema.define do
2
- create_table :audits, :force => true do |t|
2
+ create_table :audits, force: true do |t|
3
3
  t.column :auditable_id, :integer
4
4
  t.column :auditable_type, :string
5
5
  t.column :user_id, :integer
@@ -7,13 +7,13 @@ ActiveRecord::Schema.define do
7
7
  t.column :username, :string
8
8
  t.column :action, :string
9
9
  t.column :audited_changes, :text
10
- t.column :version, :integer, :default => 0
10
+ t.column :version, :integer, default: 0
11
11
  t.column :comment, :string
12
12
  t.column :created_at, :datetime
13
13
  end
14
14
 
15
- add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
16
- add_index :audits, [:user_id, :user_type], :name => 'user_index'
15
+ add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
16
+ add_index :audits, [:user_id, :user_type], name: 'user_index'
17
17
  add_index :audits, :created_at
18
18
  end
19
19
 
data/test/db/version_4.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ActiveRecord::Schema.define do
2
- create_table :audits, :force => true do |t|
2
+ create_table :audits, force: true do |t|
3
3
  t.column :auditable_id, :integer
4
4
  t.column :auditable_type, :string
5
5
  t.column :user_id, :integer
@@ -7,14 +7,14 @@ ActiveRecord::Schema.define do
7
7
  t.column :username, :string
8
8
  t.column :action, :string
9
9
  t.column :audited_changes, :text
10
- t.column :version, :integer, :default => 0
10
+ t.column :version, :integer, default: 0
11
11
  t.column :comment, :string
12
12
  t.column :created_at, :datetime
13
13
  t.column :remote_address, :string
14
14
  end
15
15
 
16
- add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
17
- add_index :audits, [:user_id, :user_type], :name => 'user_index'
16
+ add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
17
+ add_index :audits, [:user_id, :user_type], name: 'user_index'
18
18
  add_index :audits, :created_at
19
19
  end
20
20
 
data/test/db/version_5.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ActiveRecord::Schema.define do
2
- create_table :audits, :force => true do |t|
2
+ create_table :audits, force: true do |t|
3
3
  t.column :auditable_id, :integer
4
4
  t.column :auditable_type, :string
5
5
  t.column :user_id, :integer
@@ -7,7 +7,7 @@ ActiveRecord::Schema.define do
7
7
  t.column :username, :string
8
8
  t.column :action, :string
9
9
  t.column :audited_changes, :text
10
- t.column :version, :integer, :default => 0
10
+ t.column :version, :integer, default: 0
11
11
  t.column :comment, :string
12
12
  t.column :created_at, :datetime
13
13
  t.column :remote_address, :string
data/test/db/version_6.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ActiveRecord::Schema.define do
2
- create_table :audits, :force => true do |t|
2
+ create_table :audits, force: true do |t|
3
3
  t.column :auditable_id, :integer
4
4
  t.column :auditable_type, :string
5
5
  t.column :user_id, :integer
@@ -7,7 +7,7 @@ ActiveRecord::Schema.define do
7
7
  t.column :username, :string
8
8
  t.column :action, :string
9
9
  t.column :audited_changes, :text
10
- t.column :version, :integer, :default => 0
10
+ t.column :version, :integer, default: 0
11
11
  t.column :comment, :string
12
12
  t.column :created_at, :datetime
13
13
  t.column :remote_address, :string
@@ -11,7 +11,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
11
11
  run_generator %w(install)
12
12
 
13
13
  assert_migration "db/migrate/install_audited.rb" do |content|
14
- assert_match /class InstallAudited/, content
14
+ assert_match(/class InstallAudited/, content)
15
15
  end
16
16
  end
17
17
  end
@@ -1,12 +1,12 @@
1
1
  require 'test_helper'
2
2
 
3
- require 'audited/adapters/active_record'
4
3
  require 'generators/audited/upgrade_generator'
5
4
 
6
5
  class UpgradeGeneratorTest < Rails::Generators::TestCase
7
6
  destination File.expand_path('../../tmp', __FILE__)
8
7
  setup :prepare_destination
9
8
  tests Audited::Generators::UpgradeGenerator
9
+ self.use_transactional_fixtures = false
10
10
 
11
11
  test "should add 'comment' to audits table" do
12
12
  load_schema 1
@@ -14,7 +14,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
14
14
  run_generator %w(upgrade)
15
15
 
16
16
  assert_migration "db/migrate/add_comment_to_audits.rb" do |content|
17
- assert_match /add_column :audits, :comment, :string/, content
17
+ assert_match(/add_column :audits, :comment, :string/, content)
18
18
  end
19
19
 
20
20
  assert_migration "db/migrate/rename_changes_to_audited_changes.rb"
@@ -28,7 +28,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
28
28
  assert_no_migration "db/migrate/add_comment_to_audits.rb"
29
29
 
30
30
  assert_migration "db/migrate/rename_changes_to_audited_changes.rb" do |content|
31
- assert_match /rename_column :audits, :changes, :audited_changes/, content
31
+ assert_match(/rename_column :audits, :changes, :audited_changes/, content)
32
32
  end
33
33
  end
34
34
 
@@ -38,7 +38,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
38
38
  run_generator %w(upgrade)
39
39
 
40
40
  assert_migration "db/migrate/add_remote_address_to_audits.rb" do |content|
41
- assert_match /add_column :audits, :remote_address, :string/, content
41
+ assert_match(/add_column :audits, :remote_address, :string/, content)
42
42
  end
43
43
  end
44
44
 
@@ -48,8 +48,8 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
48
48
  run_generator %w(upgrade)
49
49
 
50
50
  assert_migration "db/migrate/add_association_to_audits.rb" do |content|
51
- assert_match /add_column :audits, :association_id, :integer/, content
52
- assert_match /add_column :audits, :association_type, :string/, content
51
+ assert_match(/add_column :audits, :association_id, :integer/, content)
52
+ assert_match(/add_column :audits, :association_type, :string/, content)
53
53
  end
54
54
  end
55
55
 
@@ -59,8 +59,8 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
59
59
  run_generator %w(upgrade)
60
60
 
61
61
  assert_migration "db/migrate/rename_association_to_associated.rb" do |content|
62
- assert_match /rename_column :audits, :association_id, :associated_id/, content
63
- assert_match /rename_column :audits, :association_type, :associated_type/, content
62
+ assert_match(/rename_column :audits, :association_id, :associated_id/, content)
63
+ assert_match(/rename_column :audits, :association_type, :associated_type/, content)
64
64
  end
65
65
  end
66
66
 
@@ -70,8 +70,8 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
70
70
  run_generator %w(upgrade)
71
71
 
72
72
  assert_migration "db/migrate/add_request_uuid_to_audits.rb" do |content|
73
- assert_match /add_column :audits, :request_uuid, :string/, content
74
- assert_match /add_index :audits, :request_uuid/, content
73
+ assert_match(/add_column :audits, :request_uuid, :string/, content)
74
+ assert_match(/add_index :audits, :request_uuid/, content)
75
75
  end
76
76
  end
77
77
  end