SPEC: ensure we test that enabling sets emails-in

This commit is contained in:
Leo McArdle 2019-10-11 18:56:53 +01:00
Родитель aae31dd98e
Коммит 36aab4f00a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8262833620A64C3F
1 изменённых файлов: 12 добавлений и 7 удалений

Просмотреть файл

@ -31,32 +31,37 @@ describe Category do
end
context "when auto-email-in is enabled" do
before { SiteSetting.auto_email_in_enabled = true }
before do
parent.subcategories << child
SiteSetting.auto_email_in_enabled = true
parent.reload
child.reload
end
it "sets email-in on new category" do
expect(parent.email_in).to eq "test-parent@example.com"
expect(Fabricate(:category, slug: "test").email_in).to eq "test@example.com"
end
it "sets email-in on new subcategory" do
expect(child.email_in).to eq "test-parent+test-child@example.com"
expect(Fabricate(:category, slug: "child", parent_category: parent).email_in).to eq "test-parent+child@example.com"
end
it "updates parent and child emails-in when the parent category is updated" do
parent.slug = "new-test-parent"
parent.save
expect(parent.email_in).to eq "new-test-parent@example.com"
expect(child.email_in).to eq "new-test-parent+test-child@example.com"
expect(child.reload.email_in).to eq "new-test-parent+test-child@example.com"
end
it "updates emails-in when auto_email_in_domain setting is changed" do
SiteSetting.auto_email_in_domain = "test.example.com"
expect(parent.email_in).to eq "test-parent@test.example.com"
expect(child.email_in).to eq "test-parent+test-child@test.example.com"
expect(parent.reload.email_in).to eq "test-parent@test.example.com"
expect(child.reload.email_in).to eq "test-parent+test-child@test.example.com"
end
it "updates emails-in when auto_email_in_divider setting is changed" do
SiteSetting.auto_email_in_divider = "."
expect(child.email_in).to eq "test-parent.test-child@example.com"
expect(child.reload.email_in).to eq "test-parent.test-child@example.com"
end
it "doesn't allow email-in to be updated normally" do