Skip to content

Commit

Permalink
FIX: don't update allow_title column of existing badges in seed. (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
vinothkannans committed May 27, 2021
1 parent 726500b commit 3358ab6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/badge.rb
Expand Up @@ -249,6 +249,7 @@ def default_icon=(val)
end

def default_allow_title=(val)
return unless self.new_record?
self.allow_title ||= val
end

Expand Down
14 changes: 14 additions & 0 deletions spec/models/badge_spec.rb
Expand Up @@ -213,4 +213,18 @@
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

0 comments on commit 3358ab6

Please sign in to comment.