-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for non-existent event types in `Webhooks::Outgoing::Endpoint#e…
…vent_types` (#983) * Add a failing test * another test * Fix the failing test
- Loading branch information
1 parent
769ad04
commit eb8ef54
Showing
2 changed files
with
52 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
bullet_train-outgoing_webhooks/test/models/webhooks/outgoing/endpoint_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,51 @@ | ||
require "test_helper" | ||
|
||
class Webhooks::Outgoing::EndpointTest < ActiveSupport::TestCase | ||
include ActiveJob::TestHelper | ||
|
||
setup do | ||
@team = Team.create!(name: "test-team") | ||
@endpoint = Webhooks::Outgoing::Endpoint.create!(url: "https://example.com/webhook", name: "test", team: @team) | ||
end | ||
|
||
test "#create should accept valid event_types" do | ||
@endpoint = Webhooks::Outgoing::Endpoint.create!( | ||
url: "https://example.com/webhook", | ||
name: "test", | ||
team: @team, | ||
event_type_ids: [Webhooks::Outgoing::EventType.all.first.id] | ||
) | ||
assert @endpoint.persisted? | ||
end | ||
|
||
test "#create should accept non-existent event_types" do | ||
@endpoint = Webhooks::Outgoing::Endpoint.create!( | ||
url: "https://example.com/webhook", | ||
name: "test", | ||
team: @team, | ||
event_type_ids: ["fake-thing.create"] | ||
) | ||
assert @endpoint.persisted? | ||
end | ||
|
||
test "#event_types should return existent EventTypes" do | ||
valid_event_type = Webhooks::Outgoing::EventType.all.first | ||
@endpoint = Webhooks::Outgoing::Endpoint.create!( | ||
url: "https://example.com/webhook", | ||
name: "test", | ||
team: @team, | ||
event_type_ids: [valid_event_type.id] | ||
) | ||
assert_equal [valid_event_type.id], @endpoint.event_types.map(&:id) | ||
end | ||
|
||
test "#event_types should not raise an error for non-existent event_type_ids" do | ||
@endpoint = Webhooks::Outgoing::Endpoint.create!( | ||
url: "https://example.com/webhook", | ||
name: "test", | ||
team: @team, | ||
event_type_ids: ["fake-thing.create"] | ||
) | ||
assert_equal [], @endpoint.event_types | ||
end | ||
end |