acts_as_votable 0.12.1 → 0.13.0

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
- SHA1:
3
- metadata.gz: 2009307e736be800daee0e8ee1ab174eaf9d0bcf
4
- data.tar.gz: 1a1bd0c1391488334ca8509fb8a18d6e95bcfb88
2
+ SHA256:
3
+ metadata.gz: b1843c2e0892abc19c5ecc63dd48e38fe8d48e1cdb7affc3c90d67b0419725e1
4
+ data.tar.gz: b05a72a3a7310c362233e9d54301a695a03fb72c9fb6068b2fde8e58d1e238bb
5
5
  SHA512:
6
- metadata.gz: '0882bea0b7292e43280c383002f2955ad8fc254a8afd838d1525d5a4bb0afe76774a1c104dd8448bb82099d086b4b668c19323f9e0bba6d19a91ecd8556987ad'
7
- data.tar.gz: 26cb45e05dce7f060a69fded4c613daf51d6090cacf4c0dab62d2d97cf7d594f0fb128000c34994205a02369369bc767b7277863ee59b6bc2bee2d0a6e1807ca
6
+ metadata.gz: a125832f11dd75fa540f90791b5bdc092b92ade7c2a34218947fa1621aae21487eb38d8664636d1113885bb878927805a10f0db5edb786c48a8339832859bd68
7
+ data.tar.gz: 23bb31cc323d1173f982b2d12895b834e26b1ede7a6293cc1343538140f2fe3f7f9c0c89daf4de4ea67d72a69b4b4bbca2c4ec53555500ec965f26ca8fb1f475
@@ -0,0 +1,44 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ branches:
8
+ - master
9
+
10
+ jobs:
11
+ tests:
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os:
16
+ - ubuntu
17
+ ruby:
18
+ - 2.5
19
+ - 2.6
20
+ - 2.7
21
+ gemfile:
22
+ - gemfiles/rails_5_1.gemfile
23
+ - gemfiles/rails_5_2.gemfile
24
+ - gemfiles/rails_6.gemfile
25
+ - gemfiles/rails_6_1.gemfile
26
+ continue-on-error:
27
+ - false
28
+
29
+ env:
30
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
31
+ runs-on: ${{ matrix.os }}-latest
32
+ continue-on-error: ${{ matrix.continue-on-error }}
33
+ steps:
34
+ - name: Checkout
35
+ uses: actions/checkout@v2
36
+ - name: Setup Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+ bundler-cache: true
41
+ - name: Test
42
+ run: bundle exec rake spec
43
+
44
+ # use this
@@ -0,0 +1 @@
1
+ 2.5.3
data/Appraisals CHANGED
@@ -1,17 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  appraise "rails-4" do
4
- gem "rails", "4.2.10"
5
- end
6
-
7
- appraise "rails-5" do
8
- gem "rails", "5.0.6"
4
+ gem "rails", "4.2.11"
9
5
  end
10
6
 
11
7
  appraise "rails-5-1" do
12
- gem "rails", "5.1.4"
8
+ gem "rails", "5.1.7"
13
9
  end
14
10
 
15
11
  appraise "rails-5-2" do
16
- gem "rails", "5.2.0"
12
+ gem "rails", "5.2.4"
17
13
  end
14
+
15
+ appraise "rails-6" do
16
+ gem "rails", "6.0.3"
17
+ gem "sqlite3", "~> 1.4"
18
+ end
19
+
20
+ appraise "rails-6-1" do
21
+ gem "rails", "6.1.0"
22
+ gem "sqlite3", "~> 1.4"
23
+ end
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Acts As Votable (aka Acts As Likeable)
2
2
 
