houston-vestal_versions 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/tests.yml +31 -0
- data/Gemfile +2 -1
- data/README.rdoc +3 -3
- data/lib/vestal_versions/changes.rb +2 -2
- data/lib/vestal_versions/control.rb +3 -3
- data/lib/vestal_versions/users.rb +9 -4
- data/spec/support/schema.rb +1 -1
- data/spec/vestal_versions/control_spec.rb +2 -2
- data/spec/vestal_versions/deletion_spec.rb +1 -1
- data/spec/vestal_versions/reset_spec.rb +1 -1
- data/spec/vestal_versions/reversion_spec.rb +3 -3
- data/spec/vestal_versions/users_spec.rb +3 -3
- data/spec/vestal_versions/version_spec.rb +3 -3
- data/spec/vestal_versions/versions_spec.rb +4 -4
- data/vestal_versions.gemspec +5 -5
- metadata +12 -29
- data/.travis.yml +0 -22
- data/gemfiles/activerecord_3_0.gemfile +0 -10
- data/gemfiles/activerecord_3_1.gemfile +0 -10
- data/gemfiles/activerecord_3_2.gemfile +0 -10
- data/gemfiles/activerecord_4_0.gemfile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3962787d496c71f96a2f1fae00a860ab372d8508acbe8bdbf84f5c28e49d812
|
4
|
+
data.tar.gz: 41649745092de1a1f2305ada45db52c4148a1ac95d1ab6812facd1c3549b7eab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5401fd38ceb38810afd696ce588c3707ed87818f06d36ed9798032bda4831db522045f156fc5312655370ca0add43106096640318942a54714976f88c8871a1d
|
7
|
+
data.tar.gz: 5e6130a2dbf8b1ff02c105d66225345a4959c814ce5398172f71fef3080256d3c5f346c471260f6f08aad867ecc9458fcd1bf7c13da4c268e445d6548fb75637
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Tests
|
2
|
+
on: [push]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
ruby:
|
6
|
+
name: Rspec
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [2.5, 2.6, 2.7]
|
12
|
+
activerecord: ["5.0", "5.1", "5.2", "6.0"]
|
13
|
+
steps:
|
14
|
+
- name: Checkout
|
15
|
+
uses: actions/checkout@v2
|
16
|
+
- name: Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
- name: Set ActiveRecord Version
|
21
|
+
env:
|
22
|
+
AR_VERSION: ${{ matrix.activerecord }}
|
23
|
+
run: echo "gem 'activerecord', '~> $AR_VERSION'" >> Gemfile
|
24
|
+
- name: Install Sqlite
|
25
|
+
run: sudo apt-get install libsqlite3-dev
|
26
|
+
- name: Bundle
|
27
|
+
run: |
|
28
|
+
bundle config path vendor/bundle
|
29
|
+
bundle install --jobs 4 --retry 3
|
30
|
+
- name: Tests
|
31
|
+
run: bundle exec rake spec
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -119,7 +119,7 @@ There are a handful of exciting new additions in version 1.0 of <tt>vestal_versi
|
|
119
119
|
@user.update_attribute(:first_name, "Stephen")
|
120
120
|
@user.first_name = "Steve"
|
121
121
|
@user.save
|
122
|
-
@user.
|
122
|
+
@user.update(:last_name => "Jobs")
|
123
123
|
end
|
124
124
|
@user.version # => 1
|
125
125
|
|
@@ -154,12 +154,12 @@ There are a handful of exciting new additions in version 1.0 of <tt>vestal_versi
|
|
154
154
|
|
155
155
|
* Storing which user is responsible for a revision. Rather than introduce a lot of controller magic to guess what to store, you can simply update an additional attribute on your versioned model: <tt>updated_by</tt>.
|
156
156
|
|
157
|
-
@user.
|
157
|
+
@user.update(:last_name => "Jobs", :updated_by => "Tyler")
|
158
158
|
@user.versions.last.user # => "Tyler"
|
159
159
|
|
160
160
|
Instead of passing a simple string to the <tt>updated_by</tt> setter, you can pass a model instance, such as an ActiveRecord user or administrator. The association will be saved polymorphically alongside the version.
|
161
161
|
|
162
|
-
@user.
|
162
|
+
@user.update(:last_name => "Jobs", :updated_by => current_user)
|
163
163
|
@user.versions.last.user # => #<User first_name: "Steven", last_name: "Tyler">
|
164
164
|
|
165
165
|
* Global configuration. The new <tt>vestal_versions</tt> Rails generator also writes an initializer with instructions on how to set application-wide options for the <tt>versioned</tt> method.
|
@@ -48,7 +48,7 @@ module VestalVersions
|
|
48
48
|
# creation. Incremental changes are reset when the record is saved because they represent
|
49
49
|
# a subset of the dirty attribute changes, which are reset upon save.
|
50
50
|
def incremental_version_changes
|
51
|
-
|
51
|
+
previous_changes.slice(*versioned_columns)
|
52
52
|
end
|
53
53
|
|
54
54
|
# Simply resets the cumulative changes after version creation.
|
@@ -118,4 +118,4 @@ module VestalVersions
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
121
|
-
end
|
121
|
+
end
|
@@ -12,7 +12,7 @@ module VestalVersions
|
|
12
12
|
# Control blocks are called on ActiveRecord::Base instances as to not cause any conflict with
|
13
13
|
# other instances of the versioned class whose behavior could be inadvertently altered within
|
14
14
|
# a control block.
|
15
|
-
|
15
|
+
|
16
16
|
# The +skip_version+ block simply allows for updates to be made to an instance of a versioned
|
17
17
|
# ActiveRecord model while ignoring all new version creation. The <tt>:if</tt> and
|
18
18
|
# <tt>:unless</tt> conditions (if given) will not be evaulated inside a +skip_version+ block.
|
@@ -55,7 +55,7 @@ module VestalVersions
|
|
55
55
|
# user = User.find_by_first_name("Steve")
|
56
56
|
# user.version # => 1
|
57
57
|
# user.merge_version do
|
58
|
-
# user.
|
58
|
+
# user.update(:first_name => "Steven", :last_name => "Tyler")
|
59
59
|
# user.update_attribute(:first_name, "Stephen")
|
60
60
|
# user.update_attribute(:last_name, "Richert")
|
61
61
|
# end
|
@@ -159,7 +159,7 @@ module VestalVersions
|
|
159
159
|
def update_version?
|
160
160
|
append_version?
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
module ClassMethods
|
164
164
|
# The +skip_version+ block simply allows for updates to be made to an instance of a versioned
|
165
165
|
# ActiveRecord model while ignoring all new version creation. The <tt>:if</tt> and
|
@@ -11,8 +11,8 @@ module VestalVersions
|
|
11
11
|
|
12
12
|
# Methods added to versioned ActiveRecord::Base instances to enable versioning with additional
|
13
13
|
# user information.
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
|
16
16
|
private
|
17
17
|
# Overrides the +version_attributes+ method to include user information passed into the
|
18
18
|
# parent object, by way of a +updated_by+ attr_accessor.
|
@@ -28,8 +28,13 @@ module VestalVersions
|
|
28
28
|
included do
|
29
29
|
belongs_to :user, :polymorphic => true
|
30
30
|
|
31
|
-
alias_method_chain :user, :name
|
32
|
-
|
31
|
+
# alias_method_chain :user, :name
|
32
|
+
alias_method :user_without_name, :user
|
33
|
+
alias_method :user, :user_with_name
|
34
|
+
|
35
|
+
# alias_method_chain :user=, :name
|
36
|
+
alias_method :user_without_name=, :user=
|
37
|
+
alias_method :user=, :user_with_name=
|
33
38
|
end
|
34
39
|
|
35
40
|
# Overrides the +user+ method created by the polymorphic +belongs_to+ user association. If
|
data/spec/support/schema.rb
CHANGED
@@ -3,7 +3,7 @@ ActiveRecord::Base.establish_connection(
|
|
3
3
|
:database => File.expand_path('../../test.db', __FILE__)
|
4
4
|
)
|
5
5
|
|
6
|
-
class CreateSchema < ActiveRecord::Migration
|
6
|
+
class CreateSchema < ActiveRecord::Migration[4.2]
|
7
7
|
def self.up
|
8
8
|
create_table :users, :force => true do |t|
|
9
9
|
t.string :first_name
|
@@ -95,7 +95,7 @@ describe VestalVersions::Control do
|
|
95
95
|
|
96
96
|
user.append_version{ user.update_attribute(:last_name, 'Jobs') }
|
97
97
|
|
98
|
-
other_last_version = user.versions
|
98
|
+
other_last_version = user.versions.reload.last
|
99
99
|
other_last_version.id.should == original_id
|
100
100
|
other_last_version.attributes.should_not == original_attrs
|
101
101
|
end
|
@@ -110,7 +110,7 @@ describe VestalVersions::Control do
|
|
110
110
|
user.update_attribute(:first_name, 'Steve')
|
111
111
|
end
|
112
112
|
|
113
|
-
other_last_version = user.versions
|
113
|
+
other_last_version = user.versions.reload.last
|
114
114
|
other_last_version.id.should == original_id
|
115
115
|
other_last_version.attributes.should_not == original_attrs
|
116
116
|
end
|
@@ -60,7 +60,7 @@ describe VestalVersions::Deletion do
|
|
60
60
|
|
61
61
|
it "restores even if the schema has changed" do
|
62
62
|
new_mods = last_version.modifications.merge(:old_column => 'old')
|
63
|
-
last_version.
|
63
|
+
last_version.update(:modifications => new_mods)
|
64
64
|
|
65
65
|
last_version.restore.should == subject
|
66
66
|
end
|
@@ -29,7 +29,7 @@ describe VestalVersions::Reset do
|
|
29
29
|
it 'dissociates all versions after the target' do
|
30
30
|
versions.reverse.each do |version|
|
31
31
|
subject.reset_to!(version)
|
32
|
-
subject.versions
|
32
|
+
subject.versions.reload.after(version).count.should == 0
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -73,7 +73,7 @@ describe VestalVersions::Reversion do
|
|
73
73
|
|
74
74
|
it "does not store the reverted_from for subsequent saves" do
|
75
75
|
subject.revert_to!(1)
|
76
|
-
subject.
|
76
|
+
subject.update(:name => 'Bill Gates')
|
77
77
|
subject.versions.last.reverted_from.should be_nil
|
78
78
|
end
|
79
79
|
|
@@ -88,14 +88,14 @@ describe VestalVersions::Reversion do
|
|
88
88
|
subject.revert_to(1)
|
89
89
|
subject.name = "Reverted"
|
90
90
|
subject.save
|
91
|
-
subject.
|
91
|
+
subject.update(:name => 'Bill Gates')
|
92
92
|
subject.versions.last.reverted_from.should be_nil
|
93
93
|
end
|
94
94
|
|
95
95
|
it "clears the reverted_from if the model is reloaded after a revert_to without a save" do
|
96
96
|
subject.revert_to(1)
|
97
97
|
subject.reload
|
98
|
-
subject.
|
98
|
+
subject.update(:name => 'Bill Gates')
|
99
99
|
|
100
100
|
subject.versions.last.reverted_from.should be_nil
|
101
101
|
end
|
@@ -5,17 +5,17 @@ describe VestalVersions::Users do
|
|
5
5
|
let(:user){ User.create(:name => 'Steve Richert') }
|
6
6
|
|
7
7
|
it 'defaults to nil' do
|
8
|
-
user.
|
8
|
+
user.update(:first_name => 'Stephen')
|
9
9
|
user.versions.last.user.should be_nil
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'accepts and returns an ActiveRecord user' do
|
13
|
-
user.
|
13
|
+
user.update(:first_name => 'Stephen', :updated_by => updated_by)
|
14
14
|
user.versions.last.user.should == updated_by
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'accepts and returns a string user name' do
|
18
|
-
user.
|
18
|
+
user.update(:first_name => 'Stephen', :updated_by => updated_by.name)
|
19
19
|
user.versions.last.user.should == updated_by.name
|
20
20
|
end
|
21
21
|
end
|
@@ -40,7 +40,7 @@ describe VestalVersions::Versions do
|
|
40
40
|
version.number.should == 1
|
41
41
|
version.should be_initial
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "sreturn the version number if it is not a revert" do
|
45
45
|
user.version.should == user.versions.last.original_number
|
46
46
|
end
|
@@ -53,9 +53,9 @@ describe VestalVersions::Versions do
|
|
53
53
|
it "return the original version if it is a double revert" do
|
54
54
|
user.revert_to!(2)
|
55
55
|
version = user.version
|
56
|
-
user.
|
56
|
+
user.update(:last_name => 'Gates')
|
57
57
|
user.revert_to!(version)
|
58
58
|
user.versions.last.original_number.should == 2
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
end
|
@@ -125,15 +125,15 @@ describe VestalVersions::Versions do
|
|
125
125
|
|
126
126
|
it 'provides a version number for any given numeric version value' do
|
127
127
|
times.keys.each do |number|
|
128
|
-
subject.versions.number_at(number).should be_a(
|
129
|
-
subject.versions.number_at(number + 0.5).should be_a(
|
128
|
+
subject.versions.number_at(number).should be_a(Integer)
|
129
|
+
subject.versions.number_at(number + 0.5).should be_a(Integer)
|
130
130
|
subject.versions.number_at(number).should == subject.versions.number_at(number + 0.5)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'provides a version number for a valid tag' do
|
135
135
|
times.keys.map{|n| [n, n.to_s] }.each do |number, tag|
|
136
|
-
subject.versions.number_at(tag).should be_a(
|
136
|
+
subject.versions.number_at(tag).should be_a(Integer)
|
137
137
|
subject.versions.number_at(tag).should == number
|
138
138
|
end
|
139
139
|
end
|
@@ -155,7 +155,7 @@ describe VestalVersions::Versions do
|
|
155
155
|
|
156
156
|
it "provides a version number for any time after the model's creation" do
|
157
157
|
times.each do |number, time|
|
158
|
-
subject.versions.number_at(time + 30.minutes).should be_a(
|
158
|
+
subject.versions.number_at(time + 30.minutes).should be_a(Integer)
|
159
159
|
subject.versions.number_at(time + 30.minutes).should == number
|
160
160
|
end
|
161
161
|
end
|
data/vestal_versions.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'houston-vestal_versions'
|
5
|
-
gem.version = '
|
5
|
+
gem.version = '3.0.0'
|
6
6
|
|
7
7
|
gem.authors = ['Steve Richert', "James O'Kelly", 'C. Jason Harrelson']
|
8
8
|
gem.email = ['steve.richert@gmail.com', 'dreamr.okelly@gmail.com', 'jason@lookforwardenterprises.com']
|
@@ -11,11 +11,11 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.homepage = 'http://github.com/laserlemon/vestal_versions'
|
12
12
|
gem.license = 'MIT'
|
13
13
|
|
14
|
-
gem.add_dependency 'activerecord', '>=
|
15
|
-
gem.add_dependency 'activesupport', '>=
|
14
|
+
gem.add_dependency 'activerecord', '>= 5'
|
15
|
+
gem.add_dependency 'activesupport', '>= 5'
|
16
16
|
|
17
|
-
gem.add_development_dependency 'bundler', '
|
18
|
-
gem.add_development_dependency 'rake', '
|
17
|
+
gem.add_development_dependency 'bundler', '>= 1.0'
|
18
|
+
gem.add_development_dependency 'rake', '>= 10.0'
|
19
19
|
|
20
20
|
gem.files = `git ls-files`.split($\)
|
21
21
|
gem.test_files = gem.files.grep(/^spec/)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: houston-vestal_versions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Richert
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-07-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,66 +18,54 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
-
- - "<"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '6'
|
21
|
+
version: '5'
|
25
22
|
type: :runtime
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
requirements:
|
29
26
|
- - ">="
|
30
27
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
32
|
-
- - "<"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '6'
|
28
|
+
version: '5'
|
35
29
|
- !ruby/object:Gem::Dependency
|
36
30
|
name: activesupport
|
37
31
|
requirement: !ruby/object:Gem::Requirement
|
38
32
|
requirements:
|
39
33
|
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
42
|
-
- - "<"
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '6'
|
35
|
+
version: '5'
|
45
36
|
type: :runtime
|
46
37
|
prerelease: false
|
47
38
|
version_requirements: !ruby/object:Gem::Requirement
|
48
39
|
requirements:
|
49
40
|
- - ">="
|
50
41
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
52
|
-
- - "<"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '6'
|
42
|
+
version: '5'
|
55
43
|
- !ruby/object:Gem::Dependency
|
56
44
|
name: bundler
|
57
45
|
requirement: !ruby/object:Gem::Requirement
|
58
46
|
requirements:
|
59
|
-
- - "
|
47
|
+
- - ">="
|
60
48
|
- !ruby/object:Gem::Version
|
61
49
|
version: '1.0'
|
62
50
|
type: :development
|
63
51
|
prerelease: false
|
64
52
|
version_requirements: !ruby/object:Gem::Requirement
|
65
53
|
requirements:
|
66
|
-
- - "
|
54
|
+
- - ">="
|
67
55
|
- !ruby/object:Gem::Version
|
68
56
|
version: '1.0'
|
69
57
|
- !ruby/object:Gem::Dependency
|
70
58
|
name: rake
|
71
59
|
requirement: !ruby/object:Gem::Requirement
|
72
60
|
requirements:
|
73
|
-
- - "
|
61
|
+
- - ">="
|
74
62
|
- !ruby/object:Gem::Version
|
75
63
|
version: '10.0'
|
76
64
|
type: :development
|
77
65
|
prerelease: false
|
78
66
|
version_requirements: !ruby/object:Gem::Requirement
|
79
67
|
requirements:
|
80
|
-
- - "
|
68
|
+
- - ">="
|
81
69
|
- !ruby/object:Gem::Version
|
82
70
|
version: '10.0'
|
83
71
|
description: Keep a DRY history of your ActiveRecord models' changes
|
@@ -89,17 +77,13 @@ executables: []
|
|
89
77
|
extensions: []
|
90
78
|
extra_rdoc_files: []
|
91
79
|
files:
|
80
|
+
- ".github/workflows/tests.yml"
|
92
81
|
- ".gitignore"
|
93
|
-
- ".travis.yml"
|
94
82
|
- CHANGELOG.md
|
95
83
|
- Gemfile
|
96
84
|
- LICENSE
|
97
85
|
- README.rdoc
|
98
86
|
- Rakefile
|
99
|
-
- gemfiles/activerecord_3_0.gemfile
|
100
|
-
- gemfiles/activerecord_3_1.gemfile
|
101
|
-
- gemfiles/activerecord_3_2.gemfile
|
102
|
-
- gemfiles/activerecord_4_0.gemfile
|
103
87
|
- lib/generators/vestal_versions.rb
|
104
88
|
- lib/generators/vestal_versions/migration/migration_generator.rb
|
105
89
|
- lib/generators/vestal_versions/migration/templates/initializer.rb
|
@@ -156,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
140
|
- !ruby/object:Gem::Version
|
157
141
|
version: '0'
|
158
142
|
requirements: []
|
159
|
-
|
160
|
-
rubygems_version: 2.5.1
|
143
|
+
rubygems_version: 3.1.6
|
161
144
|
signing_key:
|
162
145
|
specification_version: 4
|
163
146
|
summary: Keep a DRY history of your ActiveRecord models' changes
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
branches:
|
2
|
-
only:
|
3
|
-
- master
|
4
|
-
gemfile:
|
5
|
-
- gemfiles/activerecord_3_0.gemfile
|
6
|
-
- gemfiles/activerecord_3_1.gemfile
|
7
|
-
- gemfiles/activerecord_3_2.gemfile
|
8
|
-
- gemfiles/activerecord_4_0.gemfile
|
9
|
-
language: ruby
|
10
|
-
matrix:
|
11
|
-
allow_failures:
|
12
|
-
- rvm: ruby-head
|
13
|
-
include:
|
14
|
-
- env: COVERAGE=1
|
15
|
-
gemfile: Gemfile
|
16
|
-
rvm: 2.1.0
|
17
|
-
rvm:
|
18
|
-
- 1.9.3
|
19
|
-
- 2.0.0
|
20
|
-
- 2.1.0
|
21
|
-
- ruby-head
|
22
|
-
script: bundle exec rspec
|