[ARVADOS] updated: 976a754dc7fceee767322ae964c287b63595211f
git at public.curoverse.com
git at public.curoverse.com
Mon Jan 13 16:34:40 EST 2014
Summary of changes:
.../api/app/controllers/application_controller.rb | 9 +++--
.../arvados/v1/collections_controller.rb | 6 ++--
.../arvados/v1/collections_controller_test.rb | 38 ++++++++++++++++++++
3 files changed, 46 insertions(+), 7 deletions(-)
via 976a754dc7fceee767322ae964c287b63595211f (commit)
from 57dbb702fde186b90fb2ad2504a35603a33b15dc (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 976a754dc7fceee767322ae964c287b63595211f
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Jan 13 13:34:18 2014 -0800
Use symbol keys to access request parameters.
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index d439779..c7cbc60 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -101,7 +101,7 @@ class ApplicationController < ActionController::Base
@where = params[:where]
elsif params[:where].is_a? String
begin
- @where = Oj.load(params[:where])
+ @where = Oj.load(params[:where], symbol_keys: true)
rescue
raise ArgumentError.new("Could not parse \"where\" param as an object")
end
@@ -125,7 +125,7 @@ class ApplicationController < ActionController::Base
if !@where.empty?
conditions = ['1=1']
@where.each do |attr,value|
- if attr == 'any' or attr == :any
+ if attr == :any
if value.is_a?(Array) and
value[0] == 'contains' and
model_class.columns.collect(&:name).index('name') then
@@ -191,7 +191,7 @@ class ApplicationController < ActionController::Base
return @attrs if @attrs
@attrs = params[resource_name]
if @attrs.is_a? String
- @attrs = Oj.load @attrs
+ @attrs = Oj.load @attrs, symbol_keys: true
end
unless @attrs.is_a? Hash
message = "No #{resource_name}"
@@ -319,7 +319,8 @@ class ApplicationController < ActionController::Base
def accept_attribute_as_json(attr, force_class)
if params[resource_name].is_a? Hash
if params[resource_name][attr].is_a? String
- params[resource_name][attr] = Oj.load params[resource_name][attr]
+ params[resource_name][attr] = Oj.load(params[resource_name][attr],
+ symbol_keys: true)
if force_class and !params[resource_name][attr].is_a? force_class
raise TypeError.new("#{resource_name}[#{attr.to_s}] must be a #{force_class.to_s}")
end
diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb
index a719de9..d81f441 100644
--- a/services/api/app/controllers/arvados/v1/collections_controller.rb
+++ b/services/api/app/controllers/arvados/v1/collections_controller.rb
@@ -7,11 +7,11 @@ class Arvados::V1::CollectionsController < ApplicationController
@object.save!
rescue ActiveRecord::RecordNotUnique
logger.debug resource_attrs.inspect
- if resource_attrs['manifest_text'] and resource_attrs['uuid']
+ if resource_attrs[:manifest_text] and resource_attrs[:uuid]
@existing_object = model_class.
where('uuid=? and manifest_text=?',
- resource_attrs['uuid'],
- resource_attrs['manifest_text']).
+ resource_attrs[:uuid],
+ resource_attrs[:manifest_text]).
first
@object = @existing_object || @object
end
diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb
index dc181ff..4f33d0b 100644
--- a/services/api/test/functional/arvados/v1/collections_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb
@@ -9,4 +9,42 @@ class Arvados::V1::CollectionsControllerTest < ActionController::TestCase
assert_not_nil assigns(:objects)
end
+ test "should create" do
+ authorize_with :active
+ post :create, {
+ collection: {
+ manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",
+ uuid: "d30fe8ae534397864cb96c544f4cf102"
+ }
+ }
+ assert_response :success
+ assert_nil assigns(:objects)
+ end
+
+ test "should create with collection passed as json" do
+ authorize_with :active
+ post :create, {
+ collection: <<-EOS
+ {
+ "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",\
+ "uuid":"d30fe8ae534397864cb96c544f4cf102"\
+ }
+ EOS
+ }
+ assert_response :success
+ end
+
+ test "should fail to create with checksum mismatch" do
+ authorize_with :active
+ post :create, {
+ collection: <<-EOS
+ {
+ "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:bar.txt\n",\
+ "uuid":"d30fe8ae534397864cb96c544f4cf102"\
+ }
+ EOS
+ }
+ assert_response 422
+ end
+
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list