Deconflate organization/conference IDs in role versions
Resolves failing test spec/features/versions_spec.rb:321
Partially reverts 81853d1ef9
This commit is contained in:
parent
150bbef61f
commit
3f6a9e91bd
6 changed files with 69 additions and 37 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -4,11 +4,8 @@ class UsersRole < ApplicationRecord
|
|||
belongs_to :role
|
||||
belongs_to :user
|
||||
|
||||
has_paper_trail on: [:create, :destroy], meta: { conference_id: :conference_id }
|
||||
delegate :conference_id, :organization_id, to: :role
|
||||
|
||||
private
|
||||
|
||||
def conference_id
|
||||
role.resource_id
|
||||
end
|
||||
has_paper_trail on: [:create, :destroy],
|
||||
meta: { conference_id: :conference_id, organization_id: :organization_id }
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue