From eeac47c3d601bbfc766973639e1cc1289b2a0003 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 3 Jun 2022 11:53:15 +1000 Subject: [PATCH] fix: ensure pacticipant name is retained when updating with PUT --- lib/pact_broker/pacticipants/repository.rb | 3 ++- spec/lib/pact_broker/pacticipants/repository_spec.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/pacticipants/repository.rb b/lib/pact_broker/pacticipants/repository.rb index e8a49ccf1..9fec7b4cf 100644 --- a/lib/pact_broker/pacticipants/repository.rb +++ b/lib/pact_broker/pacticipants/repository.rb @@ -67,8 +67,9 @@ def update(pacticipant_name, pacticipant) pacticipant.save end - def replace(_pacticipant_name, open_struct_pacticipant) + def replace(pacticipant_name, open_struct_pacticipant) PactBroker::Domain::Pacticipant.new( + name: pacticipant_name, display_name: open_struct_pacticipant.display_name, repository_url: open_struct_pacticipant.repository_url, repository_name: open_struct_pacticipant.repository_name, diff --git a/spec/lib/pact_broker/pacticipants/repository_spec.rb b/spec/lib/pact_broker/pacticipants/repository_spec.rb index 23505d29c..a858f448b 100644 --- a/spec/lib/pact_broker/pacticipants/repository_spec.rb +++ b/spec/lib/pact_broker/pacticipants/repository_spec.rb @@ -63,6 +63,7 @@ module Pacticipants subject { Repository.new.replace("Bar", OpenStruct.new(main_branch: "bar", repository_url: "new_url")) } it "replaces the pacticipant" do + expect(subject.name).to eq "Bar" expect(subject.main_branch).to eq "bar" expect(subject.repository_namespace).to eq nil expect(subject.display_name).to eq "display_name"