Skip to content

Commit 2a7f07f

Browse files
committed
Adding in sentry message to let us know that a course card is calling replaced by
1 parent b06cfae commit 2a7f07f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/services/cms/dynamic_components/course_card.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def initialize(title:, banner_text:, course_code:, description:, image:)
1212
activity = Activity.find_by(stem_activity_code: course_code)
1313
@course = if activity
1414
if activity.replaced_by
15+
Sentry.capture_message("Course card has been found with a now replaced course (#{course_code} -> #{activity.replaced_by.stem_activity_code}) - get comms to update Strapi to new course instance")
1516
get_achiever_course(activity.replaced_by)
1617
elsif activity
1718
get_achiever_course(activity)

spec/services/cms/dynamic_components/course_card_section_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
before do
1212
stub_course_templates
1313
stub_duration_units
14+
allow(Sentry).to receive(:capture_message)
1415
end
1516

1617
context "with valid activity" do
@@ -32,6 +33,10 @@
3233
it "should have correct course instance" do
3334
expect(first_block.course.activity_code).to eq("CP228")
3435
end
36+
37+
it "should not send sentry notification" do
38+
expect(Sentry).not_to have_received(:capture_message)
39+
end
3540
end
3641

3742
context "with invalid activity" do
@@ -45,12 +50,17 @@
4550
it "should have no course instance" do
4651
expect(first_block.course).to be_nil
4752
end
53+
54+
it "should not send sentry notification" do
55+
expect(Sentry).not_to have_received(:capture_message)
56+
end
4857
end
4958

5059
context "with replaced activity" do
51-
let(:card_section) { Cms::Providers::Strapi::Factories::ComponentFactory.process_component(Cms::Mocks::CourseCardSection.generate_raw_data(cards: [replaced_course_card])) }
60+
let!(:card_section) { Cms::Providers::Strapi::Factories::ComponentFactory.process_component(Cms::Mocks::CourseCardSection.generate_raw_data(cards: [replaced_course_card])) }
5261
let(:first_block) { card_section.cards_block.first }
5362

63+
5464
it "should render as Cms::CardWrapperComponent" do
5565
expect(card_section.render).to be_a(Cms::CardWrapperComponent)
5666
end
@@ -66,5 +76,9 @@
6676
it "should have correct course instance" do
6777
expect(first_block.course.activity_code).to eq("CP229")
6878
end
79+
80+
it "should send sentry notification" do
81+
expect(Sentry).to have_received(:capture_message).once.with("Course card has been found with a now replaced course (RP228 -> CP229) - get comms to update Strapi to new course instance")
82+
end
6983
end
7084
end

0 commit comments

Comments
 (0)