Last active
May 5, 2017 11:40
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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