+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
require 'test_helper'
class ArvadosModelTest < ActiveSupport::TestCase
properties: {'foo' => 'bar'}.with_indifferent_access)
raw = ActiveRecord::Base.connection.
select_value("select properties from links where uuid='#{link.uuid}'")
- assert_equal '{"foo":"bar"}', raw
+ assert_equal '{"foo": "bar"}', raw
end
test "store long string" do
test "search index exists on models that go into projects" do
all_tables = ActiveRecord::Base.connection.tables
all_tables.delete 'schema_migrations'
+ all_tables.delete 'permission_refresh_lock'
all_tables.each do |table|
table_class = table.classify.constantize
assert_equal true, (updated_at_2 > updated_at_1), "Expected updated time 2 to be newer than 1"
end
+
+ test 'jsonb column' do
+ set_user_from_auth :active
+
+ c = Collection.create!(properties: {})
+ assert_equal({}, c.properties)
+
+ c.update_attributes(properties: {'foo' => 'foo'})
+ c.reload
+ assert_equal({'foo' => 'foo'}, c.properties)
+
+ c.update_attributes(properties: nil)
+ c.reload
+ assert_equal({}, c.properties)
+
+ c.update_attributes(properties: {foo: 'bar'})
+ assert_equal({'foo' => 'bar'}, c.properties)
+ c.reload
+ assert_equal({'foo' => 'bar'}, c.properties)
+ end
end