active_record-events 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5039a0306f7a2a2c89a4e6cea36d6995153caeaf8e2941ac12baea60e351f9bd
4
- data.tar.gz: ffaa64e1917f5824b67e9a9b72f6edff09a25b05149aff624c08974e8ab264b5
3
+ metadata.gz: 18d2fc6a8788d3190b5da3dd8dc45fbf307bb55344a6072ba24db67ff9b0e6cb
4
+ data.tar.gz: 17767f7e00810c9717cc5fa4bd92d49303b22427eb5da06a3f27ea39f8a4fbf8
5
5
  SHA512:
6
- metadata.gz: ce136868ee5545c3a13d28a766b43adb868c3b6f4e92574f006eb7338d1247982fceeff0aca60f39ad395b90bfb002a65f964f2180914dde566397e79676918b
7
- data.tar.gz: 9acbffdd536499d00fb481d3eb16d60798fb34e6cfdefb0daf5c6f1400e5b3cb750d5e50892dea62c897c673d0f2e14221173ea1cba486cccc77f6b6ffe4055a
6
+ metadata.gz: d39a25b8c5695aa8c81b9780744f0639ab2b0bac74296486721ec1c28cad0c67f801441b78c3faa48162d60938297a33638dada9e597a84a7c8c888c94cc86b2
7
+ data.tar.gz: afb5395aba7821776ff9aa3790d0f04f625daa1a4de6495e9069cf210a4ea3023b7449bb6cce58e9eb158887a541da6f927b9ba03e61df0974b6cd473a6beacf
data/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  An ActiveRecord extension providing convenience methods for timestamp management.
4
4
 
5
+ ## Screencast
6
+
7
+ <a href="https://www.youtube.com/watch?v=TIR7YDF3O-4">
8
+ <img src="https://img.youtube.com/vi/TIR7YDF3O-4/maxresdefault.jpg" title="ActiveRecord::Events - Awesome Ruby Gems" width="50%">
9
+ </a>
10
+
11
+ [Watch screencast](https://www.youtube.com/watch?v=TIR7YDF3O-4) (courtesy of [Mike Rogers](https://github.com/MikeRogers0))
12
+
5
13
  ## Installation
6
14
 
7
15
  Add the following line to your application's Gemfile:
@@ -199,6 +207,7 @@ end
199
207
  - [Bartosz Pieńkowski](https://github.com/pienkowb)
200
208
  - [Tomasz Skupiński](https://github.com/tskupinski)
201
209
  - [Oskar Janusz](https://github.com/oskaror)
210
+ - [Mike Rogers](https://github.com/MikeRogers0)
202
211
 
203
212
  ## See also
204
213
 
@@ -48,7 +48,11 @@ module ActiveRecord
48
48
 
49
49
  def define_action_method(module_, naming)
50
50
  module_.send(:define_method, naming.action) do
51
- touch(naming.field)
51
+ if persisted?
52
+ touch(naming.field)
53
+ else
54
+ self[naming.field] = current_time_from_proper_timezone
55
+ end
52
56
  end
53
57
  end
54
58
 
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Events
3
- VERSION = '4.0.0'.freeze
3
+ VERSION = '4.0.1'.freeze
4
4
  end
5
5
  end
@@ -32,6 +32,16 @@ RSpec.describe ActiveRecord::Events do
32
32
  expect(task.completed_at).to eq(Time.current)
33
33
  end
34
34
 
35
+ context 'with a non-persisted object' do
36
+ it 'updates the timestamp' do
37
+ task = build(:task, completed_at: 3.days.ago)
38
+
39
+ task.complete!
40
+
41
+ expect(task.completed_at).to eq(Time.current)
42
+ end
43
+ end
44
+
35
45
  it 'records multiple timestamps at once' do
36
46
  Task.complete_all
37
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Pieńkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord