3 class Arvados::V1::LinksControllerTest < ActionController::TestCase
5 test "no symbol keys in serialized hash" do
7 properties: {username: 'testusername'},
10 tail_kind: 'arvados#user',
11 tail_uuid: users(:admin).uuid,
12 head_kind: 'arvados#virtualMachine',
13 head_uuid: virtual_machines(:testvm).uuid
16 [link, link.to_json].each do |formatted_link|
17 post :create, link: formatted_link
18 assert_response :success
19 assert_not_nil assigns(:object)
20 assert_equal 'testusername', assigns(:object).properties['username']
21 assert_equal false, assigns(:object).properties.has_key?(:username)
25 %w(created_at updated_at modified_at).each do |attr|
26 {nil: nil, bogus: 2.days.ago}.each do |bogustype, bogusvalue|
27 test "cannot set #{bogustype} #{attr} in create" do
28 authorize_with :active
34 }.merge(attr => bogusvalue)
36 assert_response :success
37 resp = JSON.parse @response.body
38 assert_in_delta Time.now, Time.parse(resp[attr]), 3.0
40 test "cannot set #{bogustype} #{attr} in update" do
41 really_created_at = links(:test_timestamps).created_at
42 authorize_with :active
44 id: links(:test_timestamps).uuid,
46 :properties => {test: 'test'},
50 assert_response :success
51 resp = JSON.parse @response.body
54 assert_in_delta really_created_at, Time.parse(resp[attr]), 0.001
56 assert_in_delta Time.now, Time.parse(resp[attr]), 3.0