Skip to content
This repository was archived by the owner on Mar 29, 2022. It is now read-only.

Commit 53c6f91

Browse files
authored
Merge pull request #439 from fridaland/fix-gifted-segment-calls
Fix bad conditional transition event check for 'gifted' segment calls
2 parents 905b4a7 + 458c894 commit 53c6f91

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

app/services/user_state_transition_segment_service.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def call(user, transition)
1515
when :incomplete then incomplete(user)
1616
when :ineligible then ineligible(user)
1717
when :won then won(user, transition)
18-
when :gift_sticker then gift_sticker(user)
18+
when :gifted then gifted(user)
1919
end
2020
end
2121

@@ -62,7 +62,9 @@ def won(user, transition)
6262
end
6363
end
6464

65-
def gift_sticker(user)
65+
# TODO: change this to gifted(user, transition) and check transition.to to
66+
# add case for 'gifted_shirt'
67+
def gifted(user)
6668
segment(user).identify(state: 'gifted_sticker')
6769
segment(user).track('user_gifted_sticker')
6870
end

spec/models/user_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
describe '#gift' do
523523
before do
524524
allow(UserStateTransitionSegmentService)
525-
.to receive(:gift_sticker).and_return(true)
525+
.to receive(:gifted).and_return(true)
526526
end
527527

528528
context 'the user is in the incompleted state' do

spec/services/gift_service_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
context 'there is 1 sticker coupon' do
3333
before do
34+
allow(UserStateTransitionSegmentService).to receive(:call)
3435
FactoryBot.create(:sticker_coupon)
3536
GiftService.call
3637
end
@@ -44,6 +45,7 @@
4445

4546
context 'there are 2 sticker coupons' do
4647
before do
48+
allow(UserStateTransitionSegmentService).to receive(:call)
4749
FactoryBot.create(:sticker_coupon)
4850
FactoryBot.create(:sticker_coupon)
4951
GiftService.call
@@ -64,6 +66,7 @@
6466

6567
context 'there are 3 sticker coupons' do
6668
before do
69+
allow(UserStateTransitionSegmentService).to receive(:call)
6770
FactoryBot.create(:sticker_coupon)
6871
FactoryBot.create(:sticker_coupon)
6972
FactoryBot.create(:sticker_coupon)

spec/services/user_state_transition_segment_service_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@
186186
end
187187
end
188188

189-
context 'the event is gift_sticker and the user is incompleted' do
189+
context 'the event is gifted and the user is incompleted' do
190190
let(:user) { FactoryBot.create(:user, :incompleted) }
191191

192192
before do
193-
allow(transition).to receive(:event).and_return(:gift_sticker)
193+
allow(transition).to receive(:event).and_return(:gifted)
194194
end
195195

196196
it 'calls SegmentService#identify with proper arguments' do

0 commit comments

Comments
 (0)