Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gemfiles/activerecord_5_0.gemfile
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions lib/vestal_versions/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec/support/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/vestal_versions/control_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/vestal_versions/reset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions vestal_versions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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($\)
Expand Down