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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -0
- data/lib/rating/models/rating/rate.rb +0 -5
- data/lib/rating/version.rb +1 -1
- data/spec/models/rate_spec.rb +0 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48063ae9a3d3e0ac0573471477dddae7834219fd
|
4
|
+
data.tar.gz: 20df48c7bb6af87d89ceddb6a5c2b029b7c751fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a4ed2ace00a53bc4076942fad4fa3c6fb402c24867ab4b80ea550d27b6b4874464bc2a7a68d8f009a3ef4afc42e1c79286906958a986f20d14eca3327490d31
|
7
|
+
data.tar.gz: '09c238d2ceed932e4f40a8304d3bfa5bc5ad276082a91be4c0e4f2b3addd89f1ed45ee188f976d811fc3dcdcd1a2e33c129e08d06ee7f6c2f7fd3c513ed3a031'
|
data/CHANGELOG.md
CHANGED
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
|
|
data/lib/rating/version.rb
CHANGED
data/spec/models/rate_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|