Merge pull request #6875 from opf/core/fix/15909/respect-current-date-setting

[15909] Respect current_date as start_date setting
pull/6880/head
ulferts 6 years ago committed by GitHub
commit 240f2d845e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/services/work_packages/set_attributes_service.rb
  2. 1
      config/settings.yml
  3. 24
      spec/services/work_packages/set_attributes_service_spec.rb
  4. 2
      spec_legacy/unit/mail_handler_spec.rb

@ -85,6 +85,10 @@ class WorkPackages::SetAttributesService
work_package.priority ||= IssuePriority.active.default
work_package.author ||= user
work_package.status ||= Status.default
if Setting.work_package_startdate_is_adddate?
work_package.start_date ||= Date.today
end
end
def set_custom_attributes(attributes)

@ -329,6 +329,7 @@ emails_header:
en: ''
work_package_startdate_is_adddate:
default: 1
format: boolean
user_default_timezone:
default: ""
users_deletable_by_admins:

@ -354,20 +354,38 @@ describe WorkPackages::SetAttributesService, type: :model do
end
end
context 'no value set on existing work package' do
context 'start_date with default setting', with_settings: { work_package_startdate_is_adddate: true } do
context 'no value set before for a new work package' do
let(:call_attributes) { {} }
let(:attributes) { {} }
let(:work_package) { new_work_package }
before do
work_package.priority = nil
end
it_behaves_like 'service call' do
it 'stays nil' do
it "sets the default priority" do
subject
expect(work_package.priority)
.to be_nil
.to eql default_priority
end
end
end
context 'value set on new work package' do
let(:call_attributes) { { start_date: Date.today + 1.day } }
let(:attributes) { {} }
let(:work_package) { new_work_package }
it_behaves_like 'service call' do
it 'stays that value' do
subject
expect(work_package.start_date)
.to eq(Date.today + 1.day)
end
end
end
end

@ -241,6 +241,7 @@ describe MailHandler, type: :model do
assert_equal false, submit_email('ticket_without_from_header.eml')
end
context 'without default start_date', with_settings: { work_package_startdate_is_adddate: false } do
it 'should add work package with invalid attributes' do
issue = submit_email('ticket_with_invalid_attributes.eml', allow_override: 'type,category,priority')
assert issue.is_a?(WorkPackage)
@ -253,6 +254,7 @@ describe MailHandler, type: :model do
assert_equal 'Normal', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
end
it 'should add work package with localized attributes' do
User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'de'

Loading…
Cancel
Save