* 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)
23 lines
817 B
Ruby
23 lines
817 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe PodcastEpisodeAppearance, type: :model do
|
|
let(:podcast_episode_appearance) { create(:podcast_episode_appearance) }
|
|
|
|
describe "validations" do
|
|
subject { podcast_episode_appearance }
|
|
|
|
it { is_expected.to belong_to(:user).inverse_of(:podcast_episode_appearances) }
|
|
it { is_expected.to belong_to(:podcast_episode) }
|
|
|
|
it { is_expected.to validate_presence_of(:podcast_episode_id) }
|
|
it { is_expected.to validate_presence_of(:user_id) }
|
|
it { is_expected.to validate_presence_of(:role) }
|
|
|
|
it do
|
|
expect(podcast_episode_appearance).to validate_inclusion_of(:role).in_array(%w[host guest])
|
|
.with_message("provided role is not valid")
|
|
end
|
|
|
|
it { is_expected.to validate_uniqueness_of(:podcast_episode_id).scoped_to(:user_id) }
|
|
end
|
|
end
|