* Add podcast_appearances joined table (forem#82) * Add podcast appearances keys unique constraint and creator property (forem#82) * Add podcast_appearance role validation forem(#82) * Add spec test for podcast_appearances model (forem#82) * Small refactoring - place podcast appearance association by alphabetical order * Adapt m2m association to pass rspec test (forem#82) * Rename podcast appearance model to podcast episode appearance and remove fk indexing * Rename podcast appearance model to podcast episode appearance and remove fk indexing * Rename podcast episode appearance models and spec models. Update podcast episode and user spec tests (forem#82) * Rename podcast episode appearances composite index to follow Rails naming pattern (forem#82) * Remove ddl_transaction disabling and conurrent index adding from appearance migration * Add role validation in model spec (forem#82)
7 lines
388 B
Ruby
7 lines
388 B
Ruby
class PodcastEpisodeAppearance < ApplicationRecord
|
|
belongs_to :user, class_name: "User", inverse_of: :podcast_episode_appearances
|
|
belongs_to :podcast_episode
|
|
validates :podcast_episode_id, uniqueness: { scope: :user_id }
|
|
validates :podcast_episode_id, :user_id, :role, presence: true
|
|
validates :role, inclusion: { in: %w[host guest], message: "provided role is not valid" }
|
|
end
|