Skip to content

Commit

Permalink
Merge pull request #602 from alphagov/validate_done_prefix
Browse files Browse the repository at this point in the history
Validate that you can't create a done page without the done/ prefix
  • Loading branch information
issyl0 committed Mar 24, 2017
2 parents ab69937 + 76b11ce commit 32283c6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -10,7 +10,7 @@ gem 'gds-sso', '~> 11.2'
gem 'gds-api-adapters', '~> 41.0.0'
gem 'govspeak', '~> 3.4.0'
gem 'govuk_admin_template', '4.2.0'
gem "govuk_content_models", '44.0.0'
gem "govuk_content_models", '44.0.1'
gem 'govuk_sidekiq', '0.0.4'
gem 'has_scope'
gem 'inherited_resources'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -137,7 +137,7 @@ GEM
bootstrap-sass (= 3.3.5.1)
jquery-rails (~> 3.1.3)
rails (>= 3.2.0)
govuk_content_models (44.0.0)
govuk_content_models (44.0.1)
bson_ext
gds-api-adapters (>= 10.9.0)
gds-sso (~> 11.2)
Expand Down Expand Up @@ -460,7 +460,7 @@ DEPENDENCIES
govuk-content-schema-test-helpers (~> 1.4)
govuk-lint (~> 0.7)
govuk_admin_template (= 4.2.0)
govuk_content_models (= 44.0.0)
govuk_content_models (= 44.0.1)
govuk_sidekiq (= 0.0.4)
has_scope
inherited_resources
Expand Down
13 changes: 13 additions & 0 deletions test/integration/add_artefact_test.rb
Expand Up @@ -36,4 +36,17 @@ class AddArtefactTest < ActionDispatch::IntegrationTest
options = find_field("Format").find_all('option').map(&:value)
assert_empty options & Artefact::RETIRED_FORMATS
end

should "not allow creation of a done page without the /done prefix" do
visit root_path
click_link "Add artefact"

fill_in "Title", with: "Done thing"
fill_in "Slug", with: "done-thing"
select "Completed transaction", from: "Format"

click_button "Save and go to item"

assert page.has_content?("Done page slugs must have a done/ prefix")
end
end
2 changes: 2 additions & 0 deletions test/integration/change_edition_type_test.rb
Expand Up @@ -25,6 +25,8 @@ def edition_parts(edition)
def create_artefact_of_kind(kind)
if kind == 'help_page'
FactoryGirl.create(:artefact, slug: "help/foo", kind: kind)
elsif kind == 'completed_transaction'
FactoryGirl.create(:artefact, slug: "done/foo", kind: kind)
else
FactoryGirl.create(:artefact, kind: kind)
end
Expand Down
Expand Up @@ -18,7 +18,7 @@ def edition
end

def artefact
@_artefact ||= FactoryGirl.create(:artefact, kind: "completed_transaction")
@_artefact ||= FactoryGirl.create(:artefact, kind: "completed_transaction", slug: "done/artefact")
end

def result
Expand Down
13 changes: 10 additions & 3 deletions test/unit/services/search_indexer_test.rb
Expand Up @@ -36,9 +36,16 @@ def test_indexing_to_rummager

def test_format_exceptions_are_not_indexed
SearchIndexer::FORMATS_NOT_TO_INDEX.each do |format|
artefact = FactoryGirl.create(
:artefact, kind: format, content_id: "content-id",
)
if format == 'completed_transaction'
artefact = FactoryGirl.create(
:artefact,
kind: format,
slug: "done/something",
content_id: "content-id")
else
artefact = FactoryGirl.create(:artefact, kind: format, content_id: "content_id")
end

edition = FactoryGirl.create(:answer_edition, panopticon_id: artefact.id)
search_index_presenter = SearchIndexPresenter.new(edition)

Expand Down

0 comments on commit 32283c6

Please sign in to comment.