3
- [![Build Status](https://travis-ci.org/ryanto/acts_as_votable.svg?branch=master)](https://travis-ci.org/ryanto/acts_as_votable)
4
- [![Code Climate](https://codeclimate.com/github/ryanto/acts_as_votable.svg)](https://codeclimate.com/github/ryanto/acts_as_votable)
3
+ ![Build status](https://github.com/ryanto/acts_as_votable/workflows/CI/badge.svg)
5
4
 
6
5
  Acts As Votable is a Ruby Gem specifically written for Rails/ActiveRecord models.
7
6
  The main goals of this gem are:
@@ -24,7 +23,7 @@ The main goals of this gem are:
24
23
  Just add the following to your Gemfile to install the latest release.
25
24
 
26
25
  ```ruby
27
- gem 'acts_as_votable', '~> 0.12.0'
26
+ gem 'acts_as_votable'
28
27
  ```
29
28
 
30
29
  And follow that up with a ``bundle install``.
@@ -35,7 +34,7 @@ Acts As Votable uses a votes table to store all voting information. To
35
34
  generate and run the migration just use.
36
35
 
37
36
  rails generate acts_as_votable:migration
38
- rake db:migrate
37
+ rails db:migrate
39
38
 
40
39
  You will get a performance increase by adding in cached columns to your model's
41
40
  tables. You will have to do this manually through your own migrations. See the
@@ -46,7 +45,7 @@ caching section of this document for more information.
46
45
  ### Votable Models
47
46
 
48
47
  ```ruby
49
- class Post < ActiveRecord::Base
48
+ class Post < ApplicationRecord
50
49
  acts_as_votable
51
50
  end
52
51
 
@@ -193,15 +192,15 @@ You can add weight to your vote. The default value is 1.
193
192
  You can have your voters `acts_as_voter` to provide some reserve functionality.
194
193
 
195
194
  ```ruby
196
- class User < ActiveRecord::Base
195
+ class User < ApplicationRecord
197
196
  acts_as_voter
198
197
  end
199
198
 
200
199
  @user.likes @article
201
200
 
202
- @article.votes.size # => 1
203
- @article.likes.size # => 1
204
- @article.dislikes.size # => 0
201
+ @article.votes_for.size # => 1
202
+ @article.get_likes.size # => 1
203
+ @article.get_dislikes.size # => 0
205
204
  ```
206
205
 
207
206
  To check if a voter has voted on a model, you can use ``voted_for?``. You can
@@ -274,8 +273,8 @@ because `@user` has already voted for `@shoe`.
274
273
  @user.likes @shoe
275
274
  @user.likes @shoe
276
275
 
277
- @shoe.votes # => 1
278
- @shoe.likes # => 1
276
+ @shoe.votes_for.size # => 1
277
+ @shoe.get_likes.size # => 1
279
278
  ```
280
279
 
281
280
  To check if a vote counted, or registered, use `vote_registered?` on your model
@@ -291,9 +290,9 @@ after voting. For example:
291
290
  @hat.disliked_by @user
292
291
  @hat.vote_registered? # => true, because user changed their vote
293
292
 
294
- @hat.votes.size # => 1
295
- @hat.positives.size # => 0
296
- @hat.negatives.size # => 1
293
+ @hat.votes_for.size # => 1
294
+ @hat.get_positives.size # => 0
295
+ @hat.get_negatives.size # => 1
297
296
  ```
298
297
 
299
298
  To permit duplicates entries of a same voter, use option duplicate. Also notice that this
@@ -368,7 +367,7 @@ not by passing `cacheable_strategy` option to `acts_as_votable` method.
368
367
  By default, `update` strategy is used. Pass `:update_columns` as
369
368
  `cacheable_strategy` if you don't want to touch model's `updated_at` column.
370
369
  ```ruby
371
- class Post < ActiveRecord::Base
370
+ class Post < ApplicationRecord
372
371
  acts_as_votable cacheable_strategy: :update_columns
373
372
  end
374
373
  ```
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "4.2.10"
5
+ gem "rails", "4.2.11"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "5.1.4"
5
+ gem "rails", "5.1.7"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "5.2.0"
5
+ gem "rails", "5.2.4"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "6.0.3"
6
+ gem "sqlite3", "~> 1.4"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "6.1.0"
6
+ gem "sqlite3", "~> 1.4"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "6.0.0.rc1"
6
+ gem "sqlite3", "~> 1.4"
7
+
8
+ gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsVotable
4
- VERSION = "0.12.1"
4
+ VERSION = "0.13.0"
5
5
  end
@@ -93,14 +93,16 @@ module ActsAsVotable
93
93
  #Allowing for a vote_weight to be associated with every vote. Could change with every voter object
94
94
  vote.vote_weight = (options[:vote_weight].to_i if options[:vote_weight].present?) || 1
95
95
 
96
+ vote_saved = false
96
97
  ActiveRecord::Base.transaction do
97
98
  self.vote_registered = false
98
- return false unless vote.save
99
-
100
- self.vote_registered = true if last_update != vote.updated_at
101
- update_cached_votes(options[:vote_scope])
102
- return true
99
+ vote_saved = vote.save
100
+ if vote_saved
101
+ self.vote_registered = true if last_update != vote.updated_at
102
+ update_cached_votes(options[:vote_scope])
103
+ end
103
104
  end
105
+ vote_saved
104
106
  end
105
107
 
106
108
  def unvote(args = {})
@@ -416,7 +416,7 @@ shared_examples "a votable_model" do
416
416
 
417
417
  it do
418
418
  expect(votable_cache.cached_votes_total).to eq(1)
419
- expect(votable_cache.updated_at).to_not eq updated_at
419
+ expect(votable_cache.updated_at.to_i).to_not eq updated_at.to_i
420
420
  end
421
421
  end
422
422
 
@@ -425,7 +425,7 @@ shared_examples "a votable_model" do
425
425
 
426
426
  it do
427
427
  expect(votable_cache.cached_votes_total).to eq(1)
428
- expect(votable_cache.updated_at).to eq updated_at
428
+ expect(votable_cache.updated_at.to_i).to eq updated_at.to_i
429
429
  end
430
430
  end
431
431
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_votable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-18 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -101,9 +101,10 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/workflows/main.yml"
104
105
  - ".gitignore"
105
106
  - ".rubocop.yml"
106
- - ".travis.yml"
107
+ - ".ruby-version"
107
108
  - Appraisals
108
109
  - Gemfile
109
110
  - README.md
@@ -114,6 +115,9 @@ files:
114
115
  - gemfiles/rails_5.gemfile
115
116
  - gemfiles/rails_5_1.gemfile
116
117
  - gemfiles/rails_5_2.gemfile
118
+ - gemfiles/rails_6.gemfile
119
+ - gemfiles/rails_6_1.gemfile
120
+ - gemfiles/rails_6_rc1.gemfile
117
121
  - lib/acts_as_votable.rb
118
122
  - lib/acts_as_votable/cacheable.rb
119
123
  - lib/acts_as_votable/extenders/controller.rb
@@ -148,7 +152,7 @@ homepage: http://rubygems.org/gems/acts_as_votable
148
152
  licenses:
149
153
  - MIT
150
154
  metadata: {}
151
- post_install_message:
155
+ post_install_message:
152
156
  rdoc_options: []
153
157
  require_paths:
154
158
  - lib
@@ -163,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
167
  - !ruby/object:Gem::Version
164
168
  version: '0'
165
169
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.6.14
168
- signing_key:
170
+ rubygems_version: 3.2.2
171
+ signing_key:
169
172
  specification_version: 4
170
173
  summary: Rails gem to allowing records to be votable
171
174
  test_files:
@@ -1,21 +0,0 @@
1
- language: ruby
2
-
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.3.4
7
- - 2.4.2
8
- - 2.5.1
9
-
10
- before_install:
11
- - gem update --system
12
- # Stay on Bundler 1.x (for dependency reasons as we want to support Rails 4.2.x and Ruby 2.3.x)
13
- # More info here: https://docs.travis-ci.com/user/languages/ruby/#bundler-20
14
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
15
- - gem install bundler -v '< 2'
16
-
17
- gemfile:
18
- - gemfiles/rails_4.gemfile
19
- - gemfiles/rails_5.gemfile
20
- - gemfiles/rails_5_1.gemfile
21
- - gemfiles/rails_5_2.gemfile