Added priority as link to work_package and changed specs accordingly

pull/2456/head
Alexander Bach 10 years ago committed by Jan Sandbrink
parent 979e4270f9
commit e8f3b97c45
  1. 8
      lib/api/v3/work_packages/work_package_representer.rb
  2. 16
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -210,6 +210,13 @@ module API
version_policy.allowed?(represented.fixed_version, :show)
end
link :priority do
{
href: api_v3_paths.priority(represented.priority.id),
title: represented.priority.name
}
end
links :children do
visible_children.map do |child|
{ href: "#{root_path}api/v3/work_packages/#{child.id}", title: child.subject }
@ -231,7 +238,6 @@ module API
},
setter: -> (value, *) { represented.description = value['raw'] },
render_nil: true
property :priority, getter: -> (*) { priority.try(:name) }, render_nil: true
property :start_date, getter: -> (*) { start_date.to_datetime.utc.iso8601 unless start_date.nil? }, render_nil: true
property :due_date, getter: -> (*) { due_date.to_datetime.utc.iso8601 unless due_date.nil? }, render_nil: true
property :estimated_time,

@ -81,7 +81,6 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
it { is_expected.to have_json_path('dueDate') }
it { is_expected.to have_json_path('percentageDone') }
it { is_expected.to have_json_path('priority') }
it { is_expected.to have_json_path('projectId') }
it { is_expected.to have_json_path('projectName') }
@ -287,6 +286,21 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
end
describe 'priority' do
let(:link) { "/api/v3/priorities/#{work_package.priority.id}".to_json }
let(:title) { "#{work_package.priority.name}".to_json }
let(:href_path) { '_links/priority/href' }
let(:title_path) { '_links/priority/title' }
it 'has a link' do
is_expected.to be_json_eql(link).at_path(href_path)
end
it 'has a title' do
is_expected.to be_json_eql(title).at_path(title_path)
end
end
context 'when the user has the permission to view work packages' do
context 'and the user is not watching the work package' do
it 'should have a link to watch' do

Loading…
Cancel
Save