Skip to content

Commit

Permalink
Rename reference to slug
Browse files Browse the repository at this point in the history
We refer to these as slugs in Email Alert API so we should be
consistent in the API adapters.
  • Loading branch information
thomasleese committed Mar 29, 2019
1 parent cb08f6b commit 18650f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/gds_api/email_alert_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def subscribe(subscriber_list_id:, address:, frequency: "immediately")
# government_document_supertype
# subscriber_count
# }
def get_subscriber_list(reference:)
get_json("#{endpoint}/subscriber-lists/#{reference}")
def get_subscriber_list(slug:)
get_json("#{endpoint}/subscriber-lists/#{slug}")
end

# Get a Subscription
Expand Down
8 changes: 4 additions & 4 deletions lib/gds_api/test_helpers/email_alert_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def assert_subscribed(subscriber_list_id, address, frequency = "immediately")
end
end

def stub_email_alert_api_has_subscriber_list_by_slug(reference:, returned_attributes:)
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{reference}")
def stub_email_alert_api_has_subscriber_list_by_slug(slug:, returned_attributes:)
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
.to_return(
status: 200,
body: {
Expand All @@ -214,8 +214,8 @@ def stub_email_alert_api_has_subscriber_list_by_slug(reference:, returned_attrib
)
end

def stub_email_alert_api_does_not_have_subscriber_list_by_slug(reference:)
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{reference}")
def stub_email_alert_api_does_not_have_subscriber_list_by_slug(slug:)
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
.to_return(status: 404)
end

Expand Down
8 changes: 4 additions & 4 deletions test/email_alert_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@
describe "get_subscriber_list when one exists" do
it "returns it" do
stub_email_alert_api_has_subscriber_list_by_slug(
reference: "test123",
slug: "test123",
returned_attributes: {
id: 1,
gov_delivery_id: "test123",
}
)
api_response = api_client.get_subscriber_list(reference: "test123")
api_response = api_client.get_subscriber_list(slug: "test123")
assert_equal(200, api_response.code)
parsed_body = api_response.to_h
assert_equal(1, parsed_body["subscriber_list"]["id"])
Expand All @@ -412,10 +412,10 @@

describe "get_subscriber_list when one doesn't exist" do
it "returns 404" do
stub_email_alert_api_does_not_have_subscriber_list_by_slug(reference: "test123")
stub_email_alert_api_does_not_have_subscriber_list_by_slug(slug: "test123")

assert_raises GdsApi::HTTPNotFound do
api_client.get_subscriber_list(reference: "test123")
api_client.get_subscriber_list(slug: "test123")
end
end
end
Expand Down

0 comments on commit 18650f3

Please sign in to comment.