# user.uuid==object.owner_uuid.
has_many(:permissions,
->{where(link_class: 'permission')},
- foreign_key: :head_uuid,
+ foreign_key: 'head_uuid',
class_name: 'Link',
- primary_key: :uuid)
+ primary_key: 'uuid')
# If async is true at create or update, permission graph
# update is deferred allowing making multiple calls without the performance
before_update :permission_to_set_authorized_user_uuid
belongs_to :authorized_user, {
- foreign_key: :authorized_user_uuid,
+ foreign_key: 'authorized_user_uuid',
class_name: 'User',
- primary_key: :uuid,
+ primary_key: 'uuid',
optional: true,
}
after_save :update_cr_logs
after_save :handle_completed
- has_many :container_requests, :foreign_key => :container_uuid, :class_name => 'ContainerRequest', :primary_key => :uuid
+ has_many :container_requests, {
+ class_name: 'ContainerRequest',
+ foreign_key: 'container_uuid',
+ primary_key: 'uuid',
+ }
belongs_to :auth, {
class_name: 'ApiClientAuthorization',
- foreign_key: :auth_uuid,
- primary_key: :uuid,
+ foreign_key: 'auth_uuid',
+ primary_key: 'uuid',
optional: true,
}
include WhitelistUpdate
belongs_to :container, {
- foreign_key: :container_uuid,
- primary_key: :uuid,
+ foreign_key: 'container_uuid',
+ primary_key: 'uuid',
optional: true,
}
belongs_to :requesting_container, {
class_name: 'Container',
- foreign_key: :requesting_container_uuid,
- primary_key: :uuid,
+ foreign_key: 'requesting_container_uuid',
+ primary_key: 'uuid',
optional: true,
}
before_create :create_disabled
before_update :update_disabled
- has_many(:nodes, foreign_key: :job_uuid, primary_key: :uuid)
+ has_many(:nodes, foreign_key: 'job_uuid', primary_key: 'uuid')
class SubmitIdReused < RequestError
end
# have access to the associated Job. They're expected to set
# job_readable=true if the Job UUID can be included in the API response.
belongs_to :job, {
- foreign_key: :job_uuid,
- primary_key: :uuid,
+ foreign_key: 'job_uuid',
+ primary_key: 'uuid',
optional: true,
}
attr_accessor :job_readable
serialize :properties, Hash
serialize :components_summary, Hash
belongs_to :pipeline_template, {
- foreign_key: :pipeline_template_uuid,
- primary_key: :uuid,
+ foreign_key: 'pipeline_template_uuid',
+ primary_key: 'uuid',
optional: true,
}
before_destroy :clear_permissions
after_destroy :remove_self_from_permissions
- has_many :authorized_keys, :foreign_key => :authorized_user_uuid, :primary_key => :uuid
- has_many :repositories, foreign_key: :owner_uuid, primary_key: :uuid
+ has_many :authorized_keys, foreign_key: 'authorized_user_uuid', primary_key: 'uuid'
+ has_many :repositories, foreign_key: 'owner_uuid', primary_key: 'uuid'
default_scope { where('redirect_to_user_uuid is null') }
has_many(:login_permissions,
-> { where("link_class = 'permission' and name = 'can_login'") },
- foreign_key: :head_uuid,
+ foreign_key: 'head_uuid',
class_name: 'Link',
- primary_key: :uuid)
+ primary_key: 'uuid')
api_accessible :user, extend: :common do |t|
t.add :hostname
klass = t.classify.constantize
next unless klass and 'owner_uuid'.in?(klass.columns.collect(&:name))
base.has_many(t.to_sym,
- foreign_key: :owner_uuid,
- primary_key: :uuid,
+ foreign_key: 'owner_uuid',
+ primary_key: 'uuid',
dependent: :restrict_with_exception)
end
# We need custom protection for changing an owner's primary
# Check for objects that have my old uuid listed as their owner.
self.class.reflect_on_all_associations(:has_many).each do |assoc|
- next unless assoc.foreign_key == :owner_uuid
+ next unless assoc.foreign_key == 'owner_uuid'
if assoc.klass.where(owner_uuid: uuid_was).any?
errors.add(:uuid,
"cannot be changed on a #{self.class} that owns objects")
base.has_many(:links_via_head,
-> { where("not (link_class = 'permission')") },
class_name: 'Link',
- foreign_key: :head_uuid,
- primary_key: :uuid,
+ foreign_key: 'head_uuid',
+ primary_key: 'uuid',
dependent: :destroy)
base.has_many(:links_via_tail,
-> { where("not (link_class = 'permission')") },
class_name: 'Link',
- foreign_key: :tail_uuid,
- primary_key: :uuid,
+ foreign_key: 'tail_uuid',
+ primary_key: 'uuid',
dependent: :destroy)
end
assert_nil json_response['trash_at']
end
+ test 'untrash a trashed collection by assigning nil to trash_at' do
+ authorize_with :active
+ post :update, params: {
+ id: collections(:expired_collection).uuid,
+ collection: {
+ trash_at: nil,
+ },
+ include_trash: true,
+ }
+ assert_response 200
+ assert_equal false, json_response['is_trashed']
+ assert_nil json_response['trash_at']
+ end
+
test 'untrash error on not trashed collection' do
authorize_with :active
post :untrash, params: {