Skip to content

Commit

Permalink
Fix gds-api-adapters deprecation warning
Browse files Browse the repository at this point in the history
Resolves:

> #content_store_has_item is deprecated on GdsApi::TestHelpers::ContentStore
> and will be removed in a future version. Use #stub_content_store_has_item instead
  • Loading branch information
sihugh committed Jan 26, 2020
1 parent 969615b commit 76e9bd2
Show file tree
Hide file tree
Showing 22 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion test/contracts/govuk_content_schemas_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class GovukContentSchemasTest < ActionDispatch::IntegrationTest

all_examples_for_supported_schemas.each do |content_item|
test "can successfully render #{content_item['base_path']} schema example" do
content_store_has_item(content_item["base_path"], content_item)
stub_content_store_has_item(content_item["base_path"], content_item)

get content_item["base_path"]

Expand Down
12 changes: 6 additions & 6 deletions test/controllers/content_items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class ContentItemsControllerTest < ActionController::TestCase

test "sets the expiry as sent by content-store" do
content_item = content_store_has_schema_example("coming_soon", "coming_soon")
content_store_has_item(content_item["base_path"], content_item, max_age: 20)
stub_content_store_has_item(content_item["base_path"], content_item, max_age: 20)

get :show, params: { path: path_for(content_item) }
assert_response :success
Expand All @@ -242,7 +242,7 @@ class ContentItemsControllerTest < ActionController::TestCase

test "honours cache-control private items" do
content_item = content_store_has_schema_example("coming_soon", "coming_soon")
content_store_has_item(content_item["base_path"], content_item, private: true)
stub_content_store_has_item(content_item["base_path"], content_item, private: true)

get :show, params: { path: path_for(content_item) }
assert_response :success
Expand Down Expand Up @@ -282,7 +282,7 @@ class ContentItemsControllerTest < ActionController::TestCase
utf8_path = "government/case-studies/caf\u00e9-culture"
content_item["base_path"] = "/#{utf8_path}"

content_store_has_item(content_item["base_path"], content_item)
stub_content_store_has_item(content_item["base_path"], content_item)

get :show, params: { path: utf8_path }
assert_response :success
Expand Down Expand Up @@ -312,7 +312,7 @@ class ContentItemsControllerTest < ActionController::TestCase
content_item = content_store_has_schema_example("special_route", "special_route")
content_item["base_path"] = "/government"

content_store_has_item("/#{path}", content_item)
stub_content_store_has_item("/#{path}", content_item)

get :show, params: { path: path }
assert_response :not_found
Expand Down Expand Up @@ -342,15 +342,15 @@ class ContentItemsControllerTest < ActionController::TestCase

test "returns a redirect when content item is a redirect" do
content_item = content_store_has_schema_example("redirect", "redirect")
content_store_has_item("/406beacon", content_item)
stub_content_store_has_item("/406beacon", content_item)

get :show, params: { path: "406beacon" }
assert_redirected_to "https://www.test.gov.uk/maritime-safety-weather-and-navigation/register-406-mhz-beacons?query=answer#fragment"
end

test "returns a prefixed redirect when content item is a prefix redirect" do
content_item = content_store_has_schema_example("redirect", "redirect")
content_store_has_item("/406beacon/prefix/to-preserve", content_item)
stub_content_store_has_item("/406beacon/prefix/to-preserve", content_item)

get :show, params: { path: "406beacon/prefix/to-preserve" }
assert_redirected_to "https://www.test.gov.uk/new-406-beacons-destination/to-preserve"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ContentItemsControllerTest < ActionController::TestCase
content_item = govuk_content_schema_example("service_sign_in", "service_sign_in")
link = "https://www.horse.service.gov.uk/account?horse=brown"
content_item["details"]["choose_sign_in"]["options"][0]["url"] = link
content_store_has_item(content_item["base_path"], content_item)
stub_content_store_has_item(content_item["base_path"], content_item)

path = "#{path_for(content_item)}/#{content_item['details']['choose_sign_in']['slug']}"

Expand Down
4 changes: 2 additions & 2 deletions test/controllers/step_navigation_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ContentItemsControllerTest < ActionController::TestCase
content_item["base_path"] = "/pass-plus"
path = content_item["base_path"][1..-1]

content_store_has_item(content_item["base_path"], content_item)
stub_content_store_has_item(content_item["base_path"], content_item)

@controller.stubs(:page_in_scope?).returns(false)

Expand All @@ -24,7 +24,7 @@ class ContentItemsControllerTest < ActionController::TestCase
content_item["base_path"] = "/not-part-of-a-step-by-step"
path = content_item["base_path"][1..-1]

content_store_has_item(content_item["base_path"], content_item)
stub_content_store_has_item(content_item["base_path"], content_item)

@controller.stubs(:page_in_scope?).returns(false)

Expand Down
4 changes: 2 additions & 2 deletions test/integration/corporate_information_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CorporateInformationPageTest < ActionDispatch::IntegrationTest
<h2>Item two</h2><p>Content about item two</p>
</div>"

content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
Expand Down Expand Up @@ -79,7 +79,7 @@ class CorporateInformationPageTest < ActionDispatch::IntegrationTest
'explanation': "This is out of date",
'withdrawn_at': "2014-08-09T11:39:05Z",
}
content_store_has_item("/government/organisations/department-of-health/about", content_item.to_json)
stub_content_store_has_item("/government/organisations/department-of-health/about", content_item.to_json)

visit_with_cachebust "/government/organisations/department-of-health/about"

Expand Down
4 changes: 2 additions & 2 deletions test/integration/document_collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest
test "document collection with no body and 2 collection groups where 1st group has long body" do
content_item = get_content_example("document_collection")
content_item["details"]["collection_groups"][0]["body"] = Faker::Lorem.characters(number: 416)
content_store_has_item(content_item["base_path"], content_item.to_json)
stub_content_store_has_item(content_item["base_path"], content_item.to_json)
visit(content_item["base_path"])

assert page.has_css?(".gem-c-contents-list")
Expand Down Expand Up @@ -53,7 +53,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest
"documents" => %w[a-content-id],
},
]
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/guide_print_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GuidePrint < ActionDispatch::IntegrationTest
def setup_and_visit_guide_print(name)
example = get_content_example_by_schema_and_name("guide", name)
@content_item = example.tap do |item|
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit "#{item['base_path']}/print"
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class GuideTest < ActionDispatch::IntegrationTest
def setup_and_visit_part_in_guide
@content_item = get_content_example("guide").tap do |item|
chapter_path = "#{item['base_path']}/key-stage-1-and-2"
content_store_has_item(chapter_path, item.to_json)
stub_content_store_has_item(chapter_path, item.to_json)
visit_with_cachebust(chapter_path)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/help_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HelpPageTest < ActionDispatch::IntegrationTest
test "sets noindex meta tag for '/help/cookie-details'" do
@content_item = get_content_example("help_page").tap do |item|
item["base_path"] = "/help/cookie-details"
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/html_publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def assert_has_component_organisation_logo_with_brand(brand, index = 1)
'withdrawn_at': "2014-08-09T11:39:05Z",
}

content_store_has_item("/government/publications/canada-united-kingdom-joint-declaration/canada-united-kingdom-joint-declaration", content_item.to_json)
stub_content_store_has_item("/government/publications/canada-united-kingdom-joint-declaration/canada-united-kingdom-joint-declaration", content_item.to_json)
visit_with_cachebust "/government/publications/canada-united-kingdom-joint-declaration/canada-united-kingdom-joint-declaration"

assert page.has_css?(".gem-c-notice__title", text: "This policy paper was withdrawn on 9 August 2014")
Expand All @@ -101,7 +101,7 @@ def assert_has_component_organisation_logo_with_brand(brand, index = 1)
'withdrawn_at': "2014-08-09T11:39:05Z",
}

content_store_has_item("/government/publications/canada-united-kingdom-joint-declaration/canada-united-kingdom-joint-declaration", content_item.to_json)
stub_content_store_has_item("/government/publications/canada-united-kingdom-joint-declaration/canada-united-kingdom-joint-declaration", content_item.to_json)
visit_with_cachebust "/government/publications/canada-united-kingdom-joint-declaration/canada-united-kingdom-joint-declaration"

assert page.has_css?(".gem-c-notice__title", text: "This publication was withdrawn on 9 August 2014")
Expand Down
6 changes: 3 additions & 3 deletions test/integration/meta_tags_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MetaTagsTest < ActionDispatch::IntegrationTest
)
end

content_store_has_item("/some-page", case_study.to_json)
stub_content_store_has_item("/some-page", case_study.to_json)

visit_with_cachebust "/some-page"

Expand All @@ -22,7 +22,7 @@ class MetaTagsTest < ActionDispatch::IntegrationTest
random
end

content_store_has_item("/some-page", case_study.to_json)
stub_content_store_has_item("/some-page", case_study.to_json)

visit_with_cachebust "/some-page"

Expand All @@ -41,7 +41,7 @@ class MetaTagsTest < ActionDispatch::IntegrationTest
random
end

content_store_has_item("/some-page", case_study.to_json)
stub_content_store_has_item("/some-page", case_study.to_json)

visit_with_cachebust "/some-page"

Expand Down
4 changes: 2 additions & 2 deletions test/integration/phase_label_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PhaseLabelTest < ActionDispatch::IntegrationTest
case_study = GovukSchemas::Example.find("case_study", example_name: "case_study")
case_study["phase"] = "alpha"

content_store_has_item("/government/case-studies/get-britain-building-carlisle-park", case_study.to_json)
stub_content_store_has_item("/government/case-studies/get-britain-building-carlisle-park", case_study.to_json)

