From 1c574834340ad21b585180b65281fd5c7abba1b4 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Sat, 13 Jul 2013 00:17:42 +0400 Subject: [PATCH] #214: updated PullRequest API --- app/controllers/api/v1/pull_requests_controller.rb | 4 ++-- app/views/api/v1/pull_requests/_pull.json.jbuilder | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/pull_requests_controller.rb b/app/controllers/api/v1/pull_requests_controller.rb index b42086df4..bd3a4804c 100644 --- a/app/controllers/api/v1/pull_requests_controller.rb +++ b/app/controllers/api/v1/pull_requests_controller.rb @@ -75,9 +75,9 @@ class Api::V1::PullRequestsController < Api::V1::BaseController attrs.merge(:assignee_id => pull_params[:assignee_id]) if can?(:write, @project) if (action = pull_params[:status]) && %w(close reopen).include?(pull_params[:status]) - if @pull.valid? && @pull.send("can_#{action}?") + if @pull.send("can_#{action}?") @pull.set_user_and_time current_user - need_check = true if action == 'reopen' + need_check = true if action == 'reopen' && @pull.valid? end end end diff --git a/app/views/api/v1/pull_requests/_pull.json.jbuilder b/app/views/api/v1/pull_requests/_pull.json.jbuilder index ae919757b..6041c80b1 100644 --- a/app/views/api/v1/pull_requests/_pull.json.jbuilder +++ b/app/views/api/v1/pull_requests/_pull.json.jbuilder @@ -2,14 +2,14 @@ json.number pull.serial_id json.(pull, :title, :status) json.to_ref do |json_ref| json_ref.ref pull.to_ref - json_ref.sha pull.to_commit.id + json_ref.sha pull.to_commit.try(:id) json_ref.project do |json_project| json_project.partial! 'api/v1/projects/project', :project => pull.to_project, :json => json end end json.from_ref do |json_ref| json_ref.ref pull.from_ref - json_ref.sha pull.from_commit.id + json_ref.sha pull.from_commit.try(:id) json_ref.project do |json_project| json_project.partial! 'api/v1/projects/project', :project => pull.from_project, :json => json end