Adding default tag rules

This commit is contained in:
Rob Harrington
2016-05-23 10:19:21 +10:00
parent bf0db2287b
commit fa3b43a970
14 changed files with 151 additions and 85 deletions

View File

@@ -7,6 +7,7 @@ describe "TagRulesCtrl", ->
module('admin.tagRules')
enterprise =
id: 45
default_tag_group: { tags: "", rules: [{ id: 7, preferred_customer_tags: "trusted" }] }
tag_groups: [
{ tags: "member", rules: [{ id: 1, preferred_customer_tags: "member" }, { id: 2, preferred_customer_tags: "member" }] },
{ tags: "volunteer", rules: [{ id: 3, preferred_customer_tags: "local" }] }
@@ -18,8 +19,8 @@ describe "TagRulesCtrl", ->
describe "tagGroup start indices", ->
it "updates on initialization", ->
expect(scope.tagGroups[0].startIndex).toEqual 0
expect(scope.tagGroups[1].startIndex).toEqual 2
expect(scope.tagGroups[0].startIndex).toEqual 1
expect(scope.tagGroups[1].startIndex).toEqual 3
describe "adding a new tag group", ->
beforeEach ->
@@ -30,8 +31,8 @@ describe "TagRulesCtrl", ->
expect(scope.tagGroups[0].rules[2].type).toEqual "TagRule::DiscountOrder"
it "updates tagGroup start indices", ->
expect(scope.tagGroups[0].startIndex).toEqual 0
expect(scope.tagGroups[1].startIndex).toEqual 3
expect(scope.tagGroups[0].startIndex).toEqual 1
expect(scope.tagGroups[1].startIndex).toEqual 4
describe "deleting a tag group", ->
describe "where the rule is not in the rule list for the tagGroup", ->
@@ -58,8 +59,8 @@ describe "TagRulesCtrl", ->
expect(scope.tagGroups[0].rules.indexOf(rule)).toEqual -1
it "updates tagGroup start indices", ->
expect(scope.tagGroups[0].startIndex).toEqual 0
expect(scope.tagGroups[1].startIndex).toEqual 1
expect(scope.tagGroups[0].startIndex).toEqual 1
expect(scope.tagGroups[1].startIndex).toEqual 2
describe "without an id", ->
rule = null
@@ -75,5 +76,5 @@ describe "TagRulesCtrl", ->
expect(scope.tagGroups[0].rules.indexOf(rule)).toEqual -1
it "updates tagGroup start indices", ->
expect(scope.tagGroups[0].startIndex).toEqual 0
expect(scope.tagGroups[1].startIndex).toEqual 1
expect(scope.tagGroups[0].startIndex).toEqual 1
expect(scope.tagGroups[1].startIndex).toEqual 2