diff --git a/gemfiles/activerecord_5_0.gemfile b/gemfiles/activerecord_5_0.gemfile new file mode 100644 index 00000000..00d90bdf --- /dev/null +++ b/gemfiles/activerecord_5_0.gemfile @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gem 'activerecord', '~> 5.0.0' + +gemspec :path => '..' + +group :test do + gem 'rspec', '~> 2.0' + gem 'sqlite3', '~> 1.0', '< 1.4' +end diff --git a/lib/vestal_versions/users.rb b/lib/vestal_versions/users.rb index 167c930e..4d225f4d 100644 --- a/lib/vestal_versions/users.rb +++ b/lib/vestal_versions/users.rb @@ -6,13 +6,13 @@ module Users included do attr_accessor :updated_by - Version.class_eval{ include VersionMethods } + Version.class_eval{ include UserVersionMethods } end # Methods added to versioned ActiveRecord::Base instances to enable versioning with additional # user information. - - + + private # Overrides the +version_attributes+ method to include user information passed into the # parent object, by way of a +updated_by+ attr_accessor. @@ -22,14 +22,16 @@ def version_attributes end # Instance methods added to VestalVersions::Version to accomodate incoming user information. - module VersionMethods + module UserVersionMethods extend ActiveSupport::Concern included do belongs_to :user, :polymorphic => true - alias_method_chain :user, :name - alias_method_chain :user=, :name + alias_method :user_without_name, :user + alias_method :user, :user_with_name + alias_method :user_without_name=, :user= + alias_method :user=, :user_with_name= end # Overrides the +user+ method created by the polymorphic +belongs_to+ user association. If diff --git a/spec/support/schema.rb b/spec/support/schema.rb index 650f6b3c..95e63bd9 100644 --- a/spec/support/schema.rb +++ b/spec/support/schema.rb @@ -3,7 +3,11 @@ :database => File.expand_path('../../test.db', __FILE__) ) -class CreateSchema < ActiveRecord::Migration +major, minor = ActiveRecord.version.segments[0..1] +ar_migration = ActiveRecord::Migration +ar_migration = ar_migration["#{major}.#{minor}"] if major > 4 + +class CreateSchema < ar_migration def self.up create_table :users, :force => true do |t| t.string :first_name diff --git a/spec/vestal_versions/control_spec.rb b/spec/vestal_versions/control_spec.rb index 3ab76554..a8ddf94d 100644 --- a/spec/vestal_versions/control_spec.rb +++ b/spec/vestal_versions/control_spec.rb @@ -95,7 +95,7 @@ user.append_version{ user.update_attribute(:last_name, 'Jobs') } - other_last_version = user.versions(true).last + other_last_version = user.versions.reload.last other_last_version.id.should == original_id other_last_version.attributes.should_not == original_attrs end @@ -110,7 +110,7 @@ user.update_attribute(:first_name, 'Steve') end - other_last_version = user.versions(true).last + other_last_version = user.versions.reload.last other_last_version.id.should == original_id other_last_version.attributes.should_not == original_attrs end diff --git a/spec/vestal_versions/reset_spec.rb b/spec/vestal_versions/reset_spec.rb index 04a254e7..62075502 100644 --- a/spec/vestal_versions/reset_spec.rb +++ b/spec/vestal_versions/reset_spec.rb @@ -29,7 +29,7 @@ it 'dissociates all versions after the target' do versions.reverse.each do |version| subject.reset_to!(version) - subject.versions(true).after(version).count.should == 0 + subject.versions.reload.after(version).count.should == 0 end end diff --git a/vestal_versions.gemspec b/vestal_versions.gemspec index ed150d5a..bd757138 100644 --- a/vestal_versions.gemspec +++ b/vestal_versions.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |gem| gem.name = 'vestal_versions' - gem.version = '2.0.0' + gem.version = '2.1.0' gem.authors = ['Steve Richert', "James O'Kelly", 'C. Jason Harrelson'] gem.email = ['steve.richert@gmail.com', 'dreamr.okelly@gmail.com', 'jason@lookforwardenterprises.com'] @@ -11,10 +11,10 @@ Gem::Specification.new do |gem| gem.homepage = 'http://github.com/laserlemon/vestal_versions' gem.license = 'MIT' - gem.add_dependency 'activerecord', '>= 3', '< 5' - gem.add_dependency 'activesupport', '>= 3', '< 5' + gem.add_dependency 'activerecord', '>= 3', '< 6' + gem.add_dependency 'activesupport', '>= 3', '< 6' - gem.add_development_dependency 'bundler', '~> 1.0' + gem.add_development_dependency 'bundler' gem.add_development_dependency 'rake', '~> 10.0' gem.files = `git ls-files`.split($\)