Deconflate organization/conference IDs in role versions

Resolves failing test spec/features/versions_spec.rb:320.
This commit is contained in:
Andrew Kvalheim 2020-04-03 09:51:35 -07:00
parent 79cd1c9fcd
commit fe2e5febe3
5 changed files with 67 additions and 35 deletions

View file

@ -5,7 +5,9 @@ class Role < ApplicationRecord
has_many :users_roles
has_many :users, through: :users_roles
has_paper_trail on: [:create, :update], only: [:name, :description], meta: { conference_id: :resource_id }
has_paper_trail on: [:create, :update],
only: [:name, :description],
meta: { conference_id: :conference_id, organization_id: :organization_id }
before_destroy :cancel
scopify
@ -14,6 +16,14 @@ class Role < ApplicationRecord
validates :name, uniqueness: { scope: :resource }
def conference_id
resource_type == 'Conference' ? resource_id : nil
end
def organization_id
resource_type == 'Organization' ? resource_id : nil
end
private
# Needed to ensure that removing all user from role doesn't remove role.