API v3: make polymorphic has_many work
This commit is contained in:
parent
d8f1075491
commit
99ca87b7c4
|
@ -27,6 +27,11 @@ module Travis::API::V3
|
|||
polymorfic_foreign_types << (options[:foreign_type] || "#{field}_type") if options[:polymorphic]
|
||||
super
|
||||
end
|
||||
|
||||
def name
|
||||
return super unless caller_locations.first.base_label == 'add_constraints'.freeze
|
||||
@constraint_name ||= super.sub("#{parent}::", ''.freeze)
|
||||
end
|
||||
end
|
||||
|
||||
def self.included(base)
|
||||
|
|
|
@ -13,5 +13,6 @@ describe Travis::API::V3::Extensions::BelongsTo do
|
|||
|
||||
example { expect(repo.owner).to be_a(Travis::API::V3::Models::User) }
|
||||
example { expect(::Repository.find(repo.id).owner).to be_a(::User) }
|
||||
example { expect(user.repositories).to include(repo) }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user