groovy 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/groovy/model.rb +7 -3
- data/lib/groovy/version.rb +1 -1
- data/spec/model_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d24298885415bc4acd243ec853d839187216d3f3bf8be758e309168fb3a4b4a6
|
4
|
+
data.tar.gz: c8a743dab8efe577290c91688e5107114bd5c0c7a7153f79db4d6985ce4467dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 156828c23af648e267cee9a761183dd49b7d16d783fb993cee0653a449340c23bd25c03162da6666f30cc3989978c196d671198ac8da041bace897aa1bb0419d
|
7
|
+
data.tar.gz: 100290a07dabdd5da4dacd586ff5571c08c433b4f182a91530eb31bc6d5c78b21960d056190d73054952e614e21e428018ea2f8bad9b2637633739929d1216e7
|
data/lib/groovy/model.rb
CHANGED
@@ -353,10 +353,16 @@ module Groovy
|
|
353
353
|
@attributes
|
354
354
|
end
|
355
355
|
|
356
|
+
alias_method :attrs, :attributes
|
357
|
+
|
356
358
|
def inspect
|
357
359
|
"#<#{self.class.name} id:#{id.inspect} attributes:[#{self.class.attribute_names.join(', ')}]>"
|
358
360
|
end
|
359
361
|
|
362
|
+
def dump
|
363
|
+
pp attributes; nil
|
364
|
+
end
|
365
|
+
|
360
366
|
def new_record?
|
361
367
|
id.nil?
|
362
368
|
# _key.nil?
|
@@ -474,7 +480,6 @@ module Groovy
|
|
474
480
|
|
475
481
|
private
|
476
482
|
|
477
|
-
|
478
483
|
def get_record_attribute(key)
|
479
484
|
return if record.nil?
|
480
485
|
val = record[key]
|
@@ -511,7 +516,6 @@ module Groovy
|
|
511
516
|
end
|
512
517
|
end
|
513
518
|
|
514
|
-
|
515
519
|
def set_ref(name, obj, from_foreign = false)
|
516
520
|
# puts "Setting ref #{name} -> #{obj} (#{obj.class})"
|
517
521
|
|
@@ -569,7 +573,7 @@ module Groovy
|
|
569
573
|
# puts "Updating #{key} from #{values[0]} to #{values[1]}"
|
570
574
|
record[key] = values.last
|
571
575
|
end
|
572
|
-
self.class.set_timestamp(record, :updated_at)
|
576
|
+
self.class.set_timestamp(record, :updated_at) unless changes[:updated_at]
|
573
577
|
changes = {}
|
574
578
|
update_foreign_refs
|
575
579
|
fire_callbacks(:after_update)
|
data/lib/groovy/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -123,6 +123,21 @@ describe Groovy::Model do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
describe '#save' do
|
126
|
+
|
127
|
+
it 'sets created_at/updated_at timestamps when necesssary' do
|
128
|
+
time = Time.parse('2012-12-12')
|
129
|
+
allow(Time).to receive(:now).and_return(time)
|
130
|
+
prod = TestProduct.create!(name: 'A product', price: 100)
|
131
|
+
expect(prod.created_at).to eq(time)
|
132
|
+
expect(prod.updated_at).to eq(time)
|
133
|
+
|
134
|
+
another_time = Time.parse('2024-12-12')
|
135
|
+
prod.updated_at = another_time
|
136
|
+
prod.save
|
137
|
+
|
138
|
+
expect(prod.reload.created_at).to eq(time)
|
139
|
+
expect(prod.updated_at).to eq(another_time)
|
140
|
+
end
|
126
141
|
end
|
127
142
|
|
128
143
|
describe '#delete' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groovy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomás Pollak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rroonga
|