Merge pull request #741 from warpc/733-fix_answer

[refs #733] Fix wrong positive answer for special build list action
This commit is contained in:
Vladimir Sharshov 2012-11-28 08:06:48 -08:00
commit 834b83bf28
1 changed files with 9 additions and 6 deletions

View File

@ -52,11 +52,14 @@ class Api::V1::BuildListsController < Api::V1::BaseController
private
def render_json(action_name)
if @build_list.send(action_name)
render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")}
res, message = if !@build_list.send "can_#{action_name}?"
[false, "Incorrect action for current build list"]
elsif @build_list.send(action_name)
[true, t("layout.build_lists.#{action_name}_success")]
else
render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")}
end
[false, t("layout.build_lists.#{action_name}_fail")]
end
render :json => {:"is_#{action_name}ed" => res, :url => api_v1_build_list_path(@build_list, :format => :json), :message => message}
end
end