Commit cefbe4e2 authored by jplang's avatar jplang

Adds support for GET on /issues/:issue_id/relations (#7366).

git-svn-id: https://svn.redmine.org/redmine/trunk@6179 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent a97055e8
......@@ -17,7 +17,16 @@
class IssueRelationsController < ApplicationController
before_filter :find_issue, :find_project_from_association, :authorize
accept_key_auth :show, :create, :destroy
accept_key_auth :index, :show, :create, :destroy
def index
@relations = @issue.relations
respond_to do |format|
format.html { render :nothing => true }
format.api
end
end
def show
@relation = @issue.find_relation(params[:id])
......
api.array :relations do
@relations.each do |relation|
api.relation do
api.id relation.id
api.issue_id relation.issue_from_id
api.issue_to_id relation.issue_to_id
api.relation_type relation.relation_type
api.delay relation.delay
end
end
end
......@@ -27,7 +27,7 @@ api.issue do
api.array :relations do
@relations.each do |relation|
api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay)
api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type, :delay => relation.delay)
end
end if include_in_api_response?('relations') && @relations.present?
......
......@@ -110,7 +110,7 @@ ActionController::Routing::Routes.draw do |map|
map.resources :issues, :member => { :edit => :post }, :collection => {} do |issues|
issues.resources :time_entries, :controller => 'timelog'
issues.resources :relations, :controller => 'issue_relations', :only => [:show, :create, :destroy]
issues.resources :relations, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
end
map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues|
......
......@@ -69,7 +69,7 @@ Redmine::AccessControl.map do |map|
:reports => [:issue_report, :issue_report_details]}
map.permission :add_issues, {:issues => [:new, :create, :update_form]}
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
map.permission :manage_issue_relations, {:issue_relations => [:show, :create, :destroy]}
map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
map.permission :manage_subtasks, {}
map.permission :set_issues_private, {}
map.permission :set_own_issues_private, {}, :require => :loggedin
......
......@@ -25,6 +25,25 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
end
context "/issues/:issue_id/relations" do
context "GET" do
should "return issue relations" do
get '/issues/9/relations.xml', {}, :authorization => credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'relations',
:attributes => { :type => 'array' },
:child => {
:tag => 'relation',
:child => {
:tag => 'id',
:content => '1'
}
}
end
end
context "POST" do
should "create a relation" do
assert_difference('IssueRelation.count') do
......
......@@ -118,6 +118,10 @@ class RoutingTest < ActionController::IntegrationTest
end
context "issue relations" do
should_route :get, "/issues/1/relations", :controller => 'issue_relations', :action => 'index', :issue_id => '1'
should_route :get, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'xml'
should_route :get, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'json'
should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'create', :issue_id => '1'
should_route :post, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'xml'
should_route :post, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'json'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment