From 81296b542681eebd4de3350da289243bd2cd7e7a Mon Sep 17 00:00:00 2001 From: Nic Pottier Date: Tue, 30 May 2017 16:18:03 -0500 Subject: [PATCH] make sure to add contact to group in local flow state --- cmd/flowrunner/testdata/contacts/default.json | 2 +- .../testdata/flows/all_actions.json | 4 +-- .../testdata/flows/all_actions_test.json | 26 +++++++++++++++++-- .../testdata/flows/subflow_test.json | 8 +++--- flows/actions/add_to_group.go | 1 + 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/cmd/flowrunner/testdata/contacts/default.json b/cmd/flowrunner/testdata/contacts/default.json index e74b0059b..af34acf02 100644 --- a/cmd/flowrunner/testdata/contacts/default.json +++ b/cmd/flowrunner/testdata/contacts/default.json @@ -1,4 +1,4 @@ -{ +{ "uuid": "contact1-test-4b7f-a34b-e37e31e86451", "name": "Ben Haggerty", "language": "eng", diff --git a/cmd/flowrunner/testdata/flows/all_actions.json b/cmd/flowrunner/testdata/flows/all_actions.json index 198004701..20c61a8ea 100644 --- a/cmd/flowrunner/testdata/flows/all_actions.json +++ b/cmd/flowrunner/testdata/flows/all_actions.json @@ -52,8 +52,8 @@ "type": "remove_from_group", "groups": [ { - "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", - "name": "Registered Users" + "uuid": "2aad21f6-30b7-42c5-bd7f-1b720c154817", + "name": "Survey Audience" } ] }, diff --git a/cmd/flowrunner/testdata/flows/all_actions_test.json b/cmd/flowrunner/testdata/flows/all_actions_test.json index 4573ec59b..bd34d5a15 100644 --- a/cmd/flowrunner/testdata/flows/all_actions_test.json +++ b/cmd/flowrunner/testdata/flows/all_actions_test.json @@ -65,6 +65,17 @@ "urn": "tel:+12065551212", "text": "Hi Ben Haggerty, are you ready?" }, + { + "type": "remove_from_group", + "groups": [ + { + "uuid": "", + "name": "Survey Audience" + } + ], + "created_on": "2000-01-01T00:00:00.000000000-00:00", + "step": "" + }, { "type": "msg_out", "created_on": "2000-01-01T00:00:00.000000000-00:00", @@ -103,7 +114,7 @@ } ], "status": "C", - "child": "c9943827-b80b-4e22-8e46-6be598049f4e", + "child": "0a020b41-fe73-4bd2-ae79-62efd9af5a98", "results": { "gender": { "node": "node1", @@ -126,7 +137,7 @@ "contact": "contact1-test-4b7f-a34b-e37e31e86451", "path": [], "status": "C", - "parent": "746ab857-7354-4aa9-8b16-a9b62d23c4aa", + "parent": "2963771a-2b7a-4b99-86aa-3ab76c769408", "results": {}, "created_on": "2000-01-01T00:00:00.000000000-00:00", "modified_on": "2000-01-01T00:00:00.000000000-00:00", @@ -186,6 +197,17 @@ "urn": "tel:+12065551212", "text": "Hi Ben Haggerty, are you ready?" }, + { + "type": "remove_from_group", + "groups": [ + { + "uuid": "", + "name": "Survey Audience" + } + ], + "created_on": "2000-01-01T00:00:00.000000000-00:00", + "step": "" + }, { "type": "msg_out", "created_on": "2000-01-01T00:00:00.000000000-00:00", diff --git a/cmd/flowrunner/testdata/flows/subflow_test.json b/cmd/flowrunner/testdata/flows/subflow_test.json index 39bc31072..2a48a4599 100644 --- a/cmd/flowrunner/testdata/flows/subflow_test.json +++ b/cmd/flowrunner/testdata/flows/subflow_test.json @@ -53,7 +53,7 @@ "type": "flow", "flow": "flow2" }, - "child": "ec00435a-38a7-499a-9bf3-0ae8796d5e06", + "child": "3f206963-8c04-4e04-b7f1-236389fe29d1", "results": {}, "created_on": "2000-01-01T00:00:00.000000000-00:00", "modified_on": "2000-01-01T00:00:00.000000000-00:00", @@ -92,7 +92,7 @@ "wait": { "type": "msg" }, - "parent": "b891f53a-9f65-400b-9d48-7fcbfba55e5e", + "parent": "bf32954c-3278-457b-82c5-997fee8c375d", "results": {}, "created_on": "2000-01-01T00:00:00.000000000-00:00", "modified_on": "2000-01-01T00:00:00.000000000-00:00", @@ -213,7 +213,7 @@ "contact": "contact1-test-4b7f-a34b-e37e31e86451", "text": "Ryan Lewis" }, - "parent": "b891f53a-9f65-400b-9d48-7fcbfba55e5e", + "parent": "bf32954c-3278-457b-82c5-997fee8c375d", "results": { "name": { "node": "flow2-node1", @@ -290,7 +290,7 @@ } ], "status": "C", - "child": "ec00435a-38a7-499a-9bf3-0ae8796d5e06", + "child": "3f206963-8c04-4e04-b7f1-236389fe29d1", "results": {}, "created_on": "2000-01-01T00:00:00.000000000-00:00", "modified_on": "2000-01-01T00:00:00.000000000-00:00", diff --git a/flows/actions/add_to_group.go b/flows/actions/add_to_group.go index fc6a731eb..30837330b 100644 --- a/flows/actions/add_to_group.go +++ b/flows/actions/add_to_group.go @@ -44,6 +44,7 @@ func (a *AddToGroupAction) Execute(run flows.FlowRun, step flows.Step) error { groups := make([]*flows.Group, 0, len(a.Groups)) for _, group := range a.Groups { if contact.Groups().FindGroup(group.UUID()) == nil { + contact.AddGroup(group.UUID(), group.Name()) groups = append(groups, group) }