From de179d7546a3bf0ec0c2c188944eeeaeb3d2bd9e Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 25 Jan 2018 16:00:43 +1100 Subject: [PATCH] feat: add latest provider version tag names to dashboard UI --- lib/pact_broker/ui/view_models/index_item.rb | 9 +++++++++ lib/pact_broker/ui/views/index/show-with-tags.haml | 2 ++ .../pact_broker/ui/view_models/index_item_spec.rb | 13 ++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/ui/view_models/index_item.rb b/lib/pact_broker/ui/view_models/index_item.rb index 26fcee6e4..f139f6386 100644 --- a/lib/pact_broker/ui/view_models/index_item.rb +++ b/lib/pact_broker/ui/view_models/index_item.rb @@ -34,6 +34,15 @@ def tag_names @relationship.tag_names.any? ? " (#{latest_overall}latest #{@relationship.tag_names.join(', ')}) ": " (latest) " end + def verification_tag_names + if @relationship.latest_verification_latest_tags.any? + tag_names = @relationship.latest_verification_latest_tags.collect(&:name) + " (latest #{tag_names.join(', ')})" + else + "" + end + end + def consumer_group_url Helpers::URLHelper.group_url consumer_name end diff --git a/lib/pact_broker/ui/views/index/show-with-tags.haml b/lib/pact_broker/ui/views/index/show-with-tags.haml index 9e144e494..eb8568095 100644 --- a/lib/pact_broker/ui/views/index/show-with-tags.haml +++ b/lib/pact_broker/ui/views/index/show-with-tags.haml @@ -56,6 +56,8 @@ = index_item.provider_name %td.provider-version-number = index_item.provider_version_number + %span{style: 'color:gray'} + = index_item.verification_tag_names %td = index_item.publication_date_of_latest_pact.gsub("about ", "") %td{ class: index_item.webhook_status } diff --git a/spec/lib/pact_broker/ui/view_models/index_item_spec.rb b/spec/lib/pact_broker/ui/view_models/index_item_spec.rb index 751776707..643ada9ff 100644 --- a/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +++ b/spec/lib/pact_broker/ui/view_models/index_item_spec.rb @@ -11,8 +11,11 @@ module ViewDomain let(:provider) { instance_double("PactBroker::Domain::Pacticipant", name: 'Provider Name')} let(:latest_pact) { instance_double("PactBroker::Domain::Pact") } let(:latest_verification) { instance_double("PactBroker::Domain::Verification") } - let(:domain_relationship) { PactBroker::Domain::IndexItem.new(consumer, provider, latest_pact, latest, latest_verification, [], [], tags)} + let(:domain_relationship) { PactBroker::Domain::IndexItem.new(consumer, provider, latest_pact, latest, latest_verification, [], [], tags, latest_verification_latest_tags)} let(:tags) { [] } + let(:verification_tag_1) { instance_double("PactBroker::Tags::TagWithLatestFlag", name: 'dev') } + let(:verification_tag_2) { instance_double("PactBroker::Tags::TagWithLatestFlag", name: 'prod') } + let(:latest_verification_latest_tags) { [verification_tag_1, verification_tag_2] } let(:latest) { true } subject { IndexItem.new(domain_relationship) } @@ -125,7 +128,15 @@ module ViewDomain let(:tags) { ["master", "prod"] } its(:tag_names) { is_expected.to eq " (latest master, prod) " } end + end + + describe "verification_tag_names" do + its(:verification_tag_names) { is_expected.to eq " (latest dev, prod)"} + context "when there are no tags" do + let(:latest_verification_latest_tags) { [] } + its(:verification_tag_names) { is_expected.to eq "" } + end end describe "<=>" do