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
[38323] Remove linebreak for shorter journal diffs
Oliver Günthera0841ac6cf21
diff --git a/.rubocop.yml b/.rubocop.ymlindex f746bd22776..c0752191094 100644--- a/.rubocop.yml+++ b/.rubocop.yml@@ -119,6 +119,13 @@ Rails/SkipsModelValidations:Rails/ContentTag:Enabled: false+# Disable I18n.locale = in specs, where it is reset+# by us explicitly+Rails/I18nLocaleAssignment:+ Enabled: true+ Exclude:+ - 'spec/**/*.rb'+# For feature specs, we tend to have longer specs that cover a larger part of the functionality.# This is done for multiple reasons:# * performance, as setting up integration tests is costlydiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 3b19f75deb2..b007a0ca8e9 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2608,8 +2608,8 @@ en:text_work_packages_ref_in_commit_messages: "Referencing and fixing work packages in commit messages"text_journal_added: "%{label} %{value} added"text_journal_aggregation_time_explanation: "Individual actions of a user (e.g. updating a work package twice) are aggregated into a single action if their age difference is less than the specified timespan. They will be displayed as a single action within the application. This will also delay notifications by the same amount of time reducing the number of emails being sent."- text_journal_changed: "%{label} changed from %{old} <br/><strong>to</strong> %{new}"- text_journal_changed_plain: "%{label} changed from %{old} \nto %{new}"+ text_journal_changed_html: "%{label} changed from %{old} %{linebreak}<strong>to</strong> %{new}"+ text_journal_changed_plain: "%{label} changed from %{old} %{linebreak}to %{new}"text_journal_changed_no_detail: "%{label} updated"text_journal_changed_with_diff: "%{label} changed (%{link})"text_journal_deleted: "%{label} deleted (%{old})"diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.htmlindex 56ed23676ee..df1bf9912e7 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html@@ -1,116 +1,111 @@<div- class="op-ian-item"- [class.op-ian-item_expanded]="notification.expanded"- attr.data-qa-selector="op-ian-notification-item-{{notification.id}}"- [attr.data-qa-ian-read]="notification.readIAN === true || undefined"+ class="op-ian-item"+ [class.op-ian-item_expanded]="notification.expanded"+ attr.data-qa-selector="op-ian-notification-item-{{notification.id}}"+ [attr.data-qa-ian-read]="notification.readIAN === true || undefined"><button- type="button"- class="op-ian-item--row"- [class.op-ian-item--row_unexpandable]="unexpandable"+ type="button"+ class="op-ian-item--row"+ [class.op-ian-item--row_unexpandable]="unexpandable"(click)="toggleDetails()"><div- *ngIf="project"- class="op-ian-item--project"- >+ *ngIf="project"+ class="op-ian-item--project"+ ><a- class="op-ian-item--project-link"[href]="project.showUrl"- [textContent]="project.title"- (click)="projectClicked($event)"- target="_blank"- ></a></div>+ class="op-ian-item--project-link" [href]="project.showUrl"+ [textContent]="project.title"+ (click)="projectClicked($event)"+ target="_blank"+ ></a></div><ng-container *ngIf="workPackage$ && (workPackage$ | async) as workPackage; else workPackageLoading"><span- class="op-ian-item--title"- ngPreserveWhitespaces+ class="op-ian-item--title"+ ngPreserveWhitespaces><span [ngClass]="'__hl_inline_type_' + workPackage.type.id" [textContent]="workPackage.type.name"></span><a- [attr.title]="workPackage.subject"- uiSref="work-packages.show"- [uiParams]="{workPackageId: workPackage.id}"- [textContent]="'#' + workPackage.id"- (click)="resourceLinkClicked.emit(workPackage)"+ [attr.title]="workPackage.subject"+ uiSref="work-packages.show"+ [uiParams]="{workPackageId: workPackage.id}"+ [textContent]="'#' + workPackage.id"+ (click)="resourceLinkClicked.emit(workPackage)"></a><span- [textContent]="workPackage.subject"- class="op-ian-item--work-package-subject"- [class.-read]="notification.readIAN"+ [textContent]="workPackage.subject"+ class="op-ian-item--work-package-subject"+ [class.-read]="notification.readIAN"></span></span></ng-container><ng-template #workPackageLoading><span- *ngIf="workPackage$"+ *ngIf="workPackage$"class="op-ian-item--title"[textContent]="text.loading"></span></ng-template><ng-container *ngIf="!workPackage$"><span- class="op-ian-item--title"- [textContent]="notification.subject"+ class="op-ian-item--title"+ [textContent]="notification.subject"></span></ng-container><div- class="op-ian-item--actor"- *ngIf="actor"+ class="op-ian-item--actor"+ *ngIf="actor"><op-principal- [hide-name]="false"- [principal]="actor"- [link]="false"- size="medium"- class="op-principal_hide-name-on-mobile"+ [hide-name]="false"+ [principal]="actor"+ [link]="false"+ size="medium"+ class="op-principal_hide-name-on-mobile"></op-principal></div><div- class="op-ian-item--reason"- [textContent]="translatedReason || notification.reason"+ class="op-ian-item--reason"+ [textContent]="translatedReason || notification.reason"></div><div- class="op-ian-item--date"- [title]="fixedTime"- [textContent]="relativeTime$ | async"+ class="op-ian-item--date"+ [title]="fixedTime"+ [textContent]="relativeTime$ | async"></div></button><div- *ngIf="notification.expanded"- class="op-ian-item--details"- data-qa-selector="op-ian-details"+ *ngIf="notification.expanded"+ class="op-ian-item--details"+ data-qa-selector="op-ian-details"><ng-container *ngIf="body.length > 0"><div class="op-ian-item--body"><ng-container *ngFor="let bodyItem of body"><div- class="op-ian-item--body-item"- [innerHTML]="bodyItem.html"+ class="op-ian-item--body-item"+ [innerHTML]="bodyItem.html"></div></ng-container></div></ng-container><ul- class="work-package-details-activities-messages"- *ngIf="details.length > 0"+ class="work-package-details-activities-messages"+ *ngIf="details.length > 0"><ng-container *ngFor="let detail of details"><li *ngIf="detail.html && detail.html !== ''"><span- class="message"- [innerHtml]="detail.html"+ class="message"+ [innerHtml]="detail.html"></span></li></ng-container></ul>- <span- *ngIf="details.length === 1"- class="message"- [innerHtml]="details[0].html"- ></span></div></div>diff --git a/lib/plugins/acts_as_journalized/lib/journal_formatter/base.rb b/lib/plugins/acts_as_journalized/lib/journal_formatter/base.rbindex 582e3378661..5547dcac326 100644--- a/lib/plugins/acts_as_journalized/lib/journal_formatter/base.rb+++ b/lib/plugins/acts_as_journalized/lib/journal_formatter/base.rb@@ -35,6 +35,11 @@ module JournalFormatterinclude Rails.application.routes.url_helpersinclude ERB::Util+ # We break the values between from and to values+ # in the formatter if the length of one of the values+ # exceeds this magic number of characters+ LINEBREAK_ON_VALUE_LENGTH = 100+def initialize(journal)@journal = journalend@@ -62,7 +67,7 @@ module JournalFormatterdef format_html_details(label, old_value, value)label = content_tag('strong', label)- old_value = content_tag('i', h(old_value), title: h(old_value)) if old_value && !old_value.blank?+ old_value = content_tag('i', h(old_value), title: h(old_value)) if old_value.present?old_value = content_tag('strike', old_value) if old_value and value.blank?value = content_tag('i', h(value), title: h(value)) if value.present?value ||= ''@@ -78,10 +83,20 @@ module JournalFormatterreturn I18n.t(:text_journal_deleted, label: label, old: old_value) if value.blank?return I18n.t(:text_journal_set_to, label: label, value: value) if old_value.blank?+ linebreak = should_linebreak?(old_value.to_s, value.to_s)+if options[:no_html]- I18n.t(:text_journal_changed_plain, label: label, old: old_value, new: value).html_safe+ I18n.t(:text_journal_changed_plain,+ label: label,+ linebreak: linebreak ? "\n" : '',+ old: old_value,+ new: value)else- I18n.t(:text_journal_changed, label: label, old: old_value, new: value).html_safe+ I18n.t(:text_journal_changed_html,+ label: label,+ linebreak: linebreak ? "<br/>".html_safe : '',+ old: old_value,+ new: value)endend@@ -92,5 +107,11 @@ module JournalFormatterI18n.t(:text_journal_added, label: label, value: value)endend++ def should_linebreak?(old_value, new_value)+ [old_value, new_value].any? do |val|+ val.length >= LINEBREAK_ON_VALUE_LENGTH+ end+ endendenddiff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rbindex 5bdcaeb398e..c03c5c2213d 100644--- a/spec/features/work_packages/edit_work_package_spec.rb+++ b/spec/features/work_packages/edit_work_package_spec.rb@@ -110,7 +110,7 @@ describe 'edit work package', js: true dowp_page.update_attributes status: status2.namewp_page.expect_attributes status: status2.name- wp_page.expect_activity_message("Status changed from #{status.name}\nto #{status2.name}")+ wp_page.expect_activity_message("Status changed from #{status.name} to #{status2.name}")endend@@ -156,7 +156,7 @@ describe 'edit work package', js: true dostatus: status2.name,version: version.name,category: category.name- wp_page.expect_activity_message("Status changed from #{status.name}\nto #{status2.name}")+ wp_page.expect_activity_message("Status changed from #{status.name} to #{status2.name}")endit 'correctly assigns and un-assigns users' dodiff --git a/spec/features/work_packages/work_package_workflow_form_spec.rb b/spec/features/work_packages/work_package_workflow_form_spec.rbindex bc05a4ce57a..f24d22b20c0 100644--- a/spec/features/work_packages/work_package_workflow_form_spec.rb+++ b/spec/features/work_packages/work_package_workflow_form_spec.rb@@ -95,13 +95,13 @@ describe 'Work package transitive status workflows', js: true dowp_page.update_attributes status: status_intermediate.namewp_page.expect_attributes status: status_intermediate.name- wp_page.expect_activity_message "Status changed from #{status_from.name}\n" \+ wp_page.expect_activity_message "Status changed from #{status_from.name} " \"to #{status_intermediate.name}"wp_page.update_attributes status: status_to.namewp_page.expect_attributes status: status_to.name- wp_page.expect_activity_message "Status changed from #{status_from.name}\n" \+ wp_page.expect_activity_message "Status changed from #{status_from.name} " \"to #{status_to.name}"work_package.reloaddiff --git a/spec/lib/journal_formatter/custom_field_spec.rb b/spec/lib/journal_formatter/custom_field_spec.rbindex 3cd3a869842..7b572d2129f 100644--- a/spec/lib/journal_formatter/custom_field_spec.rb+++ b/spec/lib/journal_formatter/custom_field_spec.rb@@ -68,7 +68,8 @@ describe OpenProject::JournalFormatter::CustomField dolet(:new_formatted_value) { format_value(values.last, custom_field) }let(:expected) do- I18n.t(:text_journal_changed,+ I18n.t(:text_journal_changed_html,+ linebreak: '',label: "<strong>#{custom_field.name}</strong>",linebreak: '',old: "<i title=\"#{old_formatted_value}\">#{old_formatted_value}</i>",@@ -111,6 +112,7 @@ describe OpenProject::JournalFormatter::CustomField dolet(:expected) doI18n.t(:text_journal_changed_plain,label: custom_field.name,+ linebreak: '',old: format_value(values.first, custom_field),linebreak: '',new: format_value(values.last, custom_field))@@ -152,7 +154,8 @@ describe OpenProject::JournalFormatter::CustomField dolet(:key) { 'custom_values0' }let(:expected) do- I18n.t(:text_journal_changed,+ I18n.t(:text_journal_changed_html,+ linebreak: '',label: "<strong>#{I18n.t(:label_deleted_custom_field)}</strong>",linebreak: '',old: "<i title=\"#{values.first}\">#{values.first}</i>",@@ -230,7 +233,8 @@ describe OpenProject::JournalFormatter::CustomField dolet(:values) { %w[1,2 3,4] }let(:expected) do- I18n.t(:text_journal_changed,+ I18n.t(:text_journal_changed_html,+ linebreak: '',label: "<strong>#{custom_field.name}</strong>",linebreak: '',old: "<i title=\"cf 1, cf 2\">cf 1, cf 2</i>",@@ -245,7 +249,8 @@ describe OpenProject::JournalFormatter::CustomField dolet(:new_custom_option_names) { [[4, 'cf 4']] }let(:expected) do- I18n.t(:text_journal_changed,+ I18n.t(:text_journal_changed_html,+ linebreak: '',label: "<strong>#{custom_field.name}</strong>",linebreak: '',old: "<i title=\"cf 1, cf 2\">cf 1, cf 2</i>",diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rbindex 4c443e1f9db..1de1440aee3 100644--- a/spec/mailers/user_mailer_spec.rb+++ b/spec/mailers/user_mailer_spec.rb@@ -39,7 +39,7 @@ describe UserMailer, type: :mailer doFactoryBot.build_stubbed(:work_package_journal).tap do |j|allow(j).to receive(:data)- .and_return(FactoryBot.build_stubbed(:journal_work_package_journal))+ .and_return(FactoryBot.build_stubbed(:journal_work_package_journal))endendlet(:work_package) do@@ -87,8 +87,7 @@ describe UserMailer, type: :mailer doshared_examples_for 'mail is not sent' doit 'sends no mail' do- expect(deliveries)- be_empty+ expect(deliveries).to be_emptyendend@@ -98,11 +97,11 @@ describe UserMailer, type: :mailer doendlet(:user) { FactoryBot.build_stubbed(:user, preference: user_preference) }- context 'mail is for another user' do+ context 'when mail is for another user' doit_behaves_like 'mail is sent'end- context 'mail is for author' do+ context 'when mail is for author' dolet(:recipient) { user }it_behaves_like 'mail is not sent'@@ -136,7 +135,7 @@ describe UserMailer, type: :mailer dolet(:recipient) { FactoryBot.build_stubbed(:user, firstname: 'Bob', lastname: 'Bobbi', mail: test_email) }before do- UserMailer.test_mail(recipient).deliver_now+ described_class.test_mail(recipient).deliver_nowendit_behaves_like 'mail is sent' do@@ -154,14 +153,15 @@ describe UserMailer, type: :mailer do# the name method uses a format setting to determine how to concatenate first name# and last name whereby an unescaped comma will lead to have two email addresses# defined instead of one (['Bobbi', '[email protected]'] vs. ['[email protected]'])- context 'with the user name setting prone to trip up email address separation', with_settings: { user_format: :lastname_coma_firstname } do+ context 'with the user name setting prone to trip up email address separation',+ with_settings: { user_format: :lastname_coma_firstname } doit_behaves_like 'mail is sent'endenddescribe '#work_package_added' dobefore do- UserMailer.work_package_added(recipient, journal, user).deliver_now+ described_class.work_package_added(recipient, journal, user).deliver_nowendit_behaves_like 'mail is sent' do@@ -182,7 +182,7 @@ describe UserMailer, type: :mailer doit 'carries a message_id' doexpect(deliveries.first.message_id)- .to eql(UserMailer.generate_message_id(journal, recipient))+ .to eql(described_class.generate_message_id(journal, recipient))endit 'does not reference' do@@ -210,18 +210,18 @@ describe UserMailer, type: :mailer dodescribe '#work_package_updated' dobefore do- UserMailer.work_package_updated(recipient, journal, user).deliver_now+ described_class.work_package_updated(recipient, journal, user).deliver_nowendit_behaves_like 'mail is sent' doit 'carries a message_id' doexpect(deliveries.first.message_id)- .to eql(UserMailer.generate_message_id(journal, recipient))+ .to eql(described_class.generate_message_id(journal, recipient))endit 'references the message_id' doexpect(deliveries.first.references)- .to eql UserMailer.generate_message_id(journal, recipient)+ .to eql described_class.generate_message_id(journal, recipient)endcontext 'with a link' do@@ -256,9 +256,10 @@ describe UserMailer, type: :mailer dodescribe '#work_package_watcher_changed' dolet(:watcher_changer) { user }+before do- UserMailer.work_package_watcher_changed(work_package, recipient, watcher_changer, 'added').deliver_now- UserMailer.work_package_watcher_changed(work_package, recipient, watcher_changer, 'removed').deliver_now+ described_class.work_package_watcher_changed(work_package, recipient, watcher_changer, 'added').deliver_now+ described_class.work_package_watcher_changed(work_package, recipient, watcher_changer, 'removed').deliver_nowendinclude_examples 'multiple mails are sent', 2@@ -272,7 +273,7 @@ describe UserMailer, type: :mailer dolet(:wiki_content) { FactoryBot.create(:wiki_content) }before do- UserMailer.wiki_content_added(recipient, wiki_content, user).deliver_now+ described_class.wiki_content_added(recipient, wiki_content, user).deliver_nowendit_behaves_like 'mail is sent'@@ -284,12 +285,12 @@ describe UserMailer, type: :mailer dolet(:wiki_content) { FactoryBot.create(:wiki_content) }before do- UserMailer.wiki_content_updated(recipient, wiki_content, user).deliver_now+ described_class.wiki_content_updated(recipient, wiki_content, user).deliver_nowendit_behaves_like 'mail is sent'- it 'should link to the latest version diff page' do+ it 'links to the latest version diff page' doexpect(deliveries.first.body.encoded).to include 'diff/1'end@@ -306,13 +307,13 @@ describe UserMailer, type: :mailer doendbefore do- UserMailer.message_posted(recipient, message, user).deliver_now+ described_class.message_posted(recipient, message, user).deliver_nowendit_behaves_like 'mail is sent' doit 'carries a message_id' doexpect(deliveries.first.message_id)- .to eql(UserMailer.generate_message_id(message, recipient))+ .to eql(described_class.generate_message_id(message, recipient))endit 'has no references' do@@ -334,7 +335,7 @@ describe UserMailer, type: :mailer dolet(:pwd) { "pAsswORd" }before do- UserMailer.account_information(recipient, pwd).deliver_now+ described_class.account_information(recipient, pwd).deliver_nowendit_behaves_like 'mail is sent' do@@ -343,21 +344,19 @@ describe UserMailer, type: :mailer do.to have_content(pwd)endend-- it_behaves_like 'does only send mails to author if permitted'enddescribe '#news_added' dolet(:news) { FactoryBot.build_stubbed(:news) }before do- UserMailer.news_added(recipient, news, user).deliver_now+ described_class.news_added(recipient, news, user).deliver_nowendit_behaves_like 'mail is sent' doit 'carries a message_id' doexpect(mail.message_id)- .to eql(UserMailer.generate_message_id(news, recipient))+ .to eql(described_class.generate_message_id(news, recipient))endend@@ -369,7 +368,7 @@ describe UserMailer, type: :mailer dolet(:comment) { FactoryBot.build_stubbed(:comment, commented: news) }before do- UserMailer.news_comment_added(recipient, comment, user).deliver_now+ described_class.news_comment_added(recipient, comment, user).deliver_nowendit_behaves_like 'mail is sent'@@ -382,7 +381,7 @@ describe UserMailer, type: :mailer dolet(:recipient) { token.user }before do- UserMailer.password_lost(token).deliver_now+ described_class.password_lost(token).deliver_nowendit_behaves_like 'mail is sent' do@@ -394,8 +393,6 @@ describe UserMailer, type: :mailer dohref: url)endend-- it_behaves_like 'does only send mails to author if permitted'enddescribe '#user_signed_up' do@@ -403,7 +400,7 @@ describe UserMailer, type: :mailer dolet(:recipient) { token.user }before do- UserMailer.user_signed_up(token).deliver_now+ described_class.user_signed_up(token).deliver_nowendit_behaves_like 'mail is sent' do@@ -415,23 +412,21 @@ describe UserMailer, type: :mailer dohref: url)endend-- it_behaves_like 'does only send mails to author if permitted'enddescribe '#message_id' dodescribe 'same user' do- let(:journal_2) { FactoryBot.build_stubbed(:work_package_journal) }+ let(:journal2) { FactoryBot.build_stubbed(:work_package_journal) }before do- allow(journal_2).to receive(:journable).and_return(work_package)- allow(journal_2).to receive(:user).and_return(user)- allow(journal_2).to receive(:created_at).and_return(journal.created_at + 5.seconds)+ allow(journal2).to receive(:journable).and_return(work_package)+ allow(journal2).to receive(:user).and_return(user)+ allow(journal2).to receive(:created_at).and_return(journal.created_at + 5.seconds)endsubject do- message_ids = [journal, journal_2].each_with_object([]) do |j, l|- l << UserMailer.work_package_updated(user, j).message_id+ message_ids = [journal, journal2].each_with_object([]) do |j, l|+ l << described_class.work_package_updated(user, j).message_idendmessage_ids.uniq.count@@ -441,15 +436,15 @@ describe UserMailer, type: :mailer doenddescribe 'same timestamp' do- let(:user_2) { FactoryBot.build_stubbed(:user) }+ let(:user2) { FactoryBot.build_stubbed(:user) }before do- allow(work_package).to receive(:recipients).and_return([user, user_2])+ allow(work_package).to receive(:recipients).and_return([user, user2])endsubject do- message_ids = [user, user_2].each_with_object([]) do |u, l|- l << UserMailer.work_package_updated(u, journal).message_id+ message_ids = [user, user2].each_with_object([]) do |u, l|+ l << described_class.work_package_updated(u, journal).message_idendmessage_ids.uniq.count@@ -460,280 +455,274 @@ describe UserMailer, type: :mailer doenddescribe 'journal details' do- subject { UserMailer.work_package_updated(user, journal).body.encoded.gsub("\r\n", "\n") }+ subject { described_class.work_package_updated(user, journal).body.encoded.gsub("\r\n", "\n") }describe 'plain text mail' dobefore doallow(Setting).to receive(:plain_text_mail).and_return('1')end- describe 'done ration modifications' do- context 'changed done ratio' do- before do- allow(journal).to receive(:details).and_return('done_ratio' => [40, 100])- end+ context 'with changed done ratio' do+ before do+ allow(journal).to receive(:details).and_return('done_ratio' => [40, 100])+ end- it 'displays changed done ratio' do- is_expected.to include("Progress (%) changed from 40 \nto 100")- end+ it 'displays changed done ratio' do+ expect(subject).to include("Progress (%) changed from 40 to 100")end+ end- context 'new done ratio' do- before do- allow(journal).to receive(:details).and_return('done_ratio' => [nil, 100])- end+ context 'with new done ratio' do+ before do+ allow(journal).to receive(:details).and_return('done_ratio' => [nil, 100])+ end- it 'displays new done ratio' do- is_expected.to include("Progress (%) changed from 0 \nto 100")- end+ it 'displays new done ratio' do+ expect(subject).to include("Progress (%) changed from 0 to 100")end+ end- context 'deleted done ratio' do- before do- allow(journal).to receive(:details).and_return('done_ratio' => [50, nil])- end+ context 'with deleted done ratio' do+ before do+ allow(journal).to receive(:details).and_return('done_ratio' => [50, nil])+ end- it 'displays deleted done ratio' do- is_expected.to include("Progress (%) changed from 50 \nto 0")- end+ it 'displays deleted done ratio' do+ expect(subject).to include("Progress (%) changed from 50 to 0")endenddescribe 'start_date attribute' do- context 'format the start date' do- before do- allow(journal).to receive(:details).and_return('start_date' => ['2010-01-01', '2010-01-31'])- end+ before do+ allow(journal).to receive(:details).and_return('start_date' => %w[2010-01-01 2010-01-31])+ end- it 'old date should be formatted' do- is_expected.to match('01/01/2010')- end+ it 'old date should be formatted' do+ expect(subject).to match('01/01/2010')+ end- it 'new date should be formatted' do- is_expected.to match('01/31/2010')- end+ it 'new date should be formatted' do+ expect(subject).to match('01/31/2010')endenddescribe 'due_date attribute' do- context 'format the end date' do- before do- allow(journal).to receive(:details).and_return('due_date' => ['2010-01-01', '2010-01-31'])- end+ before do+ allow(journal).to receive(:details).and_return('due_date' => %w[2010-01-01 2010-01-31])+ end- it 'old date should be formatted' do- is_expected.to match('01/01/2010')- end+ it 'old date should be formatted' do+ expect(subject).to match('01/01/2010')+ end- it 'new date should be formatted' do- is_expected.to match('01/31/2010')- end+ it 'new date should be formatted' do+ expect(subject).to match('01/31/2010')endenddescribe 'project attribute' do- let(:project_1) { FactoryBot.create(:project) }- let(:project_2) { FactoryBot.create(:project) }+ let(:project1) { FactoryBot.create(:project) }+ let(:project2) { FactoryBot.create(:project) }before do- allow(journal).to receive(:details).and_return('project_id' => [project_1.id, project_2.id])+ allow(journal).to receive(:details).and_return('project_id' => [project1.id, project2.id])endit "shows the old project's name" do- is_expected.to match(project_1.name)+ expect(subject).to match(project1.name)endit "shows the new project's name" do- is_expected.to match(project_2.name)+ expect(subject).to match(project2.name)endenddescribe 'attribute issue status' do- let(:status_1) { FactoryBot.create(:status) }- let(:status_2) { FactoryBot.create(:status) }+ let(:status1) { FactoryBot.create(:status) }+ let(:status2) { FactoryBot.create(:status) }before do- allow(journal).to receive(:details).and_return('status_id' => [status_1.id, status_2.id])+ allow(journal).to receive(:details).and_return('status_id' => [status1.id, status2.id])endit "shows the old status' name" do- is_expected.to match(status_1.name)+ expect(subject).to match(status1.name)endit "shows the new status' name" do- is_expected.to match(status_2.name)+ expect(subject).to match(status2.name)endenddescribe 'attribute type' do- let(:type_1) { FactoryBot.create(:type_standard) }- let(:type_2) { FactoryBot.create(:type_bug) }+ let(:type1) { FactoryBot.create(:type_standard) }+ let(:type2) { FactoryBot.create(:type_bug) }before do- allow(journal).to receive(:details).and_return('type_id' => [type_1.id, type_2.id])+ allow(journal).to receive(:details).and_return('type_id' => [type1.id, type2.id])endit "shows the old type's name" do- is_expected.to match(type_1.name)+ expect(subject).to match(type1.name)endit "shows the new type's name" do- is_expected.to match(type_2.name)+ expect(subject).to match(type2.name)endenddescribe 'attribute assigned to' do- let(:assignee_1) { FactoryBot.create(:user) }- let(:assignee_2) { FactoryBot.create(:user) }+ let(:assignee1) { FactoryBot.create(:user) }+ let(:assignee2) { FactoryBot.create(:user) }before do- allow(journal).to receive(:details).and_return('assigned_to_id' => [assignee_1.id, assignee_2.id])+ allow(journal).to receive(:details).and_return('assigned_to_id' => [assignee1.id, assignee2.id])endit "shows the old assignee's name" do- is_expected.to match(assignee_1.name)+ expect(subject).to match(assignee1.name)endit "shows the new assignee's name" do- is_expected.to match(assignee_2.name)+ expect(subject).to match(assignee2.name)endenddescribe 'attribute priority' do- let(:priority_1) { FactoryBot.create(:priority) }- let(:priority_2) { FactoryBot.create(:priority) }+ let(:priority1) { FactoryBot.create(:priority) }+ let(:priority2) { FactoryBot.create(:priority) }before do- allow(journal).to receive(:details).and_return('priority_id' => [priority_1.id, priority_2.id])+ allow(journal).to receive(:details).and_return('priority_id' => [priority1.id, priority2.id])endit "shows the old priority's name" do- is_expected.to match(priority_1.name)+ expect(subject).to match(priority1.name)endit "shows the new priority's name" do- is_expected.to match(priority_2.name)+ expect(subject).to match(priority2.name)endenddescribe 'attribute category' do- let(:category_1) { FactoryBot.create(:category) }- let(:category_2) { FactoryBot.create(:category) }+ let(:category1) { FactoryBot.create(:category) }+ let(:category2) { FactoryBot.create(:category) }before do- allow(journal).to receive(:details).and_return('category_id' => [category_1.id, category_2.id])+ allow(journal).to receive(:details).and_return('category_id' => [category1.id, category2.id])endit "shows the old category's name" do- is_expected.to match(category_1.name)+ expect(subject).to match(category1.name)endit "shows the new category's name" do- is_expected.to match(category_2.name)+ expect(subject).to match(category2.name)endenddescribe 'attribute version' do- let(:version_1) { FactoryBot.create(:version) }- let(:version_2) { FactoryBot.create(:version) }+ let(:version1) { FactoryBot.create(:version) }+ let(:version2) { FactoryBot.create(:version) }before do- allow(journal).to receive(:details).and_return('version_id' => [version_1.id, version_2.id])+ allow(journal).to receive(:details).and_return('version_id' => [version1.id, version2.id])endit "shows the old version's name" do- is_expected.to match(version_1.name)+ expect(subject).to match(version1.name)endit "shows the new version's name" do- is_expected.to match(version_2.name)+ expect(subject).to match(version2.name)endenddescribe 'attribute estimated hours' do- let(:estimated_hours_1) { 30.5678 }- let(:estimated_hours_2) { 35.912834 }+ let(:estimated_hours1) { 30.5678 }+ let(:estimated_hours2) { 35.912834 }before do- allow(journal).to receive(:details).and_return('estimated_hours' => [estimated_hours_1, estimated_hours_2])+ allow(journal).to receive(:details).and_return('estimated_hours' => [estimated_hours1, estimated_hours2])endit 'shows the old estimated hours' do- is_expected.to match('%.2f' % estimated_hours_1)+ expect(subject).to match('%.2f' % estimated_hours1)endit 'shows the new estimated hours' do- is_expected.to match('%.2f' % estimated_hours_2)+ expect(subject).to match('%.2f' % estimated_hours2)endenddescribe 'custom field' do- let(:expected_text_1) { 'original, unchanged text' }- let(:expected_text_2) { 'modified, new text' }+ let(:expected_text) { 'original, unchanged text' }+ let(:expected_text2) { 'modified, new text' }let(:custom_field) doFactoryBot.create :work_package_custom_field,field_format: 'text'endbefore do- allow(journal).to receive(:details).and_return("custom_fields_#{custom_field.id}" => [expected_text_1, expected_text_2])+ allow(journal).to receive(:details).and_return("custom_fields_#{custom_field.id}" => [expected_text, expected_text2])endit 'shows the old custom field value' do- is_expected.to match(expected_text_1)+ expect(subject).to match(expected_text)endit 'shows the new custom field value' do- is_expected.to match(expected_text_2)+ expect(subject).to match(expected_text2)endenddescribe 'attachments' doshared_let(:attachment) { FactoryBot.create(:attachment) }- context 'added' do+ context 'when added' do # rubocop:disable Rspec/NestedGroupsbefore doallow(journal).to receive(:details).and_return("attachments_#{attachment.id}" => [nil, attachment.filename])endit "shows the attachment's filename" do- is_expected.to match(attachment.filename)+ expect(subject).to match(attachment.filename)endit "links correctly" do- is_expected.to match("<a href=\"http://mydomain.foo/api/v3/attachments/#{attachment.id}/content\">")+ expect(subject).to match("<a href=\"http://mydomain.foo/api/v3/attachments/#{attachment.id}/content\">")end- context 'with a suburl', with_config: { rails_relative_url_root: '/rdm' } do+ context 'with a suburl', with_config: { rails_relative_url_root: '/rdm' } do # rubocop:disable Rspec/NestedGroupsit "links correctly" do- is_expected.to match("<a href=\"http://mydomain.foo/rdm/api/v3/attachments/#{attachment.id}/content\">")+ expect(subject).to match("<a href=\"http://mydomain.foo/rdm/api/v3/attachments/#{attachment.id}/content\">")endendit "shows status 'added'" do- is_expected.to match('added')+ expect(subject).to match('added')endit "shows no status 'deleted'" do- is_expected.not_to match('deleted')+ expect(subject).not_to match('deleted')endend- context 'removed' do+ context 'when removed' do # rubocop:disable Rspec/NestedGroupsbefore doallow(journal).to receive(:details).and_return("attachments_#{attachment.id}" => [attachment.filename, nil])endit "shows the attachment's filename" do- is_expected.to match(attachment.filename)+ expect(subject).to match(attachment.filename)endit "shows no status 'added'" do- is_expected.not_to match('added')+ expect(subject).not_to match('added')endit "shows status 'deleted'" do- is_expected.to match('deleted')+ expect(subject).to match('deleted')endendend@@ -751,9 +740,9 @@ describe UserMailer, type: :mailer doallow(Setting).to receive(:plain_text_mail).and_return('0')end- context 'changed done ratio' do+ context 'with changed done ratio' dolet(:expected) do- "#{expected_prefix} changed from <i title=\"40\">40</i> <br/><strong>to</strong> <i title=\"100\">100</i>"+ "#{expected_prefix} changed from <i title=\"40\">40</i> <strong>to</strong> <i title=\"100\">100</i>"endbefore do@@ -761,13 +750,30 @@ describe UserMailer, type: :mailer doendit 'displays changed done ratio' do- is_expected.to include(expected)+ expect(subject).to include(expected)endend- context 'new done ratio' do+ context 'with changed subject to long value' do+ let(:old_subject) { 'foo' }+ let(:new_subject) { 'abcd' * 25 }let(:expected) do- "#{expected_prefix} changed from <i title=\"0\">0</i> <br/><strong>to</strong> <i title=\"100\">100</i>"+ "<strong>Subject</strong> changed from <i title=\"#{old_subject}\">#{old_subject}</i> <br/><strong>to</strong> " \+ "<i title=\"#{new_subject}\">#{new_subject}</i>"+ end++ before do+ allow(journal).to receive(:details).and_return('subject' => [old_subject, new_subject])+ end++ it 'displays changed subject with newline' do+ expect(subject).to include(expected)+ end+ end++ context 'with new done ratio' do+ let(:expected) do+ "#{expected_prefix} changed from <i title=\"0\">0</i> <strong>to</strong> <i title=\"100\">100</i>"endbefore do@@ -775,19 +781,19 @@ describe UserMailer, type: :mailer doendit 'displays new done ratio' do- is_expected.to include(expected)+ expect(subject).to include(expected)endend- context 'deleted done ratio' do- let(:expected) { "#{expected_prefix} changed from <i title=\"50\">50</i> <br/><strong>to</strong> <i title=\"0\">0</i>" }+ context 'with deleted done ratio' do+ let(:expected) { "#{expected_prefix} changed from <i title=\"50\">50</i> <strong>to</strong> <i title=\"0\">0</i>" }before doallow(journal).to receive(:details).and_return('done_ratio' => [50, nil])endit 'displays deleted done ratio' do- is_expected.to include(expected)+ expect(subject).to include(expected)endendend@@ -806,8 +812,6 @@ describe UserMailer, type: :mailer doendbefore do- I18n.locale = :en-described_class.account_information(recipient, 'pwd').deliver_nowend@@ -818,7 +822,7 @@ describe UserMailer, type: :mailer doit 'does not alter I18n.locale' doexpect(I18n.locale)- .to eql :en+ .to be :enendit 'include the user language header' do@@ -856,7 +860,7 @@ describe UserMailer, type: :mailer doit 'does not alter I18n.locale' doexpect(I18n.locale)- .to eql :de+ .to be :deendendend