Washington Botelho 2022-05-17 23:33:23 -03:00
parent 62a428549c
commit 52b4785161
3 changed files with 21 additions and 0 deletions

1
.rspec 100644
View File

@ -0,0 +1 @@
--require common_helper

View File

@ -423,6 +423,16 @@ author.rate resource, 5, extra_scope: { approved: true }
As you can see, now, only the rate with value `5` will be included on the final rating.
### Specs
To run all specs, run the following rakes:
```sh
bundle exec rake spec
bundle exec rake spec_config
bundle exec rake spec_config_with_extra_scopes
```
### References
- [Evan Miller](http://www.evanmiller.org/ranking-items-with-star-ratings.html)

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
require 'mysql2'
client = Mysql2::Client.new(host: '127.0.0.1', username: :root)
client.query('DROP DATABASE IF EXISTS rating_test;')
client.query('CREATE DATABASE IF NOT EXISTS rating_test;')
ActiveRecord::Base.establish_connection(adapter: :mysql2, database: :rating_test, username: :root, host: '127.0.0.1')