OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
refactor: Make spec more focused and legible
Christophe Bliard4dae890c89c1
diff --git a/spec/lib/journal_formatter/cause_spec.rb b/spec/lib/journal_formatter/cause_spec.rbindex 85eb7cf5b45..b8c6995e808 100644--- a/spec/lib/journal_formatter/cause_spec.rb+++ b/spec/lib/journal_formatter/cause_spec.rb@@ -36,14 +36,15 @@ RSpec.describe OpenProject::JournalFormatter::Cause doshared_let(:work_package) { create(:work_package) }let(:instance) { described_class.new(build(:work_package_journal)) }- let(:link) do+ let(:work_package_html_link) dolink_to_work_package(work_package, all_link: true)end+ let(:work_package_raw_link) { "##{work_package.id}" }# we need to tell the url_helper that there is not controller to get url_options so that we can call link_tolet(:controller) { nil }- subject do+ def render(cause, html:)if Journal::VALID_CAUSE_TYPES.exclude?(cause["type"])raise "#{cause['type'].inspect} is not a valid cause type from Journal::VALID_CAUSE_TYPES. " \"Please use one of #{Journal::VALID_CAUSE_TYPES}"@@ -52,197 +53,211 @@ RSpec.describe OpenProject::JournalFormatter::Cause doinstance.render("cause", [nil, cause], html:)end+ RSpec::Matchers.define :render_html_variant do |expected|+ match do |cause|+ @cause = cause+ @actual = render(cause, html: true)+ values_match? expected, @actual+ end++ description do+ "render HTML variant with #{surface_descriptions_in(expected).inspect}"+ end++ failure_message do |actual|+ "expected #{@cause} to render HTML variant as expected\n " \+ "expected: #{surface_descriptions_in(expected).inspect}\n " \+ "actual: #{actual.inspect}"+ end+ end++ RSpec::Matchers.define :render_raw_variant do |expected|+ match do |cause|+ @cause = cause+ @actual = render(cause, html: false)+ values_match? expected, @actual+ end++ description do+ "render raw text variant with #{surface_descriptions_in(expected).inspect}"+ end++ failure_message do |actual|+ "expected #{@cause} to render raw text variant as expected\n " \+ "expected: #{surface_descriptions_in(expected).inspect}\n " \+ "actual: #{actual.inspect}"+ end+ end++ shared_examples "XSS-proof rendering of status name" do+ before do+ cause["status_name"] = "<script>alert('xss')</script>"+ end++ it "escapes the status name when rendering HTML" do+ expect(cause).to render_html_variant(a_string_including("<script>alert('xss')</script>"))+ end++ it "does not escape the status name when rendering raw text" do+ expect(cause).to render_raw_variant(a_string_including("<script>alert('xss')</script>"))+ end+ end+context "when the change was caused by a change to the parent" do- let(:cause) do+ subject(:cause) do{"type" => "work_package_parent_changed_times","work_package_id" => work_package.id}end- context "when rendering HTML variant" do- let(:html) { true }-- context "when the user is able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))- end-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.work_package_parent_changed_times', link:)}"- end+ context "when the user is able to access the related work package" do+ before do+ allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))end- context "when the user is not able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)- end+ it do+ link = work_package_html_link+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.work_package_parent_changed_times', link:)}"+ )+ end- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"- end+ it do+ link = work_package_raw_link+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.work_package_parent_changed_times', link:)}"+ )endend- context "when rendering raw variant" do- let(:html) { false }-- context "when the user is able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))- end-- let(:link) { "##{work_package.id}" }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.work_package_parent_changed_times', link:)}"- end+ context "when the user is not able to access the related work package" do+ before do+ allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)end- context "when the user is not able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)- end+ it do+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"+ )+ end- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"- end+ it do+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"+ )endendendcontext "when the change was caused by a change to a predecessor" do- let(:cause) do+ subject(:cause) do{"type" => "work_package_predecessor_changed_times","work_package_id" => work_package.id}end- context "when rendering HTML variant" do- let(:html) { true }-- context "when the user is able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))- end-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.work_package_predecessor_changed_times', link:)}"- end+ context "when the user is able to access the related work package" do+ before do+ allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))end- context "when the user is not able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)- end+ it do+ link = work_package_html_link+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.work_package_predecessor_changed_times', link:)}"+ )+ end- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"- end+ it do+ link = work_package_raw_link+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.work_package_predecessor_changed_times', link:)}"+ )endend- context "when rendering raw variant" do- let(:html) { false }-- context "when the user is able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))- end-- let(:link) { "##{work_package.id}" }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.work_package_predecessor_changed_times', link:)}"- end+ context "when the user is not able to access the related work package" do+ before do+ allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)end- context "when the user is not able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)- end+ it do+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"+ )+ end- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"- end+ it do+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"+ )endendendcontext "when the change was caused by a change to a child" do- let(:cause) do+ subject(:cause) do{"type" => "work_package_children_changed_times","work_package_id" => work_package.id}end- context "when rendering HTML variant" do- let(:html) { true }-- context "when the user is able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))- end-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.work_package_children_changed_times', link:)}"- end+ context "when the user is able to access the related work package" do+ before do+ allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))end- context "when the user is not able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)- end+ it do+ link = work_package_html_link+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.work_package_children_changed_times', link:)}"+ )+ end- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"- end+ it do+ link = work_package_raw_link+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.work_package_children_changed_times', link:)}"+ )endend- context "when rendering raw variant" do- let(:html) { false }-- context "when the user is able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.where(id: work_package.id))- end-- let(:link) { "##{work_package.id}" }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.work_package_children_changed_times', link:)}"- end+ context "when the user is not able to access the related work package" do+ before do+ allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)end- context "when the user is not able to access the related work package" do- before do- allow(WorkPackage).to receive(:visible).with(User.current).and_return(WorkPackage.none)- end+ it do+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"+ )+ end- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"- end+ it do+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.unaccessable_work_package_changed')}"+ )endendendcontext "when the change was caused by working day changes" do- let(:cause) do+ subject(:cause) do{"type" => "working_days_changed","changed_days" => {@@ -259,40 +274,36 @@ RSpec.describe OpenProject::JournalFormatter::Cause do}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- changes = [- I18n.t("journals.cause_descriptions.working_days_changed.days.non_working", day: WeekDay.find_by!(day: 2).name),- I18n.t("journals.cause_descriptions.working_days_changed.days.working", day: WeekDay.find_by!(day: 6).name),- I18n.t("journals.cause_descriptions.working_days_changed.dates.working", date: I18n.l(Date.new(2023, 1, 1))),- I18n.t("journals.cause_descriptions.working_days_changed.dates.non_working", date: I18n.l(Date.new(2023, 12, 24)))- ].join(", ")- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \- "#{I18n.t('journals.cause_descriptions.working_days_changed.changed', changes:)}"- end- end-- context "when rendering raw variant" do- let(:html) { false }-- it do- changes = [- I18n.t("journals.cause_descriptions.working_days_changed.days.non_working", day: WeekDay.find_by!(day: 2).name),- I18n.t("journals.cause_descriptions.working_days_changed.days.working", day: WeekDay.find_by!(day: 6).name),- I18n.t("journals.cause_descriptions.working_days_changed.dates.working", date: I18n.l(Date.new(2023, 1, 1))),- I18n.t("journals.cause_descriptions.working_days_changed.dates.non_working", date: I18n.l(Date.new(2023, 12, 24)))- ].join(", ")- expect(subject).to eq "#{I18n.t('journals.caused_changes.dates_changed')} " \- "#{I18n.t('journals.cause_descriptions.working_days_changed.changed', changes:)}"- end+ it do+ changes = [+ I18n.t("journals.cause_descriptions.working_days_changed.days.non_working", day: WeekDay.find_by!(day: 2).name),+ I18n.t("journals.cause_descriptions.working_days_changed.days.working", day: WeekDay.find_by!(day: 6).name),+ I18n.t("journals.cause_descriptions.working_days_changed.dates.working", date: I18n.l(Date.new(2023, 1, 1))),+ I18n.t("journals.cause_descriptions.working_days_changed.dates.non_working", date: I18n.l(Date.new(2023, 12, 24)))+ ].join(", ")+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.dates_changed')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.working_days_changed.changed', changes:)}"+ )+ end++ it do+ changes = [+ I18n.t("journals.cause_descriptions.working_days_changed.days.non_working", day: WeekDay.find_by!(day: 2).name),+ I18n.t("journals.cause_descriptions.working_days_changed.days.working", day: WeekDay.find_by!(day: 6).name),+ I18n.t("journals.cause_descriptions.working_days_changed.dates.working", date: I18n.l(Date.new(2023, 1, 1))),+ I18n.t("journals.cause_descriptions.working_days_changed.dates.non_working", date: I18n.l(Date.new(2023, 12, 24)))+ ].join(", ")+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.dates_changed')} " \+ "#{I18n.t('journals.cause_descriptions.working_days_changed.changed', changes:)}"+ )endendcontext "when a change of status % complete is the cause" doshared_let(:status) { create(:status, name: "In progress", default_done_ratio: 40) }- let(:cause) do+ subject(:cause) do{"type" => "status_p_complete_changed","status_name" => status.name,@@ -301,41 +312,26 @@ RSpec.describe OpenProject::JournalFormatter::Cause do}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.status_p_complete_changed')}</strong> " \- "% complete value for status 'In progress' changed from 20% to 40%"- end-- it "escapes the status name" do- cause["status_name"] = "<script>alert('xss')</script>"- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.status_p_complete_changed')}</strong> " \- "% complete value for status '<script>alert('xss')</script>' " \- "changed from 20% to 40%"- end+ it do+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.status_p_complete_changed')}</strong> " \+ "% complete value for status 'In progress' changed from 20% to 40%"+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.status_p_complete_changed')} " \- "% complete value for status 'In progress' changed from 20% to 40%"- end-- it "does not escape the status name" do- cause["status_name"] = "<script>alert('xss')</script>"- expect(subject).to eq "#{I18n.t('journals.caused_changes.status_p_complete_changed')} " \- "% complete value for status '<script>alert('xss')</script>' changed from 20% to 40%"- end+ it do+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.status_p_complete_changed')} " \+ "% complete value for status 'In progress' changed from 20% to 40%"+ )end++ it_behaves_like "XSS-proof rendering of status name"endcontext "when a status being excluded from totals is the cause" doshared_let(:status) { create(:status, name: "Rejected") }- let(:cause) do+ subject(:cause) do{"type" => "status_excluded_from_totals_changed","status_name" => status.name,@@ -344,40 +340,26 @@ RSpec.describe OpenProject::JournalFormatter::Cause do}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')}</strong> " \- "status 'Rejected' was excluded from totals calculations"- end-- it "escapes the status name" do- cause["status_name"] = "<script>alert('xss')</script>"- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')}</strong> " \- "status '<script>alert('xss')</script>' was excluded from totals calculations"- end+ it do+ expect(cause).to render_html_variant(+ "<strong>Status Excluded from totals changed</strong> " \+ "status 'Rejected' was excluded from totals calculations"+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')} " \- "status 'Rejected' was excluded from totals calculations"- end-- it "does not escape the status name" do- cause["status_name"] = "<script>alert('xss')</script>"- expect(subject).to eq "#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')} " \- "status '<script>alert('xss')</script>' was excluded from totals calculations"- end+ it do+ expect(cause).to render_raw_variant(+ "Status Excluded from totals changed " \+ "status 'Rejected' was excluded from totals calculations"+ )end++ it_behaves_like "XSS-proof rendering of status name"endcontext "when a status being no longer excluded from totals is the cause" doshared_let(:status) { create(:status, name: "Rejected") }- let(:cause) do+ subject(:cause) do{"type" => "status_excluded_from_totals_changed","status_name" => status.name,@@ -386,190 +368,151 @@ RSpec.describe OpenProject::JournalFormatter::Cause do}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')}</strong> " \- "status 'Rejected' was included in totals calculations"- end-- it "escapes the status name" do- cause["status_name"] = "<script>alert('xss')</script>"- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')}</strong> " \- "status '<script>alert('xss')</script>' was included in totals calculations"- end+ it do+ expect(cause).to render_html_variant(+ "<strong>Status Excluded from totals changed</strong> " \+ "status 'Rejected' was included in totals calculations"+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')} " \- "status 'Rejected' was included in totals calculations"- end-- it "does not escape the status name" do- cause["status_name"] = "<script>alert('xss')</script>"- expect(subject).to eq "#{I18n.t('journals.caused_changes.status_excluded_from_totals_changed')} " \- "status '<script>alert('xss')</script>' was included in totals calculations"- end+ it do+ expect(cause).to render_raw_variant(+ "Status Excluded from totals changed " \+ "status 'Rejected' was included in totals calculations"+ )end++ it_behaves_like "XSS-proof rendering of status name"endcontext "when a change of progress calculation mode to status-based is the cause" do- let(:cause) do+ subject(:cause) do{"type" => "progress_mode_changed_to_status_based"}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.progress_mode_changed_to_status_based')}</strong> " \- "Progress calculation mode set to status-based"- end+ it do+ expect(cause).to render_html_variant(+ "<strong>Progress calculation updated</strong> " \+ "Progress calculation mode set to status-based"+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.progress_mode_changed_to_status_based')} " \- "Progress calculation mode set to status-based"- end+ it do+ expect(cause).to render_raw_variant(+ "Progress calculation updated " \+ "Progress calculation mode set to status-based"+ )endendcontext "when cause is a system update: change of progress calculation mode from disabled to work-based" do- let(:cause) do+ subject(:cause) do{"type" => "system_update","feature" => "progress_calculation_adjusted_from_disabled_mode"}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- href = OpenProject::Static::Links.links[:blog_article_progress_changes][:href]- expect(subject).to eq "<strong>OpenProject system update:</strong> Progress calculation automatically " \- "<a href=\"#{href}\" target=\"_blank\">set to work-based mode and adjusted with version update</a>."- end+ it do+ href = OpenProject::Static::Links.links[:blog_article_progress_changes][:href]+ expect(cause).to render_html_variant(+ "<strong>OpenProject system update:</strong> Progress calculation automatically " \+ "<a href=\"#{href}\" target=\"_blank\">set to work-based mode and adjusted with version update</a>."+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "OpenProject system update: Progress calculation automatically " \- "set to work-based mode and adjusted with version update."- end+ it do+ expect(cause).to render_raw_variant(+ "OpenProject system update: Progress calculation automatically " \+ "set to work-based mode and adjusted with version update."+ )endendcontext "when cause is a system update: progress calculation adjusted" do- let(:cause) do+ subject(:cause) do{"type" => "system_update","feature" => "progress_calculation_adjusted"}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- href = OpenProject::Static::Links.links[:blog_article_progress_changes][:href]- expect(subject).to eq "<strong>OpenProject system update:</strong> Progress calculation automatically " \- "<a href=\"#{href}\" target=\"_blank\">adjusted with version update</a>."- end+ it do+ href = OpenProject::Static::Links.links[:blog_article_progress_changes][:href]+ expect(cause).to render_html_variant(+ "<strong>OpenProject system update:</strong> Progress calculation automatically " \+ "<a href=\"#{href}\" target=\"_blank\">adjusted with version update</a>."+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "OpenProject system update: Progress calculation automatically " \- "adjusted with version update."- end+ it do+ expect(cause).to render_raw_variant(+ "OpenProject system update: Progress calculation automatically adjusted with version update."+ )endcontext "with previous feature key 'progress_calculation_changed'" do- let(:cause) do- {- "type" => "system_update",- "feature" => "progress_calculation_changed"- }+ before do+ cause["feature"] = "progress_calculation_changed"end- let(:html) { false }it "is rendered like 'progress_calculation_adjusted'" do- expect(subject).to eq "OpenProject system update: Progress calculation automatically " \- "adjusted with version update."+ expect(cause).to render_raw_variant(+ "OpenProject system update: Progress calculation automatically adjusted with version update."+ )endendendcontext "when cause is a system update: totals removed from childless work packages" do- let(:cause) do+ subject(:cause) do{"type" => "system_update","feature" => "totals_removed_from_childless_work_packages"}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- href = OpenProject::Static::Links.links[:release_notes_14_0_1][:href]- expect(subject).to eq "<strong>OpenProject system update:</strong> Work and progress totals " \- "automatically removed for non-parent work packages with " \- "<a href=\"#{href}\" target=\"_blank\">version update</a>. " \- "This is a maintenance task and can be safely ignored."- end+ it do+ href = OpenProject::Static::Links.links[:release_notes_14_0_1][:href]+ expect(cause).to render_html_variant(+ "<strong>OpenProject system update:</strong> Work and progress totals " \+ "automatically removed for non-parent work packages with " \+ "<a href=\"#{href}\" target=\"_blank\">version update</a>. " \+ "This is a maintenance task and can be safely ignored."+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "OpenProject system update: Work and progress totals " \- "automatically removed for non-parent work packages with " \- "version update. " \- "This is a maintenance task and can be safely ignored."- end+ it do+ expect(cause).to render_raw_variant(+ "OpenProject system update: Work and progress totals " \+ "automatically removed for non-parent work packages with version update. " \+ "This is a maintenance task and can be safely ignored."+ )endendcontext "when the change was caused by a system update" do- let(:cause) do+ subject(:cause) do{"type" => "system_update","feature" => "file_links_journal"}end- context "when rendering HTML variant" do- let(:html) { true }-- it do- expect(subject).to eq "<strong>#{I18n.t('journals.caused_changes.system_update')}</strong> " \- "#{I18n.t('journals.cause_descriptions.system_update.file_links_journal')}"- end+ it do+ expect(cause).to render_html_variant(+ "<strong>#{I18n.t('journals.caused_changes.system_update')}</strong> " \+ "#{I18n.t('journals.cause_descriptions.system_update.file_links_journal')}"+ )end- context "when rendering raw variant" do- let(:html) { false }-- it do- expect(subject).to eq "#{I18n.t('journals.caused_changes.system_update')} " \- "#{I18n.t('journals.cause_descriptions.system_update.file_links_journal')}"- end+ it do+ expect(cause).to render_raw_variant(+ "#{I18n.t('journals.caused_changes.system_update')} " \+ "#{I18n.t('journals.cause_descriptions.system_update.file_links_journal')}"+ )endendend