rating 0.5.0 → 0.6.0

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: 870497d9efe65b495fb63f0205c701da2ec6a754
4
- data.tar.gz: e9d022d3c26ee5876c5bad1bf93ca0f80a98d5c9
3
+ metadata.gz: 48063ae9a3d3e0ac0573471477dddae7834219fd
4
+ data.tar.gz: 20df48c7bb6af87d89ceddb6a5c2b029b7c751fe
5
5
  SHA512:
6
- metadata.gz: fba27be52abc6695936928d7ecdb076e0d733cfd9757c8f8f35a1d4853c00606f6878944f5cee6d3f6eab918888f5b2c9cf7a7a033cfce73246ef9b83c599513
7
- data.tar.gz: f46c512cac625b12fc7f66c4d00993ece9f91427901af861843fc96a0656b12f979c2e5f95f0b42fecf01877144622f98e2050addd472162096dc565294422a5
6
+ metadata.gz: 2a4ed2ace00a53bc4076942fad4fa3c6fb402c24867ab4b80ea550d27b6b4874464bc2a7a68d8f009a3ef4afc42e1c79286906958a986f20d14eca3327490d31
7
+ data.tar.gz: '09c238d2ceed932e4f40a8304d3bfa5bc5ad276082a91be4c0e4f2b3addd89f1ed45ee188f976d811fc3dcdcd1a2e33c129e08d06ee7f6c2f7fd3c513ed3a031'
@@ -1,3 +1,9 @@
1
+ ## v0.6.0
2
+
3
+ ### Updates
4
+
5
+ - The author unique validations was removed to enable custom validations
6
+
1
7
  ## v0.5.0
2
8
 
3
9
  ### News
data/README.md CHANGED
@@ -347,6 +347,19 @@ rating:
347
347
  Now the rates will be written on `reviews` table over `rating_rates` and calculation will be on `review_ratings` over `rating_ratings`.
348
348
  You can change one table o both of them.
349
349
 
350
+
351
+ ## Validation
352
+
353
+ It is recommended that you add a validation to ensure that the author do not vote multiple times on the same resource and its scope.
354
+ This validation is not inside the gem since you could want make your own custom validation.
355
+
356
+ ```ruby
357
+ validates :author_id, uniqueness: {
358
+ case_sensitive: false,
359
+ scope: %i[author_type resource_id resource_type scopeable_id scopeable_type]
360
+ }
361
+ ```
362
+
350
363
  ## Love it!
351
364
 
352
365
  Via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=rating) or [Patreon](https://www.patreon.com/wbotelhos). Thanks! (:
@@ -14,11 +14,6 @@ module Rating
14
14
  validates :author, :resource, :value, presence: true
15
15
  validates :value, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 100 }
16
16
 
17
- validates :author_id, uniqueness: {
18
- case_sensitive: false,
19
- scope: %i[author_type resource_id resource_type scopeable_id scopeable_type]
20
- }
21
-
22
17
  def self.create(author:, metadata:, resource:, scopeable: nil, value:)
23
18
  record = find_or_initialize_by(author: author, resource: resource, scopeable: scopeable)
24
19
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rating
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -18,10 +18,4 @@ RSpec.describe Rating::Rate do
18
18
  it do
19
19
  is_expected.to validate_numericality_of(:value).is_less_than_or_equal_to(100).is_less_than_or_equal_to 100
20
20
  end
21
-
22
- it do
23
- expect(object).to validate_uniqueness_of(:author_id)
24
- .scoped_to(%i[author_type resource_id resource_type scopeable_id scopeable_type])
25
- .case_insensitive
26
- end
27
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rating
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord