spec/audited_spec_helpers.rb in audited-4.6.0 vs spec/audited_spec_helpers.rb in audited-4.7.0
- old
+ new
@@ -6,15 +6,27 @@
def build_user(attrs = {})
Models::ActiveRecord::User.new({name: 'darth', username: 'darth', password: 'noooooooo'}.merge(attrs))
end
- def create_versions(n = 2)
- Models::ActiveRecord::User.create(name: 'Foobar 1').tap do |u|
+ def create_versions(n = 2, attrs = {})
+ Models::ActiveRecord::User.create(name: 'Foobar 1', **attrs).tap do |u|
(n - 1).times do |i|
u.update_attribute :name, "Foobar #{i + 2}"
end
u.reload
end
+ end
+
+ def run_migrations(direction, migrations_paths, target_version = nil)
+ if rails_below?('5.2.0.rc1')
+ ActiveRecord::Migrator.send(direction, migrations_paths, target_version)
+ else
+ ActiveRecord::MigrationContext.new(migrations_paths).send(direction, target_version)
+ end
+ end
+
+ def rails_below?(rails_version)
+ Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new(rails_version)
end
end