Fix Style/HashSyntax
This commit is contained in:
parent
ae6358d93c
commit
10941c8459
|
@ -75,13 +75,6 @@ Style/FirstParameterIndentation:
|
|||
Exclude:
|
||||
- 'lib/paper_trail/serializers/json.rb'
|
||||
|
||||
# Offense count: 606
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
||||
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
|
||||
Style/HashSyntax:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: MaxLineLength.
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -27,4 +27,4 @@ require 'rubocop/rake_task'
|
|||
RuboCop::RakeTask.new
|
||||
|
||||
desc 'Default: run all available test suites'
|
||||
task :default => [:rubocop, :prepare, :test, :spec]
|
||||
task default: [:rubocop, :prepare, :test, :spec]
|
||||
|
|
|
@ -2,19 +2,19 @@ class CreateVersionAssociations < ActiveRecord::Migration
|
|||
def self.up
|
||||
create_table :version_associations do |t|
|
||||
t.integer :version_id
|
||||
t.string :foreign_key_name, :null => false
|
||||
t.string :foreign_key_name, null: false
|
||||
t.integer :foreign_key_id
|
||||
end
|
||||
add_index :version_associations, [:version_id]
|
||||
add_index :version_associations,
|
||||
[:foreign_key_name, :foreign_key_id],
|
||||
:name => 'index_version_associations_on_foreign_key'
|
||||
name: 'index_version_associations_on_foreign_key'
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :version_associations, [:version_id]
|
||||
remove_index :version_associations,
|
||||
:name => 'index_version_associations_on_foreign_key'
|
||||
name: 'index_version_associations_on_foreign_key'
|
||||
drop_table :version_associations
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,11 +15,11 @@ class CreateVersions < ActiveRecord::Migration
|
|||
|
||||
def change
|
||||
create_table :versions, versions_table_options do |t|
|
||||
t.string :item_type, :null => false
|
||||
t.integer :item_id, :null => false
|
||||
t.string :event, :null => false
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.string :whodunnit
|
||||
t.text :object, :limit => TEXT_BYTES
|
||||
t.text :object, limit: TEXT_BYTES
|
||||
|
||||
# Known issue in MySQL: fractional second precision
|
||||
# -------------------------------------------------
|
||||
|
|
|
@ -15,7 +15,7 @@ module PaperTrail
|
|||
# causes all items to be cleaned. Defaults to `nil`.
|
||||
#
|
||||
def clean_versions!(options = {})
|
||||
options = {:keeping => 1, :date => :all}.merge(options)
|
||||
options = {keeping: 1, date: :all}.merge(options)
|
||||
gather_versions(options[:item_id], options[:date]).each do |_item_id, item_versions|
|
||||
group_versions_by_date(item_versions).each do |_date, date_versions|
|
||||
# Remove the number of versions we wish to keep from the collection
|
||||
|
@ -37,7 +37,7 @@ module PaperTrail
|
|||
unless date == :all || date.respond_to?(:to_date)
|
||||
raise ArgumentError.new("`date` argument must receive a Timestamp or `:all`")
|
||||
end
|
||||
versions = item_id ? PaperTrail::Version.where(:item_id => item_id) : PaperTrail::Version
|
||||
versions = item_id ? PaperTrail::Version.where(item_id: item_id) : PaperTrail::Version
|
||||
versions = versions.order(PaperTrail::Version.timestamp_sort_order)
|
||||
versions = versions.between(date.to_date, date.to_date + 1.day) unless date == :all
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.configure do |config|
|
|||
::PaperTrail.controller_info = {} if defined?(::Rails) && defined?(::RSpec::Rails)
|
||||
end
|
||||
|
||||
config.before(:each, :versioning => true) do
|
||||
config.before(:each, versioning: true) do
|
||||
::PaperTrail.enabled = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module PaperTrail
|
|||
module ClassMethods
|
||||
# enable versioning for specific blocks (at class-level)
|
||||
def with_versioning(&block)
|
||||
context 'with versioning', :versioning => true do
|
||||
context 'with versioning', versioning: true do
|
||||
class_exec(&block)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -94,12 +94,12 @@ module PaperTrail
|
|||
if ::ActiveRecord::VERSION::MAJOR >= 4
|
||||
has_many self.versions_association_name,
|
||||
lambda { order(model.timestamp_sort_order) },
|
||||
:class_name => self.version_class_name, :as => :item
|
||||
class_name: self.version_class_name, as: :item
|
||||
else
|
||||
has_many self.versions_association_name,
|
||||
:class_name => self.version_class_name,
|
||||
:as => :item,
|
||||
:order => self.paper_trail_version_class.timestamp_sort_order
|
||||
class_name: self.version_class_name,
|
||||
as: :item,
|
||||
order: self.paper_trail_version_class.timestamp_sort_order
|
||||
end
|
||||
|
||||
# Reset the transaction id when the transaction is closed.
|
||||
|
@ -131,7 +131,7 @@ module PaperTrail
|
|||
end
|
||||
end
|
||||
|
||||
send "#{recording_order}_destroy", :record_destroy, :if => :save_version?
|
||||
send "#{recording_order}_destroy", :record_destroy, if: :save_version?
|
||||
|
||||
return if paper_trail_options[:on].include?(:destroy)
|
||||
paper_trail_options[:on] << :destroy
|
||||
|
@ -139,8 +139,8 @@ module PaperTrail
|
|||
|
||||
# Record version after "update" event
|
||||
def paper_trail_on_update
|
||||
before_save :reset_timestamp_attrs_for_update_if_needed!, :on => :update
|
||||
after_update :record_update, :if => :save_version?
|
||||
before_save :reset_timestamp_attrs_for_update_if_needed!, on: :update
|
||||
after_update :record_update, if: :save_version?
|
||||
after_update :clear_version_instance!
|
||||
|
||||
return if paper_trail_options[:on].include?(:update)
|
||||
|
@ -149,7 +149,7 @@ module PaperTrail
|
|||
|
||||
# Record version after "create" event
|
||||
def paper_trail_on_create
|
||||
after_create :record_create, :if => :save_version?
|
||||
after_create :record_create, if: :save_version?
|
||||
|
||||
return if paper_trail_options[:on].include?(:create)
|
||||
paper_trail_options[:on] << :create
|
||||
|
@ -288,7 +288,7 @@ module PaperTrail
|
|||
attributes.each { |column| write_attribute(column, current_time) }
|
||||
|
||||
record_update(true) unless will_record_after_update?
|
||||
save!(:validate => false)
|
||||
save!(validate: false)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -307,8 +307,8 @@ module PaperTrail
|
|||
def record_create
|
||||
if paper_trail_switched_on?
|
||||
data = {
|
||||
:event => paper_trail_event || 'create',
|
||||
:whodunnit => PaperTrail.whodunnit
|
||||
event: paper_trail_event || 'create',
|
||||
whodunnit: PaperTrail.whodunnit
|
||||
}
|
||||
if respond_to?(:updated_at)
|
||||
data[PaperTrail.timestamp_field] = updated_at
|
||||
|
@ -328,9 +328,9 @@ module PaperTrail
|
|||
def record_update(force = nil)
|
||||
if paper_trail_switched_on? && (force || changed_notably?)
|
||||
data = {
|
||||
:event => paper_trail_event || 'update',
|
||||
:object => pt_recordable_object,
|
||||
:whodunnit => PaperTrail.whodunnit
|
||||
event: paper_trail_event || 'update',
|
||||
object: pt_recordable_object,
|
||||
whodunnit: PaperTrail.whodunnit
|
||||
}
|
||||
if respond_to?(:updated_at)
|
||||
data[PaperTrail.timestamp_field] = updated_at
|
||||
|
@ -414,11 +414,11 @@ module PaperTrail
|
|||
def record_destroy
|
||||
if paper_trail_switched_on? && !new_record?
|
||||
data = {
|
||||
:item_id => self.id,
|
||||
:item_type => self.class.base_class.name,
|
||||
:event => paper_trail_event || 'destroy',
|
||||
:object => pt_recordable_object,
|
||||
:whodunnit => PaperTrail.whodunnit
|
||||
item_id: self.id,
|
||||
item_type: self.class.base_class.name,
|
||||
event: paper_trail_event || 'destroy',
|
||||
object: pt_recordable_object,
|
||||
whodunnit: PaperTrail.whodunnit
|
||||
}
|
||||
if self.class.paper_trail_version_class.column_names.include?('transaction_id')
|
||||
data[:transaction_id] = PaperTrail.transaction_id
|
||||
|
@ -436,8 +436,8 @@ module PaperTrail
|
|||
return unless PaperTrail.config.track_associations?
|
||||
self.class.reflect_on_all_associations(:belongs_to).each do |assoc|
|
||||
assoc_version_args = {
|
||||
:version_id => version.id,
|
||||
:foreign_key_name => assoc.foreign_key
|
||||
version_id: version.id,
|
||||
foreign_key_name: assoc.foreign_key
|
||||
}
|
||||
|
||||
if assoc.options[:polymorphic]
|
||||
|
|
|
@ -9,11 +9,11 @@ module PaperTrail
|
|||
options = options.dup
|
||||
|
||||
options.reverse_merge!(
|
||||
:version_at => version.created_at,
|
||||
:mark_for_destruction => false,
|
||||
:has_one => false,
|
||||
:has_many => false,
|
||||
:unversioned_attributes => :nil
|
||||
version_at: version.created_at,
|
||||
mark_for_destruction: false,
|
||||
has_one: false,
|
||||
has_many: false,
|
||||
unversioned_attributes: :nil
|
||||
)
|
||||
|
||||
attrs = version.class.object_col_is_json? ?
|
||||
|
@ -108,7 +108,7 @@ module PaperTrail
|
|||
elsif version.event == 'create'
|
||||
options[:mark_for_destruction] ? record.tap { |r| r.mark_for_destruction } : nil
|
||||
else
|
||||
version.reify(options.merge(:has_many => false, :has_one => false))
|
||||
version.reify(options.merge(has_many: false, has_one: false))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -117,7 +117,7 @@ module PaperTrail
|
|||
# associations.
|
||||
array.concat(
|
||||
versions.values.map { |v|
|
||||
v.reify(options.merge(:has_many => false, :has_one => false))
|
||||
v.reify(options.merge(has_many: false, has_one: false))
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -150,7 +150,7 @@ module PaperTrail
|
|||
end
|
||||
end
|
||||
else
|
||||
child = version.reify(options.merge(:has_many => false, :has_one => false))
|
||||
child = version.reify(options.merge(has_many: false, has_one: false))
|
||||
model.appear_as_new_record do
|
||||
without_persisting(child) do
|
||||
model.send "#{assoc.name}=", child
|
||||
|
|
|
@ -5,14 +5,14 @@ module PaperTrail
|
|||
extend ::ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
belongs_to :item, :polymorphic => true
|
||||
belongs_to :item, polymorphic: true
|
||||
|
||||
# Since the test suite has test coverage for this, we want to declare
|
||||
# the association when the test suite is running. This makes it pass when
|
||||
# DB is not initialized prior to test runs such as when we run on Travis
|
||||
# CI (there won't be a db in `test/dummy/db/`).
|
||||
if PaperTrail.config.track_associations?
|
||||
has_many :version_associations, :dependent => :destroy
|
||||
has_many :version_associations, dependent: :destroy
|
||||
end
|
||||
|
||||
validates_presence_of :event
|
||||
|
@ -32,24 +32,24 @@ module PaperTrail
|
|||
|
||||
after_create :enforce_version_limit!
|
||||
|
||||
scope :within_transaction, lambda { |id| where :transaction_id => id }
|
||||
scope :within_transaction, lambda { |id| where transaction_id: id }
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def with_item_keys(item_type, item_id)
|
||||
where :item_type => item_type, :item_id => item_id
|
||||
where item_type: item_type, item_id: item_id
|
||||
end
|
||||
|
||||
def creates
|
||||
where :event => 'create'
|
||||
where event: 'create'
|
||||
end
|
||||
|
||||
def updates
|
||||
where :event => 'update'
|
||||
where event: 'update'
|
||||
end
|
||||
|
||||
def destroys
|
||||
where :event => 'destroy'
|
||||
where event: 'destroy'
|
||||
end
|
||||
|
||||
def not_creates
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
|||
require 'generator_spec/test_case'
|
||||
require File.expand_path('../../../lib/generators/paper_trail/install_generator', __FILE__)
|
||||
|
||||
describe PaperTrail::InstallGenerator, :type => :generator do
|
||||
describe PaperTrail::InstallGenerator, type: :generator do
|
||||
include GeneratorSpec::TestCase
|
||||
destination File.expand_path('../tmp', __FILE__)
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Animal, :type => :model do
|
||||
describe Animal, type: :model do
|
||||
it { is_expected.to be_versioned }
|
||||
|
||||
describe "STI", :versioning => true do
|
||||
describe "STI", versioning: true do
|
||||
it { expect(Animal.inheritance_column).to eq('species') }
|
||||
|
||||
describe "updates to the `inheritance_column`" do
|
||||
subject { Cat.create!(:name => 'Leo') }
|
||||
subject { Cat.create!(name: 'Leo') }
|
||||
|
||||
it "should be allowed" do
|
||||
subject.update_attributes(:name => 'Spike', :species => 'Dog')
|
||||
subject.update_attributes(name: 'Spike', species: 'Dog')
|
||||
dog = Animal.find(subject.id)
|
||||
expect(dog).to be_instance_of(Dog)
|
||||
end
|
||||
|
@ -18,10 +18,10 @@ describe Animal, :type => :model do
|
|||
|
||||
context 'with callback-methods' do
|
||||
context 'when only has_paper_trail set in super class' do
|
||||
let(:callback_cat) { Cat.create(:name => 'Markus') }
|
||||
let(:callback_cat) { Cat.create(name: 'Markus') }
|
||||
|
||||
it 'trails all events' do
|
||||
callback_cat.update_attributes(:name => 'Billie')
|
||||
callback_cat.update_attributes(name: 'Billie')
|
||||
callback_cat.destroy
|
||||
expect(callback_cat.versions.collect(&:event)).to eq %w(create update destroy)
|
||||
end
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
require 'rails_helper'
|
||||
require Rails.root.join('..', 'custom_json_serializer')
|
||||
|
||||
describe Boolit, :type => :model do
|
||||
describe Boolit, type: :model do
|
||||
it { is_expected.to be_versioned }
|
||||
|
||||
it "has a default scope" do
|
||||
expect(subject.default_scopes).to_not be_empty
|
||||
end
|
||||
|
||||
describe "Versioning", :versioning => true do
|
||||
describe "Versioning", versioning: true do
|
||||
subject { Boolit.create! }
|
||||
before { subject.update_attributes!(:name => FFaker::Name.name) }
|
||||
before { subject.update_attributes!(name: FFaker::Name.name) }
|
||||
|
||||
it "should have versions" do
|
||||
expect(subject.versions.size).to eq(2)
|
||||
|
@ -21,7 +21,7 @@ describe Boolit, :type => :model do
|
|||
end
|
||||
|
||||
context "Instance falls out of default scope" do
|
||||
before { subject.update_attributes!(:scoped => false) }
|
||||
before { subject.update_attributes!(scoped: false) }
|
||||
|
||||
it "is NOT scoped" do
|
||||
expect(Boolit.first).to be_nil
|
||||
|
@ -34,8 +34,8 @@ describe Boolit, :type => :model do
|
|||
context "with `nil` attributes on the live instance" do
|
||||
before do
|
||||
PaperTrail.serializer = CustomJsonSerializer
|
||||
subject.update_attributes!(:name => nil)
|
||||
subject.update_attributes!(:name => FFaker::Name.name)
|
||||
subject.update_attributes!(name: nil)
|
||||
subject.update_attributes!(name: FFaker::Name.name)
|
||||
end
|
||||
after { PaperTrail.serializer = PaperTrail::Serializers::YAML }
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe CallbackModifier, :type => :model do
|
||||
describe CallbackModifier, type: :model do
|
||||
with_versioning do
|
||||
describe 'callback-methods', :versioning => true do
|
||||
describe 'callback-methods', versioning: true do
|
||||
describe 'paper_trail_on_destroy' do
|
||||
it 'should add :destroy to paper_trail_options[:on]' do
|
||||
modifier = NoArgDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = NoArgDestroyModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
expect(modifier.paper_trail_options[:on]).to eq [:destroy]
|
||||
end
|
||||
|
||||
context 'when :before' do
|
||||
it 'should create the version before destroy' do
|
||||
modifier = BeforeDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = BeforeDestroyModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.test_destroy
|
||||
expect(modifier.versions.last.reify).not_to be_flagged_deleted
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ describe CallbackModifier, :type => :model do
|
|||
|
||||
context 'when :after' do
|
||||
it 'should create the version after destroy' do
|
||||
modifier = AfterDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = AfterDestroyModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.test_destroy
|
||||
expect(modifier.versions.last.reify).to be_flagged_deleted
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ describe CallbackModifier, :type => :model do
|
|||
|
||||
context 'when no argument' do
|
||||
it 'should default to before destroy' do
|
||||
modifier = NoArgDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = NoArgDestroyModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.test_destroy
|
||||
expect(modifier.versions.last.reify).not_to be_flagged_deleted
|
||||
end
|
||||
|
@ -36,57 +36,57 @@ describe CallbackModifier, :type => :model do
|
|||
|
||||
describe 'paper_trail_on_update' do
|
||||
it 'should add :update to paper_trail_options[:on]' do
|
||||
modifier = UpdateModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = UpdateModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
expect(modifier.paper_trail_options[:on]).to eq [:update]
|
||||
end
|
||||
|
||||
it 'should create a version' do
|
||||
modifier = UpdateModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier.update_attributes! :some_content => 'modified'
|
||||
modifier = UpdateModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.update_attributes! some_content: 'modified'
|
||||
expect(modifier.versions.last.event).to eq 'update'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'paper_trail_on_create' do
|
||||
it 'should add :create to paper_trail_options[:on]' do
|
||||
modifier = CreateModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = CreateModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
expect(modifier.paper_trail_options[:on]).to eq [:create]
|
||||
end
|
||||
|
||||
it 'should create a version' do
|
||||
modifier = CreateModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = CreateModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
expect(modifier.versions.last.event).to eq 'create'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no callback-method used' do
|
||||
it 'should set paper_trail_options[:on] to [:create, :update, :destroy]' do
|
||||
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = DefaultModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
expect(modifier.paper_trail_options[:on]).to eq [:create, :update, :destroy]
|
||||
end
|
||||
|
||||
it 'should default to track destroy' do
|
||||
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = DefaultModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.destroy
|
||||
expect(modifier.versions.last.event).to eq 'destroy'
|
||||
end
|
||||
|
||||
it 'should default to track update' do
|
||||
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier.update_attributes! :some_content => 'modified'
|
||||
modifier = DefaultModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.update_attributes! some_content: 'modified'
|
||||
expect(modifier.versions.last.event).to eq 'update'
|
||||
end
|
||||
|
||||
it 'should default to track create' do
|
||||
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier = DefaultModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
expect(modifier.versions.last.event).to eq 'create'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when only one callback-method' do
|
||||
it 'does only track the corresponding event' do
|
||||
modifier = CreateModifier.create!(:some_content => FFaker::Lorem.sentence)
|
||||
modifier.update_attributes!(:some_content => 'modified')
|
||||
modifier = CreateModifier.create!(some_content: FFaker::Lorem.sentence)
|
||||
modifier.update_attributes!(some_content: 'modified')
|
||||
modifier.test_destroy
|
||||
expect(modifier.versions.collect(&:event)).to eq ['create']
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Fluxor, :type => :model do
|
||||
describe Fluxor, type: :model do
|
||||
describe '`be_versioned` matcher' do
|
||||
it { is_expected.to_not be_versioned }
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Gadget, :type => :model do
|
||||
describe Gadget, type: :model do
|
||||
it { is_expected.to be_versioned }
|
||||
|
||||
let(:gadget) { Gadget.create!(:name => 'Wrench', :brand => 'Acme') }
|
||||
let(:gadget) { Gadget.create!(name: 'Wrench', brand: 'Acme') }
|
||||
|
||||
describe "updates", :versioning => true do
|
||||
describe "updates", versioning: true do
|
||||
it "should generate a version for updates to `name` attribute" do
|
||||
expect { gadget.update_attribute(:name, 'Hammer').to change{gadget.versions.size}.by(1) }
|
||||
end
|
||||
|
@ -23,10 +23,10 @@ describe Gadget, :type => :model do
|
|||
end
|
||||
|
||||
describe "Methods" do
|
||||
describe "Instance", :versioning => true do
|
||||
describe "Instance", versioning: true do
|
||||
describe "private" do
|
||||
describe '#changed_notably?' do
|
||||
subject { Gadget.new(:created_at => Time.now) }
|
||||
subject { Gadget.new(created_at: Time.now) }
|
||||
|
||||
it { expect(subject.private_methods).to include(:changed_notably?) }
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe JoinedVersion, :type => :model, :versioning => true do
|
||||
describe JoinedVersion, type: :model, versioning: true do
|
||||
it { expect(JoinedVersion.superclass).to be PaperTrail::Version }
|
||||
|
||||
let(:widget) { Widget.create!(:name => FFaker::Name.name) }
|
||||
let(:widget) { Widget.create!(name: FFaker::Name.name) }
|
||||
let(:version) { JoinedVersion.first }
|
||||
|
||||
describe "Scopes" do
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
# table is only created when testing against postgres and ActiveRecord >= 4.
|
||||
if JsonVersion.table_exists?
|
||||
|
||||
describe JsonVersion, :type => :model do
|
||||
describe JsonVersion, type: :model do
|
||||
it "should include the `VersionConcern` module to get base functionality" do
|
||||
expect(JsonVersion).to include(PaperTrail::VersionConcern)
|
||||
end
|
||||
|
@ -15,11 +15,11 @@ if JsonVersion.table_exists?
|
|||
it { expect(JsonVersion).to respond_to(:where_object) }
|
||||
|
||||
it "escapes values" do
|
||||
f = Fruit.create(:name => 'Bobby')
|
||||
f = Fruit.create(name: 'Bobby')
|
||||
expect(
|
||||
f.
|
||||
versions.
|
||||
where_object(:name => "Robert'; DROP TABLE Students;--").
|
||||
where_object(name: "Robert'; DROP TABLE Students;--").
|
||||
count
|
||||
).to eq(0)
|
||||
end
|
||||
|
@ -31,21 +31,21 @@ if JsonVersion.table_exists?
|
|||
end
|
||||
end
|
||||
|
||||
context "valid arguments", :versioning => true do
|
||||
context "valid arguments", versioning: true do
|
||||
let(:fruit_names) { %w(apple orange lemon banana lime coconut strawberry blueberry) }
|
||||
let(:fruit) { Fruit.new }
|
||||
let(:name) { 'pomegranate' }
|
||||
let(:color) { FFaker::Color.name }
|
||||
|
||||
before do
|
||||
fruit.update_attributes!(:name => name)
|
||||
fruit.update_attributes!(:name => fruit_names.sample, :color => color)
|
||||
fruit.update_attributes!(:name => fruit_names.sample, :color => FFaker::Color.name)
|
||||
fruit.update_attributes!(name: name)
|
||||
fruit.update_attributes!(name: fruit_names.sample, color: color)
|
||||
fruit.update_attributes!(name: fruit_names.sample, color: FFaker::Color.name)
|
||||
end
|
||||
|
||||
it "should be able to locate versions according to their `object` contents" do
|
||||
expect(JsonVersion.where_object(:name => name)).to eq([fruit.versions[1]])
|
||||
expect(JsonVersion.where_object(:color => color)).to eq([fruit.versions[2]])
|
||||
expect(JsonVersion.where_object(name: name)).to eq([fruit.versions[1]])
|
||||
expect(JsonVersion.where_object(color: color)).to eq([fruit.versions[2]])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -54,11 +54,11 @@ if JsonVersion.table_exists?
|
|||
it { expect(JsonVersion).to respond_to(:where_object_changes) }
|
||||
|
||||
it "escapes values" do
|
||||
f = Fruit.create(:name => 'Bobby')
|
||||
f = Fruit.create(name: 'Bobby')
|
||||
expect(
|
||||
f.
|
||||
versions.
|
||||
where_object_changes(:name => "Robert'; DROP TABLE Students;--").
|
||||
where_object_changes(name: "Robert'; DROP TABLE Students;--").
|
||||
count
|
||||
).to eq(0)
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ if JsonVersion.table_exists?
|
|||
end
|
||||
end
|
||||
|
||||
context "valid arguments", :versioning => true do
|
||||
context "valid arguments", versioning: true do
|
||||
let(:color) { %w[red green] }
|
||||
let(:fruit) { Fruit.create!(name: name[0]) }
|
||||
let(:name) { %w[banana kiwi mango] }
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
module Kitchen
|
||||
describe Banana, :type => :model do
|
||||
describe Banana, type: :model do
|
||||
it { is_expected.to be_versioned }
|
||||
|
||||
describe '#versions' do
|
||||
it "returns instances of Kitchen::BananaVersion", :versioning => true do
|
||||
it "returns instances of Kitchen::BananaVersion", versioning: true do
|
||||
banana = described_class.create!
|
||||
expect(banana.versions.first).to be_a(Kitchen::BananaVersion)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe NotOnUpdate, :type => :model do
|
||||
describe "#touch_with_version", :versioning => true do
|
||||
describe NotOnUpdate, type: :model do
|
||||
describe "#touch_with_version", versioning: true do
|
||||
let!(:record) { described_class.create! }
|
||||
|
||||
it "should create a version, regardless" do
|
||||
|
|
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
|||
|
||||
# This model is in the test suite soley for the purpose of testing ActiveRecord::Enum,
|
||||
# which is available in ActiveRecord4+ only
|
||||
describe PostWithStatus, :type => :model do
|
||||
describe PostWithStatus, type: :model do
|
||||
if defined?(ActiveRecord::Enum)
|
||||
with_versioning do
|
||||
let(:post) { PostWithStatus.create!(:status => 'draft') }
|
||||
let(:post) { PostWithStatus.create!(status: 'draft') }
|
||||
|
||||
it "should stash the enum value properly in versions" do
|
||||
post.published!
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Skipper, :type => :model do
|
||||
describe Skipper, type: :model do
|
||||
with_versioning do
|
||||
it { is_expected.to be_versioned }
|
||||
|
||||
describe "#update_attributes!", :versioning => true do
|
||||
describe "#update_attributes!", versioning: true do
|
||||
context "updating a skipped attribute" do
|
||||
let(:t1) { Time.zone.local(2015, 7, 15, 20, 34, 0) }
|
||||
let(:t2) { Time.zone.local(2015, 7, 15, 20, 34, 30) }
|
||||
|
||||
it "should not create a version" do
|
||||
skipper = Skipper.create!(:another_timestamp => t1)
|
||||
skipper = Skipper.create!(another_timestamp: t1)
|
||||
expect {
|
||||
skipper.update_attributes!(:another_timestamp => t2)
|
||||
skipper.update_attributes!(another_timestamp: t2)
|
||||
}.to_not change { skipper.versions.length }
|
||||
end
|
||||
end
|
||||
|
@ -25,8 +25,8 @@ describe Skipper, :type => :model do
|
|||
|
||||
context "without preserve (default)" do
|
||||
it "should have no timestamp" do
|
||||
skipper = Skipper.create!(:another_timestamp => t1)
|
||||
skipper.update_attributes!(:another_timestamp => t2, :name => "Foobar")
|
||||
skipper = Skipper.create!(another_timestamp: t1)
|
||||
skipper.update_attributes!(another_timestamp: t2, name: "Foobar")
|
||||
skipper = skipper.versions.last.reify
|
||||
expect(skipper.another_timestamp).to be(nil)
|
||||
end
|
||||
|
@ -34,9 +34,9 @@ describe Skipper, :type => :model do
|
|||
|
||||
context "with preserve" do
|
||||
it "should preserve its timestamp" do
|
||||
skipper = Skipper.create!(:another_timestamp => t1)
|
||||
skipper.update_attributes!(:another_timestamp => t2, :name => "Foobar")
|
||||
skipper = skipper.versions.last.reify(:unversioned_attributes => :preserve)
|
||||
skipper = Skipper.create!(another_timestamp: t1)
|
||||
skipper.update_attributes!(another_timestamp: t2, name: "Foobar")
|
||||
skipper = skipper.versions.last.reify(unversioned_attributes: :preserve)
|
||||
expect(skipper.another_timestamp).to eq(t2)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Thing, :type => :model do
|
||||
describe Thing, type: :model do
|
||||
it { is_expected.to be_versioned }
|
||||
|
||||
describe "should not store object_changes", :versioning => true do
|
||||
let(:thing) { Thing.create(:name =>"pencil") }
|
||||
describe "should not store object_changes", versioning: true do
|
||||
let(:thing) { Thing.create(name: "pencil") }
|
||||
|
||||
it { expect(thing.versions.last.object_changes).to be_nil }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe PaperTrail::Version, :type => :model do
|
||||
describe PaperTrail::Version, type: :model do
|
||||
it "should include the `VersionConcern` module to get base functionality" do
|
||||
expect(PaperTrail::Version).to include(PaperTrail::VersionConcern)
|
||||
end
|
||||
|
@ -13,8 +13,8 @@ describe PaperTrail::Version, :type => :model do
|
|||
it { is_expected.to have_db_column(:object).of_type(:text) }
|
||||
it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
|
||||
|
||||
describe "object_changes column", :versioning => true do
|
||||
let(:widget) { Widget.create!(:name => 'Dashboard') }
|
||||
describe "object_changes column", versioning: true do
|
||||
let(:widget) { Widget.create!(name: 'Dashboard') }
|
||||
let(:value) { widget.versions.last.object_changes }
|
||||
|
||||
context "serializer is YAML" do
|
||||
|
@ -56,12 +56,12 @@ describe PaperTrail::Version, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
context "Has previous version", :versioning => true do
|
||||
context "Has previous version", versioning: true do
|
||||
let(:name) { FFaker::Name.name }
|
||||
let(:widget) { Widget.create!(:name => FFaker::Name.name) }
|
||||
let(:widget) { Widget.create!(name: FFaker::Name.name) }
|
||||
before do
|
||||
widget.versions.first.update_attributes!(:whodunnit => name)
|
||||
widget.update_attributes!(:name => FFaker::Name.first_name)
|
||||
widget.versions.first.update_attributes!(whodunnit: name)
|
||||
widget.update_attributes!(name: FFaker::Name.first_name)
|
||||
end
|
||||
subject { widget.versions.last }
|
||||
|
||||
|
@ -92,7 +92,7 @@ describe PaperTrail::Version, :type => :model do
|
|||
describe '#terminator' do
|
||||
it { is_expected.to respond_to(:terminator) }
|
||||
|
||||
let(:attributes) { {:whodunnit => FFaker::Name.first_name} }
|
||||
let(:attributes) { {whodunnit: FFaker::Name.first_name} }
|
||||
|
||||
it "is an alias for the `whodunnit` attribute" do
|
||||
expect(subject.terminator).to eq(attributes[:whodunnit])
|
||||
|
@ -153,15 +153,15 @@ describe PaperTrail::Version, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
context "valid arguments", :versioning => true do
|
||||
context "valid arguments", versioning: true do
|
||||
let(:widget) { Widget.new }
|
||||
let(:name) { FFaker::Name.first_name }
|
||||
let(:int) { rand(10) + 1 }
|
||||
|
||||
before do
|
||||
widget.update_attributes!(:name => name, :an_integer => int)
|
||||
widget.update_attributes!(:name => 'foobar', :an_integer => 100)
|
||||
widget.update_attributes!(:name => FFaker::Name.last_name, :an_integer => 15)
|
||||
widget.update_attributes!(name: name, an_integer: int)
|
||||
widget.update_attributes!(name: 'foobar', an_integer: 100)
|
||||
widget.update_attributes!(name: FFaker::Name.last_name, an_integer: 15)
|
||||
end
|
||||
|
||||
context "`serializer == YAML`" do
|
||||
|
@ -171,10 +171,10 @@ describe PaperTrail::Version, :type => :model do
|
|||
|
||||
it "should be able to locate versions according to their `object` contents" do
|
||||
expect(
|
||||
PaperTrail::Version.where_object(:name => name)
|
||||
PaperTrail::Version.where_object(name: name)
|
||||
).to eq([widget.versions[1]])
|
||||
expect(
|
||||
PaperTrail::Version.where_object(:an_integer => 100)
|
||||
PaperTrail::Version.where_object(an_integer: 100)
|
||||
).to eq([widget.versions[2]])
|
||||
end
|
||||
end
|
||||
|
@ -190,10 +190,10 @@ describe PaperTrail::Version, :type => :model do
|
|||
|
||||
it "should be able to locate versions according to their `object` contents" do
|
||||
expect(
|
||||
PaperTrail::Version.where_object(:name => name)
|
||||
PaperTrail::Version.where_object(name: name)
|
||||
).to eq([widget.versions[1]])
|
||||
expect(
|
||||
PaperTrail::Version.where_object(:an_integer => 100)
|
||||
PaperTrail::Version.where_object(an_integer: 100)
|
||||
).to eq([widget.versions[2]])
|
||||
end
|
||||
|
||||
|
@ -216,15 +216,15 @@ describe PaperTrail::Version, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
context "valid arguments", :versioning => true do
|
||||
context "valid arguments", versioning: true do
|
||||
let(:widget) { Widget.new }
|
||||
let(:name) { FFaker::Name.first_name }
|
||||
let(:int) { rand(5) + 2 }
|
||||
|
||||
before do
|
||||
widget.update_attributes!(:name => name, :an_integer => 0)
|
||||
widget.update_attributes!(:name => 'foobar', :an_integer => 77)
|
||||
widget.update_attributes!(:name => FFaker::Name.last_name, :an_integer => int)
|
||||
widget.update_attributes!(name: name, an_integer: 0)
|
||||
widget.update_attributes!(name: 'foobar', an_integer: 77)
|
||||
widget.update_attributes!(name: FFaker::Name.last_name, an_integer: int)
|
||||
end
|
||||
|
||||
context "YAML serializer" do
|
||||
|
@ -232,19 +232,19 @@ describe PaperTrail::Version, :type => :model do
|
|||
|
||||
it "locates versions according to their `object_changes` contents" do
|
||||
expect(
|
||||
widget.versions.where_object_changes(:name => name)
|
||||
widget.versions.where_object_changes(name: name)
|
||||
).to eq(widget.versions[0..1])
|
||||
expect(
|
||||
widget.versions.where_object_changes(:an_integer => 77)
|
||||
widget.versions.where_object_changes(an_integer: 77)
|
||||
).to eq(widget.versions[1..2])
|
||||
expect(
|
||||
widget.versions.where_object_changes(:an_integer => int)
|
||||
widget.versions.where_object_changes(an_integer: int)
|
||||
).to eq([widget.versions.last])
|
||||
end
|
||||
|
||||
it "handles queries for multiple attributes" do
|
||||
expect(
|
||||
widget.versions.where_object_changes(:an_integer => 77, :name => 'foobar')
|
||||
widget.versions.where_object_changes(an_integer: 77, name: 'foobar')
|
||||
).to eq(widget.versions[1..2])
|
||||
end
|
||||
end
|
||||
|
@ -255,19 +255,19 @@ describe PaperTrail::Version, :type => :model do
|
|||
|
||||
it "locates versions according to their `object_changes` contents" do
|
||||
expect(
|
||||
widget.versions.where_object_changes(:name => name)
|
||||
widget.versions.where_object_changes(name: name)
|
||||
).to eq(widget.versions[0..1])
|
||||
expect(
|
||||
widget.versions.where_object_changes(:an_integer => 77)
|
||||
widget.versions.where_object_changes(an_integer: 77)
|
||||
).to eq(widget.versions[1..2])
|
||||
expect(
|
||||
widget.versions.where_object_changes(:an_integer => int)
|
||||
widget.versions.where_object_changes(an_integer: int)
|
||||
).to eq([widget.versions.last])
|
||||
end
|
||||
|
||||
it "handles queries for multiple attributes" do
|
||||
expect(
|
||||
widget.versions.where_object_changes(:an_integer => 77, :name => 'foobar')
|
||||
widget.versions.where_object_changes(an_integer: 77, name: 'foobar')
|
||||
).to eq(widget.versions[1..2])
|
||||
end
|
||||
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Widget, :type => :model do
|
||||
describe Widget, type: :model do
|
||||
describe '`be_versioned` matcher' do
|
||||
it { is_expected.to be_versioned }
|
||||
end
|
||||
|
||||
let(:widget) { Widget.create! :name => 'Bob', :an_integer => 1 }
|
||||
let(:widget) { Widget.create! name: 'Bob', an_integer: 1 }
|
||||
|
||||
describe '`have_a_version_with` matcher', :versioning => true do
|
||||
describe '`have_a_version_with` matcher', versioning: true do
|
||||
before do
|
||||
widget.update_attributes!(:name => 'Leonard', :an_integer => 1 )
|
||||
widget.update_attributes!(:name => 'Tom')
|
||||
widget.update_attributes!(:name => 'Bob')
|
||||
widget.update_attributes!(name: 'Leonard', an_integer: 1 )
|
||||
widget.update_attributes!(name: 'Tom')
|
||||
widget.update_attributes!(name: 'Bob')
|
||||
end
|
||||
|
||||
it "is possible to do assertions on versions" do
|
||||
expect(widget).to have_a_version_with :name => 'Leonard', :an_integer => 1
|
||||
expect(widget).to have_a_version_with :an_integer => 1
|
||||
expect(widget).to have_a_version_with :name => 'Tom'
|
||||
expect(widget).to have_a_version_with name: 'Leonard', an_integer: 1
|
||||
expect(widget).to have_a_version_with an_integer: 1
|
||||
expect(widget).to have_a_version_with name: 'Tom'
|
||||
end
|
||||
end
|
||||
|
||||
describe "versioning option" do
|
||||
context "enabled", :versioning => true do
|
||||
context "enabled", versioning: true do
|
||||
it "should enable versioning" do
|
||||
expect(widget.versions.size).to eq(1)
|
||||
end
|
||||
|
@ -35,10 +35,10 @@ describe Widget, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "Callbacks", :versioning => true do
|
||||
describe "Callbacks", versioning: true do
|
||||
describe :before_save do
|
||||
context ':on => :update' do
|
||||
before { widget.update_attributes!(:name => 'Foobar') }
|
||||
before { widget.update_attributes!(name: 'Foobar') }
|
||||
|
||||
subject { widget.versions.last.reify }
|
||||
|
||||
|
@ -52,7 +52,7 @@ describe Widget, :type => :model do
|
|||
end
|
||||
|
||||
describe :after_create do
|
||||
let(:widget) { Widget.create!(:name => 'Foobar', :created_at => Time.now - 1.week) }
|
||||
let(:widget) { Widget.create!(name: 'Foobar', created_at: Time.now - 1.week) }
|
||||
|
||||
it "corresponding version should use the widget's `updated_at`" do
|
||||
expect(widget.versions.last.created_at.to_i).to eq(widget.updated_at.to_i)
|
||||
|
@ -60,7 +60,7 @@ describe Widget, :type => :model do
|
|||
end
|
||||
|
||||
describe :after_update do
|
||||
before { widget.update_attributes!(:name => 'Foobar', :updated_at => Time.now + 1.week) }
|
||||
before { widget.update_attributes!(name: 'Foobar', updated_at: Time.now + 1.week) }
|
||||
|
||||
subject { widget.versions.last.reify }
|
||||
|
||||
|
@ -95,8 +95,8 @@ describe Widget, :type => :model do
|
|||
before do
|
||||
begin
|
||||
widget.transaction do
|
||||
widget.update_attributes!(:name => rolled_back_name)
|
||||
widget.update_attributes!(:name => Widget::EXCLUDED_NAME)
|
||||
widget.update_attributes!(name: rolled_back_name)
|
||||
widget.update_attributes!(name: Widget::EXCLUDED_NAME)
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
widget.reload
|
||||
|
@ -113,7 +113,7 @@ describe Widget, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "Association", :versioning => true do
|
||||
describe "Association", versioning: true do
|
||||
describe "sort order" do
|
||||
it "should sort by the timestamp order from the `VersionConcern`" do
|
||||
expect(widget.versions.to_sql).to eq(
|
||||
|
@ -123,7 +123,7 @@ describe Widget, :type => :model do
|
|||
end
|
||||
|
||||
describe "Methods" do
|
||||
describe "Instance", :versioning => true do
|
||||
describe "Instance", versioning: true do
|
||||
describe '#paper_trail_originator' do
|
||||
it { is_expected.to respond_to(:paper_trail_originator) }
|
||||
|
||||
|
@ -137,16 +137,16 @@ describe Widget, :type => :model do
|
|||
|
||||
it "should return the originator for the model at a given state" do
|
||||
expect(widget.paper_trail_originator).to eq(orig_name)
|
||||
widget.whodunnit(new_name) { |w| w.update_attributes(:name => 'Elizabeth') }
|
||||
widget.whodunnit(new_name) { |w| w.update_attributes(name: 'Elizabeth') }
|
||||
expect(widget.paper_trail_originator).to eq(new_name)
|
||||
end
|
||||
end
|
||||
|
||||
context "accessed from a reified model instance" do
|
||||
before do
|
||||
widget.update_attributes(:name => 'Andy')
|
||||
widget.update_attributes(name: 'Andy')
|
||||
PaperTrail.whodunnit = new_name
|
||||
widget.update_attributes(:name => 'Elizabeth')
|
||||
widget.update_attributes(name: 'Elizabeth')
|
||||
end
|
||||
|
||||
context "default behavior (no `options[:dup]` option passed in)" do
|
||||
|
@ -162,7 +162,7 @@ describe Widget, :type => :model do
|
|||
end
|
||||
|
||||
context "creating a new instance (`options[:dup] == true`)" do
|
||||
let(:reified_widget) { widget.versions[1].reify(:dup => true) }
|
||||
let(:reified_widget) { widget.versions[1].reify(dup: true) }
|
||||
|
||||
it "should return the appropriate originator" do
|
||||
expect(reified_widget.paper_trail_originator).to eq(orig_name)
|
||||
|
@ -232,14 +232,14 @@ describe Widget, :type => :model do
|
|||
it "should modify value of `PaperTrail.whodunnit` while executing the block" do
|
||||
widget.whodunnit(new_name) do
|
||||
expect(PaperTrail.whodunnit).to eq(new_name)
|
||||
widget.update_attributes(:name => 'Elizabeth')
|
||||
widget.update_attributes(name: 'Elizabeth')
|
||||
end
|
||||
expect(widget.versions.last.whodunnit).to eq(new_name)
|
||||
end
|
||||
|
||||
context "after executing the block" do
|
||||
it "reverts value of whodunnit to previous value" do
|
||||
widget.whodunnit(new_name) { |w| w.update_attributes(:name => 'Elizabeth') }
|
||||
widget.whodunnit(new_name) { |w| w.update_attributes(name: 'Elizabeth') }
|
||||
expect(PaperTrail.whodunnit).to eq(orig_name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe PaperTrail, :type => :module, :versioning => true do
|
||||
describe PaperTrail, type: :module, versioning: true do
|
||||
describe '#config' do
|
||||
it { is_expected.to respond_to(:config) }
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ describe PaperTrail::VersionConcern do
|
|||
expect(Bar::Document.version_class_name).to eq('Bar::Version')
|
||||
end
|
||||
|
||||
describe 'persistence', :versioning => true do
|
||||
describe 'persistence', versioning: true do
|
||||
before do
|
||||
@foo_doc = Foo::Document.create!(:name => 'foobar')
|
||||
@bar_doc = Bar::Document.create!(:name => 'raboof')
|
||||
@foo_doc = Foo::Document.create!(name: 'foobar')
|
||||
@bar_doc = Bar::Document.create!(name: 'raboof')
|
||||
end
|
||||
|
||||
it 'should store versions in the correct corresponding db location' do
|
||||
|
|
|
@ -23,7 +23,7 @@ describe PaperTrail do
|
|||
end
|
||||
end
|
||||
|
||||
context '`versioning: true`', :versioning => true do
|
||||
context '`versioning: true`', versioning: true do
|
||||
it 'should have versioning on by default' do
|
||||
expect(PaperTrail).to be_enabled
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ describe PaperTrail do
|
|||
end
|
||||
|
||||
describe :controller_info do
|
||||
before(:all) { ::PaperTrail.controller_info = {:foo => 'bar'} }
|
||||
before(:all) { ::PaperTrail.controller_info = {foo: 'bar'} }
|
||||
|
||||
it "should get set to an empty hash before each test" do
|
||||
expect(PaperTrail.controller_info).to eq({})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe "Articles management", :type => :request, :order => :defined do
|
||||
let(:valid_params) { { :article => { :title => 'Doh', :content => FFaker::Lorem.sentence } } }
|
||||
describe "Articles management", type: :request, order: :defined do
|
||||
let(:valid_params) { { article: { title: 'Doh', content: FFaker::Lorem.sentence } } }
|
||||
|
||||
context "versioning disabled" do
|
||||
specify { expect(PaperTrail).not_to be_enabled }
|
||||
|
|
|
@ -24,7 +24,7 @@ module Foo
|
|||
end
|
||||
|
||||
class Document < Base
|
||||
has_paper_trail :class_name => 'Foo::Version'
|
||||
has_paper_trail class_name: 'Foo::Version'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ module Bar
|
|||
end
|
||||
|
||||
class Document < Base
|
||||
has_paper_trail :class_name => 'Bar::Version'
|
||||
has_paper_trail class_name: 'Bar::Version'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def info_for_paper_trail
|
||||
{:ip => request.remote_ip, :user_agent => request.user_agent}
|
||||
{ip: request.remote_ip, user_agent: request.user_agent}
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
class Article < ActiveRecord::Base
|
||||
has_paper_trail(
|
||||
:ignore => [
|
||||
ignore: [
|
||||
:title, {
|
||||
:abstract => Proc.new { |obj|
|
||||
abstract: Proc.new { |obj|
|
||||
['ignore abstract', 'Other abstract'].include? obj.abstract
|
||||
}
|
||||
}
|
||||
],
|
||||
:only => [:content, { :abstract => Proc.new { |obj| obj.abstract.present? } } ],
|
||||
:skip => [:file_upload],
|
||||
:meta => {
|
||||
:answer => 42,
|
||||
:action => :action_data_provider_method,
|
||||
:question => Proc.new { "31 + 11 = #{31 + 11}" },
|
||||
:article_id => Proc.new { |article| article.id },
|
||||
:title => :title
|
||||
only: [:content, { abstract: Proc.new { |obj| obj.abstract.present? } } ],
|
||||
skip: [:file_upload],
|
||||
meta: {
|
||||
answer: 42,
|
||||
action: :action_data_provider_method,
|
||||
question: Proc.new { "31 + 11 = #{31 + 11}" },
|
||||
article_id: Proc.new { |article| article.id },
|
||||
title: :title
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class Book < ActiveRecord::Base
|
||||
has_many :authorships, :dependent => :destroy
|
||||
has_many :authors, :through => :authorships, :source => :person
|
||||
has_many :authorships, dependent: :destroy
|
||||
has_many :authors, through: :authorships, source: :person
|
||||
|
||||
has_many :editorships, :dependent => :destroy
|
||||
has_many :editors, :through => :editorships
|
||||
has_many :editorships, dependent: :destroy
|
||||
has_many :editors, through: :editorships
|
||||
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Boolit < ActiveRecord::Base
|
||||
default_scope { where(:scoped => true) }
|
||||
default_scope { where(scoped: true) }
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CallbackModifier < ActiveRecord::Base
|
||||
has_paper_trail :on => []
|
||||
has_paper_trail on: []
|
||||
|
||||
def test_destroy
|
||||
transaction do
|
||||
|
@ -16,27 +16,27 @@ class CallbackModifier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
class BeforeDestroyModifier < CallbackModifier
|
||||
has_paper_trail :on => []
|
||||
has_paper_trail on: []
|
||||
paper_trail_on_destroy :before
|
||||
end
|
||||
|
||||
class AfterDestroyModifier < CallbackModifier
|
||||
has_paper_trail :on => []
|
||||
has_paper_trail on: []
|
||||
paper_trail_on_destroy :after
|
||||
end
|
||||
|
||||
class NoArgDestroyModifier < CallbackModifier
|
||||
has_paper_trail :on => []
|
||||
has_paper_trail on: []
|
||||
paper_trail_on_destroy
|
||||
end
|
||||
|
||||
class UpdateModifier < CallbackModifier
|
||||
has_paper_trail :on => []
|
||||
has_paper_trail on: []
|
||||
paper_trail_on_update
|
||||
end
|
||||
|
||||
class CreateModifier < CallbackModifier
|
||||
has_paper_trail :on => []
|
||||
has_paper_trail on: []
|
||||
paper_trail_on_create
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class Chapter < ActiveRecord::Base
|
||||
has_many :sections, :dependent => :destroy
|
||||
has_many :paragraphs, :through => :sections
|
||||
has_many :sections, dependent: :destroy
|
||||
has_many :paragraphs, through: :sections
|
||||
|
||||
has_many :quotations, :dependent => :destroy
|
||||
has_many :citations, :through => :quotations
|
||||
has_many :quotations, dependent: :destroy
|
||||
has_many :citations, through: :quotations
|
||||
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Customer < ActiveRecord::Base
|
||||
has_many :orders, :dependent => :destroy
|
||||
has_many :orders, dependent: :destroy
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Document < ActiveRecord::Base
|
||||
has_paper_trail :versions => :paper_trail_versions,
|
||||
:on => [:create, :update]
|
||||
has_paper_trail versions: :paper_trail_versions,
|
||||
on: [:create, :update]
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# to demonstrate a has_through association that does not have paper_trail enabled
|
||||
class Editor < ActiveRecord::Base
|
||||
has_many :editorships, :dependent => :destroy
|
||||
has_many :editorships, dependent: :destroy
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Fruit < ActiveRecord::Base
|
||||
if ENV['DB'] == 'postgres' || JsonVersion.table_exists?
|
||||
has_paper_trail :class_name => 'JsonVersion'
|
||||
has_paper_trail class_name: 'JsonVersion'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Gadget < ActiveRecord::Base
|
||||
has_paper_trail :ignore => :brand
|
||||
has_paper_trail ignore: :brand
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module Kitchen
|
||||
class Banana < ActiveRecord::Base
|
||||
has_paper_trail :class_name => "Kitchen::BananaVersion"
|
||||
has_paper_trail class_name: "Kitchen::BananaVersion"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class LegacyWidget < ActiveRecord::Base
|
||||
has_paper_trail :ignore => :version,
|
||||
:version => 'custom_version'
|
||||
has_paper_trail ignore: :version,
|
||||
version: 'custom_version'
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class LineItem < ActiveRecord::Base
|
||||
belongs_to :order, :dependent => :destroy
|
||||
belongs_to :order, dependent: :destroy
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# This model does not record versions when updated.
|
||||
class NotOnUpdate < ActiveRecord::Base
|
||||
has_paper_trail :on => [:create, :destroy]
|
||||
has_paper_trail on: [:create, :destroy]
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Person < ActiveRecord::Base
|
||||
has_many :authorships, :dependent => :destroy
|
||||
has_many :books, :through => :authorships
|
||||
has_many :authorships, dependent: :destroy
|
||||
has_many :books, through: :authorships
|
||||
has_paper_trail
|
||||
|
||||
# Convert strings to TimeZone objects when assigned
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Post < ActiveRecord::Base
|
||||
has_paper_trail :class_name => "PostVersion"
|
||||
has_paper_trail class_name: "PostVersion"
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ class PostWithStatus < ActiveRecord::Base
|
|||
|
||||
# ActiveRecord::Enum is only supported in AR4.1+
|
||||
if defined?(ActiveRecord::Enum)
|
||||
enum :status => { :draft => 0, :published => 1, :archived => 2 }
|
||||
enum status: { draft: 0, published: 1, archived: 2 }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Quotation < ActiveRecord::Base
|
||||
belongs_to :chapter
|
||||
has_many :citations, :dependent => :destroy
|
||||
has_many :citations, dependent: :destroy
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Section < ActiveRecord::Base
|
||||
belongs_to :chapter
|
||||
has_many :paragraphs, :dependent => :destroy
|
||||
has_many :paragraphs, dependent: :destroy
|
||||
|
||||
has_paper_trail
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Skipper < ActiveRecord::Base
|
||||
has_paper_trail(
|
||||
:ignore => [:created_at],
|
||||
:skip => [:another_timestamp]
|
||||
ignore: [:created_at],
|
||||
skip: [:another_timestamp]
|
||||
)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ class Song < ActiveRecord::Base
|
|||
# override attributes hashes like some libraries do
|
||||
def attributes_with_name
|
||||
if name
|
||||
attributes_without_name.merge(:name => name)
|
||||
attributes_without_name.merge(name: name)
|
||||
else
|
||||
attributes_without_name
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ class Song < ActiveRecord::Base
|
|||
|
||||
def changed_attributes_with_name
|
||||
if name
|
||||
changed_attributes_without_name.merge(:name => name)
|
||||
changed_attributes_without_name.merge(name: name)
|
||||
else
|
||||
changed_attributes_without_name
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Thing < ActiveRecord::Base
|
||||
has_paper_trail :save_changes => false
|
||||
has_paper_trail save_changes: false
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
class Translation < ActiveRecord::Base
|
||||
has_paper_trail :if => Proc.new { |t| t.language_code == 'US' },
|
||||
:unless => Proc.new { |t| t.type == 'DRAFT' }
|
||||
has_paper_trail if: Proc.new { |t| t.language_code == 'US' },
|
||||
unless: Proc.new { |t| t.type == 'DRAFT' }
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Whatchamajigger < ActiveRecord::Base
|
||||
has_paper_trail
|
||||
belongs_to :owner, :polymorphic => true
|
||||
belongs_to :owner, polymorphic: true
|
||||
end
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
class Widget < ActiveRecord::Base
|
||||
has_paper_trail
|
||||
has_one :wotsit
|
||||
has_many :whatchamajiggers, :as => :owner
|
||||
has_many :whatchamajiggers, as: :owner
|
||||
|
||||
EXCLUDED_NAME = 'Biglet'
|
||||
|
||||
validates :name, :exclusion => { :in => [EXCLUDED_NAME] }
|
||||
validates :name, exclusion: { in: [EXCLUDED_NAME] }
|
||||
|
||||
# `has_many` syntax for specifying order uses a lambda in Rails 4
|
||||
if ::ActiveRecord::VERSION::MAJOR >= 4
|
||||
has_many :fluxors, lambda { order(:name) }
|
||||
else
|
||||
has_many :fluxors, :order => :name
|
||||
has_many :fluxors, order: :name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
||||
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
||||
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Dummy::Application.routes.draw do
|
||||
resources :articles, :only => [:create]
|
||||
resources :widgets, :only => [:create, :update, :destroy]
|
||||
resources :articles, only: [:create]
|
||||
resources :widgets, only: [:create, :update, :destroy]
|
||||
end
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
class SetUpTestTables < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :skippers, :force => true do |t|
|
||||
create_table :skippers, force: true do |t|
|
||||
t.string :name
|
||||
t.datetime :another_timestamp
|
||||
t.timestamps :null => true
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
create_table :widgets, :force => true do |t|
|
||||
create_table :widgets, force: true do |t|
|
||||
t.string :name
|
||||
t.text :a_text
|
||||
t.integer :an_integer
|
||||
t.float :a_float
|
||||
t.decimal :a_decimal, :precision => 6, :scale => 4
|
||||
t.decimal :a_decimal, precision: 6, scale: 4
|
||||
t.datetime :a_datetime
|
||||
t.time :a_time
|
||||
t.date :a_date
|
||||
t.boolean :a_boolean
|
||||
t.string :sacrificial_column
|
||||
t.string :type
|
||||
t.timestamps :null => true
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
create_table :versions, :force => true do |t|
|
||||
t.string :item_type, :null => false
|
||||
t.integer :item_id, :null => false
|
||||
t.string :event, :null => false
|
||||
create_table :versions, force: true do |t|
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.string :whodunnit
|
||||
t.text :object
|
||||
t.text :object_changes
|
||||
|
@ -46,18 +46,18 @@ class SetUpTestTables < ActiveRecord::Migration
|
|||
|
||||
create_table :version_associations do |t|
|
||||
t.integer :version_id
|
||||
t.string :foreign_key_name, :null => false
|
||||
t.string :foreign_key_name, null: false
|
||||
t.integer :foreign_key_id
|
||||
end
|
||||
add_index :version_associations, [:version_id]
|
||||
add_index :version_associations,
|
||||
[:foreign_key_name, :foreign_key_id],
|
||||
:name => 'index_version_associations_on_foreign_key'
|
||||
name: 'index_version_associations_on_foreign_key'
|
||||
|
||||
create_table :post_versions, :force => true do |t|
|
||||
t.string :item_type, :null => false
|
||||
t.integer :item_id, :null => false
|
||||
t.string :event, :null => false
|
||||
create_table :post_versions, force: true do |t|
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.string :whodunnit
|
||||
t.text :object
|
||||
t.datetime :created_at
|
||||
|
@ -69,10 +69,10 @@ class SetUpTestTables < ActiveRecord::Migration
|
|||
add_index :post_versions, [:item_type, :item_id]
|
||||
|
||||
if ENV['DB'] == 'postgres' && ::ActiveRecord::VERSION::MAJOR >= 4
|
||||
create_table :json_versions, :force => true do |t|
|
||||
t.string :item_type, :null => false
|
||||
t.integer :item_id, :null => false
|
||||
t.string :event, :null => false
|
||||
create_table :json_versions, force: true do |t|
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.string :whodunnit
|
||||
t.json :object
|
||||
t.json :object_changes
|
||||
|
@ -81,163 +81,163 @@ class SetUpTestTables < ActiveRecord::Migration
|
|||
add_index :json_versions, [:item_type, :item_id]
|
||||
end
|
||||
|
||||
create_table :not_on_updates, :force => true do |t|
|
||||
t.timestamps :null => true
|
||||
create_table :not_on_updates, force: true do |t|
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
create_table :bananas, :force => true do |t|
|
||||
t.timestamps :null => true
|
||||
create_table :bananas, force: true do |t|
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
create_table :banana_versions, :force => true do |t|
|
||||
t.string :item_type, :null => false
|
||||
t.integer :item_id, :null => false
|
||||
t.string :event, :null => false
|
||||
create_table :banana_versions, force: true do |t|
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.string :whodunnit
|
||||
t.text :object
|
||||
t.datetime :created_at
|
||||
end
|
||||
add_index :banana_versions, [:item_type, :item_id]
|
||||
|
||||
create_table :wotsits, :force => true do |t|
|
||||
create_table :wotsits, force: true do |t|
|
||||
t.integer :widget_id
|
||||
t.string :name
|
||||
t.timestamps :null => true
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
create_table :fluxors, :force => true do |t|
|
||||
create_table :fluxors, force: true do |t|
|
||||
t.integer :widget_id
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :whatchamajiggers, :force => true do |t|
|
||||
create_table :whatchamajiggers, force: true do |t|
|
||||
t.string :owner_type
|
||||
t.integer :owner_id
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :articles, :force => true do |t|
|
||||
create_table :articles, force: true do |t|
|
||||
t.string :title
|
||||
t.string :content
|
||||
t.string :abstract
|
||||
t.string :file_upload
|
||||
end
|
||||
|
||||
create_table :books, :force => true do |t|
|
||||
create_table :books, force: true do |t|
|
||||
t.string :title
|
||||
end
|
||||
|
||||
create_table :authorships, :force => true do |t|
|
||||
create_table :authorships, force: true do |t|
|
||||
t.integer :book_id
|
||||
t.integer :person_id
|
||||
end
|
||||
|
||||
create_table :people, :force => true do |t|
|
||||
create_table :people, force: true do |t|
|
||||
t.string :name
|
||||
t.string :time_zone
|
||||
end
|
||||
|
||||
create_table :editorships, :force => true do |t|
|
||||
create_table :editorships, force: true do |t|
|
||||
t.integer :book_id
|
||||
t.integer :editor_id
|
||||
end
|
||||
|
||||
create_table :editors, :force => true do |t|
|
||||
create_table :editors, force: true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :songs, :force => true do |t|
|
||||
create_table :songs, force: true do |t|
|
||||
t.integer :length
|
||||
end
|
||||
|
||||
create_table :posts, :force => true do |t|
|
||||
create_table :posts, force: true do |t|
|
||||
t.string :title
|
||||
t.string :content
|
||||
end
|
||||
|
||||
create_table :post_with_statuses, :force => true do |t|
|
||||
create_table :post_with_statuses, force: true do |t|
|
||||
t.integer :status
|
||||
end
|
||||
|
||||
create_table :animals, :force => true do |t|
|
||||
create_table :animals, force: true do |t|
|
||||
t.string :name
|
||||
t.string :species # single table inheritance column
|
||||
end
|
||||
|
||||
create_table :documents, :force => true do |t|
|
||||
create_table :documents, force: true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :legacy_widgets, :force => true do |t|
|
||||
create_table :legacy_widgets, force: true do |t|
|
||||
t.string :name
|
||||
t.integer :version
|
||||
end
|
||||
|
||||
create_table :things, :force => true do |t|
|
||||
create_table :things, force: true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :translations, :force => true do |t|
|
||||
create_table :translations, force: true do |t|
|
||||
t.string :headline
|
||||
t.string :content
|
||||
t.string :language_code
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :gadgets, :force => true do |t|
|
||||
create_table :gadgets, force: true do |t|
|
||||
t.string :name
|
||||
t.string :brand
|
||||
t.timestamps :null => true
|
||||
t.timestamps null: true
|
||||
end
|
||||
|
||||
create_table :customers, :force => true do |t|
|
||||
create_table :customers, force: true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :orders, :force => true do |t|
|
||||
create_table :orders, force: true do |t|
|
||||
t.integer :customer_id
|
||||
t.string :order_date
|
||||
end
|
||||
|
||||
create_table :line_items, :force => true do |t|
|
||||
create_table :line_items, force: true do |t|
|
||||
t.integer :order_id
|
||||
t.string :product
|
||||
end
|
||||
|
||||
create_table :fruits, :force => true do |t|
|
||||
create_table :fruits, force: true do |t|
|
||||
t.string :name
|
||||
t.string :color
|
||||
end
|
||||
|
||||
create_table :boolits, :force => true do |t|
|
||||
create_table :boolits, force: true do |t|
|
||||
t.string :name
|
||||
t.boolean :scoped, :default => true
|
||||
t.boolean :scoped, default: true
|
||||
end
|
||||
|
||||
create_table :callback_modifiers, :force => true do |t|
|
||||
create_table :callback_modifiers, force: true do |t|
|
||||
t.string :some_content
|
||||
t.boolean :deleted, :default => false
|
||||
t.boolean :deleted, default: false
|
||||
end
|
||||
|
||||
create_table :chapters, :force => true do |t|
|
||||
create_table :chapters, force: true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :sections, :force => true do |t|
|
||||
create_table :sections, force: true do |t|
|
||||
t.integer :chapter_id
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :paragraphs, :force => true do |t|
|
||||
create_table :paragraphs, force: true do |t|
|
||||
t.integer :section_id
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :quotations, :force => true do |t|
|
||||
create_table :quotations, force: true do |t|
|
||||
t.integer :chapter_id
|
||||
end
|
||||
|
||||
create_table :citations, :force => true do |t|
|
||||
create_table :citations, force: true do |t|
|
||||
t.integer :quotation_id
|
||||
end
|
||||
end
|
||||
|
@ -259,12 +259,12 @@ class SetUpTestTables < ActiveRecord::Migration
|
|||
drop_table :whatchamajiggers
|
||||
drop_table :fluxors
|
||||
drop_table :wotsits
|
||||
remove_index :post_versions, :column => [:item_type, :item_id]
|
||||
remove_index :post_versions, column: [:item_type, :item_id]
|
||||
drop_table :post_versions
|
||||
remove_index :versions, :column => [:item_type, :item_id]
|
||||
remove_index :versions, column: [:item_type, :item_id]
|
||||
drop_table :versions
|
||||
if JsonVersion.table_exists?
|
||||
remove_index :json_versions, :column => [:item_type, :item_id]
|
||||
remove_index :json_versions, column: [:item_type, :item_id]
|
||||
drop_table :json_versions
|
||||
end
|
||||
drop_table :widgets
|
||||
|
@ -281,8 +281,8 @@ class SetUpTestTables < ActiveRecord::Migration
|
|||
drop_table :chapters
|
||||
drop_table :sections
|
||||
drop_table :paragraphs
|
||||
remove_index :version_associations, :column => [:version_id]
|
||||
remove_index :version_associations, :name => 'index_version_associations_on_foreign_key'
|
||||
remove_index :version_associations, column: [:version_id]
|
||||
remove_index :version_associations, name: 'index_version_associations_on_foreign_key'
|
||||
drop_table :version_associations
|
||||
drop_table :callback_modifiers
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ class ControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
test 'update' do
|
||||
w = Widget.create :name => 'Duvel'
|
||||
w = Widget.create name: 'Duvel'
|
||||
assert_equal 1, w.versions.length
|
||||
put :update, params_wrapper(id: w.id, widget: { name: 'Bugle' })
|
||||
widget = assigns(:widget)
|
||||
|
@ -59,7 +59,7 @@ class ControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
test 'destroy' do
|
||||
w = Widget.create :name => 'Roundel'
|
||||
w = Widget.create name: 'Roundel'
|
||||
assert_equal 1, w.versions.length
|
||||
delete :destroy, params_wrapper(id: w.id)
|
||||
widget = assigns(:widget)
|
||||
|
|
|
@ -18,7 +18,7 @@ if Gem::Version.new(Rack.release) < Gem::Version.new("2.0.0.alpha")
|
|||
register PaperTrail::Sinatra
|
||||
|
||||
get '/test' do
|
||||
Widget.create!(:name => 'foo')
|
||||
Widget.create!(name: 'foo')
|
||||
'Hello'
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ if Gem::Version.new(Rack.release) < Gem::Version.new("2.0.0.alpha")
|
|||
register PaperTrail::Sinatra
|
||||
|
||||
get '/test' do
|
||||
Widget.create!(:name => 'bar')
|
||||
Widget.create!(name: 'bar')
|
||||
'Hai'
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class PaperTrailTest < ActiveSupport::TestCase
|
|||
test 'update with plain model class' do
|
||||
widget = Widget.create
|
||||
assert_equal 1, widget.versions.length
|
||||
widget.update_attributes(:name => 'Bugle')
|
||||
widget.update_attributes(name: 'Bugle')
|
||||
assert_equal 2, widget.versions.length
|
||||
end
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'test_helper'
|
|||
class ARIdMapTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@widget = Widget.new
|
||||
@widget.update_attributes :name => 'Henry', :created_at => Time.now - 1.day
|
||||
@widget.update_attributes :name => 'Harry'
|
||||
@widget.update_attributes name: 'Henry', created_at: Time.now - 1.day
|
||||
@widget.update_attributes name: 'Harry'
|
||||
end
|
||||
|
||||
if defined?(ActiveRecord::IdentityMap) && ActiveRecord::IdentityMap.respond_to?(:without)
|
||||
|
|
|
@ -34,16 +34,16 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "a has_one association" do
|
||||
setup { @widget = Widget.create :name => 'widget_0' }
|
||||
setup { @widget = Widget.create name: 'widget_0' }
|
||||
|
||||
context 'before the associated was created' do
|
||||
setup do
|
||||
@widget.update_attributes :name => 'widget_1'
|
||||
@wotsit = @widget.create_wotsit :name => 'wotsit_0'
|
||||
@widget.update_attributes name: 'widget_1'
|
||||
@wotsit = @widget.create_wotsit name: 'wotsit_0'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @widget_0 = @widget.versions.last.reify(:has_one => true) }
|
||||
setup { @widget_0 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_nil @widget_0.wotsit
|
||||
|
@ -57,13 +57,13 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'where the association is created between model versions' do
|
||||
setup do
|
||||
@wotsit = @widget.create_wotsit :name => 'wotsit_0'
|
||||
@wotsit = @widget.create_wotsit name: 'wotsit_0'
|
||||
Timecop.travel 1.second.since
|
||||
@widget.update_attributes :name => 'widget_1'
|
||||
@widget.update_attributes name: 'widget_1'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @widget_0 = @widget.versions.last.reify(:has_one => true) }
|
||||
setup { @widget_0 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal 'wotsit_0', @widget_0.wotsit.name
|
||||
|
@ -76,15 +76,15 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then the associated is updated between model versions' do
|
||||
setup do
|
||||
@wotsit.update_attributes :name => 'wotsit_1'
|
||||
@wotsit.update_attributes :name => 'wotsit_2'
|
||||
@wotsit.update_attributes name: 'wotsit_1'
|
||||
@wotsit.update_attributes name: 'wotsit_2'
|
||||
Timecop.travel 1.second.since
|
||||
@widget.update_attributes :name => 'widget_2'
|
||||
@wotsit.update_attributes :name => 'wotsit_3'
|
||||
@widget.update_attributes name: 'widget_2'
|
||||
@wotsit.update_attributes name: 'wotsit_3'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @widget_1 = @widget.versions.last.reify(:has_one => true) }
|
||||
setup { @widget_1 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal 'wotsit_2', @widget_1.wotsit.name
|
||||
|
@ -96,7 +96,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified opting out of has_one reification' do
|
||||
setup { @widget_1 = @widget.versions.last.reify(:has_one => false) }
|
||||
setup { @widget_1 = @widget.versions.last.reify(has_one: false) }
|
||||
|
||||
should 'see the associated as it is live' do
|
||||
assert_equal 'wotsit_3', @widget_1.wotsit.name
|
||||
|
@ -110,7 +110,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reify' do
|
||||
setup { @widget_1 = @widget.versions.last.reify(:has_one => true) }
|
||||
setup { @widget_1 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal @wotsit, @widget_1.wotsit
|
||||
|
@ -124,11 +124,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'and then the model is updated' do
|
||||
setup do
|
||||
Timecop.travel 1.second.since
|
||||
@widget.update_attributes :name => 'widget_3'
|
||||
@widget.update_attributes name: 'widget_3'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @widget_2 = @widget.versions.last.reify(:has_one => true) }
|
||||
setup { @widget_2 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_nil @widget_2.wotsit
|
||||
|
@ -140,16 +140,16 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "a has_many association" do
|
||||
setup { @customer = Customer.create :name => 'customer_0' }
|
||||
setup { @customer = Customer.create name: 'customer_0' }
|
||||
|
||||
context 'updated before the associated was created' do
|
||||
setup do
|
||||
@customer.update_attributes! :name => 'customer_1'
|
||||
@customer.orders.create! :order_date => Date.today
|
||||
@customer.update_attributes! name: 'customer_1'
|
||||
@customer.orders.create! order_date: Date.today
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_0 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [], @customer_0.orders
|
||||
|
@ -163,8 +163,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'when reified with option mark_for_destruction' do
|
||||
should 'mark the associated for destruction' do
|
||||
@customer_0 = @customer.versions.last.reify(
|
||||
:has_many => true,
|
||||
:mark_for_destruction => true
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
assert_equal [true], @customer_0.orders.map(&:marked_for_destruction?)
|
||||
end
|
||||
|
@ -173,13 +173,13 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'where the association is created between model versions' do
|
||||
setup do
|
||||
@order = @customer.orders.create! :order_date => 'order_date_0'
|
||||
@order = @customer.orders.create! order_date: 'order_date_0'
|
||||
Timecop.travel 1.second.since
|
||||
@customer.update_attributes :name => 'customer_1'
|
||||
@customer.update_attributes name: 'customer_1'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_0 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal ['order_date_0'], @customer_0.orders.map(&:order_date)
|
||||
|
@ -188,11 +188,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then a nested has_many association is created' do
|
||||
setup do
|
||||
@order.line_items.create! :product => 'product_0'
|
||||
@order.line_items.create! product: 'product_0'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_0 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the live version of the nested association' do
|
||||
assert_equal ['product_0'], @customer_0.orders.first.line_items.map(&:product)
|
||||
|
@ -202,15 +202,15 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then the associated is updated between model versions' do
|
||||
setup do
|
||||
@order.update_attributes :order_date => 'order_date_1'
|
||||
@order.update_attributes :order_date => 'order_date_2'
|
||||
@order.update_attributes order_date: 'order_date_1'
|
||||
@order.update_attributes order_date: 'order_date_2'
|
||||
Timecop.travel 1.second.since
|
||||
@customer.update_attributes :name => 'customer_2'
|
||||
@order.update_attributes :order_date => 'order_date_3'
|
||||
@customer.update_attributes name: 'customer_2'
|
||||
@order.update_attributes order_date: 'order_date_3'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_1 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal ['order_date_2'], @customer_1.orders.map(&:order_date)
|
||||
|
@ -222,7 +222,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified opting out of has_many reification' do
|
||||
setup { @customer_1 = @customer.versions.last.reify(:has_many => false) }
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: false) }
|
||||
|
||||
should 'see the associated as it is live' do
|
||||
assert_equal ['order_date_3'], @customer_1.orders.map(&:order_date)
|
||||
|
@ -235,7 +235,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_1 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal ['order_date_2'], @customer_1.orders.map(&:order_date)
|
||||
|
@ -254,7 +254,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_1 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [@order.order_date], @customer_1.orders.map(&:order_date)
|
||||
|
@ -270,11 +270,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
setup do
|
||||
@order.destroy
|
||||
Timecop.travel 1.second.since
|
||||
@customer.update_attributes :name => 'customer_2'
|
||||
@customer.update_attributes name: 'customer_2'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_1 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [], @customer_1.orders
|
||||
|
@ -284,11 +284,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then another association is added' do
|
||||
setup do
|
||||
@customer.orders.create! :order_date => 'order_date_1'
|
||||
@customer.orders.create! order_date: 'order_date_1'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @customer_0 = @customer.versions.last.reify(:has_many => true) }
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal ['order_date_0'], @customer_0.orders.map(&:order_date)
|
||||
|
@ -303,8 +303,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'when reified with option mark_for_destruction' do
|
||||
should 'mark the newly associated for destruction' do
|
||||
@customer_0 = @customer.versions.last.reify(
|
||||
:has_many => true,
|
||||
:mark_for_destruction => true
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
assert @customer_0.
|
||||
orders.
|
||||
|
@ -318,16 +318,16 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "has_many through associations" do
|
||||
context "Books, Authors, and Authorships" do
|
||||
setup { @book = Book.create :title => 'book_0' }
|
||||
setup { @book = Book.create title: 'book_0' }
|
||||
|
||||
context 'updated before the associated was created' do
|
||||
setup do
|
||||
@book.update_attributes! :title => 'book_1'
|
||||
@book.authors.create! :name => 'author_0'
|
||||
@book.update_attributes! title: 'book_1'
|
||||
@book.authors.create! name: 'author_0'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_0 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [], @book_0.authors
|
||||
|
@ -341,8 +341,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'when reified with option mark_for_destruction' do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
:has_many => true,
|
||||
:mark_for_destruction => true
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -358,15 +358,15 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'updated before it is associated with an existing one' do
|
||||
setup do
|
||||
person_existing = Person.create(:name => 'person_existing')
|
||||
person_existing = Person.create(name: 'person_existing')
|
||||
Timecop.travel 1.second.since
|
||||
@book.update_attributes! :title => 'book_1'
|
||||
@book.update_attributes! title: 'book_1'
|
||||
@book.authors << person_existing
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(:has_many => true)
|
||||
@book_0 = @book.versions.last.reify(has_many: true)
|
||||
end
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
|
@ -377,8 +377,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'when reified with option mark_for_destruction' do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
:has_many => true,
|
||||
:mark_for_destruction => true
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -394,14 +394,14 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'where the association is created between model versions' do
|
||||
setup do
|
||||
@author = @book.authors.create! :name => 'author_0'
|
||||
@person_existing = Person.create(:name => 'person_existing')
|
||||
@author = @book.authors.create! name: 'author_0'
|
||||
@person_existing = Person.create(name: 'person_existing')
|
||||
Timecop.travel 1.second.since
|
||||
@book.update_attributes! :title => 'book_1'
|
||||
@book.update_attributes! title: 'book_1'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_0 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal ['author_0'], @book_0.authors.map(&:name)
|
||||
|
@ -410,15 +410,15 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then the associated is updated between model versions' do
|
||||
setup do
|
||||
@author.update_attributes :name => 'author_1'
|
||||
@author.update_attributes :name => 'author_2'
|
||||
@author.update_attributes name: 'author_1'
|
||||
@author.update_attributes name: 'author_2'
|
||||
Timecop.travel 1.second.since
|
||||
@book.update_attributes :title => 'book_2'
|
||||
@author.update_attributes :name => 'author_3'
|
||||
@book.update_attributes title: 'book_2'
|
||||
@author.update_attributes name: 'author_3'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_1 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal ['author_2'], @book_1.authors.map(&:name)
|
||||
|
@ -430,7 +430,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified opting out of has_many reification' do
|
||||
setup { @book_1 = @book.versions.last.reify(:has_many => false) }
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: false) }
|
||||
|
||||
should 'see the associated as it is live' do
|
||||
assert_equal ['author_3'], @book_1.authors.map(&:name)
|
||||
|
@ -444,7 +444,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_1 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [@author.name], @book_1.authors.map(&:name)
|
||||
|
@ -460,11 +460,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
setup do
|
||||
@author.destroy
|
||||
Timecop.travel 1.second.since
|
||||
@book.update_attributes :title => 'book_2'
|
||||
@book.update_attributes title: 'book_2'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_1 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [], @book_1.authors
|
||||
|
@ -476,11 +476,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
setup do
|
||||
@book.authors = []
|
||||
Timecop.travel 1.second.since
|
||||
@book.update_attributes :title => 'book_2'
|
||||
@book.update_attributes title: 'book_2'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_1 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the associated as it was at the time' do
|
||||
assert_equal [], @book_1.authors
|
||||
|
@ -490,11 +490,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then another associated is created' do
|
||||
setup do
|
||||
@book.authors.create! :name => 'author_1'
|
||||
@book.authors.create! name: 'author_1'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_0 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'only see the first associated' do
|
||||
assert_equal ['author_0'], @book_0.authors.map(&:name)
|
||||
|
@ -508,8 +508,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'when reified with option mark_for_destruction' do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
:has_many => true,
|
||||
:mark_for_destruction => true
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -535,7 +535,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_0 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'only see the first associated' do
|
||||
assert_equal ['author_0'], @book_0.authors.map(&:name)
|
||||
|
@ -549,8 +549,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context 'when reified with option mark_for_destruction' do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
:has_many => true,
|
||||
:mark_for_destruction => true
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -573,12 +573,12 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'updated before the associated without paper_trail was created' do
|
||||
setup do
|
||||
@book.update_attributes! :title => 'book_1'
|
||||
@book.editors.create! :name => 'editor_0'
|
||||
@book.update_attributes! title: 'book_1'
|
||||
@book.editors.create! name: 'editor_0'
|
||||
end
|
||||
|
||||
context 'when reified' do
|
||||
setup { @book_0 = @book.versions.last.reify(:has_many => true) }
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should 'see the live association' do
|
||||
assert_equal ['editor_0'], @book_0.editors.map(&:name)
|
||||
|
@ -588,15 +588,15 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "Chapters, Sections, Paragraphs, Quotations, and Citations" do
|
||||
setup { @chapter = Chapter.create(:name => CHAPTER_NAMES[0]) }
|
||||
setup { @chapter = Chapter.create(name: CHAPTER_NAMES[0]) }
|
||||
|
||||
context "before any associations are created" do
|
||||
setup do
|
||||
@chapter.update_attributes(:name => CHAPTER_NAMES[1])
|
||||
@chapter.update_attributes(name: CHAPTER_NAMES[1])
|
||||
end
|
||||
|
||||
should "not reify any associations" do
|
||||
chapter_v1 = @chapter.versions[1].reify(:has_many => true)
|
||||
chapter_v1 = @chapter.versions[1].reify(has_many: true)
|
||||
assert_equal CHAPTER_NAMES[0], chapter_v1.name
|
||||
assert_equal [], chapter_v1.sections
|
||||
assert_equal [], chapter_v1.paragraphs
|
||||
|
@ -606,31 +606,31 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context "after the first has_many through relationship is created" do
|
||||
setup do
|
||||
assert_equal 1, @chapter.versions.size
|
||||
@chapter.update_attributes :name => CHAPTER_NAMES[1]
|
||||
@chapter.update_attributes name: CHAPTER_NAMES[1]
|
||||
assert_equal 2, @chapter.versions.size
|
||||
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.sections.create :name => "section 1"
|
||||
@chapter.sections.create name: "section 1"
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.sections.first.update_attributes :name => "section 2"
|
||||
@chapter.sections.first.update_attributes name: "section 2"
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes :name => CHAPTER_NAMES[2]
|
||||
@chapter.update_attributes name: CHAPTER_NAMES[2]
|
||||
assert_equal 3, @chapter.versions.size
|
||||
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.sections.first.update_attributes :name => "section 3"
|
||||
@chapter.sections.first.update_attributes name: "section 3"
|
||||
end
|
||||
|
||||
context "version 1" do
|
||||
should "have no sections" do
|
||||
chapter_v1 = @chapter.versions[1].reify(:has_many => true)
|
||||
chapter_v1 = @chapter.versions[1].reify(has_many: true)
|
||||
assert_equal [], chapter_v1.sections
|
||||
end
|
||||
end
|
||||
|
||||
context "version 2" do
|
||||
should "have one section" do
|
||||
chapter_v2 = @chapter.versions[2].reify(:has_many => true)
|
||||
chapter_v2 = @chapter.versions[2].reify(has_many: true)
|
||||
assert_equal 1, chapter_v2.sections.size
|
||||
|
||||
# Shows the value of the section as it was before
|
||||
|
@ -644,14 +644,14 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "version 2, before the section was destroyed" do
|
||||
setup do
|
||||
@chapter.update_attributes :name => CHAPTER_NAMES[2]
|
||||
@chapter.update_attributes name: CHAPTER_NAMES[2]
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.sections.destroy_all
|
||||
Timecop.travel 1.second.since
|
||||
end
|
||||
|
||||
should "have the one section" do
|
||||
chapter_v2 = @chapter.versions[2].reify(:has_many => true)
|
||||
chapter_v2 = @chapter.versions[2].reify(has_many: true)
|
||||
assert_equal ['section 2'], chapter_v2.sections.map(&:name)
|
||||
end
|
||||
end
|
||||
|
@ -660,12 +660,12 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
setup do
|
||||
@chapter.sections.destroy_all
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes :name => CHAPTER_NAMES[3]
|
||||
@chapter.update_attributes name: CHAPTER_NAMES[3]
|
||||
Timecop.travel 1.second.since
|
||||
end
|
||||
|
||||
should "have no sections" do
|
||||
chapter_v3 = @chapter.versions[3].reify(:has_many => true)
|
||||
chapter_v3 = @chapter.versions[3].reify(has_many: true)
|
||||
assert_equal 0, chapter_v3.sections.size
|
||||
end
|
||||
end
|
||||
|
@ -675,7 +675,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
assert_equal 3, @chapter.versions.size
|
||||
@section = @chapter.sections.first
|
||||
Timecop.travel 1.second.since
|
||||
@paragraph = @section.paragraphs.create :name => 'para1'
|
||||
@paragraph = @section.paragraphs.create name: 'para1'
|
||||
end
|
||||
|
||||
context "new chapter version" do
|
||||
|
@ -683,11 +683,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
initial_section_name = @section.name
|
||||
initial_paragraph_name = @paragraph.name
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes :name => CHAPTER_NAMES[4]
|
||||
@chapter.update_attributes name: CHAPTER_NAMES[4]
|
||||
assert_equal 4, @chapter.versions.size
|
||||
Timecop.travel 1.second.since
|
||||
@paragraph.update_attributes :name => 'para3'
|
||||
chapter_v3 = @chapter.versions[3].reify(:has_many => true)
|
||||
@paragraph.update_attributes name: 'para3'
|
||||
chapter_v3 = @chapter.versions[3].reify(has_many: true)
|
||||
assert_equal [initial_section_name], chapter_v3.sections.map(&:name)
|
||||
paragraphs = chapter_v3.sections.first.paragraphs
|
||||
assert_equal 1, paragraphs.size
|
||||
|
@ -698,12 +698,12 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
context "the version before a section is destroyed" do
|
||||
should "have the section and paragraph" do
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes(:name => CHAPTER_NAMES[3])
|
||||
@chapter.update_attributes(name: CHAPTER_NAMES[3])
|
||||
assert_equal 4, @chapter.versions.size
|
||||
Timecop.travel 1.second.since
|
||||
@section.destroy
|
||||
assert_equal 4, @chapter.versions.size
|
||||
chapter_v3 = @chapter.versions[3].reify(:has_many => true)
|
||||
chapter_v3 = @chapter.versions[3].reify(has_many: true)
|
||||
assert_equal CHAPTER_NAMES[2], chapter_v3.name
|
||||
assert_equal [@section], chapter_v3.sections
|
||||
assert_equal [@paragraph], chapter_v3.sections[0].paragraphs
|
||||
|
@ -715,9 +715,9 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
should "not have any sections or paragraphs" do
|
||||
@section.destroy
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes(:name => CHAPTER_NAMES[5])
|
||||
@chapter.update_attributes(name: CHAPTER_NAMES[5])
|
||||
assert_equal 4, @chapter.versions.size
|
||||
chapter_v3 = @chapter.versions[3].reify(:has_many => true)
|
||||
chapter_v3 = @chapter.versions[3].reify(has_many: true)
|
||||
assert_equal 0, chapter_v3.sections.size
|
||||
assert_equal 0, chapter_v3.paragraphs.size
|
||||
end
|
||||
|
@ -727,10 +727,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
should "have the one paragraph" do
|
||||
initial_paragraph_name = @section.paragraphs.first.name
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes(:name => CHAPTER_NAMES[5])
|
||||
@chapter.update_attributes(name: CHAPTER_NAMES[5])
|
||||
Timecop.travel 1.second.since
|
||||
@paragraph.destroy
|
||||
chapter_v3 = @chapter.versions[3].reify(:has_many => true)
|
||||
chapter_v3 = @chapter.versions[3].reify(has_many: true)
|
||||
paragraphs = chapter_v3.sections.first.paragraphs
|
||||
assert_equal 1, paragraphs.size
|
||||
assert_equal initial_paragraph_name, paragraphs.first.name
|
||||
|
@ -741,8 +741,8 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
should "have no paragraphs" do
|
||||
@paragraph.destroy
|
||||
Timecop.travel 1.second.since
|
||||
@chapter.update_attributes(:name => CHAPTER_NAMES[5])
|
||||
chapter_v3 = @chapter.versions[3].reify(:has_many => true)
|
||||
@chapter.update_attributes(name: CHAPTER_NAMES[5])
|
||||
chapter_v3 = @chapter.versions[3].reify(has_many: true)
|
||||
assert_equal 0, chapter_v3.paragraphs.size
|
||||
assert_equal [], chapter_v3.sections.first.paragraphs
|
||||
end
|
||||
|
@ -752,17 +752,17 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "a chapter with one paragraph and one citation" do
|
||||
should "reify paragraphs and citations" do
|
||||
chapter = Chapter.create(:name => CHAPTER_NAMES[0])
|
||||
section = Section.create(:name => 'Section One', :chapter => chapter)
|
||||
paragraph = Paragraph.create(:name => 'Paragraph One', :section => section)
|
||||
quotation = Quotation.create(:chapter => chapter)
|
||||
citation = Citation.create(:quotation => quotation)
|
||||
chapter = Chapter.create(name: CHAPTER_NAMES[0])
|
||||
section = Section.create(name: 'Section One', chapter: chapter)
|
||||
paragraph = Paragraph.create(name: 'Paragraph One', section: section)
|
||||
quotation = Quotation.create(chapter: chapter)
|
||||
citation = Citation.create(quotation: quotation)
|
||||
Timecop.travel 1.second.since
|
||||
chapter.update_attributes(:name => CHAPTER_NAMES[1])
|
||||
chapter.update_attributes(name: CHAPTER_NAMES[1])
|
||||
assert_equal 2, chapter.versions.count
|
||||
paragraph.destroy
|
||||
citation.destroy
|
||||
reified = chapter.versions[1].reify(:has_many => true)
|
||||
reified = chapter.versions[1].reify(has_many: true)
|
||||
assert_equal [paragraph], reified.sections.first.paragraphs
|
||||
assert_equal [citation], reified.quotations.first.citations
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
|
||||
context '`:keeping` option' do
|
||||
should 'modifies the number of versions ommitted from destruction' do
|
||||
PaperTrail.clean_versions!(:keeping => 2)
|
||||
PaperTrail.clean_versions!(keeping: 2)
|
||||
assert_equal 6, PaperTrail::Version.all.count
|
||||
@animals.each { |animal| assert_equal 2, animal.versions.size }
|
||||
end
|
||||
|
@ -54,7 +54,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
assert_equal 10, PaperTrail::Version.count
|
||||
assert_equal 4, @animal.versions.size
|
||||
assert_equal 3, @animal.versions_between(@date, @date + 1.day).size
|
||||
PaperTrail.clean_versions!(:date => @date)
|
||||
PaperTrail.clean_versions!(date: @date)
|
||||
assert_equal 8, PaperTrail::Version.count
|
||||
assert_equal 2, @animal.versions.reload.size
|
||||
assert_equal @date, @animal.versions.first.created_at.to_date
|
||||
|
@ -65,7 +65,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
context '`:item_id` option' do
|
||||
context 'single ID received' do
|
||||
should 'restrict the versions destroyed to the versions for the Item with that ID' do
|
||||
PaperTrail.clean_versions!(:item_id => @animal.id)
|
||||
PaperTrail.clean_versions!(item_id: @animal.id)
|
||||
assert_equal 1, @animal.versions.size
|
||||
assert_equal 7, PaperTrail::Version.count
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
|
||||
context "collection of ID's received" do
|
||||
should "restrict the versions destroyed to the versions for the Item with those ID's" do
|
||||
PaperTrail.clean_versions!(:item_id => [@animal.id, @dog.id])
|
||||
PaperTrail.clean_versions!(item_id: [@animal.id, @dog.id])
|
||||
assert_equal 1, @animal.versions.size
|
||||
assert_equal 1, @dog.versions.size
|
||||
assert_equal 5, PaperTrail::Version.count
|
||||
|
@ -101,7 +101,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and `:keeping`' do
|
||||
should 'restrict cleaning properly' do
|
||||
PaperTrail.clean_versions!(:date => @date, :keeping => 2)
|
||||
PaperTrail.clean_versions!(date: @date, keeping: 2)
|
||||
[@animal, @dog].each do |animal|
|
||||
# reload the association to pick up the destructions made by the `Cleaner`
|
||||
animal.versions.reload
|
||||
|
@ -115,7 +115,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and `:item_id`' do
|
||||
should 'restrict cleaning properly' do
|
||||
PaperTrail.clean_versions!(:date => @date, :item_id => @dog.id)
|
||||
PaperTrail.clean_versions!(date: @date, item_id: @dog.id)
|
||||
# reload the association to pick up the destructions made by the `Cleaner`
|
||||
@dog.versions.reload
|
||||
assert_equal 2, @dog.versions.size
|
||||
|
@ -127,7 +127,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
|
||||
context ', `:item_id`, and `:keeping`' do
|
||||
should 'restrict cleaning properly' do
|
||||
PaperTrail.clean_versions!(:date => @date, :item_id => @dog.id, :keeping => 2)
|
||||
PaperTrail.clean_versions!(date: @date, item_id: @dog.id, keeping: 2)
|
||||
# reload the association to pick up the destructions made by the `Cleaner`
|
||||
@dog.versions.reload
|
||||
assert_equal 3, @dog.versions.size
|
||||
|
@ -140,7 +140,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
|
||||
context '`:keeping` and `:item_id`' do
|
||||
should 'restrict cleaning properly' do
|
||||
PaperTrail.clean_versions!(:keeping => 2, :item_id => @animal.id)
|
||||
PaperTrail.clean_versions!(keeping: 2, item_id: @animal.id)
|
||||
assert_equal 2, @animal.versions.size
|
||||
# ensure the versions for other animals besides `@animal` weren't touched
|
||||
assert_equal 8, PaperTrail::Version.count
|
||||
|
|
|
@ -3,19 +3,19 @@ require 'test_helper'
|
|||
class InheritanceColumnTest < ActiveSupport::TestCase
|
||||
context 'STI models' do
|
||||
setup do
|
||||
@animal = Animal.create :name => 'Animal'
|
||||
@animal.update_attributes :name => 'Animal from the Muppets'
|
||||
@animal.update_attributes :name => 'Animal Muppet'
|
||||
@animal = Animal.create name: 'Animal'
|
||||
@animal.update_attributes name: 'Animal from the Muppets'
|
||||
@animal.update_attributes name: 'Animal Muppet'
|
||||
@animal.destroy
|
||||
|
||||
@dog = Dog.create :name => 'Snoopy'
|
||||
@dog.update_attributes :name => 'Scooby'
|
||||
@dog.update_attributes :name => 'Scooby Doo'
|
||||
@dog = Dog.create name: 'Snoopy'
|
||||
@dog.update_attributes name: 'Scooby'
|
||||
@dog.update_attributes name: 'Scooby Doo'
|
||||
@dog.destroy
|
||||
|
||||
@cat = Cat.create :name => 'Garfield'
|
||||
@cat.update_attributes :name => 'Garfield (I hate Mondays)'
|
||||
@cat.update_attributes :name => 'Garfield The Cat'
|
||||
@cat = Cat.create name: 'Garfield'
|
||||
@cat.update_attributes name: 'Garfield (I hate Mondays)'
|
||||
@cat.update_attributes name: 'Garfield The Cat'
|
||||
@cat.destroy
|
||||
end
|
||||
|
||||
|
@ -27,13 +27,13 @@ class InheritanceColumnTest < ActiveSupport::TestCase
|
|||
|
||||
# For some reason `@dog.versions` doesn't include the final `destroy` version.
|
||||
# Neither do `@dog.versions.scoped` nor `@dog.versions(true)` nor `@dog.versions.reload`.
|
||||
dog_versions = PaperTrail::Version.where(:item_id => @dog.id).
|
||||
dog_versions = PaperTrail::Version.where(item_id: @dog.id).
|
||||
order(PaperTrail.timestamp_field)
|
||||
assert_equal 4, dog_versions.count
|
||||
assert_nil dog_versions.first.reify
|
||||
assert_equal %w[NilClass Dog Dog Dog], dog_versions.map { |v| v.reify.class.name }
|
||||
|
||||
cat_versions = PaperTrail::Version.where(:item_id => @cat.id).
|
||||
cat_versions = PaperTrail::Version.where(item_id: @cat.id).
|
||||
order(PaperTrail.timestamp_field)
|
||||
assert_equal 4, cat_versions.count
|
||||
assert_nil cat_versions.first.reify
|
||||
|
|
|
@ -11,21 +11,21 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'which updates an ignored column' do
|
||||
should 'not change the number of versions' do
|
||||
@article.update_attributes :title => 'My first title'
|
||||
@article.update_attributes title: 'My first title'
|
||||
assert_equal(1, PaperTrail::Version.count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'which updates an ignored column with truly Proc' do
|
||||
should 'not change the number of versions' do
|
||||
@article.update_attributes :abstract => 'ignore abstract'
|
||||
@article.update_attributes abstract: 'ignore abstract'
|
||||
assert_equal(1, PaperTrail::Version.count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'which updates an ignored column with falsy Proc' do
|
||||
should 'change the number of versions' do
|
||||
@article.update_attributes :abstract => 'do not ignore abstract!'
|
||||
@article.update_attributes abstract: 'do not ignore abstract!'
|
||||
assert_equal(2, PaperTrail::Version.count)
|
||||
end
|
||||
end
|
||||
|
@ -80,7 +80,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'which updates a selected column' do
|
||||
setup { @article.update_attributes :content => 'Some text here.' }
|
||||
setup { @article.update_attributes content: 'Some text here.' }
|
||||
should 'change the number of versions' do
|
||||
assert_equal(2, PaperTrail::Version.count)
|
||||
end
|
||||
|
@ -92,14 +92,14 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'which updates a non-ignored and non-selected column' do
|
||||
should 'not change the number of versions' do
|
||||
@article.update_attributes :abstract => 'Other abstract'
|
||||
@article.update_attributes abstract: 'Other abstract'
|
||||
assert_equal(1, PaperTrail::Version.count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'which updates a skipped column' do
|
||||
should 'not change the number of versions' do
|
||||
@article.update_attributes :file_upload => 'Your data goes here'
|
||||
@article.update_attributes file_upload: 'Your data goes here'
|
||||
assert_equal(1, PaperTrail::Version.count)
|
||||
end
|
||||
end
|
||||
|
@ -158,20 +158,20 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
setup { @legacy_widget = LegacyWidget.create }
|
||||
|
||||
context 'which updates an ignored column' do
|
||||
setup { @legacy_widget.update_attributes :version => 1 }
|
||||
setup { @legacy_widget.update_attributes version: 1 }
|
||||
should 'not change the number of versions' do assert_equal(1, PaperTrail::Version.count) end
|
||||
end
|
||||
end
|
||||
|
||||
context 'A record with defined "if" and "unless" attributes' do
|
||||
setup { @translation = Translation.new :headline => 'Headline' }
|
||||
setup { @translation = Translation.new headline: 'Headline' }
|
||||
|
||||
context 'for non-US translations' do
|
||||
setup { @translation.save }
|
||||
should 'not change the number of versions' do assert_equal(0, PaperTrail::Version.count) end
|
||||
|
||||
context 'after update' do
|
||||
setup { @translation.update_attributes :content => 'Content' }
|
||||
setup { @translation.update_attributes content: 'Content' }
|
||||
should 'not change the number of versions' do assert_equal(0, PaperTrail::Version.count) end
|
||||
end
|
||||
|
||||
|
@ -195,7 +195,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'after update' do
|
||||
setup { @translation.update_attributes :content => 'Content' }
|
||||
setup { @translation.update_attributes content: 'Content' }
|
||||
should 'not change the number of versions' do
|
||||
assert_equal(0, PaperTrail::Version.count)
|
||||
end
|
||||
|
@ -210,7 +210,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'after update' do
|
||||
setup { @translation.update_attributes :content => 'Content' }
|
||||
setup { @translation.update_attributes content: 'Content' }
|
||||
should 'change the number of versions' do
|
||||
assert_equal(2, PaperTrail::Version.count)
|
||||
end
|
||||
|
@ -246,7 +246,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'which is then created' do
|
||||
setup { @widget.update_attributes :name => 'Henry', :created_at => Time.now - 1.day }
|
||||
setup { @widget.update_attributes name: 'Henry', created_at: Time.now - 1.day }
|
||||
|
||||
should 'have one previous version' do
|
||||
assert_equal 1, @widget.versions.length
|
||||
|
@ -294,7 +294,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'and then updated with changes' do
|
||||
setup { @widget.update_attributes :name => 'Harry' }
|
||||
setup { @widget.update_attributes name: 'Harry' }
|
||||
|
||||
should 'have two previous versions' do
|
||||
assert_equal 2, @widget.versions.length
|
||||
|
@ -342,7 +342,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and has one associated object' do
|
||||
setup do
|
||||
@wotsit = @widget.create_wotsit :name => 'John'
|
||||
@wotsit = @widget.create_wotsit name: 'John'
|
||||
end
|
||||
|
||||
should 'not copy the has_one association by default when reifying' do
|
||||
|
@ -354,7 +354,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should 'copy the has_one association when reifying with :has_one => true' do
|
||||
reified_widget = @widget.versions.last.reify(:has_one => true)
|
||||
reified_widget = @widget.versions.last.reify(has_one: true)
|
||||
# wotsit wasn't there at the last version
|
||||
assert_nil reified_widget.wotsit
|
||||
# wotsit should still exist on live object
|
||||
|
@ -364,8 +364,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and has many associated objects' do
|
||||
setup do
|
||||
@f0 = @widget.fluxors.create :name => 'f-zero'
|
||||
@f1 = @widget.fluxors.create :name => 'f-one'
|
||||
@f0 = @widget.fluxors.create name: 'f-zero'
|
||||
@f1 = @widget.fluxors.create name: 'f-one'
|
||||
@reified_widget = @widget.versions.last.reify
|
||||
end
|
||||
|
||||
|
@ -380,8 +380,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and has many associated polymorphic objects' do
|
||||
setup do
|
||||
@f0 = @widget.whatchamajiggers.create :name => 'f-zero'
|
||||
@f1 = @widget.whatchamajiggers.create :name => 'f-zero'
|
||||
@f0 = @widget.whatchamajiggers.create name: 'f-zero'
|
||||
@f1 = @widget.whatchamajiggers.create name: 'f-zero'
|
||||
@reified_widget = @widget.versions.last.reify
|
||||
end
|
||||
|
||||
|
@ -396,7 +396,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'polymorphic objects by themselves' do
|
||||
setup do
|
||||
@widget = Whatchamajigger.new :name => 'f-zero'
|
||||
@widget = Whatchamajigger.new name: 'f-zero'
|
||||
end
|
||||
|
||||
should 'not fail with a nil pointer on the polymorphic association' do
|
||||
|
@ -406,7 +406,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and then destroyed' do
|
||||
setup do
|
||||
@fluxor = @widget.fluxors.create :name => 'flux'
|
||||
@fluxor = @widget.fluxors.create name: 'flux'
|
||||
@widget.destroy
|
||||
@reified_widget = PaperTrail::Version.last.reify
|
||||
end
|
||||
|
@ -541,7 +541,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'A record' do
|
||||
setup { @widget = Widget.create :name => 'Zaphod' }
|
||||
setup { @widget = Widget.create name: 'Zaphod' }
|
||||
|
||||
context 'with PaperTrail globally disabled' do
|
||||
setup do
|
||||
|
@ -552,7 +552,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
teardown { PaperTrail.enabled = true }
|
||||
|
||||
context 'when updated' do
|
||||
setup { @widget.update_attributes :name => 'Beeblebrox' }
|
||||
setup { @widget.update_attributes name: 'Beeblebrox' }
|
||||
|
||||
should 'not add to its trail' do
|
||||
assert_equal @count, @widget.versions.length
|
||||
|
@ -569,7 +569,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
teardown { Widget.paper_trail_on! }
|
||||
|
||||
context 'when updated' do
|
||||
setup { @widget.update_attributes :name => 'Beeblebrox' }
|
||||
setup { @widget.update_attributes name: 'Beeblebrox' }
|
||||
|
||||
should 'not add to its trail' do
|
||||
assert_equal @count, @widget.versions.length
|
||||
|
@ -587,7 +587,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
setup { Widget.paper_trail_on! }
|
||||
|
||||
context 'when updated' do
|
||||
setup { @widget.update_attributes :name => 'Ford' }
|
||||
setup { @widget.update_attributes name: 'Ford' }
|
||||
|
||||
should 'add to its trail' do
|
||||
assert_equal @count + 1, @widget.versions.length
|
||||
|
@ -597,10 +597,10 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context 'when updated "without versioning"' do
|
||||
setup do
|
||||
@widget.without_versioning do
|
||||
@widget.update_attributes :name => 'Ford'
|
||||
@widget.update_attributes name: 'Ford'
|
||||
end
|
||||
# The model instance should yield itself for convenience purposes
|
||||
@widget.without_versioning { |w| w.update_attributes :name => 'Nixon' }
|
||||
@widget.without_versioning { |w| w.update_attributes name: 'Nixon' }
|
||||
end
|
||||
|
||||
should 'not create new version' do
|
||||
|
@ -629,7 +629,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'A papertrail with somebody making changes' do
|
||||
setup do
|
||||
@widget = Widget.new :name => 'Fidget'
|
||||
@widget = Widget.new name: 'Fidget'
|
||||
end
|
||||
|
||||
context 'when a record is created' do
|
||||
|
@ -649,7 +649,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context 'when a record is updated' do
|
||||
setup do
|
||||
PaperTrail.whodunnit = 'Bob'
|
||||
@widget.update_attributes :name => 'Rivet'
|
||||
@widget.update_attributes name: 'Rivet'
|
||||
@version = @widget.versions.last
|
||||
end
|
||||
|
||||
|
@ -680,11 +680,11 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'Timestamps' do
|
||||
setup do
|
||||
@wotsit = Wotsit.create! :name => 'wotsit'
|
||||
@wotsit = Wotsit.create! name: 'wotsit'
|
||||
end
|
||||
|
||||
should 'record timestamps' do
|
||||
@wotsit.update_attributes! :name => 'changed'
|
||||
@wotsit.update_attributes! name: 'changed'
|
||||
assert_not_nil @wotsit.versions.last.reify.created_at
|
||||
assert_not_nil @wotsit.versions.last.reify.updated_at
|
||||
end
|
||||
|
@ -700,7 +700,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
should 'not generate warning' do
|
||||
assert_update_raises_nothing = -> {
|
||||
assert_nothing_raised {
|
||||
@wotsit.update_attributes! :name => 'changed'
|
||||
@wotsit.update_attributes! name: 'changed'
|
||||
}
|
||||
}
|
||||
warnings =
|
||||
|
@ -716,7 +716,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context 'A subclass' do
|
||||
setup do
|
||||
@foo = FooWidget.create
|
||||
@foo.update_attributes! :name => 'Foo'
|
||||
@foo.update_attributes! name: 'Foo'
|
||||
end
|
||||
|
||||
should 'reify with the correct type' do
|
||||
|
@ -747,9 +747,9 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'An item with versions' do
|
||||
setup do
|
||||
@widget = Widget.create :name => 'Widget'
|
||||
@widget.update_attributes :name => 'Fidget'
|
||||
@widget.update_attributes :name => 'Digit'
|
||||
@widget = Widget.create name: 'Widget'
|
||||
@widget.update_attributes name: 'Fidget'
|
||||
@widget.update_attributes name: 'Digit'
|
||||
end
|
||||
|
||||
context 'which were created over time' do
|
||||
|
@ -757,9 +757,9 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
@created = 2.days.ago
|
||||
@first_update = 1.day.ago
|
||||
@second_update = 1.hour.ago
|
||||
@widget.versions[0].update_attributes :created_at => @created
|
||||
@widget.versions[1].update_attributes :created_at => @first_update
|
||||
@widget.versions[2].update_attributes :created_at => @second_update
|
||||
@widget.versions[0].update_attributes created_at: @created
|
||||
@widget.versions[1].update_attributes created_at: @first_update
|
||||
@widget.versions[2].update_attributes created_at: @second_update
|
||||
@widget.update_attribute :updated_at, @second_update
|
||||
end
|
||||
|
||||
|
@ -807,9 +807,9 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
@created = 30.days.ago
|
||||
@first_update = 15.days.ago
|
||||
@second_update = 1.day.ago
|
||||
@widget.versions[0].update_attributes :created_at => @created
|
||||
@widget.versions[1].update_attributes :created_at => @first_update
|
||||
@widget.versions[2].update_attributes :created_at => @second_update
|
||||
@widget.versions[0].update_attributes created_at: @created
|
||||
@widget.versions[1].update_attributes created_at: @first_update
|
||||
@widget.versions[2].update_attributes created_at: @second_update
|
||||
@widget.update_attribute :updated_at, @second_update
|
||||
end
|
||||
|
||||
|
@ -861,7 +861,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context 'An item' do
|
||||
setup do
|
||||
@initial_title = 'Foobar'
|
||||
@article = Article.new :title => @initial_title
|
||||
@article = Article.new title: @initial_title
|
||||
end
|
||||
|
||||
context 'which is created' do
|
||||
|
@ -889,7 +889,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'and updated' do
|
||||
setup do
|
||||
@article.update_attributes! :content => 'Better text.', :title => 'Rhubarb'
|
||||
@article.update_attributes! content: 'Better text.', title: 'Rhubarb'
|
||||
end
|
||||
|
||||
should 'store fixed meta data' do
|
||||
|
@ -933,8 +933,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'A reified item' do
|
||||
setup do
|
||||
widget = Widget.create :name => 'Bob'
|
||||
%w( Tom Dick Jane ).each { |name| widget.update_attributes :name => name }
|
||||
widget = Widget.create name: 'Bob'
|
||||
%w( Tom Dick Jane ).each { |name| widget.update_attributes name: name }
|
||||
@version = widget.versions.last
|
||||
@widget = @version.reify
|
||||
end
|
||||
|
@ -962,7 +962,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context 'with versions' do
|
||||
setup do
|
||||
@widget.save
|
||||
%w( Tom Dick Jane ).each { |name| @widget.update_attributes :name => name }
|
||||
%w( Tom Dick Jane ).each { |name| @widget.update_attributes name: name }
|
||||
end
|
||||
|
||||
should 'have a previous version' do
|
||||
|
@ -977,8 +977,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'A reified item' do
|
||||
setup do
|
||||
@widget = Widget.create :name => 'Bob'
|
||||
%w(Tom Dick Jane).each { |name| @widget.update_attributes :name => name }
|
||||
@widget = Widget.create name: 'Bob'
|
||||
%w(Tom Dick Jane).each { |name| @widget.update_attributes name: name }
|
||||
@second_widget = @widget.versions[1].reify # first widget is `nil`
|
||||
@last_widget = @widget.versions.last.reify
|
||||
end
|
||||
|
@ -996,9 +996,9 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context ":has_many :through" do
|
||||
setup do
|
||||
@book = Book.create :title => 'War and Peace'
|
||||
@dostoyevsky = Person.create :name => 'Dostoyevsky'
|
||||
@solzhenitsyn = Person.create :name => 'Solzhenitsyn'
|
||||
@book = Book.create title: 'War and Peace'
|
||||
@dostoyevsky = Person.create name: 'Dostoyevsky'
|
||||
@solzhenitsyn = Person.create name: 'Solzhenitsyn'
|
||||
end
|
||||
|
||||
should 'store version on source <<' do
|
||||
|
@ -1010,7 +1010,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
should 'store version on source create' do
|
||||
count = PaperTrail::Version.count
|
||||
@book.authors.create :name => 'Tolstoy'
|
||||
@book.authors.create name: 'Tolstoy'
|
||||
assert_equal 2, PaperTrail::Version.count - count
|
||||
actual = [
|
||||
PaperTrail::Version.order(:id).to_a[-2].item,
|
||||
|
@ -1040,7 +1040,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'When an attribute has a custom serializer' do
|
||||
setup do
|
||||
@person = Person.new(:time_zone => "Samoa")
|
||||
@person = Person.new(time_zone: "Samoa")
|
||||
end
|
||||
|
||||
should "be an instance of ActiveSupport::TimeZone" do
|
||||
|
@ -1214,8 +1214,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'An overwritten default accessor' do
|
||||
setup do
|
||||
@song = Song.create :length => 4
|
||||
@song.update_attributes :length => 5
|
||||
@song = Song.create length: 4
|
||||
@song.update_attributes length: 5
|
||||
end
|
||||
|
||||
should 'return "overwritten" value on live instance' do
|
||||
|
@ -1254,7 +1254,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context 'A model with a custom association' do
|
||||
setup do
|
||||
@doc = Document.create
|
||||
@doc.update_attributes :name => 'Doc 1'
|
||||
@doc.update_attributes name: 'Doc 1'
|
||||
end
|
||||
|
||||
should 'not respond to versions method' do
|
||||
|
@ -1270,7 +1270,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should 'respond to `previous_version` as normal' do
|
||||
@doc.update_attributes :name => 'Doc 2'
|
||||
@doc.update_attributes name: 'Doc 2'
|
||||
assert_equal 3, @doc.paper_trail_versions.length
|
||||
assert_equal 'Doc 1', @doc.previous_version.name
|
||||
end
|
||||
|
@ -1283,7 +1283,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => [:create]
|
||||
END
|
||||
@fluxor = Fluxor.create
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for the create event' do
|
||||
|
@ -1300,7 +1300,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => [:update]
|
||||
END
|
||||
@fluxor = Fluxor.create
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for the update event' do
|
||||
|
@ -1317,7 +1317,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => [:destroy]
|
||||
END
|
||||
@fluxor = Fluxor.create
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for the destroy event' do
|
||||
|
@ -1334,7 +1334,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => []
|
||||
END
|
||||
@fluxor = Fluxor.create
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
@ -1359,7 +1359,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => :create
|
||||
END
|
||||
@fluxor = Fluxor.create
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for hte create event' do
|
||||
|
@ -1371,7 +1371,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'A model with column version and custom version_method' do
|
||||
setup do
|
||||
@legacy_widget = LegacyWidget.create(:name => "foo", :version => 2)
|
||||
@legacy_widget = LegacyWidget.create(name: "foo", version: 2)
|
||||
end
|
||||
|
||||
should 'set version on create' do
|
||||
|
@ -1379,7 +1379,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should 'allow version updates' do
|
||||
@legacy_widget.update_attributes :version => 3
|
||||
@legacy_widget.update_attributes version: 3
|
||||
assert_equal 3, @legacy_widget.version
|
||||
end
|
||||
|
||||
|
@ -1390,8 +1390,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
|
||||
context 'A reified item with a column -version- and custom version_method' do
|
||||
setup do
|
||||
widget = LegacyWidget.create(:name => "foo", :version => 2)
|
||||
%w( bar baz ).each { |name| widget.update_attributes :name => name }
|
||||
widget = LegacyWidget.create(name: "foo", version: 2)
|
||||
%w( bar baz ).each { |name| widget.update_attributes name: name }
|
||||
@version = widget.versions.last
|
||||
@widget = @version.reify
|
||||
end
|
||||
|
@ -1415,7 +1415,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => [:create]
|
||||
END
|
||||
@fluxor = Fluxor.new.tap { |model| model.paper_trail_event = 'created' }
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for the created event' do
|
||||
|
@ -1432,7 +1432,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => [:update]
|
||||
END
|
||||
@fluxor = Fluxor.create.tap { |model| model.paper_trail_event = 'name_updated' }
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for the name_updated event' do
|
||||
|
@ -1449,7 +1449,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
has_paper_trail :on => [:destroy]
|
||||
END
|
||||
@fluxor = Fluxor.create.tap { |model| model.paper_trail_event = 'destroyed' }
|
||||
@fluxor.update_attributes :name => 'blah'
|
||||
@fluxor.update_attributes name: 'blah'
|
||||
@fluxor.destroy
|
||||
end
|
||||
should 'only have a version for the destroy event' do
|
||||
|
@ -1462,7 +1462,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
context '`PaperTrail::Config.version_limit` set' do
|
||||
setup do
|
||||
PaperTrail.config.version_limit = 2
|
||||
@widget = Widget.create! :name => 'Henry'
|
||||
@widget = Widget.create! name: 'Henry'
|
||||
6.times { @widget.update_attribute(:name, FFaker::Lorem.word) }
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class ProtectedAttrsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'A model with `attr_accessible` created' do
|
||||
setup do
|
||||
@widget = ProtectedWidget.create! :name => 'Henry'
|
||||
@widget = ProtectedWidget.create! name: 'Henry'
|
||||
@initial_attributes = @widget.attributes
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ class ProtectedAttrsTest < ActiveSupport::TestCase
|
|||
|
||||
context 'which is then updated' do
|
||||
setup do
|
||||
@widget.assign_attributes(:name => 'Jeff', :a_text => 'Short statement')
|
||||
@widget.assign_attributes(name: 'Jeff', a_text: 'Short statement')
|
||||
@widget.an_integer = 42
|
||||
@widget.save!
|
||||
end
|
||||
|
|
|
@ -8,12 +8,12 @@ class SerializerTest < ActiveSupport::TestCase
|
|||
has_paper_trail
|
||||
END
|
||||
|
||||
@fluxor = Fluxor.create :name => 'Some text.'
|
||||
@fluxor = Fluxor.create name: 'Some text.'
|
||||
|
||||
# this is exactly what PaperTrail serializes
|
||||
@original_fluxor_attributes = @fluxor.send(:attributes_before_change)
|
||||
|
||||
@fluxor.update_attributes :name => 'Some more text.'
|
||||
@fluxor.update_attributes name: 'Some more text.'
|
||||
end
|
||||
|
||||
should 'work with the default `YAML` serializer' do
|
||||
|
@ -38,12 +38,12 @@ class SerializerTest < ActiveSupport::TestCase
|
|||
has_paper_trail
|
||||
END
|
||||
|
||||
@fluxor = Fluxor.create :name => 'Some text.'
|
||||
@fluxor = Fluxor.create name: 'Some text.'
|
||||
|
||||
# this is exactly what PaperTrail serializes
|
||||
@original_fluxor_attributes = @fluxor.send(:attributes_before_change)
|
||||
|
||||
@fluxor.update_attributes :name => 'Some more text.'
|
||||
@fluxor.update_attributes name: 'Some more text.'
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
@ -88,7 +88,7 @@ class SerializerTest < ActiveSupport::TestCase
|
|||
send(:attributes_before_change).
|
||||
reject { |_k, v| v.nil? }
|
||||
|
||||
@fluxor.update_attributes :name => 'Some more text.'
|
||||
@fluxor.update_attributes name: 'Some more text.'
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
|
|
@ -9,9 +9,9 @@ class TimestampTest < ActiveSupport::TestCase
|
|||
has_paper_trail
|
||||
END
|
||||
|
||||
@fluxor = Fluxor.create :name => 'Some text.'
|
||||
@fluxor.update_attributes :name => 'Some more text.'
|
||||
@fluxor.update_attributes :name => 'Even more text.'
|
||||
@fluxor = Fluxor.create name: 'Some text.'
|
||||
@fluxor.update_attributes name: 'Some more text.'
|
||||
@fluxor.update_attributes name: 'Even more text.'
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
|
|
@ -24,7 +24,7 @@ module PaperTrail
|
|||
|
||||
context ".updates" do
|
||||
setup {
|
||||
@animal.update_attributes(:name => 'Animal')
|
||||
@animal.update_attributes(name: 'Animal')
|
||||
assert Version.updates.present?
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ module PaperTrail
|
|||
|
||||
context ".not_creates" do
|
||||
setup {
|
||||
@animal.update_attributes(:name => 'Animal')
|
||||
@animal.update_attributes(name: 'Animal')
|
||||
@animal.destroy
|
||||
assert Version.not_creates.present?
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue