Skip to content

Commit 3f9990d

Browse files
committed
try to untangle this mess?
1 parent 4b9e236 commit 3f9990d

File tree

5 files changed

+37
-45
lines changed

5 files changed

+37
-45
lines changed

app/models/onboarding_scenarios/flavortown.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def dialogue_flow
4848
welcome: "flavortown/01_welcome",
4949
kitchen_code: "flavortown/02_kitchen_code",
5050
taste_test: "flavortown/03_taste_test",
51-
taste_wrong: "flavortown/03b_taste_wrong",
52-
taste_gave_up: "flavortown/03c_taste_incredibly_wrong",
51+
taste_retry: "flavortown/03b_taste_retry",
52+
taste_reveal: "flavortown/03c_taste_reveal",
5353
taste_terrible: "flavortown/03d_taste_terrible",
5454
dino_nuggets: "flavortown/03e_dino_nuggets",
5555
promoted: "flavortown/04_promoted"
@@ -61,10 +61,10 @@ def handle_action(action_id)
6161
when "flavortown_continue" then :kitchen_code
6262
when "flavortown_agree" then :taste_test
6363
when "flavortown_taste_correct" then { step: :promoted, promote: true }
64-
when /\Aflavortown_taste_wrong_[wt]\d+\z/ then :taste_wrong
65-
when "flavortown_try_again" then :taste_test
66-
when /\Aflavortown_taste_wrong_again_[wt]\d+\z/ then :taste_gave_up
67-
when /\Aflavortown_taste_incredibly_wrong_[wt]\d+\z/ then :taste_terrible
64+
when /\Aflavortown_retry_[wt]\d+\z/ then :taste_retry
65+
when "flavortown_try_again" then :taste_retry
66+
when /\Aflavortown_final_[wt]\d+\z/ then :taste_reveal
67+
when /\Aflavortown_terrible_t\d+\z/ then :taste_terrible
6868
when "flavortown_dino_nuggets" then :dino_nuggets
6969
end
7070
end

app/views/slack/flavortown/03_taste_test.slack_message.slocks

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ section <<~MSG, markdown: true
88
*What makes a dish truly great?*
99
MSG
1010

11-
wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, action, opts), i| button(label, "#{action}_w#{i}", **opts) }
12-
terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, action, opts), i| button(label, "#{action}_t#{i}", **opts) }
11+
wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_retry_w#{i}", **(opts || {})) }
12+
terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_terrible_t#{i}", **(opts || {})) }
1313
dino_nuggets = OnboardingScenarios::Flavortown::DINO_NUGGETS.then { |(label, action, opts)| button(label, action, **opts) }
1414

15-
actions [
16-
button("Love", "flavortown_taste_correct", style: "primary"),
17-
*wrong_answers.sample(2),
18-
*terrible_answers.sample(3),
19-
dino_nuggets
20-
].shuffle
15+
love = button("Love", "flavortown_taste_correct", style: "primary")
16+
first_five = [love, *wrong_answers.sample(2), *terrible_answers.sample(2)].shuffle
17+
actions [*first_five, terrible_answers.sample(1).first, dino_nuggets].compact

app/views/slack/flavortown/03b_taste_wrong.slack_message.slocks renamed to app/views/slack/flavortown/03b_taste_retry.slack_message.slocks

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ section <<~MSG, markdown: true
1010
*What makes a dish truly great?*
1111
MSG
1212

13-
wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_taste_wrong_again_w#{i}", **opts) }
14-
terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_taste_wrong_again_t#{i}", **opts) }
13+
wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_final_w#{i}", **(opts || {})) }
14+
terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_final_t#{i}", **(opts || {})) }
1515

16-
actions [
17-
button("Love", "flavortown_taste_correct", style: "primary"),
18-
*wrong_answers.sample(3),
19-
*terrible_answers.sample(2),
20-
].shuffle
16+
love = button("Love", "flavortown_taste_correct", style: "primary")
17+
first_five = [love, *wrong_answers.sample(2), *terrible_answers.sample(2)].shuffle
18+
actions [*first_five, terrible_answers.sample(1).first].compact

app/views/slack/flavortown/03c_taste_incredibly_wrong.slack_message.slocks renamed to app/views/slack/flavortown/03c_taste_reveal.slack_message.slocks

File renamed without changes.

spec/models/onboarding_scenarios/flavortown_spec.rb

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
:welcome,
1717
:kitchen_code,
1818
:taste_test,
19-
:taste_wrong,
20-
:taste_gave_up,
19+
:taste_retry,
20+
:taste_reveal,
2121
:taste_terrible,
2222
:dino_nuggets,
2323
:promoted
@@ -28,8 +28,8 @@
2828
expect(scenario.dialogue_flow[:welcome]).to eq("flavortown/01_welcome")
2929
expect(scenario.dialogue_flow[:kitchen_code]).to eq("flavortown/02_kitchen_code")
3030
expect(scenario.dialogue_flow[:taste_test]).to eq("flavortown/03_taste_test")
31-
expect(scenario.dialogue_flow[:taste_wrong]).to eq("flavortown/03b_taste_wrong")
32-
expect(scenario.dialogue_flow[:taste_gave_up]).to eq("flavortown/03c_taste_incredibly_wrong")
31+
expect(scenario.dialogue_flow[:taste_retry]).to eq("flavortown/03b_taste_retry")
32+
expect(scenario.dialogue_flow[:taste_reveal]).to eq("flavortown/03c_taste_reveal")
3333
expect(scenario.dialogue_flow[:taste_terrible]).to eq("flavortown/03d_taste_terrible")
3434
expect(scenario.dialogue_flow[:dino_nuggets]).to eq("flavortown/03e_dino_nuggets")
3535
expect(scenario.dialogue_flow[:promoted]).to eq("flavortown/04_promoted")
@@ -59,22 +59,22 @@
5959
end
6060

6161
context "wrong answers" do
62-
it "goes to taste_wrong on first wrong answer" do
63-
expect(scenario.handle_action("flavortown_taste_wrong_w0")).to eq(:taste_wrong)
62+
it "goes to taste_retry on first wrong answer" do
63+
expect(scenario.handle_action("flavortown_retry_w0")).to eq(:taste_retry)
6464
end
6565

66-
it "allows retry from taste_wrong" do
67-
expect(scenario.handle_action("flavortown_try_again")).to eq(:taste_test)
66+
it "allows retry from scolding screens" do
67+
expect(scenario.handle_action("flavortown_try_again")).to eq(:taste_retry)
6868
end
6969

70-
it "gives up after second wrong answer" do
71-
expect(scenario.handle_action("flavortown_taste_wrong_again_w0")).to eq(:taste_gave_up)
70+
it "reveals answer after second wrong answer" do
71+
expect(scenario.handle_action("flavortown_final_w0")).to eq(:taste_reveal)
7272
end
7373
end
7474

7575
context "terrible answers" do
7676
it "goes to taste_terrible on incredibly wrong answer" do
77-
expect(scenario.handle_action("flavortown_taste_incredibly_wrong_t0")).to eq(:taste_terrible)
77+
expect(scenario.handle_action("flavortown_terrible_t0")).to eq(:taste_terrible)
7878
end
7979

8080
it "goes to dino_nuggets on dino nuggets answer" do
@@ -140,25 +140,22 @@
140140
step = scenario.handle_action("flavortown_agree")
141141
expect(step).to eq(:taste_test)
142142

143-
step = scenario.handle_action("flavortown_taste_wrong_w0")
144-
expect(step).to eq(:taste_wrong)
145-
146-
step = scenario.handle_action("flavortown_try_again")
147-
expect(step).to eq(:taste_test)
143+
step = scenario.handle_action("flavortown_retry_w0")
144+
expect(step).to eq(:taste_retry)
148145

149146
result = scenario.handle_action("flavortown_taste_correct")
150147
expect(result).to eq({ step: :promoted, promote: true })
151148
end
152149

153-
it "can complete the gave-up path (wrong twice)" do
150+
it "can complete the reveal path (wrong twice)" do
154151
scenario.handle_action("flavortown_continue")
155152
scenario.handle_action("flavortown_agree")
156153

157-
step = scenario.handle_action("flavortown_taste_wrong_w0")
158-
expect(step).to eq(:taste_wrong)
154+
step = scenario.handle_action("flavortown_retry_w0")
155+
expect(step).to eq(:taste_retry)
159156

160-
step = scenario.handle_action("flavortown_taste_wrong_again_w0")
161-
expect(step).to eq(:taste_gave_up)
157+
step = scenario.handle_action("flavortown_final_w0")
158+
expect(step).to eq(:taste_reveal)
162159
end
163160

164161
it "can complete the dino nuggets path" do
@@ -169,18 +166,18 @@
169166
expect(step).to eq(:dino_nuggets)
170167

171168
step = scenario.handle_action("flavortown_try_again")
172-
expect(step).to eq(:taste_test)
169+
expect(step).to eq(:taste_retry)
173170
end
174171

175172
it "can complete the terrible answer path" do
176173
scenario.handle_action("flavortown_continue")
177174
scenario.handle_action("flavortown_agree")
178175

179-
step = scenario.handle_action("flavortown_taste_incredibly_wrong_t0")
176+
step = scenario.handle_action("flavortown_terrible_t0")
180177
expect(step).to eq(:taste_terrible)
181178

182179
step = scenario.handle_action("flavortown_try_again")
183-
expect(step).to eq(:taste_test)
180+
expect(step).to eq(:taste_retry)
184181
end
185182
end
186183
end

0 commit comments

Comments
 (0)