@@ -121,7 +121,9 @@ def update_pact params, existing_pact
121
121
logger . info "Updating existing pact publication with params #{ params . reject { |k , v | k == :json_content } } "
122
122
logger . debug "Content #{ params [ :json_content ] } "
123
123
pact_version_sha = generate_sha ( params [ :json_content ] )
124
- updated_pact = pact_repository . update ( existing_pact . id , params . merge ( pact_version_sha : pact_version_sha ) )
124
+ json_content = add_interaction_ids ( params [ :json_content ] )
125
+ update_params = { pact_version_sha : pact_version_sha , json_content : json_content }
126
+ updated_pact = pact_repository . update ( existing_pact . id , update_params )
125
127
126
128
webhook_service . trigger_webhooks updated_pact , nil , PactBroker ::Webhooks ::WebhookEvent ::CONTRACT_PUBLISHED
127
129
# TODO this should use the sha!
@@ -137,12 +139,15 @@ def update_pact params, existing_pact
137
139
def create_pact params , version , provider
138
140
logger . info "Creating new pact publication with params #{ params . reject { |k , v | k == :json_content } } "
139
141
logger . debug "Content #{ params [ :json_content ] } "
142
+ pact_version_sha = generate_sha ( params [ :json_content ] )
143
+ json_content = add_interaction_ids ( params [ :json_content ] )
140
144
pact = pact_repository . create (
141
145
json_content : params [ :json_content ] ,
142
146
version_id : version . id ,
143
147
provider_id : provider . id ,
144
148
consumer_id : version . pacticipant_id ,
145
- pact_version_sha : generate_sha ( params [ :json_content ] )
149
+ pact_version_sha : pact_version_sha ,
150
+ json_content : json_content
146
151
)
147
152
trigger_webhooks pact
148
153
pact
@@ -152,6 +157,10 @@ def generate_sha(json_content)
152
157
PactBroker . configuration . sha_generator . call ( json_content )
153
158
end
154
159
160
+ def add_interaction_ids ( json_content )
161
+ Content . from_json ( json_content ) . with_ids . to_json
162
+ end
163
+
155
164
def trigger_webhooks pact
156
165
# TODO add tests for this
157
166
webhook_service . trigger_webhooks pact , nil , PactBroker ::Webhooks ::WebhookEvent ::CONTRACT_PUBLISHED
0 commit comments