ar_transaction_changes 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -19
- data/Gemfile.rails52 +1 -1
- data/ar_transaction_changes.gemspec +1 -1
- data/lib/ar_transaction_changes.rb +3 -8
- data/lib/ar_transaction_changes/version.rb +1 -1
- data/test/test_helper.rb +8 -3
- data/test/transaction_changes_test.rb +10 -1
- metadata +5 -9
- data/Gemfile.rails42 +0 -5
- data/Gemfile.rails50 +0 -5
- data/Gemfile.rails51 +0 -5
- data/Gemfile.rails60 +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2acb53b1999dcee1b3665da06ef90afec0801aee463790207632d3618120a28
|
4
|
+
data.tar.gz: edd02898b47f64d95ee7f0eb0d30859db66b75cf75b1a2a5112b42ecd808a89c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7b27f1e322d10dee7d93155594b8c174c2024dbecce12d4d1b6dd5b310664aa0a1df76b09ce4dc1c9c0332b752a2af4795386b95d4867bc0bb583ac1a280a9
|
7
|
+
data.tar.gz: 10a385416ff519564fff02e55df735718b50d3bf26a88788c396e6ba591b87ad0644d8290ea65ba6924ac7725a70fc46d36cb18e959923135d3307274395de93
|
data/.travis.yml
CHANGED
@@ -1,27 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
|
4
|
-
|
5
|
-
- 2.2.5
|
6
|
-
- 2.3.1
|
7
|
-
|
8
|
-
gemfile:
|
9
|
-
- Gemfile.rails42
|
10
|
-
- Gemfile.rails50
|
11
|
-
- Gemfile.rails51
|
12
|
-
- Gemfile.rails52
|
13
|
-
|
14
|
-
matrix:
|
4
|
+
jobs:
|
15
5
|
include:
|
16
|
-
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
- name: "Minimum supported versions"
|
7
|
+
rvm: 2.4
|
8
|
+
gemfile: Gemfile.rails52
|
9
|
+
- name: "Latest released versions"
|
10
|
+
rvm: 2.7
|
11
|
+
gemfile: Gemfile
|
12
|
+
- name: "Rails master branch"
|
13
|
+
rvm: 2.7
|
21
14
|
gemfile: Gemfile.rails_head
|
22
15
|
|
23
16
|
services:
|
24
17
|
- mysql
|
25
|
-
|
26
|
-
before_script:
|
27
|
-
- mysql -e 'create database ar_transaction_changes_test'
|
data/Gemfile.rails52
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "activerecord", ">=
|
20
|
+
gem.add_dependency "activerecord", ">= 5.2.0"
|
21
21
|
|
22
22
|
gem.add_development_dependency("rake")
|
23
23
|
gem.add_development_dependency("mysql2")
|
@@ -18,17 +18,12 @@ module ArTransactionChanges
|
|
18
18
|
@transaction_changed_attributes ||= HashWithIndifferentAccess.new
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
"_write_attribute"
|
23
|
-
else
|
24
|
-
"write_attribute"
|
25
|
-
end
|
26
|
-
|
27
|
-
define_method(method_name) do |attr_name, value|
|
21
|
+
def _write_attribute(attr_name, value)
|
28
22
|
attr_name = attr_name.to_s
|
29
23
|
old_value = read_attribute(attr_name)
|
30
24
|
ret = super(attr_name, value)
|
31
|
-
|
25
|
+
new_value = read_attribute(attr_name)
|
26
|
+
unless transaction_changed_attributes.key?(attr_name) || new_value == old_value
|
32
27
|
transaction_changed_attributes[attr_name] = old_value
|
33
28
|
end
|
34
29
|
ret
|
data/test/test_helper.rb
CHANGED
@@ -1,19 +1,24 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
1
|
require 'pathname'
|
3
2
|
require 'yaml'
|
4
3
|
require 'ar_transaction_changes'
|
5
4
|
require 'minitest/autorun'
|
6
5
|
|
6
|
+
ENV["RAILS_ENV"] = "test"
|
7
|
+
|
7
8
|
test_dir = Pathname.new(File.dirname(__FILE__))
|
8
9
|
config_filename = test_dir.join("database.yml").exist? ? "database.yml" : "database.yml.default"
|
9
10
|
database_yml = YAML.load(test_dir.join(config_filename).read)
|
10
|
-
|
11
|
+
database_config = database_yml.fetch("test")
|
12
|
+
|
13
|
+
ActiveRecord::Base.establish_connection(database_config.except("database"))
|
14
|
+
ActiveRecord::Base.connection.recreate_database(database_config.fetch("database"))
|
15
|
+
ActiveRecord::Base.establish_connection(database_config)
|
11
16
|
|
12
17
|
ActiveRecord::Base.connection.tap do |db|
|
13
|
-
db.drop_table(:users) if db.table_exists?(:users)
|
14
18
|
db.create_table(:users) do |t|
|
15
19
|
t.string :name
|
16
20
|
t.string :occupation
|
21
|
+
t.integer :age
|
17
22
|
t.timestamps null: false
|
18
23
|
end
|
19
24
|
end
|
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class TransactionChangesTest < MiniTest::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@user = User.new(:name => "Dylan", :occupation => "Developer")
|
5
|
+
@user = User.new(:name => "Dylan", :occupation => "Developer", age: 20)
|
6
6
|
@user.save!
|
7
7
|
@user.stored_transaction_changes = nil
|
8
8
|
end
|
@@ -94,4 +94,13 @@ class TransactionChangesTest < MiniTest::Unit::TestCase
|
|
94
94
|
end
|
95
95
|
refute @user.stored_transaction_changes["name"]
|
96
96
|
end
|
97
|
+
|
98
|
+
def test_transaction_changes_type_cast
|
99
|
+
# "20" will be converted to 20 by read_attribute https://apidock.com/rails/ActiveRecord/AttributeMethods/read_attribute
|
100
|
+
@user.transaction do
|
101
|
+
@user.age = "20"
|
102
|
+
@user.save!
|
103
|
+
end
|
104
|
+
assert_empty @user.stored_transaction_changes
|
105
|
+
end
|
97
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_transaction_changes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Thacker-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,11 +63,7 @@ files:
|
|
63
63
|
- ".gitignore"
|
64
64
|
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
|
-
- Gemfile.rails42
|
67
|
-
- Gemfile.rails50
|
68
|
-
- Gemfile.rails51
|
69
66
|
- Gemfile.rails52
|
70
|
-
- Gemfile.rails60
|
71
67
|
- Gemfile.rails_head
|
72
68
|
- LICENSE.txt
|
73
69
|
- README.md
|
@@ -97,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
93
|
- !ruby/object:Gem::Version
|
98
94
|
version: '0'
|
99
95
|
requirements: []
|
100
|
-
rubygems_version: 3.0.
|
96
|
+
rubygems_version: 3.0.3
|
101
97
|
signing_key:
|
102
98
|
specification_version: 4
|
103
99
|
summary: Store transaction changes for active record objects
|
data/Gemfile.rails42
DELETED
data/Gemfile.rails50
DELETED
data/Gemfile.rails51
DELETED