Here is my has_many
statement:
has_many :managed_athletes, class_name: "Athlete",
finder_sql: ->(record) do
record = self if record.nil?
"SELECT DISTINCT users.* FROM users INNER JOIN contributorships
ON users.id = contributorships.athlete_id
INNER JOIN invitations
ON users.id = invitations.sender_id
WHERE users.type IN ('Athlete') AND contributorships.user_id = #{record.id}
AND invitations.requester_id = #{record.id}
AND (invitations.current_state = 'accepted')"
end
This is my Rspec test (it's failing). Is there any way to write a test for the above? I could turn this into an instance method and test against that, but was trying to leave this has a has_many
scope.
it { should have_many(:managed_athletes).class_name "Athlete" }