FIX: don't update `allow_title` column of existing badges in seed. (#13190)

The default `allow_title` column value is "true" for regular and leader badges. After we disable it in admin side the seed method enabling it again while upgrading. So we shouldn't do it for existing badges.
This commit is contained in:
Vinoth Kannan 2021-05-28 00:30:57 +05:30 committed by GitHub
parent 726500bc59
commit 3358ab6b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -249,6 +249,7 @@ class Badge < ActiveRecord::Base
end
def default_allow_title=(val)
return unless self.new_record?
self.allow_title ||= val
end

View File

@ -213,4 +213,18 @@ describe Badge do
expect(UserBadge.where(user_id: post.user.id, badge_id: Badge::PopularLink).count).to eq(0)
end
end
context "#seed" do
let(:regular_badge) do
Badge.find(Badge::Regular)
end
it "`allow_title` is not updated for existing records" do
regular_badge.update(allow_title: false)
SeedFu.seed
regular_badge.reload
expect(regular_badge.allow_title).to eq(false)
end
end
end