hstore_accessor 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a802c392aa44501909aca2592be40d690f047ae
4
- data.tar.gz: 3a6c54bc24ba9d4202fe8d17331f9958a66fb752
3
+ metadata.gz: 6d1d9d199923f0290f48ead646d03e1be0f0b009
4
+ data.tar.gz: ffc1ee0d3cd7a29c0805d3e92dcb627ce0077a8f
5
5
  SHA512:
6
- metadata.gz: 6e29122e812fa3097e773f8e6a81116d7b9809975406ba91d6b6c5a2dcda399678db3cce6d3ec6e75cfb3acd0479ff9ab71f03ed9fd61825e0cb19afc3e5fe6b
7
- data.tar.gz: 8b6cc7c1d1bf7bcdcfd52c7f158b283782f8a722c1607538c5c0d40645ae2af7f230bd5d745d1427ffb28703dbf81bf53407a3f3b405cf113a65fecc5d1b9795
6
+ metadata.gz: 40623599c41d3321f48291f5dad8ad8fd38597883e100b8493efe279446ba7da1d4de6c7c2f4d5a77c0c3ff32fcd092229b412e3dd400f1ef02a808649e70359
7
+ data.tar.gz: 6043b45908543deed165f6817d9c6c8ee4109b68ab7e6bd932f10fe07b18c312f77f00e2673a104f12dde4fd325e90a9784a72923e180e353029e4b2c6caf0fa
@@ -0,0 +1 @@
1
+ 2.1.5
@@ -92,7 +92,7 @@ module HstoreAccessor
92
92
  hstore_changes = send("#{hstore_attribute}_change")
93
93
  return if hstore_changes.nil?
94
94
  attribute_changes = hstore_changes.map { |change| change.try(:[], store_key.to_s) }
95
- attribute_changes.compact.present? ? attribute_changes : nil
95
+ attribute_changes.uniq.size == 1 ? nil : attribute_changes
96
96
  end
97
97
 
98
98
  define_method("restore_#{key}!") do
@@ -1,3 +1,3 @@
1
1
  module HstoreAccessor
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -161,8 +161,9 @@ describe HstoreAccessor do
161
161
  let!(:product_category) { ProductCategory.create!(name: "widget", likes: 2) }
162
162
 
163
163
  before do
164
- product_category.products = Product.all
165
- product_category.save!
164
+ Product.all.to_a.each do |product|
165
+ product_category.products << product
166
+ end
166
167
  end
167
168
 
168
169
  context "eq query" do
@@ -442,7 +443,7 @@ describe HstoreAccessor do
442
443
  product.save!
443
444
  product.reload
444
445
  Time.use_zone(new_york_timezone) do
445
- expect(product.build_timestamp.utc_offset).to eq new_york_timezone.utc_offset
446
+ expect(product.build_timestamp.to_s).to eq timestamp.in_time_zone(new_york_timezone).to_s
446
447
  end
447
448
  end
448
449
  end
@@ -625,12 +626,14 @@ describe HstoreAccessor do
625
626
  product.color = "GREEN"
626
627
  expect(product.color_change).to eq %w(ORANGE GREEN)
627
628
  end
629
+
628
630
  context "when store_key differs from key" do
629
631
  it "returns the old and new values" do
630
632
  product.weight = 100.01
631
633
  expect(product.weight_change[1]).to eq "100.01"
632
634
  end
633
635
  end
636
+
634
637
  context "hstore attribute was nil" do
635
638
  it "returns old and new values" do
636
639
  product.options = nil
@@ -647,6 +650,18 @@ describe HstoreAccessor do
647
650
  product.price = 6
648
651
  expect(product.color_change).to be_nil
649
652
  end
653
+
654
+ it "returns nil when other attributes were changed" do
655
+ product.price = 5
656
+ product.save!
657
+ product = Product.first
658
+
659
+ expect(product.price_change).to be_nil
660
+
661
+ product.color = "red"
662
+
663
+ expect(product.price_change).to be_nil
664
+ end
650
665
  end
651
666
 
652
667
  context "not persisted" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hstore_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Hirn
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-03-16 00:00:00.000000000 Z
15
+ date: 2015-04-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -181,6 +181,7 @@ extra_rdoc_files: []
181
181
  files:
182
182
  - ".gitignore"
183
183
  - ".rubocop.yml"
184
+ - ".ruby-version"
184
185
  - Appraisals
185
186
  - Gemfile
186
187
  - LICENSE.txt