visit_with_cachebust "/government/case-studies/get-britain-building-carlisle-park"

Expand All @@ -15,7 +15,7 @@ class PhaseLabelTest < ActionDispatch::IntegrationTest
test "No phase label is displayed for a Content item without a phase field" do
content_item = GovukSchemas::Example.find("case_study", example_name: "case_study")
content_item.delete("phase")
content_store_has_item("/government/case-studies/get-britain-building-carlisle-park", content_item.to_json)
stub_content_store_has_item("/government/case-studies/get-britain-building-carlisle-park", content_item.to_json)

visit_with_cachebust "/government/case-studies/get-britain-building-carlisle-park"

Expand Down
2 changes: 1 addition & 1 deletion test/integration/service_sign_in/choose_sign_in_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ChooseSignInTest < ActionDispatch::IntegrationTest
def setup_and_visit_choose_sign_in_page(example_name, example_path)
content_item = get_content_example(example_name)
content_path = content_item["base_path"] + example_path
content_store_has_item(content_path, content_item.to_json)
stub_content_store_has_item(content_path, content_item.to_json)
visit(content_path)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CreateNewAccount < ActionDispatch::IntegrationTest
def setup_and_visit_create_new_account_page
content_item = get_content_example("service_sign_in")
path = content_item["base_path"] + "/create-new-account"
content_store_has_item(path, content_item.to_json)
stub_content_store_has_item(path, content_item.to_json)
visit(path)
end

Expand Down
2 changes: 1 addition & 1 deletion test/integration/statistical_data_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest
<h2>Item two</h2><p>Content about item two</p>
</div>"

content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
Expand Down
4 changes: 2 additions & 2 deletions test/integration/topical_event_about_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TopicalEventAboutPageTest < ActionDispatch::IntegrationTest
@content_item = get_content_example("topical_event_about_page")
@content_item["details"]["body"] = body_with_two_contents_list_items

content_store_has_item(@content_item["base_path"], @content_item.to_json)
stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)

visit_with_cachebust @content_item["base_path"]
assert_not page.has_css?(".gem-c-contents-list")
Expand All @@ -36,7 +36,7 @@ class TopicalEventAboutPageTest < ActionDispatch::IntegrationTest
@content_item = get_content_example("topical_event_about_page")
@content_item["details"]["body"] = long_first_item_body

content_store_has_item(@content_item["base_path"], @content_item.to_json)
stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)

visit_with_cachebust @content_item["base_path"]
assert page.has_css?(".gem-c-contents-list")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/travel_advice_atom_feed_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setup_and_parse_travel_advice_atom_feed(name)
path: "#{@content_item['base_path']}.atom",
)

content_store_has_item(@content_item["base_path"], @content_item.to_json)
stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)

@feed = RSS::Parser.parse(uri.read)
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/travel_advice_print_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TravelAdvicePrint < ActionDispatch::IntegrationTest
def setup_and_visit_travel_advice_print(name)
example = get_content_example_by_schema_and_name("travel_advice", name)
@content_item = example.tap do |item|
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit "#{item['base_path']}/print"
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/travel_advice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TravelAdviceTest < ActionDispatch::IntegrationTest

def setup_and_visit_travel_advice_part(name, part)
@content_item = get_content_example(name).tap do |item|
content_store_has_item("#{item['base_path']}/#{part}", item.to_json)
stub_content_store_has_item("#{item['base_path']}/#{part}", item.to_json)
visit "#{item['base_path']}/#{part}"
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/integration/working_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WorkingGroupTest < ActionDispatch::IntegrationTest
test "with a body that has no h2s" do
item = get_content_example("short")
item["details"]["body"] = "<div class='govspeak'><p>Some content<p></div>"
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit(item["base_path"])

assert page.has_text?("Some content")
Expand All @@ -49,7 +49,7 @@ class WorkingGroupTest < ActionDispatch::IntegrationTest
<h2>Item two</h2><p>Content about item two</p>
</div>"

content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
Expand Down
2 changes: 1 addition & 1 deletion test/support/govuk_content_schema_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module GovukContentSchemaExamples

def content_store_has_schema_example(schema_name, example_name)
document = govuk_content_schema_example(schema_name, example_name)
content_store_has_item(document["base_path"], document)
stub_content_store_has_item(document["base_path"], document)
document
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ def assert_footer_has_published_dates(published = nil, last_updated = nil, histo

def setup_and_visit_content_item(name, parameter_string = "")
@content_item = get_content_example(name).tap do |item|
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust("#{item['base_path']}#{parameter_string}")
end
end

def setup_and_visit_content_item_with_taxons(name, taxons)
@content_item = get_content_example(name).tap do |item|
item["links"]["taxons"] = taxons
content_store_has_item(item["base_path"], item.to_json)
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])
end
end
Expand Down

0 comments on commit 76e9bd2

Please sign in to comment.