historiographer 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/historiographer.gemspec +2 -2
- data/lib/historiographer.rb +3 -1
- data/spec/historiographer_spec.rb +25 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb038b8ee2ab30ab82ee72f3191328bf6dfbd895f1052d7023e75ccc4beb7189
|
4
|
+
data.tar.gz: 73e36c7f2576b916666ca4ecf43e8041f098faf6e0a8ed003db37f78b1515e48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06b64598ac55f5c011f3e58bca504eaf270430b913e2eb00e74234d19b6601aeed4f4de75463d15a74e979effb3dcc0062f26273f46e021145a21eb9c7357ac9
|
7
|
+
data.tar.gz: c619f5a42db6e3fc8521445ed8c0d8517ce211591ffe440fdd08507e776b0e45b9dbbfa5962f11073c68bdad26a33593c538f4817ee2e2b48dd494eb5f162403
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.1
|
data/historiographer.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: historiographer 1.4.
|
5
|
+
# stub: historiographer 1.4.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "historiographer".freeze
|
9
|
-
s.version = "1.4.
|
9
|
+
s.version = "1.4.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
data/lib/historiographer.rb
CHANGED
@@ -91,7 +91,9 @@ module Historiographer
|
|
91
91
|
end
|
92
92
|
|
93
93
|
alias_method :destroy_without_history, :destroy
|
94
|
-
def destroy_with_history(history_user_id: )
|
94
|
+
def destroy_with_history(history_user_id: nil)
|
95
|
+
history_user_absent_action if history_user_id.nil?
|
96
|
+
|
95
97
|
current_history = histories.where(history_ended_at: nil).order("id desc").limit(1).last
|
96
98
|
current_history.update!(history_ended_at: UTC.now) if current_history.present?
|
97
99
|
|
@@ -10,6 +10,7 @@ end
|
|
10
10
|
|
11
11
|
class SafePost < ActiveRecord::Base
|
12
12
|
include Historiographer::Safe
|
13
|
+
acts_as_paranoid
|
13
14
|
end
|
14
15
|
|
15
16
|
class SafePostHistory < ActiveRecord::Base
|
@@ -445,6 +446,30 @@ describe Historiographer do
|
|
445
446
|
expect(PostHistory.where.not(deleted_at: nil).count).to eq 1
|
446
447
|
expect(PostHistory.last.history_user_id).to eq 2
|
447
448
|
end
|
449
|
+
|
450
|
+
it "works with Historiographer::Safe" do
|
451
|
+
post = SafePost.create(title: "HELLO", body: "YO", author_id: 1)
|
452
|
+
|
453
|
+
expect {
|
454
|
+
post.destroy
|
455
|
+
}.to_not raise_error
|
456
|
+
|
457
|
+
expect(SafePost.count).to eq 0
|
458
|
+
expect(post.deleted_at).to_not be_nil
|
459
|
+
expect(SafePostHistory.count).to eq 2
|
460
|
+
expect(SafePostHistory.current.last.deleted_at).to eq post.deleted_at
|
461
|
+
|
462
|
+
post2 = SafePost.create(title: "HELLO", body: "YO", author_id: 1)
|
463
|
+
|
464
|
+
expect {
|
465
|
+
post2.destroy!
|
466
|
+
}.to_not raise_error
|
467
|
+
|
468
|
+
expect(SafePost.count).to eq 0
|
469
|
+
expect(post2.deleted_at).to_not be_nil
|
470
|
+
expect(SafePostHistory.count).to eq 4
|
471
|
+
expect(SafePostHistory.current.where(safe_post_id: post2.id).last.deleted_at).to eq post2.deleted_at
|
472
|
+
end
|
448
473
|
end
|
449
474
|
|
450
475
|
describe "Scopes" do
|