Merge pull request #8384 from opf/fix/time_logging_with_version_cf

add method missing if logging time with version cf
pull/8389/head
Henriette Darge 5 years ago committed by GitHub
commit 22af81ec6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/contracts/time_entries/base_contract.rb
  2. 54
      spec/contracts/time_entries/shared_contract_examples.rb

@ -73,6 +73,12 @@ module TimeEntries
end end
end end
# Necessary for custom fields
# of type version.
def assignable_versions
work_package.try(:assignable_versions) || project.try(:assignable_versions) || []
end
private private
def validate_work_package def validate_work_package

@ -227,4 +227,58 @@ shared_examples_for 'time entry contract' do
end end
end end
end end
describe 'assignable_versions' do
let(:project_versions) { double('project versions') }
let(:wp_versions) { double('work_package versions') }
before do
if time_entry_project
allow(time_entry_project)
.to receive(:assignable_versions)
.and_return project_versions
end
if time_entry_work_package
allow(time_entry_work_package)
.to receive(:assignable_versions)
.and_return wp_versions
end
end
context 'if no project and no work package is set' do
let(:time_entry_project) { nil }
let(:time_entry_work_package) { nil }
it 'is empty' do
expect(contract.assignable_versions)
.to be_empty
end
end
context 'if a project is set but no work package' do
let(:time_entry_work_package) { nil }
it 'returns assignable_versions of the project' do
expect(contract.assignable_versions)
.to eql project_versions
end
end
context 'if a work_package is set but no project' do
let(:time_entry_project) { nil }
it 'returns assignable_versions of the project' do
expect(contract.assignable_versions)
.to eql wp_versions
end
end
context 'if both project and work_package are set' do
it 'returns assignable_versions of the project' do
expect(contract.assignable_versions)
.to eql wp_versions
end
end
end
end end

Loading…
Cancel
Save