1

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" }
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
  • what is this part supposed to do? `.class_name "Athlete"` i don't think that the matcher will work this way – phoet Nov 12 '13 at 19:40

0 Answers0