mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Can delete default tag rules
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
%td
|
||||
%tags-with-translation{ object: "rule", max: 1, "tags-attr" => "{{opt[rule.type].tagsAttr}}", "tag-list-attr" => "{{opt[rule.type].tagListAttr}}" }
|
||||
%td.actions{ rowspan: 2 }
|
||||
%a{ ng: { click: "deleteTagRule(tagGroup, rule)" }, :class => "delete-tag-rule icon-trash no-text" }
|
||||
%a{ ng: { click: "deleteTagRule(tagGroup || defaultTagGroup, rule)" }, :class => "delete-tag-rule icon-trash no-text" }
|
||||
%tr
|
||||
%td
|
||||
%span.text-normal {{ opt[rule.type].textBottom }}
|
||||
|
||||
@@ -219,24 +219,23 @@ feature 'Tag Rules', js: true do
|
||||
end
|
||||
|
||||
context "deleting" do
|
||||
let!(:tag_rule) { create(:tag_rule, enterprise: enterprise, preferred_customer_tags: "member" ) }
|
||||
let!(:tag_rule) { create(:filter_products_tag_rule, enterprise: enterprise, preferred_customer_tags: "member" ) }
|
||||
let!(:default_rule) { create(:filter_products_tag_rule, is_default: true, enterprise: enterprise ) }
|
||||
|
||||
before do
|
||||
login_to_admin_section
|
||||
visit main_app.edit_admin_enterprise_path(enterprise)
|
||||
end
|
||||
|
||||
it "deletes rules from the database" do
|
||||
it "deletes both default and customer rules from the database" do
|
||||
click_link "Tag Rules"
|
||||
|
||||
expect(page).to have_selector "#tr_0"
|
||||
|
||||
expect{
|
||||
within "#tr_0" do
|
||||
first("a.delete-tag-rule").click
|
||||
end
|
||||
expect do
|
||||
within "#tr_1" do first("a.delete-tag-rule").click end
|
||||
expect(page).to_not have_selector "#tr_1"
|
||||
within "#tr_0" do first("a.delete-tag-rule").click end
|
||||
expect(page).to_not have_selector "#tr_0"
|
||||
}.to change{TagRule.count}.by(-1)
|
||||
end.to change{TagRule.count}.by(-2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user