link the schema resource

pull/2536/head
Jan Sandbrink 10 years ago
parent 0ba55e6972
commit 1d0afffec7
  1. 4
      lib/api/v3/utilities/path_helper.rb
  2. 6
      lib/api/v3/work_packages/work_package_representer.rb
  3. 10
      spec/lib/api/v3/utilities/path_helper_spec.rb
  4. 10
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -104,6 +104,10 @@ module API
render_markup(format: :textile, link: link)
end
def self.schema(project_id, type_id)
"#{root}/work_packages/schemas/#{project_id}-#{type_id}"
end
def self.statuses
"#{root}/statuses"
end

@ -44,6 +44,12 @@ module API
} if current_user_allowed_to(:edit_work_packages)
end
link :schema do
{
href: api_v3_paths.schema(represented.project.id, represented.type.id)
}
end
link :updateImmediately do
{
href: api_v3_paths.work_package(represented.id),

@ -203,6 +203,16 @@ describe ::API::V3::Utilities::PathHelper do
end
end
describe 'schemas paths' do
describe '#schema' do
subject { helper.schema 1, 2}
it_behaves_like 'api v3 path'
it { is_expected.to match(/^\/api\/v3\/work_packages\/schemas\/1-2/) }
end
end
describe 'statuses paths' do
describe '#statuses' do
subject { helper.statuses }

@ -410,6 +410,16 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
end
describe 'schema' do
let(:schema_id) { "#{work_package.project.id}-#{work_package.type.id}" }
let(:link) { "/api/v3/work_packages/schemas/#{schema_id}".to_json }
let(:href_path) { '_links/schema/href' }
it 'has a link' do
is_expected.to be_json_eql(link).at_path(href_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