-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename subscribable to subscriber list
At one point we were planning to rename all instances of subscriber lists with subscribables however these never happened and it's confusing to have the same thing named differently. Instead we've decided to stick with subscriber list. This is a breaking change for users of the Email Alert API adapters, clients would be expected to update the code. However, Email Alert API itself will still accept the old style arguments.
- Loading branch information
1 parent
c648992
commit cb08f6b
Showing
4 changed files
with
44 additions
and
38 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
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 |
---|---|---|
|
@@ -328,37 +328,37 @@ | |
describe "subscribing and a subscription is created" do | ||
describe "with a frequency specified" do | ||
it "returns a 201 and the subscription id" do | ||
subscribable_id = 5 | ||
subscriber_list_id = 5 | ||
address = "[email protected]" | ||
created_subscription_id = 1 | ||
frequency = "daily" | ||
|
||
stub_email_alert_api_creates_a_subscription( | ||
subscribable_id, | ||
subscriber_list_id, | ||
address, | ||
frequency, | ||
created_subscription_id | ||
) | ||
api_response = api_client.subscribe(subscribable_id: subscribable_id, address: address, frequency: frequency) | ||
api_response = api_client.subscribe(subscriber_list_id: subscriber_list_id, address: address, frequency: frequency) | ||
assert_equal(201, api_response.code) | ||
assert_equal({ "subscription_id" => 1 }, api_response.to_h) | ||
end | ||
end | ||
|
||
describe "without a frequency specified" do | ||
it "returns a 201 and the subscription id" do | ||
subscribable_id = 6 | ||
subscriber_list_id = 6 | ||
address = "[email protected]" | ||
created_subscription_id = 1 | ||
frequency = "immediately" | ||
|
||
stub_email_alert_api_creates_a_subscription( | ||
subscribable_id, | ||
subscriber_list_id, | ||
address, | ||
frequency, | ||
created_subscription_id | ||
) | ||
api_response = api_client.subscribe(subscribable_id: subscribable_id, address: address) | ||
api_response = api_client.subscribe(subscriber_list_id: subscriber_list_id, address: address) | ||
assert_equal(201, api_response.code) | ||
assert_equal({ "subscription_id" => 1 }, api_response.to_h) | ||
end | ||
|
@@ -367,18 +367,18 @@ | |
|
||
describe "subscribing and a subscription already exists" do | ||
it "returns a 200 and the subscription id" do | ||
subscribable_id = 5 | ||
subscriber_list_id = 5 | ||
address = "[email protected]" | ||
existing_subscription_id = 1 | ||
frequency = "immediately" | ||
|
||
stub_email_alert_api_creates_an_existing_subscription( | ||
subscribable_id, | ||
subscriber_list_id, | ||
address, | ||
frequency, | ||
existing_subscription_id | ||
) | ||
api_response = api_client.subscribe(subscribable_id: subscribable_id, address: address, frequency: frequency) | ||
api_response = api_client.subscribe(subscriber_list_id: subscriber_list_id, address: address, frequency: frequency) | ||
assert_equal(200, api_response.code) | ||
assert_equal({ "subscription_id" => 1 }, api_response.to_h) | ||
end | ||
|
@@ -389,33 +389,33 @@ | |
stub_email_alert_api_refuses_to_create_subscription(123, "invalid", "weekly") | ||
|
||
assert_raises GdsApi::HTTPUnprocessableEntity do | ||
api_client.subscribe(subscribable_id: 123, address: "invalid", frequency: "weekly") | ||
api_client.subscribe(subscriber_list_id: 123, address: "invalid", frequency: "weekly") | ||
end | ||
end | ||
end | ||
|
||
describe "get_subscribable when one exists" do | ||
describe "get_subscriber_list when one exists" do | ||
it "returns it" do | ||
stub_email_alert_api_has_subscribable( | ||
stub_email_alert_api_has_subscriber_list_by_slug( | ||
reference: "test123", | ||
returned_attributes: { | ||
id: 1, | ||
gov_delivery_id: "test123", | ||
} | ||
) | ||
api_response = api_client.get_subscribable(reference: "test123") | ||
api_response = api_client.get_subscriber_list(reference: "test123") | ||
assert_equal(200, api_response.code) | ||
parsed_body = api_response.to_h | ||
assert_equal(1, parsed_body["subscribable"]["id"]) | ||
assert_equal(1, parsed_body["subscriber_list"]["id"]) | ||
end | ||
end | ||
|
||
describe "get_subscribable when one doesn't exist" do | ||
describe "get_subscriber_list when one doesn't exist" do | ||
it "returns 404" do | ||
stub_email_alert_api_does_not_have_subscribable(reference: "test123") | ||
stub_email_alert_api_does_not_have_subscriber_list_by_slug(reference: "test123") | ||
|
||
assert_raises GdsApi::HTTPNotFound do | ||
api_client.get_subscribable(reference: "test123") | ||
api_client.get_subscriber_list(reference: "test123") | ||
end | ||
end | ||
end | ||
|