Skip to content

Commit

Permalink
Harmonize the amqp event payload - it's :repo otherwise
Browse files Browse the repository at this point in the history
repository and architecture are nicer, but we started with the
short names, so better stay with it to avoid suprises
  • Loading branch information
coolo committed Nov 14, 2018
1 parent 0b6b357 commit 55b72f9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/api/app/controllers/status/checks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def update

def create_event
if @project
Event::StatusCheckForPublished.create(check_notify_params)
if @architecture
Event::StatusCheckForBuild.create(check_notify_params)
else
Event::StatusCheckForPublished.create(check_notify_params)
end
else
Event::StatusCheckForRequest.create(check_notify_params)
end
Expand Down
1 change: 1 addition & 0 deletions src/api/app/controllers/status/concerns/set_checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def set_repository
def set_repository_architecture
return unless set_repository
return @checkable unless params[:arch]
@architecture = params[:arch]
@checkable = @checkable.repository_architectures.joins(:architecture).find_by(architectures: { name: params[:arch] })
return @checkable if @checkable

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/event/status_check_for_published.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Event
class StatusCheckForPublished < StatusCheck
self.description = 'Status Check for Published Repository Created'
payload_keys :project, :repository, :uuid
payload_keys :project, :repo, :buildid

def self.message_bus_routing_key
'published.status_report'
Expand Down
4 changes: 3 additions & 1 deletion src/api/app/models/status/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def notify_params
when BsRequest
{ number: checkable.number }
when Repository
{ project: checkable.project.name, repository: checkable.name, uuid: uuid }
{ project: checkable.project.name, repo: checkable.name, buildid: uuid }
when RepositoryArchitecture
{ project: checkable.repository.project.name, repo: checkable.repository.name, arch: checkable.architecture.name, buildid: uuid }
else
{}
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/controllers/status/checks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

it 'creates the proper event' do
post :update, body: xml, params: params, format: :xml
expect(Event::StatusCheckForPublished.first.payload).to include('who' => user.login, 'project' => project.name, 'repository' => repository.name, 'state' => 'pending')
expect(Event::StatusCheckForPublished.first.payload).to include('who' => user.login, 'project' => project.name, 'repo' => repository.name, 'state' => 'pending')
end
end

Expand Down

0 comments on commit 55b72f9

Please sign in to comment.