DEV: Add spec for reusing category permalink

Follow-up to f3c76ad482
This commit is contained in:
Gerhard Schlager 2019-03-20 23:38:59 +01:00
parent 0db2846a5b
commit 64bf4d4483
1 changed files with 7 additions and 0 deletions

View File

@ -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')