Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tags using #tag_ids= breaks when migrating from v5 to v6 #1120

Closed
tatethurston opened this issue Dec 10, 2023 · 1 comment
Closed

Comments

@tatethurston
Copy link

tatethurston commented Dec 10, 2023

When updating from v5 to v6, I noticed that setting tags using #tag_ids= has stopped working. The commit that broke this functionality is #887.

Repro:

class User < ActiveRecord::Base
  acts_as_taggable_on :tags
end
require "rails_helper"

RSpec.describe "these tests pass on v5 but fail after 887" do
  let!(:existing_tags) { FactoryBot.create_list(:tag, 3) }
  
  describe "create" do
    let(:create) do
      FactoryBot.create(:user, tag_ids: existing_tags.map(&:id))
    end

    it do
      expect { create }.to change { ActsAsTaggableOn::Tagging.count }.by(3)
    end

    it do
      user = create
      expect(user.reload.tag_list).to match_array(existing_tags.map(&:name))
    end
  end
  
  describe "update" do
    let!(:user) { FactoryBot.create(:user) }
    let(:update) do
      user.update(tag_ids: existing_tags.map(&:id))
    end
    
    it do
      expect { update }.to change { ActsAsTaggableOn::Tagging.count }.by(3)
    end

    it do
      update
      expect(user.reload.tag_list).to match_array(existing_tags.map(&:name))
    end
  end
end
@tatethurston
Copy link
Author

duplicate of #914

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant