-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update org-wide-files repository dispatch
- Loading branch information
1 parent
b628cb4
commit 7427914
Showing
8 changed files
with
84 additions
and
78 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
app/commands/github/dispatch_event_to_org_wide_files_repo.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Github | ||
class DispatchEventToOrgWideFilesRepo | ||
include Mandate | ||
|
||
initialize_with :event_type, :repos | ||
|
||
def call | ||
raise "Unsupported event type" unless EVENT_TYPES.include?(event_type) | ||
|
||
Exercism.octokit_client.post("https://api.github.com/repos/exercism/org-wide-files/dispatches", body) | ||
end | ||
|
||
private | ||
def body | ||
{ | ||
event_type: event_type.to_s, | ||
client_payload: { repos: repos } | ||
}.to_json | ||
end | ||
|
||
EVENT_TYPES = %i[appends_update].freeze | ||
private_constant :EVENT_TYPES | ||
end | ||
end |
21 changes: 0 additions & 21 deletions
21
app/commands/github/notify_track_syncer_about_track_changes.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/commands/github/dispatch_event_to_org_wide_files_repo_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "test_helper" | ||
|
||
class Github::DispatchEventToOrgWideFilesRepoTest < ActiveJob::TestCase | ||
test "dispatch repository event for single repo" do | ||
stub_request(:post, "https://api.github.com/repos/exercism/org-wide-files/dispatches"). | ||
with(body: '{"event_type":"appends_update","client_payload":{"repos":["exercism/ruby"]}}') | ||
|
||
Github::DispatchEventToOrgWideFilesRepo.(:appends_update, ["exercism/ruby"]) | ||
|
||
assert_requested(:post, "https://api.github.com/repos/exercism/org-wide-files/dispatches", times: 1) do |req| | ||
req.body == '{"event_type":"appends_update","client_payload":{"repos":["exercism/ruby"]}}' | ||
end | ||
end | ||
|
||
test "dispatch repository event for multiples repos" do | ||
stub_request(:post, "https://api.github.com/repos/exercism/org-wide-files/dispatches"). | ||
with(body: '{"event_type":"appends_update","client_payload":{"repos":["exercism/website","exercism/configlet"]}}') | ||
|
||
Github::DispatchEventToOrgWideFilesRepo.(:appends_update, ["exercism/website", "exercism/configlet"]) | ||
|
||
assert_requested(:post, "https://api.github.com/repos/exercism/org-wide-files/dispatches", times: 1) do |req| | ||
req.body == '{"event_type":"appends_update","client_payload":{"repos":["exercism/website","exercism/configlet"]}}' | ||
end | ||
end | ||
|
||
test "raises for unknown event type" do | ||
assert_raises do | ||
Github::DispatchEventToOrgWideFilesRepo.(:unknown, ["exercism/website"]) | ||
end | ||
end | ||
end |
16 changes: 0 additions & 16 deletions
16
test/commands/github/notify_track_syncer_about_track_changes_test.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters