-
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.
Add GdsApi::ContentRegister#put_entry method
This endpoint is used by publishing tools to register content items with the content register.
- Loading branch information
Showing
3 changed files
with
59 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
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,23 @@ | ||
require 'gds_api/test_helpers/json_client_helper' | ||
require 'json' | ||
|
||
module GdsApi | ||
module TestHelpers | ||
module ContentRegister | ||
CONTENT_REGISTER_ENDPOINT = Plek.find('content-register') | ||
|
||
def stub_content_register_put_entry(content_id, entry) | ||
response_body = entry.merge(content_id: content_id).to_json | ||
|
||
stub_request(:put, content_register_entry_url_for(content_id)). | ||
to_return(status: 201, body: response_body) | ||
end | ||
|
||
private | ||
|
||
def content_register_entry_url_for(content_id) | ||
CONTENT_REGISTER_ENDPOINT + "/entry/" + content_id | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'test_helper' | ||
require 'gds_api/content_register' | ||
require 'gds_api/test_helpers/content_register' | ||
|
||
describe GdsApi::ContentRegister do | ||
include GdsApi::TestHelpers::ContentRegister | ||
|
||
before do | ||
@api_adapter = GdsApi::ContentRegister.new(Plek.find("content-register")) | ||
end | ||
|
||
describe "#put_entry method" do | ||
it "creates an entry in the content register" do | ||
content_id = SecureRandom.uuid | ||
entry = { | ||
"format" => 'organisation', | ||
"title" => 'Organisation', | ||
"base_path" => "/government/organisations/organisation" | ||
} | ||
|
||
stub_content_register_put_entry(content_id, entry) | ||
|
||
response = @api_adapter.put_entry(content_id, entry) | ||
assert_equal 201, response.code | ||
end | ||
end | ||
end |