diff --git a/lib/pact_broker/api/decorators/matrix_decorator.rb b/lib/pact_broker/api/decorators/matrix_decorator.rb index 644d89499..4756a0b60 100644 --- a/lib/pact_broker/api/decorators/matrix_decorator.rb +++ b/lib/pact_broker/api/decorators/matrix_decorator.rb @@ -91,7 +91,7 @@ def consumer_hash(line, consumer, consumer_version, base_url) end def tags(tags, base_url) - tags.collect do | tag | + tags.sort_by(&:created_at).collect do | tag | { name: tag.name, latest: tag.latest?, diff --git a/lib/pact_broker/index/service.rb b/lib/pact_broker/index/service.rb index 26f53a898..aba726d77 100644 --- a/lib/pact_broker/index/service.rb +++ b/lib/pact_broker/index/service.rb @@ -73,7 +73,7 @@ def self.find_index_items options = {} webhook ? [webhook]: [], pact_publication.integration.latest_triggered_webhooks, consumer_version_tags(pact_publication, options[:tags]).sort_by(&:created_at).collect(&:name), - options[:tags] && latest_verification ? latest_verification.provider_version.tags_with_latest_flag.select(&:latest?) : [] + options[:tags] && latest_verification ? latest_verification.provider_version.tags_with_latest_flag.select(&:latest?).sort_by(&:created_at) : [] ) end.sort @@ -134,7 +134,7 @@ def self.find_index_items_for_api(consumer_name: nil, provider_name: nil, **igno [], [], pact_publication.head_pact_tags.sort_by(&:created_at).collect(&:name), - pact_publication.latest_verification ? pact_publication.latest_verification.provider_version.tags_with_latest_flag.select(&:latest?) : [] + pact_publication.latest_verification ? pact_publication.latest_verification.provider_version.tags_with_latest_flag.select(&:latest?).sort_by(&:created_at) : [] ) end.sort end diff --git a/lib/pact_broker/ui/view_models/matrix_line.rb b/lib/pact_broker/ui/view_models/matrix_line.rb index cd23145c8..7313a0d0c 100644 --- a/lib/pact_broker/ui/view_models/matrix_line.rb +++ b/lib/pact_broker/ui/view_models/matrix_line.rb @@ -100,24 +100,28 @@ def provider_version_order def latest_consumer_version_tags @line.consumer_version_tags .select(&:latest) + .sort_by(&:created_at) .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) } end def other_consumer_version_tags @line.consumer_version_tags .reject(&:latest) + .sort_by(&:created_at) .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) } end def latest_provider_version_tags @line.provider_version_tags .select(&:latest) + .sort_by(&:created_at) .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) } end def other_provider_version_tags @line.provider_version_tags .reject(&:latest) + .sort_by(&:created_at) .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) } end diff --git a/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb index f67b37cb4..337ae400a 100644 --- a/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb @@ -135,7 +135,7 @@ module Decorators let(:consumer_version_tags) do [ - double("tag", name: "prod", latest?: true, version: consumer_version) + double("tag", name: "prod", latest?: true, version: consumer_version, created_at: DateTime.now ) ] end @@ -143,7 +143,7 @@ module Decorators let(:provider_version_tags) do [ - double("tag", name: "master", latest?: false, version: provider_version) + double("tag", name: "master", latest?: false, version: provider_version, created_at: DateTime.now) ] end