superstore 1.0.10 → 1.0.11

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
  SHA1:
3
- metadata.gz: c19b1ea6b25bd38b5dd4a2a64c8b12002015b750
4
- data.tar.gz: b6ae687fdf28f34c3f0ec5577d8c0abce2044cfb
3
+ metadata.gz: e540e117a43369a7a1776533365a423982b5ad61
4
+ data.tar.gz: 903bc8a9def4a329f9e9ee054101e69364a9f3e1
5
5
  SHA512:
6
- metadata.gz: f6bdbbfde5df3bad14ea2cf542fb3eda7f888fecb6c9ae516055164300e3f74ca62b466c837286baaf5a270a1f32ccdbc310a1d4e456bf5cf9b00c4a1a2ff7c5
7
- data.tar.gz: 8bb6ba4bddcd5cf5887397223da51e52b9c607e754ec365ef1219a0857e9b8c408ee4c43b89b00abcad184ddafe3272e8c49e4b24215cddff9c1e71aac28381a
6
+ metadata.gz: 5c1b861cc83c89c001983c526de0b188d4b0ef5545039bd27dfdaedcdc73749170abb75999a1f984ea2879c76c4afffabfc4e83feee5b20dd6efc595fcf65c92
7
+ data.tar.gz: 9ee34533c2261152b867b13f89d49254f1eb36de5c2a496117589c8dec713089deee9fcd04f0cd7ad0eb51fb7c6d8bc328e031a164046447dc6cfcd97e29796f
@@ -12,7 +12,7 @@ module Superstore
12
12
  end
13
13
 
14
14
  before_update if: :changed? do
15
- self.updated_at = Time.current
15
+ self.updated_at = Time.current unless self.changed_attributes.key?("updated_at")
16
16
  end
17
17
  end
18
18
  end
data/superstore.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'superstore'
5
- s.version = '1.0.10'
5
+ s.version = '1.0.11'
6
6
  s.description = 'ActiveModel for many attributes'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
  s.authors = ["Michael Koziarski", "gotime"]
@@ -8,14 +8,22 @@ class Superstore::TimestampsTest < Superstore::TestCase
8
8
  assert_in_delta Time.now.to_i, issue.updated_at.to_i, 3
9
9
  end
10
10
 
11
- test 'updated_at set on change' do
11
+ test 'updated_at set nil on change' do
12
12
  issue = Issue.create
13
13
 
14
14
  issue.updated_at = nil
15
15
  issue.description = 'lol'
16
16
  issue.save
17
17
 
18
- assert_in_delta Time.now.to_i, issue.updated_at.to_i, 3
18
+ assert issue.updated_at.nil?
19
+ end
20
+
21
+ test 'updated_at can be set on change' do
22
+ issue = Issue.create
23
+
24
+ issue.update_attribute :updated_at, 30.days.ago
25
+
26
+ assert_in_delta 30.days.ago.to_i, issue.updated_at.to_i, 3
19
27
  end
20
28
 
21
29
  test 'created_at sets only if nil' do
@@ -24,4 +32,11 @@ class Superstore::TimestampsTest < Superstore::TestCase
24
32
 
25
33
  assert_equal time, issue.created_at
26
34
  end
35
+
36
+ test 'updated_at sets only if nil' do
37
+ time = 5.days.ago
38
+ issue = Issue.create updated_at: time
39
+
40
+ assert_equal time, issue.updated_at
41
+ end
27
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Koziarski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-22 00:00:00.000000000 Z
12
+ date: 2014-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel