No uniqueness control on AspectVisibility resulted in possible having multiple AspectVisibility objects in the DB for the same aspect and shareable which doesn't make sense. Introduce uniqueness validation and fix up tests where duplication happened.
14 lines
433 B
Ruby
14 lines
433 B
Ruby
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
|
# licensed under the Affero General Public License version 3 or later. See
|
|
# the COPYRIGHT file.
|
|
|
|
class AspectVisibility < ActiveRecord::Base
|
|
|
|
belongs_to :aspect
|
|
validates :aspect, :presence => true
|
|
|
|
belongs_to :shareable, :polymorphic => true
|
|
validates :shareable, :presence => true
|
|
|
|
validates :aspect, uniqueness: {scope: %i(shareable_id shareable_type)}
|
|
end
|