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
Register status_explanation as a field to be rendered
Aaron Contreras68a8ab007318
diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rbindex dccb9d4c576..9277765e7d4 100644--- a/app/controllers/journals_controller.rb+++ b/app/controllers/journals_controller.rb@@ -61,7 +61,7 @@ class JournalsController < ApplicationControllerenddef diff- return render_404 unless valid_field?+ return render_404 unless valid_field_for_diffing?unless @journal.details[field_param] in [from, to]return render_400 message: I18n.t(:error_journal_attribute_not_present, attribute: field_param)@@ -101,9 +101,8 @@ class JournalsController < ApplicationController@field_param ||= params[:field].parameterize.underscoreend- # Is this a valid field for diff'ing?- def valid_field?- field_param == 'description'+ def valid_field_for_diffing?+ %w[description status_explanation].include?(field_param)enddef journals_index_titlediff --git a/app/models/project.rb b/app/models/project.rbindex 4478c620495..f6dcd3c8e72 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -106,6 +106,7 @@ class Project < ApplicationRecordregister_journal_formatted_fields(:template, 'templated')register_journal_formatted_fields(:plaintext, 'identifier')register_journal_formatted_fields(:plaintext, 'name')+ register_journal_formatted_fields(:diff, 'status_explanation')register_journal_formatted_fields(:diff, 'description')register_journal_formatted_fields(:visibility, 'public')register_journal_formatted_fields(:subproject_named_association, 'parent_id')diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 162ef8bf790..8598f270412 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -552,7 +552,7 @@ en:false: "private"queries: "Queries"status_code: 'Status'- status_explanation: 'Status description'+ status_explanation: 'Project status description'status_codes:not_started: 'Not started'on_track: 'On track'diff --git a/spec/features/activities/activity_page_navigation_spec.rb b/spec/features/activities/activity_page_navigation_spec.rbindex 861e6b25a0d..e1aef889317 100644--- a/spec/features/activities/activity_page_navigation_spec.rb+++ b/spec/features/activities/activity_page_navigation_spec.rb@@ -28,7 +28,7 @@require 'spec_helper'-describe 'Activity page navigation' do+RSpec.describe 'Activity page navigation' doinclude ActiveSupport::Testing::TimeHelpersshared_let(:project) { create(:project, enabled_module_names: Setting.default_projects_modules + ['activity']) }@@ -141,39 +141,87 @@ describe 'Activity page navigation' doendcontext 'when navigating to a diff' do- before do- project_work_package.update(description: 'New work package description')- end+ context 'for a project status explanation' do+ before do+ project.update(status_explanation: 'New status explanation')+ end- def assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)- visit(activity_page)- activity_page_url = page.current_url+ def ensure_project_attributes_filter_is_checked+ # First visited activity page (activities_path) will set the+ # project attributes filter as checked and subsequent visits+ # to other activity pages will persist this setting- expect(page).to have_link(text: 'Details')- expect(page.text).to include("Description changed (Details)")- click_link('Details')+ if page.current_path == activities_path+ check 'Project attributes'+ click_button 'Apply'+ end+ end- # on diff page, click the back button- expect(page).to have_link(text: 'Back')- click_link('Back')+ def assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ visit(activity_page)+ activity_page_url = page.current_url- expect(page.current_url).to eq(activity_page_url)- end+ ensure_project_attributes_filter_is_checked- it 'Back button navigates to the previously seen activity page' do- [- activities_path,- project_activities_path(project),- user_path(user)- ].each do |activity_page|- assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ expect(page).to have_link(text: 'Details')+ expect(page.text).to include("Project status description set (Details)")+ within '.op-activity-list' do+ click_link('Details')+ end++ # on diff page, click the back button+ expect(page).to have_link(text: 'Back')+ click_link('Back')++ expect(page.current_url).to eq(activity_page_url)+ end++ it 'Back button navigates to the previously seen activity page' do+ [+ activities_path,+ project_activities_path(project),+ user_path(user)+ ].each do |activity_page|+ assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ endendend- # work package activity page is rendered by Angular, so it needs js: true- it 'Back button navigates to the previously seen work package page', js: true do- activity_page = work_package_path(project_work_package)- assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ context 'for a work package description' do+ before do+ project_work_package.update(description: 'New work package description')+ end++ def assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ visit(activity_page)+ activity_page_url = page.current_url++ expect(page).to have_link(text: 'Details')+ expect(page.text).to include("Description changed (Details)")+ click_link('Details')++ # on diff page, click the back button+ expect(page).to have_link(text: 'Back')+ click_link('Back')++ expect(page.current_url).to eq(activity_page_url)+ end++ it 'Back button navigates to the previously seen activity page' do+ [+ activities_path,+ project_activities_path(project),+ user_path(user)+ ].each do |activity_page|+ assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ end+ end++ # work package activity page is rendered by Angular, so it needs js: true+ it 'Back button navigates to the previously seen work package page', js: true do+ activity_page = work_package_path(project_work_package)+ assert_navigating_to_diff_page_and_back_comes_back_to_the_same_page(activity_page)+ endendendenddiff --git a/spec/features/activities/project_attributes_activity_spec.rb b/spec/features/activities/project_attributes_activity_spec.rbindex 8883c291e1e..41e3913895b 100644--- a/spec/features/activities/project_attributes_activity_spec.rb+++ b/spec/features/activities/project_attributes_activity_spec.rb@@ -62,7 +62,7 @@ describe 'Project attributes activities' doidentifier: 'a-new-project-name',active: true,templated: true,-+ status_explanation: 'some explanation',list_project_custom_field.attribute_name => list_project_custom_field.possible_values.first.id,version_project_custom_field.attribute_name => next_version.id,bool_project_custom_field.attribute_name => true,@@ -87,6 +87,7 @@ describe 'Project attributes activities' do# own fieldsexpect(page).to have_selector('li', text: "Name changed from #{previous_project_attributes['name']} to #{project.name}")+ expect(page).to have_selector('li', text: 'Project status description set (Details)')expect(page).to have_selector('li', text: 'Description set (Details)')expect(page).to have_selector('li', text: 'Visibility set to public')expect(page).to have_selector('li', text: "No longer subproject of #{parent_project.name}")