acts_as_favoritor 5.0.2 → 5.0.3

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: 64b49c4243f1a6d24e08294de2ee32e19f7b9587ed7f796c2d9d335e6083025a
4
- data.tar.gz: dc8bc1751b08a7c9837a9a7f1ee1bf4f8059401d11147df8b1c8500fa58151fb
3
+ metadata.gz: c785314efa34b1f88cfee3d6c39acef924fb989e6a2654c65241a07facd707b0
4
+ data.tar.gz: 28dfbd0a05eab1723e871df1aec6657aabae38875402f03f5f2347ccedb7bc22
5
5
  SHA512:
6
- metadata.gz: fb5c2de5270701e94c32b22c703796f309e53db7ad56f55a2171fbe9ebd600f4e7d85084fb5152fbb69539b29ecb0bf9d67f24a6f649ec0818c9089f80c17816
7
- data.tar.gz: a58a52e5fa812dcc2e985f9be277663be0dc0d4ee3d90e25db362391132e38185e2fe18de6f3a84811b48565afe6caadaad7b38502d998f293ce1d1a2ddecfa2
6
+ metadata.gz: af2a517dc943fa69ea7d5442beced5d086a31a9586e1587fecf4ae3c0ad57ab9579099731ec5d92e794075b3d804e0facf7605fa196cdb3531edfb1f4d9855d0
7
+ data.tar.gz: 5e19c65f8f122686cf452f3690f18856e0e235d443e0772c8e4c4468d1b43bea2a46653e495f68d18dc0591ac6e725c2f53f8e3de7cbc5f6ddc0c2b89b9664a4
@@ -50,10 +50,11 @@ module ActsAsFavoritor
50
50
  self.class.build_result_for_scopes(scopes || scope) do |s|
51
51
  return nil if self == favoritable
52
52
 
53
- result = favorites.for_favoritable(favoritable).send("#{s}_list")
54
- .first_or_create!
55
- inc_cache(favoritable, s) if ActsAsFavoritor.configuration.cache
56
- result
53
+ favorites.for_favoritable(favoritable).send("#{s}_list")
54
+ .first_or_create! do |new_record|
55
+ inc_cache(favoritable, s) if ActsAsFavoritor.configuration.cache
56
+ new_record
57
+ end
57
58
  end
58
59
  end
59
60
 
@@ -65,7 +66,7 @@ module ActsAsFavoritor
65
66
  return nil unless favorite_record.present?
66
67
 
67
68
  result = favorite_record.destroy!
68
- dec_cache(favoritable, s) if ActsAsFavoritor.configuration.cache
69
+ dec_cache(favoritable, s) if ActsAsFavoritor.configuration.cache && result.destroyed?
69
70
  result
70
71
  end
71
72
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsFavoritor
4
- VERSION = '5.0.2'
4
+ VERSION = '5.0.3'
5
5
  end
@@ -19,7 +19,8 @@ class ActsAsFavoritorMigration < ActiveRecord::Migration<%= migration_version %>
19
19
  ['favoritable_id', 'favoritable_type'],
20
20
  name: 'fk_favoritables'
21
21
  add_index :favorites,
22
- ['favoritable_id', 'favoritor_id', 'favoritable_type'],
22
+ ['favoritable_type', 'favoritable_id', 'favoritor_type',
23
+ 'favoritor_id', 'scope'],
23
24
  name: 'uniq_favorites__and_favoritables', unique: true
24
25
  end
25
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_favoritor
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter