Skip to content

Instantly share code, notes, and snippets.

@bethesque bethesque/caveats.txt
Last active May 5, 2017

Embed
What would you like to do?
Moderately dirty hack to order pact versions by date instead of version in the pact broker
This will sort based on the date that the consumer application version resource is created.
If the pact for that version is updated, the sorting will not consider the date of the updated content.
app = PactBroker::App.new do | config |
#...
end
class_to_hack_exists = defined?(PactBroker::Domain) && defined?(PactBroker::Domain::OrderVersions) && defined?(PactBroker::Domain::OrderVersions::OrderableVersion)
unless class_to_hack_exists
raise "PactBroker::Domain::OrderVersions::OrderableVersion cannot be found, hack to order by date will not work!"
end
# Source class is here: https://github.com/bethesque/pact_broker/blob/a26402cf2deeb03573c77ca5eeda5857c4009caa/lib/pact_broker/domain/order_versions.rb
module PactBroker
module Domain
class OrderVersions
class OrderableVersion
def initialize version_model
@version_model = version_model
@sortable_number = version_model.created_at
end
end
end
end
end
run app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.