Merge pull request #4678 from mkllnk/4490-tag-rules-spec

4490 tag rules spec
This commit is contained in:
Matt-Yorkley
2020-01-16 14:28:37 +01:00
committed by GitHub

View File

@@ -8,16 +8,13 @@ feature 'Tag Rules', js: true do
context "creating" do
before do
login_to_admin_section
visit main_app.edit_admin_enterprise_path(enterprise)
visit_tag_rules
end
it "allows creation of rules of each type" do
click_link "Tag Rules"
# Creating a new tag
expect(page).to have_no_selector '.customer_tag'
expect(page).to have_content 'No tags apply to this enterprise yet'
expect(page).to have_no_selector '.customer_tag'
click_button '+ Add A New Tag'
find(:css, "tags-input .tags input").set "volunteer\n"
@@ -115,13 +112,10 @@ feature 'Tag Rules', js: true do
# let!(:do_tag_rule) { create(:tag_rule, enterprise: enterprise, preferred_customer_tags: "member" ) }
before do
login_to_admin_section
visit main_app.edit_admin_enterprise_path(enterprise)
visit_tag_rules
end
it "saves changes to rules of each type" do
click_link "Tag Rules"
# Tag groups exist
expect(page).to have_selector '.customer_tag .header', text: "For customers tagged:", count: 4
expect(page).to have_selector '.customer_tag .header tags-input .tag-list ti-tag-item', text: "member", count: 1
@@ -223,13 +217,10 @@ feature 'Tag Rules', js: true do
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)
visit_tag_rules
end
it "deletes both default and customer rules from the database" do
click_link "Tag Rules"
expect do
accept_alert do
within "#tr_1" do first("a.delete-tag-rule").click end
@@ -240,6 +231,20 @@ feature 'Tag Rules', js: true do
end
expect(page).to have_no_selector "#tr_0"
end.to change{ TagRule.count }.by(-2)
# After deleting tags, the form is dirty and we need to confirm leaving
# the page. If we don't do it here, Capybara may timeout waiting for the
# confirmation while resetting the session.
accept_confirm do
visit("about:blank")
end
end
end
def visit_tag_rules
login_to_admin_section
visit main_app.edit_admin_enterprise_path(enterprise)
expect(page).to have_content "PRIMARY DETAILS"
click_link "Tag Rules"
end
end