gutentag 2.5.2 → 2.5.3

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
  SHA256:
3
- metadata.gz: e934d0f1e941db5003a28ee2dc0ca30592db0b594f5633eeac2374f6a0ee8f9f
4
- data.tar.gz: 8972fd4264e0dad5499ddbd7c9642caf8b15052fa78b63bebec6de4c57f1b9b6
3
+ metadata.gz: 9b86cbc2c649e92b40be12e9be738e3b57f57cb10241103e02d2aa5ea82a0d0a
4
+ data.tar.gz: 916b5eabf6121b235ca9136ac2eaf0113bde665f532bd21afe5b728825718fee
5
5
  SHA512:
6
- metadata.gz: 55961186203575a716c658bd966102d344badbe8940f88523e6e4e76d795b8a9089be43320fd40735b749ed7f4507d3fe7d509bdd6f942dd9d2fabfb0d32e89b
7
- data.tar.gz: 90f27936f1f5a96b522d26ad53ce8c74309fdc62c4409cb662112ee8603e610158ae379785646217b0cc61ea5a5e4150d31eaea77ea83033828c0d0af2db8771
6
+ metadata.gz: 3e3dcd7dcae2889b2ab496966bbb5b57c332f46546cbc7dd8f3e557f710c5ae89cfebe833a25bc6efb73c18fb74b858422943072407b328f59251543a000da4e
7
+ data.tar.gz: e7c60af1366e1afbc647162cbd72618be7884c9dc3bf8f580a8b6ddfa61684c7c1546f2fd9f85f0aadceaa2ac7b1dd22b70332b1061c162c2b3695d1fea111ac
@@ -20,3 +20,19 @@ Style/MultilineIfModifier:
20
20
  Style/MultilineTernaryOperator:
21
21
  Exclude:
22
22
  - db/migrate/*.rb
23
+
24
+ # 0.80
25
+
26
+ Style/HashEachMethods:
27
+ Enabled: true
28
+ Style/HashTransformKeys:
29
+ Enabled: true
30
+ Style/HashTransformValues:
31
+ Enabled: true
32
+
33
+ # 0.81
34
+
35
+ Lint/RaiseException:
36
+ Enabled: true
37
+ Lint/StructNewOverride:
38
+ Enabled: true
@@ -3,9 +3,10 @@ dist: xenial
3
3
  script: bundle exec appraisal rake
4
4
  rvm:
5
5
  - 2.3.8
6
- - 2.4.6
7
- - 2.5.5
8
- - 2.6.3
6
+ - 2.4.10
7
+ - 2.5.8
8
+ - 2.6.6
9
+ - 2.7.1
9
10
  # - jruby-9.2.8.0
10
11
  before_install:
11
12
  - gem install bundler --version 1.17.3
data/Appraisals CHANGED
@@ -17,7 +17,7 @@ appraise "rails_4_2" do
17
17
  gem "activerecord-jdbcmysql-adapter", "~> 1.3.23", :platform => :jruby
18
18
  gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.23", :platform => :jruby
19
19
  gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.23", :platform => :jruby
20
- end
20
+ end if RUBY_VERSION.to_f < 2.7
21
21
 
22
22
  appraise "rails_5_0" do
23
23
  gem "rails", "~> 5.0.3"
@@ -36,7 +36,7 @@ appraise "rails_5_2" do
36
36
  end if RUBY_VERSION.to_f >= 2.2
37
37
 
38
38
  appraise "rails_6_0" do
39
- gem "rails", "~> 6.0.0.rc1"
39
+ gem "rails", "~> 6.0.0"
40
40
  gem "pg", "~> 1.0", :platform => :ruby
41
41
  gem "mysql2", "~> 0.5.0", :platform => :ruby
42
42
  gem "sqlite3", "~> 1.4", :platform => :ruby
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project (at least, from v0.5.0 onwards) will be documented in this file.
4
4
 
5
+ ## 2.5.3 - 2020-06-28
6
+
7
+ ### Fixed
8
+
9
+ * Use `saved_change_to_tag_names?` instead of `tag_names_previously_changed?` for Rails 5.1+ ([Morten Trolle](https://github.com/mtrolle) in [70](https://github.com/pat/gutentag/pull/70)).
10
+ * `Gutentag::Tag.names_for_scope` now handles empty scopes ([Mike Gunderloy](https://github.com/ffmike) in [#73](https://github.com/pat/gutentag/pull/73)).
11
+
5
12
  ## 2.5.2 - 2019-07-08
6
13
 
7
14
  ### Fixed
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Gutentag
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/gutentag.png)](http://badge.fury.io/rb/gutentag)
4
- [![Build Status](https://travis-ci.org/pat/gutentag.png?branch=master)](https://travis-ci.org/pat/gutentag)
5
- [![Code Climate](https://codeclimate.com/github/pat/gutentag.png)](https://codeclimate.com/github/pat/gutentag)
3
+ [![Gem Version](https://badge.fury.io/rb/gutentag.svg)](http://badge.fury.io/rb/gutentag)
4
+ [![Build Status](https://travis-ci.org/pat/gutentag.svg?branch=master)](https://travis-ci.org/pat/gutentag)
5
+ [![Code Climate](https://codeclimate.com/github/pat/gutentag.svg)](https://codeclimate.com/github/pat/gutentag)
6
6
 
7
7
  A good, simple, solid tagging extension for ActiveRecord.
8
8
 
@@ -21,7 +21,9 @@ class Gutentag::Tag < ActiveRecord::Base
21
21
 
22
22
  def self.names_for_scope(scope)
23
23
  join_conditions = {:taggable_type => scope.name}
24
- if scope.current_scope.present?
24
+ if scope.is_a?(ActiveRecord::Relation)
25
+ return Gutentag::Tag.none unless scope.current_scope.present?
26
+
25
27
  join_conditions[:taggable_id] = scope.select(:id)
26
28
  end
27
29
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "gutentag"
5
- s.version = "2.5.2"
5
+ s.version = "2.5.3"
6
6
  s.authors = ["Pat Allan"]
7
7
  s.email = ["pat@freelancing-gods.com"]
8
8
  s.homepage = "https://github.com/pat/gutentag"
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.add_runtime_dependency "activerecord", ">= 3.2.0"
18
18
 
19
19
  s.add_development_dependency "appraisal", "~> 2.1.0"
20
- s.add_development_dependency "bundler", "~> 1.17"
20
+ s.add_development_dependency "bundler", ">= 1.17"
21
21
  s.add_development_dependency "combustion", "~> 1.1"
22
22
  s.add_development_dependency "database_cleaner", "~> 1.6"
23
23
  s.add_development_dependency "rails"
24
24
  s.add_development_dependency "rspec-rails", "~> 3.1"
25
- s.add_development_dependency "rubocop", "~> 0.72.0"
25
+ s.add_development_dependency "rubocop", "~> 0.81.0"
26
26
  s.add_development_dependency "rubocop-performance", "~> 1"
27
27
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  # For Rails 5.0+
4
4
  module Gutentag::ActiveRecord::InstanceMethods
5
+ AR_VERSION = ActiveRecord::VERSION::STRING.to_f
6
+
5
7
  # If the tag_names attribute was one of the modified values, then let's just
6
8
  # use the modifications, rather than overwriting the stored value.
7
9
  #
@@ -9,7 +11,12 @@ module Gutentag::ActiveRecord::InstanceMethods
9
11
  # the instance directly (e.g. article.tags << tag), which invokes the save
10
12
  # callbacks, but the old tag_names value is stored but not updated.
11
13
  def reset_tag_names
12
- return if tag_names_previously_changed?
14
+ # Rails 5.1 introduces major changes to how ActiveModel::Dirty works:
15
+ # https://github.com/pat/gutentag/pull/70#issuecomment-524605448
16
+ # For Rails <5.1 we'll use *_previously_changed?
17
+ # and for 5.1+ we'll use saved_change_to_*?
18
+ return if AR_VERSION < 5.1 && tag_names_previously_changed?
19
+ return if AR_VERSION >= 5.1 && saved_change_to_tag_names?
13
20
 
14
21
  # Update the underlying value rather than going through the setter, to
15
22
  # ensure this update doesn't get marked as a 'change'.
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe "Removing unused" do
5
+ RSpec.describe "Removing unused" do
6
6
  let(:article) { Article.create }
7
7
 
8
8
  it "deletes only unused tags" do
@@ -27,4 +27,12 @@ RSpec.describe "Tag names for scopes" do
27
27
  expect(Gutentag::Tag.names_for_scope(Article)).
28
28
  to match_array(%w[ koala wombat cassowary ])
29
29
  end
30
+
31
+ it "returns an empty array for an empty scope" do
32
+ Article.create :title => "mammals", :tag_names => %w[ koala wombat ]
33
+ Article.create :title => "birds", :tag_names => %w[ cassowary ]
34
+
35
+ expect(Gutentag::Tag.names_for_scope(Article.where(:title => "reptiles"))).
36
+ to match_array([])
37
+ end
30
38
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe "Managing tags via names" do
5
+ RSpec.describe "Managing tags via names" do
6
6
  let(:article) { Article.create }
7
7
 
8
8
  it "returns tag names" do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe "Adding and removing tags" do
5
+ RSpec.describe "Adding and removing tags" do
6
6
  let(:article) { Article.create }
7
7
  let(:pancakes) { Gutentag::Tag.create :name => "pancakes" }
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Gutentag::ActiveRecord do
5
+ RSpec.describe Gutentag::ActiveRecord do
6
6
  describe ".tagged_with" do
7
7
  let!(:melbourne_article) do
8
8
  article = Article.create :title => "Overview"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Gutentag do
5
+ RSpec.describe Gutentag do
6
6
  describe ".normalizer" do
7
7
  it "downcases the provided name" do
8
8
  expect(Gutentag.normaliser.call("Tasty Pancakes")).to eq("tasty pancakes")
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Gutentag::Tag, :type => :model do
5
+ RSpec.describe Gutentag::Tag, :type => :model do
6
6
  describe ".find_by_name" do
7
7
  it "returns a tag with the same name" do
8
8
  existing = Gutentag::Tag.create! :name => "pancakes"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Gutentag::Tagging, :type => :model do
5
+ RSpec.describe Gutentag::Tagging, :type => :model do
6
6
  describe "#valid?" do
7
7
  let(:tag) { Gutentag::Tag.create! :name => "pancakes" }
8
8
  let(:taggable) { Article.create! }
@@ -4,7 +4,7 @@ require "bundler/setup"
4
4
 
5
5
  Bundler.require :default, :development
6
6
 
7
- Dir["#{__dir__}/support/**/*.rb"].each { |file| require file }
7
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |file| require file }
8
8
 
9
9
  Combustion.initialize! :active_record
10
10
  ActiveSupport.run_load_hooks :gutentag unless defined?(Gutentag::Engine)
@@ -12,6 +12,8 @@ ActiveSupport.run_load_hooks :gutentag unless defined?(Gutentag::Engine)
12
12
  require "rspec/rails"
13
13
 
14
14
  RSpec.configure do |config|
15
+ config.disable_monkey_patching!
16
+
15
17
  if config.respond_to?(:use_transactional_tests)
16
18
  config.use_transactional_tests = false
17
19
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gutentag
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2020-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.17'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.17'
55
55
  - !ruby/object:Gem::Dependency
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.72.0
117
+ version: 0.81.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.72.0
124
+ version: 0.81.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-performance
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []
214
- rubygems_version: 3.0.3
214
+ rubygems_version: 3.1.2
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: Good Tags