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
cleanup diff formatter spec
Ivan Kuchinb2c3e22fc40f
diff --git a/spec/lib/journal_formatter/diff_spec.rb b/spec/lib/journal_formatter/diff_spec.rbindex e3ad2b27c82..1ea157ac6cf 100644--- a/spec/lib/journal_formatter/diff_spec.rb+++ b/spec/lib/journal_formatter/diff_spec.rb@@ -74,93 +74,115 @@ RSpec.describe OpenProject::JournalFormatter::Diff dolet(:link) { link_to(I18n.t(:label_details), path, class: "diff-details", target: "_top") }let(:full_url_link) { link_to(I18n.t(:label_details), url, class: "diff-details", target: "_top") }- describe "#render" do- describe "WITH the first value being nil, and the second a string" do- let(:expected) do- I18n.t(:text_journal_set_with_diff,- label: "<strong>#{key.camelize}</strong>",- link:)- end+ let(:options) { {} }- it { expect(instance.render(key, [nil, "new value"])).to be_html_eql(expected) }- end+ subject(:rendered) { instance.render(key, values, **options) }- describe "WITH the first value being a string, and the second a string" do- let(:expected) do- I18n.t(:text_journal_changed_with_diff,- label: "<strong>#{key.camelize}</strong>",- link:)- end+ describe "with the first value being nil, and the second a string" do+ let(:values) { [nil, "new value"] }- it { expect(instance.render(key, ["old value", "new value"])).to be_html_eql(expected) }+ let(:expected) do+ I18n.t(:text_journal_set_with_diff,+ label: "<strong>#{key.camelize}</strong>",+ link:)end- describe "WITH the first value being a string, and the second a string WITH de as locale" do- let(:expected) do- I18n.t(:text_journal_changed_with_diff,- label: "<strong>Beschreibung</strong>",- link:)- end+ it { expect(rendered).to be_html_eql(expected) }+ end- before do- I18n.locale = :de- end+ describe "with the first value being a string, and the second a string" do+ let(:values) { ["old value", "new value"] }- after do- I18n.locale = :en- end+ let(:expected) do+ I18n.t(:text_journal_changed_with_diff,+ label: "<strong>#{key.camelize}</strong>",+ link:)+ end++ it { expect(rendered).to be_html_eql(expected) }+ end- it { expect(instance.render(key, ["old value", "new value"])).to be_html_eql(expected) }+ describe "with the first value being a string, and the second nil" do+ let(:values) { ["old_value", nil] }++ let(:expected) do+ I18n.t(:text_journal_deleted_with_diff,+ label: "<strong>#{key.camelize}</strong>",+ link:)end- describe "WITH the first value being a string, and the second nil (with link)" do- let(:expected) do- I18n.t(:text_journal_deleted_with_diff,- label: "<strong>#{key.camelize}</strong>",- link:)- end+ it { expect(rendered).to be_html_eql(expected) }+ end- it { expect(instance.render(key, ["old_value", nil])).to be_html_eql(expected) }+ describe "with de locale" do+ let(:values) { ["old value", "new value"] }++ let(:expected) do+ I18n.t(:text_journal_changed_with_diff,+ label: "<strong>Beschreibung</strong>",+ link:)end- describe "WITH the first value being nil, and the second a string WITH specifying not to output html" do+ before { I18n.locale = :de }++ after { I18n.locale = :en }++ it { expect(rendered).to be_html_eql(expected) }+ end++ context "with non html requested" do+ let(:options) { { html: false } }++ describe "with the first value being nil, and the second a string" do+ let(:values) { [nil, "new value"] }+let(:expected) doI18n.t(:text_journal_set_with_diff,label: key.camelize,link: path)end- it { expect(instance.render(key, [nil, "new value"], html: false)).to be_html_eql(expected) }+ it { expect(rendered).to be_html_eql(expected) }end- describe "WITH the first value being a string, and the second a string WITH specifying not to output html" do+ describe "with the first value being a string, and the second a string" do+ let(:values) { ["old value", "new value"] }+let(:expected) doI18n.t(:text_journal_changed_with_diff,label: key.camelize,link: path)end- it { expect(instance.render(key, ["old value", "new value"], html: false)).to be_html_eql(expected) }+ it { expect(rendered).to be_html_eql(expected) }end- describe "WITH the first value being a string, and the second a string WITH specifying to output a full url" do+ describe "with the first value being a string, and the second nil" do+ let(:values) { ["old value", nil] }+let(:expected) do- I18n.t(:text_journal_changed_with_diff,- label: "<strong>#{key.camelize}</strong>",- link: full_url_link)+ I18n.t(:text_journal_deleted_with_diff,+ label: key.camelize,+ link: path)end- it { expect(instance.render(key, ["old value", "new value"], only_path: false)).to be_html_eql(expected) }+ it { expect(rendered).to be_html_eql(expected) }end+ end++ context "with full url requested" do+ let(:options) { { only_path: false } }++ describe "with the first value being a string, and the second a string" do+ let(:values) { ["old value", "new value"] }- describe "WITH the first value being a string, and the second nil (with url)" dolet(:expected) do- I18n.t(:text_journal_deleted_with_diff,- label: key.camelize,- link: path)+ I18n.t(:text_journal_changed_with_diff,+ label: "<strong>#{key.camelize}</strong>",+ link: full_url_link)end- it { expect(instance.render(key, ["old_value", nil], html: false)).to be_html_eql(expected) }+ it { expect(rendered).to be_html_eql(expected) }endendend