diff --git a/app/furniture/journal/entry.rb b/app/furniture/journal/entry.rb index 958f6ab1e..ff0603bae 100644 --- a/app/furniture/journal/entry.rb +++ b/app/furniture/journal/entry.rb @@ -55,6 +55,10 @@ def extract_keywords self.keywords = journal.keywords.extract_and_create_from!(body).pluck(:canonical_keyword) end + def keywords=(keywords) + super(keywords.uniq) + end + def to_param slug end diff --git a/spec/furniture/journal/entry_spec.rb b/spec/furniture/journal/entry_spec.rb index 14c2ca16d..60a8dba8d 100644 --- a/spec/furniture/journal/entry_spec.rb +++ b/spec/furniture/journal/entry_spec.rb @@ -29,7 +29,7 @@ bad_apple = entry.journal.keywords.create!(canonical_keyword: "BadApple", aliases: ["BadApples"]) good_times = entry.journal.keywords.find_by!(canonical_keyword: "GoodTimes") expect do - entry.update!(body: "#GoodTimes #HardCider #BadApples") + entry.update!(body: "#GoodTimes #HardCider #BadApple #BadApples") end.not_to change { "#{bad_apple.reload.updated_at} - #{good_times.reload.updated_at}" } expect(journal.keywords.where(canonical_keyword: "GoodTimes")).to exist