* add party_shares table and model with associations * add party share errors and blueprint * add party shares controller and routes * include shared parties in listings and show * add party share factory and model specs * add party shares controller specs * include shares in party response for owners * add crew shared_parties endpoint
17 lines
553 B
Ruby
17 lines
553 B
Ruby
# frozen_string_literal: true
|
|
|
|
FactoryBot.define do
|
|
factory :party_share do
|
|
party
|
|
association :shareable, factory: :crew
|
|
association :shared_by, factory: :user
|
|
|
|
# Ensure the shared_by user owns the party and is in the crew
|
|
after(:build) do |party_share|
|
|
party_share.party.user = party_share.shared_by
|
|
unless party_share.shareable.crew_memberships.exists?(user: party_share.shared_by, retired: false)
|
|
create(:crew_membership, crew: party_share.shareable, user: party_share.shared_by)
|
|
end
|
|
end
|
|
end
|
|
end
|