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

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6179 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-07-04 17:44:41 +00:00
parent 79f25c08f8
commit daa426167f
7 changed files with 47 additions and 4 deletions

View File

@ -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])

View File

@ -0,0 +1,11 @@
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

View File

@ -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?

View File

@ -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|

View File

@ -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

View File

@ -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

View File

@ -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'