Skip to content

Commit 2f276b8

Browse files
committed
Merge pull request #3080 from raydavis/raywip
CLC-4363 Handle empty RegBlocks body in My Activities
2 parents 81f0419 + 27cac38 commit 2f276b8

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

app/models/my_activities/reg_blocks.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ class RegBlocks
44
def self.append!(uid, activities)
55
blocks_feed = Bearfacts::Regblocks.new({user_id: uid}).get
66
if blocks_feed[:errored] || blocks_feed[:noStudentId]
7-
return activities
7+
return
88
end
99

1010
%w(activeBlocks inactiveBlocks).each do |block_category|
11-
blocks_feed[block_category.to_sym].each do |block|
12-
notification = process_block!(block)
13-
activities << notification if notification.present?
11+
if (blocks = blocks_feed[block_category.to_sym])
12+
blocks.each do |block|
13+
notification = process_block!(block)
14+
activities << notification if notification.present?
15+
end
1416
end
1517
end
1618
end

spec/models/my_activities/reg_blocks_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,13 @@
6666
activities.should eq('foo')
6767
end
6868
end
69+
70+
context 'nil body from proxy' do
71+
before { allow_any_instance_of(Bearfacts::Regblocks).to receive(:get).and_return({}) }
72+
it 'should not do anything' do
73+
activities = []
74+
MyActivities::RegBlocks.append!(oski_uid, activities)
75+
expect(activities).to eq []
76+
end
77+
end
6978
end

0 commit comments

Comments
 (0)