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
Add specs for hiding removed custom fields when bulk editing work packages.
Dombi Attila731008000f6a
diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rbindex 7d4c611e634..185ac05e6c1 100644--- a/spec/features/work_packages/bulk/update_work_package_spec.rb+++ b/spec/features/work_packages/bulk/update_work_package_spec.rb@@ -11,7 +11,12 @@ RSpec.describe 'Bulk update work packages through Rails view', :js, :with_cuprittypes: [type],projects: [project])end-+ shared_let(:custom_field_removed) do+ create(:string_wp_custom_field,+ name: 'Text CF Removed',+ types: [type],+ projects: [project])+ endshared_let(:dev_role) docreate(:project_role,permissions: %i[view_work_packages])@@ -137,64 +142,79 @@ RSpec.describe 'Bulk update work packages through Rails view', :js, :with_cupritendend- context 'when editing custom field of work packages with a readonly status (regression#44673)' do- let(:work_package2_status) { create(:status, :readonly) }+ describe 'custom fields' do+ context 'when editing custom field of work packages with a readonly status (regression#44673)' do+ let(:work_package2_status) { create(:status, :readonly) }++ context 'with enterprise', with_ee: %i[readonly_work_packages] do+ it 'does not update the work packages' do+ expect(work_package.send(custom_field.attribute_getter)).to be_nil+ expect(work_package2.send(custom_field.attribute_getter)).to be_nil++ fill_in custom_field.name, with: 'Custom field text'+ click_on 'Submit'++ expect(page)+ .to have_css(+ '.op-toast.-error',+ text: I18n.t('work_packages.bulk.x_out_of_y_could_be_saved', total: 2, failing: 1, success: 1)+ )++ expect(page)+ .to have_css(+ '.op-toast.-error',+ text: <<~MSG.squish+ #{work_package2.id}:+ #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')}+ #{I18n.t('activerecord.errors.models.work_package.readonly_status')}+ MSG+ )++ # Should update 1 work package custom field only+ work_package.reload+ work_package2.reload++ expect(work_package.send(custom_field.attribute_getter))+ .to eq('Custom field text')++ expect(work_package2.send(custom_field.attribute_getter))+ .to be_nil+ end+ end- context 'with enterprise', with_ee: %i[readonly_work_packages] do- it 'does not update the work packages' do- expect(work_package.send(custom_field.attribute_getter)).to be_nil- expect(work_package2.send(custom_field.attribute_getter)).to be_nil+ context 'without enterprise', with_ee: false do+ it 'ignores the readonly status and updates the work packages' do+ expect(work_package.send(custom_field.attribute_getter)).to be_nil+ expect(work_package2.send(custom_field.attribute_getter)).to be_nil- fill_in custom_field.name, with: 'Custom field text'- click_on 'Submit'+ fill_in custom_field.name, with: 'Custom field text'+ click_on 'Submit'- expect(page)- .to have_css(- '.op-toast.-error',- text: I18n.t('work_packages.bulk.x_out_of_y_could_be_saved', total: 2, failing: 1, success: 1)- )-- expect(page)- .to have_css(- '.op-toast.-error',- text: <<~MSG.squish- #{work_package2.id}:- #{custom_field.name} #{I18n.t('activerecord.errors.messages.error_readonly')}- #{I18n.t('activerecord.errors.models.work_package.readonly_status')}- MSG- )-- # Should update 1 work package custom field only- work_package.reload- work_package2.reload-- expect(work_package.send(custom_field.attribute_getter))- .to eq('Custom field text')-- expect(work_package2.send(custom_field.attribute_getter))- .to be_nil- end- end+ expect(page).to have_css('.op-toast.-success', text: I18n.t(:notice_successful_update))- context 'without enterprise', with_ee: false do- it 'ignores the readonly status and updates the work packages' do- expect(work_package.send(custom_field.attribute_getter)).to be_nil- expect(work_package2.send(custom_field.attribute_getter)).to be_nil+ # Should update 2 work package custom fields+ work_package.reload+ work_package2.reload- fill_in custom_field.name, with: 'Custom field text'- click_on 'Submit'+ expect(work_package.send(custom_field.attribute_getter))+ .to eq('Custom field text')- expect(page).to have_css('.op-toast.-success', text: I18n.t(:notice_successful_update))+ expect(work_package2.send(custom_field.attribute_getter))+ .to eq('Custom field text')+ end+ end+ end- # Should update 2 work package custom fields- work_package.reload- work_package2.reload+ context 'when custom fields are removed from types' do+ it 'does not display them on the form' do+ expect(page).to have_field custom_field_removed.name- expect(work_package.send(custom_field.attribute_getter))- .to eq('Custom field text')+ custom_field_removed.types = []+ custom_field_removed.save!+ page.refresh+ wait_for_reload- expect(work_package2.send(custom_field.attribute_getter))- .to eq('Custom field text')+ expect(page).to have_no_field custom_field_removed.nameendendend