-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: sitewide settings calling the correct presenters
- Loading branch information
1 parent
954bfb8
commit 0d1e1ce
Showing
2 changed files
with
33 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,45 @@ | ||
require "test_helper" | ||
|
||
class SitewideSettingTest < ActiveSupport::TestCase | ||
test "toggling reshuffle mode republished the ministers index page" do | ||
payload = PublishingApi::MinistersIndexPresenter.new | ||
test "enabling reshuffle mode republishes custom ministers index and how government work pages" do | ||
ministers_payload = PublishingApi::MinistersIndexEnableReshufflePresenter.new | ||
how_gov_works_payload = PublishingApi::HowGovernmentWorksEnableReshufflePresenter.new | ||
|
||
create(:sitewide_setting, key: :minister_reshuffle_mode, on: true) | ||
Sidekiq::Testing.inline! do | ||
create(:sitewide_setting, key: :minister_reshuffle_mode, on: true) | ||
end | ||
|
||
requests = [ | ||
stub_publishing_api_put_content(payload.content_id, payload.content), | ||
stub_publishing_api_publish(payload.content_id, locale: "en", update_type: nil), | ||
stub_publishing_api_put_content(ministers_payload.content_id, ministers_payload.content), | ||
stub_publishing_api_patch_links(ministers_payload.content_id, ministers_payload.content), | ||
stub_publishing_api_publish(ministers_payload.content_id, locale: "en", update_type: nil), | ||
stub_publishing_api_put_content(how_gov_works_payload.content_id, how_gov_works_payload.content), | ||
stub_publishing_api_patch_links(how_gov_works_payload.content_id, how_gov_works_payload.content), | ||
stub_publishing_api_publish(how_gov_works_payload.content_id, locale: "en", update_type: nil), | ||
] | ||
|
||
assert_all_requested(requests) | ||
end | ||
|
||
# moved from duplicate file | ||
test "should send the how government works page to publishing api when reshuffle mode is switched on" do | ||
PresentPageToPublishingApi.any_instance.expects(:publish).with(PublishingApi::HowGovernmentWorksPresenter) | ||
|
||
Sidekiq::Testing.inline! do | ||
create(:sitewide_setting, key: :minister_reshuffle_mode, on: true) | ||
end | ||
end | ||
test "disabling reshuffle mode republishes ministers index and how government work pages" do | ||
ministers_payload = PublishingApi::MinistersIndexPresenter.new | ||
how_gov_works_payload = PublishingApi::HowGovernmentWorksPresenter.new | ||
|
||
test "should send the how government works page to publishing api when reshuffle mode is switched off" do | ||
setting = create(:sitewide_setting, key: :minister_reshuffle_mode, on: true) | ||
|
||
PresentPageToPublishingApi.any_instance.expects(:publish).with(PublishingApi::HowGovernmentWorksPresenter) | ||
|
||
Sidekiq::Testing.inline! do | ||
setting.update!(on: false) | ||
end | ||
|
||
requests = [ | ||
stub_publishing_api_put_content(ministers_payload.content_id, ministers_payload.content), | ||
stub_publishing_api_patch_links(ministers_payload.content_id, ministers_payload.content), | ||
stub_publishing_api_publish(ministers_payload.content_id, locale: "en", update_type: nil), | ||
stub_publishing_api_put_content(how_gov_works_payload.content_id, how_gov_works_payload.content), | ||
stub_publishing_api_patch_links(how_gov_works_payload.content_id, how_gov_works_payload.content), | ||
stub_publishing_api_publish(how_gov_works_payload.content_id, locale: "en", update_type: nil), | ||
] | ||
|
||
assert_all_requested(requests) | ||
end | ||
end |