Skip to content

Instantly share code, notes, and snippets.

@bethesque
Last active May 5, 2017 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bethesque/31c2d00f93bb6168cbbc645bcbc08688 to your computer and use it in GitHub Desktop.
Save bethesque/31c2d00f93bb6168cbbc645bcbc08688 to your computer and use it in GitHub Desktop.
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