-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add optional
publishing_app
param in PublishIntentPresenter
we want to send Publish Intents for Host Content (e.g. Editions that are using embedded content/Content Blocks) [1] that is published by other apps - this allows an optional app to be passed in, but retains the default Whitehall value in order not to break existing functionality. [1] #9447
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 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
36 changes: 36 additions & 0 deletions
36
test/unit/app/presenters/publishing_api/publish_intent_presenter_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,36 @@ | ||
require "test_helper" | ||
|
||
module PublishingApi | ||
class PublishIntentPresenterTest < ActiveSupport::TestCase | ||
test "it returns Whitehall as default publisher" do | ||
base_path = "/example-path" | ||
publish_timestamp = Time.zone.now.to_s | ||
|
||
presenter = PublishingApi::PublishIntentPresenter.new(base_path, publish_timestamp) | ||
expected_hash = { | ||
publish_time: publish_timestamp, | ||
publishing_app: Whitehall::PublishingApp::WHITEHALL, | ||
rendering_app: Whitehall::RenderingApp::GOVERNMENT_FRONTEND, | ||
routes: [{ path: base_path, type: "exact" }], | ||
} | ||
|
||
assert_equal presenter.as_json, expected_hash | ||
end | ||
|
||
test "it returns publishing app if provided" do | ||
base_path = "/example-path" | ||
publish_timestamp = Time.zone.now.to_s | ||
publishing_app = "example-publishing-app" | ||
|
||
presenter = PublishingApi::PublishIntentPresenter.new(base_path, publish_timestamp, publishing_app) | ||
expected_hash = { | ||
publish_time: publish_timestamp, | ||
publishing_app: "example-publishing-app", | ||
rendering_app: Whitehall::RenderingApp::GOVERNMENT_FRONTEND, | ||
routes: [{ path: base_path, type: "exact" }], | ||
} | ||
|
||
assert_equal presenter.as_json, expected_hash | ||
end | ||
end | ||
end |