DEV: Add spec for reusing category permalink

DEV: Add spec for reusing category permalink

Follow-up to f3c76ad482d3a3fd7ea0f3fdf5c8cd17b73495fe

diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index 152878d..18fbc06 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -326,6 +326,13 @@ describe Category do
       expect(Permalink.count).to eq(1)
     end
 
+    it "reuses existing permalink when category slug is changed" do
+      permalink = Permalink.create!(url: "c/#{@category.slug}", category_id: 42)
+
+      expect { @category.update_attributes(slug: 'new-slug') }.to_not change { Permalink.count }
+      expect(permalink.reload.category_id).to eq(@category.id)
+    end
+
     it "creates permalink when sub category slug is changed" do
       sub_category = Fabricate(:category, slug: 'sub-category', parent_category_id: @category.id)
       sub_category.update_attributes(slug: 'new-sub-category')

GitHub sha: 64bf4d44

2 Likes