From 33828ec8a48efe901598580388b3639592c0e98a Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 11 Jan 2022 10:06:46 -0600 Subject: [PATCH] posts: remove set_tag_string method. --- app/models/post.rb | 12 ++++-------- test/unit/post_test.rb | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 44d816833..3350988d0 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -346,7 +346,7 @@ class Post < ApplicationRecord kept_tags = current_tags & new_tags @removed_tags = old_tags - kept_tags - set_tag_string(((current_tags + new_tags) - old_tags + (current_tags & new_tags)).uniq.sort.join(" ")) + self.tag_string = ((current_tags + new_tags) - old_tags + (current_tags & new_tags)).uniq.sort.join(" ") end if old_parent_id == "" @@ -367,10 +367,6 @@ class Post < ApplicationRecord end end - def set_tag_string(string) - self.tag_string = string - end - def normalize_tags normalized_tags = PostQueryBuilder.new(tag_string).parse_tag_edit normalized_tags = apply_casesensitive_metatags(normalized_tags) @@ -385,7 +381,7 @@ class Post < ApplicationRecord normalized_tags += TagImplication.tags_implied_by(normalized_tags).map(&:name) normalized_tags = normalized_tags.compact.uniq.sort normalized_tags = Tag.create_for_list(normalized_tags) - set_tag_string(normalized_tags.join(" ")) + self.tag_string = normalized_tags.join(" ") end def remove_invalid_tags(tag_names) @@ -618,11 +614,11 @@ class Post < ApplicationRecord end def add_tag(tag) - set_tag_string("#{tag_string} #{tag}") + self.tag_string = "#{tag_string} #{tag}" end def remove_tag(tag) - set_tag_string((tag_array - Array(tag)).join(" ")) + self.tag_string = (tag_array - Array(tag)).join(" ") end def tag_categories diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 36c1055ae..cd5b2c8af 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -1049,7 +1049,7 @@ class PostTest < ActiveSupport::TestCase should "have an array representation of its tags" do post = FactoryBot.create(:post) post.reload - post.set_tag_string("aaa bbb") + post.tag_string = "aaa bbb" assert_equal(%w(aaa bbb), post.tag_array) assert_equal(%w(tag1 tag2), post.tag_array_was) end