-
-
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 (#1231)
* Update org-wide-files repository dispatch * Submit pusher name for org-wide-files dispatch event * Naming refactoring
- Loading branch information
1 parent
013a128
commit d9c1a54
Showing
8 changed files
with
97 additions
and
78 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
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,27 @@ | ||
module Github | ||
class DispatchEventToOrgWideFilesRepo | ||
include Mandate | ||
|
||
initialize_with :event_type, :repos, :pusher_github_username | ||
|
||
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, | ||
pusher: pusher_github_username | ||
} | ||
}.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"],"pusher":"user17"}}') | ||
|
||
Github::DispatchEventToOrgWideFilesRepo.(:appends_update, ["exercism/ruby"], 'user17') | ||
|
||
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"],"pusher":"user17"}}' | ||
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"],"pusher":"user17"}}') # rubocop:disable Layout/LineLength | ||
|
||
Github::DispatchEventToOrgWideFilesRepo.(:appends_update, ["exercism/website", "exercism/configlet"], 'user17') | ||
|
||
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"],"pusher":"user17"}}' # rubocop:disable Layout/LineLength | ||
end | ||
end | ||
|
||
test "raises for unknown event type" do | ||
assert_raises do | ||
Github::DispatchEventToOrgWideFilesRepo.(:unknown, ["exercism/website"], 'user17') | ||
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