[ARVADOS] updated: fa3f6860158dda089c0b4b96c346bbc643232421
git at public.curoverse.com
git at public.curoverse.com
Tue Jul 22 16:12:10 EDT 2014
Summary of changes:
apps/workbench/app/controllers/projects_controller.rb | 17 ++++++++++++++---
.../test/functional/projects_controller_test.rb | 7 ++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
via fa3f6860158dda089c0b4b96c346bbc643232421 (commit)
from 95d963b2d176e0ffe0797541368463fb5deaf3cf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit fa3f6860158dda089c0b4b96c346bbc643232421
Author: Brett Smith <brett at curoverse.com>
Date: Tue Jul 22 16:12:59 2014 -0400
2044: Improve reporting when project sharing fails.
Our select modal knows how to render an errors key in the JSON
response. This commit adjusts the project controller to conform to
this convention. Refs #2044, #3200.
diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index 118a467..f32f356 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -161,18 +161,29 @@ class ProjectsController < ApplicationController
@errors = ["No user/group UUIDs specified to share with."]
return render_error(status: 422)
end
- results = {"success" => [], "failure" => {}}
+ results = {"success" => [], "errors" => []}
params[:uuids].each do |shared_uuid|
begin
Link.create(tail_uuid: shared_uuid, link_class: "permission",
name: "can_read", head_uuid: @object.uuid)
rescue ArvadosApiClient::ApiError => error
- results["failure"][shared_uuid] = error.api_response.andand[:errors]
+ error_list = error.api_response.andand[:errors]
+ if error_list.andand.any?
+ results["errors"] += error_list.map { |e| "#{shared_uuid}: #{e}" }
+ else
+ error_code = error.api_status || "Bad status"
+ results["errors"] << "#{shared_uuid}: #{error_code} response"
+ end
else
results["success"] << shared_uuid
end
end
- status = (results["failure"].empty?) ? 200 : 422
+ if results["errors"].empty?
+ results.delete("errors")
+ status = 200
+ else
+ status = 422
+ end
respond_to do |f|
f.json { render(json: results, status: status) }
end
diff --git a/apps/workbench/test/functional/projects_controller_test.rb b/apps/workbench/test/functional/projects_controller_test.rb
index ff56928..39c32ac 100644
--- a/apps/workbench/test/functional/projects_controller_test.rb
+++ b/apps/workbench/test/functional/projects_controller_test.rb
@@ -43,12 +43,17 @@ class ProjectsControllerTest < ActionController::TestCase
end
test "user with project read permission can't add permissions" do
+ share_uuid = api_fixture("users")["spectator"]["uuid"]
post(:share_with, {
id: api_fixture("groups")["aproject"]["uuid"],
- uuids: [api_fixture("users")["spectator"]["uuid"]],
+ uuids: [share_uuid],
format: "json"},
session_for(:project_viewer))
assert_response 422
+ json_response = Oj.load(@response.body)
+ assert(json_response["errors"].andand.
+ any? { |msg| msg.start_with?("#{share_uuid}: ") },
+ "JSON response missing properly formatted sharing error")
end
def user_can_manage(user_sym, group_key)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list