* added podcast_ownership route * added podcast_ownership table * added podcast_ownership controller and pundit policy * fixed codeclimate * removed controller and pundit policy * codeclimate * codeclimate * schema.rb * schema.rb * schema.rb * user.rb * made the suggested changes * added validations * fixed build error * changed name to owned_podcasts * added validation and tests * added tests * added tests * changed spec * added factory * added factory * merge conflict * factory * factory * factory * modified spec file * modified spec file * fix build error * added class_name * adjusted m2m relations * made suggested changes * fixed build error * added subject * schema * ran migration * removed index:true from singular fields * changed schema file * set index: false
16 lines
568 B
Ruby
16 lines
568 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe PodcastOwnership, type: :model do
|
|
let(:podcast_ownership) { create(:podcast_ownership) }
|
|
|
|
describe "validations" do
|
|
subject { podcast_ownership }
|
|
|
|
it { is_expected.to belong_to(:owner).class_name("User").with_foreign_key(:user_id).inverse_of(:podcasts_owned) }
|
|
it { is_expected.to belong_to(:podcast) }
|
|
|
|
it { is_expected.to validate_presence_of(:podcast_id) }
|
|
it { is_expected.to validate_presence_of(:user_id) }
|
|
it { is_expected.to validate_uniqueness_of(:podcast_id).scoped_to(:user_id) }
|
|
end
|
|
end
|