Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add spec for reusing category permalink

Gerhard Schlager64bf4d448321
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index 152878d9ef5..18fbc066cad 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')