forked from pupilfirst/pupilfirst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add submission.graded developer event (pupilfirst#643)
Also make it possible to "not" handle webhook delivery for newly added developer events. Co-authored-by: Mirosław Pragłowski <[email protected]>
- Loading branch information
1 parent
a339b34
commit a714fdb
Showing
10 changed files
with
140 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
class WebhookDelivery < ApplicationRecord | ||
belongs_to :course | ||
|
||
enum event: { submission_created: "submission.created" } | ||
enum event: { | ||
submission_created: 'submission.created', | ||
submission_graded: 'submission.graded', | ||
noop: 'noop' # special event, which does not require webhook delivery | ||
} | ||
end |
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,11 @@ | ||
module DevelopersNotifications | ||
def publish(course, event_type, actor, resource) | ||
notification_service.execute(course, event_type, actor, resource) | ||
end | ||
|
||
private | ||
|
||
def notification_service | ||
Developers::NotificationService.new | ||
end | ||
end |
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
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
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
22 changes: 22 additions & 0 deletions
22
spec/support/spec_helpers/developers_notifications_helper.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,22 @@ | ||
module DevelopersNotificationsHelper | ||
def prepare_developers_notification | ||
notification_service = instance_double('Developers::NotificationService') | ||
allow(notification_service).to receive(:execute).with( | ||
an_instance_of(Course), | ||
kind_of(Symbol), | ||
an_instance_of(User), | ||
kind_of(ApplicationRecord) | ||
) | ||
allow(Developers::NotificationService).to receive(:new).and_return(notification_service) | ||
notification_service | ||
end | ||
|
||
def expect_published(notification_service, course, event_type, actor, resource) | ||
expect(notification_service).to have_received(:execute).with( | ||
course, | ||
event_type, | ||
actor, | ||
resource | ||
) | ||
end | ||
end |
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