Bump acts-as-taggable-on to 6.0.0
Rails 5.1 introduced certain changes in the way a record is touched when the counter cache option is enabled in a belongs to association. We need to upgrade acts-as-taggable-on so it keeps changing the `updated_at` attribute when a new tag is added to a record. Note we now need to reload the records in some cases to get the `context_tag_list` method to return what we expect. Methods like `context_tags` however work properly with no need to reload the record.
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -2,7 +2,7 @@ source "https://rubygems.org"
|
|||||||
|
|
||||||
gem "rails", "5.1.7"
|
gem "rails", "5.1.7"
|
||||||
|
|
||||||
gem "acts-as-taggable-on", "~> 5.0.0"
|
gem "acts-as-taggable-on", "~> 6.0.0"
|
||||||
gem "acts_as_votable", "~> 0.11.1"
|
gem "acts_as_votable", "~> 0.11.1"
|
||||||
gem "ahoy_matey", "~> 1.6.0"
|
gem "ahoy_matey", "~> 1.6.0"
|
||||||
gem "ancestry", "~> 3.0.7"
|
gem "ancestry", "~> 3.0.7"
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ GEM
|
|||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
acts-as-taggable-on (5.0.0)
|
acts-as-taggable-on (6.0.0)
|
||||||
activerecord (>= 4.2.8)
|
activerecord (~> 5.0)
|
||||||
acts_as_votable (0.11.1)
|
acts_as_votable (0.11.1)
|
||||||
addressable (2.7.0)
|
addressable (2.7.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
@@ -602,7 +602,7 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
acts-as-taggable-on (~> 5.0.0)
|
acts-as-taggable-on (~> 6.0.0)
|
||||||
acts_as_votable (~> 0.11.1)
|
acts_as_votable (~> 0.11.1)
|
||||||
ahoy_matey (~> 1.6.0)
|
ahoy_matey (~> 1.6.0)
|
||||||
ancestry (~> 3.0.7)
|
ancestry (~> 3.0.7)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# This migration comes from acts_as_taggable_on_engine (originally 2)
|
||||||
|
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
||||||
|
class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
|
||||||
|
else
|
||||||
|
class AddMissingUniqueIndices < ActiveRecord::Migration; end
|
||||||
|
end
|
||||||
|
AddMissingUniqueIndices.class_eval do
|
||||||
|
def self.up
|
||||||
|
add_index :taggings,
|
||||||
|
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
||||||
|
unique: true, name: "taggings_idx"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_index :taggings, name: "taggings_idx"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# This migration comes from acts_as_taggable_on_engine (originally 6)
|
||||||
|
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
||||||
|
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
|
||||||
|
else
|
||||||
|
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
|
||||||
|
end
|
||||||
|
AddMissingIndexesOnTaggings.class_eval do
|
||||||
|
def change
|
||||||
|
add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
|
||||||
|
add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
|
||||||
|
add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
|
||||||
|
add_index :taggings, :context unless index_exists? :taggings, :context
|
||||||
|
|
||||||
|
unless index_exists? :taggings, [:tagger_id, :tagger_type]
|
||||||
|
add_index :taggings, [:tagger_id, :tagger_type]
|
||||||
|
end
|
||||||
|
|
||||||
|
unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
||||||
|
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1390,8 +1390,15 @@ ActiveRecord::Schema.define(version: 20191108173350) do
|
|||||||
t.integer "tagger_id"
|
t.integer "tagger_id"
|
||||||
t.string "context", limit: 128
|
t.string "context", limit: 128
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
t.index ["context"], name: "index_taggings_on_context"
|
||||||
|
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
|
||||||
t.index ["tag_id"], name: "index_taggings_on_tag_id"
|
t.index ["tag_id"], name: "index_taggings_on_tag_id"
|
||||||
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
||||||
|
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
|
||||||
|
t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
|
||||||
|
t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
|
||||||
|
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
|
||||||
|
t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "tags", id: :serial, force: :cascade do |t|
|
create_table "tags", id: :serial, force: :cascade do |t|
|
||||||
|
|||||||
@@ -1327,7 +1327,7 @@ describe Budget::Investment do
|
|||||||
let(:investment) { create(:budget_investment, :with_milestone_tags) }
|
let(:investment) { create(:budget_investment, :with_milestone_tags) }
|
||||||
|
|
||||||
it "has milestone_tags" do
|
it "has milestone_tags" do
|
||||||
expect(investment.milestone_tag_list.count).to eq(1)
|
expect(investment.reload.milestone_tag_list.count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ describe Legislation::Process do
|
|||||||
let(:process) { create(:legislation_process, :with_milestone_tags) }
|
let(:process) { create(:legislation_process, :with_milestone_tags) }
|
||||||
|
|
||||||
it "has milestone_tags" do
|
it "has milestone_tags" do
|
||||||
expect(process.milestone_tag_list.count).to eq(1)
|
expect(process.reload.milestone_tag_list.count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1045,7 +1045,7 @@ describe Proposal do
|
|||||||
let(:proposal) { create(:proposal, :with_milestone_tags) }
|
let(:proposal) { create(:proposal, :with_milestone_tags) }
|
||||||
|
|
||||||
it "has milestone_tags" do
|
it "has milestone_tags" do
|
||||||
expect(proposal.milestone_tag_list.count).to eq(1)
|
expect(proposal.reload.milestone_tag_list.count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user