FIX: Missing iframe closing tag in discobot certificate (#13052)

FIX: Missing iframe closing tag in discobot certificate (#13052)

When issuing the discobot certificate, we were not closing the iframe tag, which meant that the final message instruction to the user was swallowed up.

diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
index 46d50d1..8efa039 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
@@ -137,7 +137,7 @@ module DiscourseNarrativeBot
       src = Discourse.base_url + DiscourseNarrativeBot::Engine.routes.url_helpers.certificate_path(options)
       alt = CGI.escapeHTML(I18n.t("#{self.class::I18N_KEY}.certificate.alt"))
 
-      "<iframe class='discobot-certificate' src='#{src}' width='650' height='464' alt='#{alt}'>"
+      "<iframe class='discobot-certificate' src='#{src}' width='650' height='464' alt='#{alt}'></iframe>"
     end
 
     protected
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
index 75a5ffb..70ee377 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
@@ -715,7 +715,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
         end
       end
 
-      it 'should create the right reply' do
+      it 'should create the right reply and issue the discobot certificate' do
         post.update!(raw: "[details=\"This is a test\"]\nwooohoo\n[/details]")
         narrative.input(:reply, user, post: post)
 
@@ -729,6 +729,12 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
 
         expect(user.badges.where(name: DiscourseNarrativeBot::AdvancedUserNarrative.badge_name).exists?)
           .to eq(true)
+
+        expect(topic.ordered_posts.last.cooked).to include("<iframe")
+        expect(Nokogiri::HTML5(topic.ordered_posts.last.cooked).at("iframe").text).not_to include(
+          "Bye for now"
+        )
+        expect(topic.ordered_posts.last.cooked).to include("</iframe>")
       end
     end
   end

GitHub sha: b690e778

This commit appears in #13052 which was approved by SamSaffron. It was merged by SamSaffron.