-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We are aiming to archive Transition Config which is currently used to create sites in Transition. This adds the actions and views necessary for a user to add a new transition.
- Loading branch information
1 parent
509d8dc
commit 927105f
Showing
9 changed files
with
259 additions
and
9 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
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,96 @@ | ||
<% breadcrumb(:new_site, @organisation) %> | ||
|
||
<div class="page-title-with-border"> | ||
<h1>New transition site</h1> | ||
</div> | ||
|
||
<%= form_for @site_form, html: { role: "form" }, url: organisation_sites_path do |form| %> | ||
<%= render "shared/error_messages", error_messages: form.object.errors.full_messages %> | ||
|
||
<div class="form-group row"> | ||
<div class="col-md-8"> | ||
<%= form.hidden_field :organisation_slug, value: @organisation.whitehall_slug %> | ||
|
||
<div class="form-group"> | ||
<%= form.label :abbr %> | ||
<%= form.text_field :abbr, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :tna_timestamp %> | ||
<%= form.text_field :tna_timestamp, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :homepage %> | ||
<%= form.text_field :homepage, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :hostname %> | ||
<%= form.text_field :hostname, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :homepage_title %> | ||
<%= form.text_field :homepage_title, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :extra_organisations %> | ||
<%= form.collection_select :extra_organisations, | ||
form.object.organisations, | ||
:id, | ||
:title, | ||
{}, | ||
{ multiple: true, class: "form-control" } | ||
%> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :homepage_furl %> | ||
<%= form.text_field :homepage_furl, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :global_type %> | ||
<%= form.collection_radio_buttons :global_type, | ||
Site::GLOBAL_TYPES, | ||
:to_s, | ||
:humanize | ||
%> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :global_new_url %> | ||
<%= form.text_field :global_new_url, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :query_params %> | ||
<%= form.text_field :query_params, class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :global_redirect_append_path %> | ||
<%= form.check_box :global_redirect_append_path %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :special_redirect_strategy %> | ||
<%= form.collection_radio_buttons :special_redirect_strategy, | ||
Site::SPECIAL_REDIRECT_STRATEGY_TYPES, | ||
:to_s, | ||
:humanize | ||
%> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.label :aliases %> | ||
<%= form.text_area :aliases, class: "form-control" %> | ||
</div> | ||
|
||
<%= form.submit 'Save', class: 'add-top-margin btn btn-success' %> | ||
</div> | ||
</div> | ||
<% 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
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
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,11 +1,33 @@ | ||
When(/^I visit the page for the (.*) organisation$/) do |organisation_title| | ||
organisation = Organisation.find_by(title: organisation_title) | ||
visit organisation_path(organisation) | ||
end | ||
|
||
When(/^I visit this site page$/) do | ||
visit site_path(@site) | ||
end | ||
|
||
When(/^I edit this site's transition date$/) do | ||
click_link "Edit date" | ||
select("2014", from: "site_launch_date_1i") | ||
select("September", from: "site_launch_date_2i") | ||
select("20", from: "site_launch_date_3i") | ||
click_button "Save" | ||
When(/^I fill in the new transition site fields/) do | ||
fill_in "Abbreviated name", with: "aaib" | ||
fill_in "TNA timestamp", with: "20141104112824" | ||
fill_in "Homepage", with: "https://www.gov.uk/government/organisations/air-accidents-investigation-branch" | ||
fill_in "Hostname", with: "www.aaib.gov.uk" | ||
fill_in "Homepage title", with: "Air accidents investigation branch" | ||
select "Government Office for Science" | ||
fill_in "Homepage full URL", with: "www.gov.uk/aaib" | ||
choose "Redirect" | ||
fill_in "Global new URL", with: "https://www.gov.uk/government/organisations/air-accidents-investigation-branch/about" | ||
fill_in "Query params", with: "file" | ||
check "Global redirect append path" | ||
choose "Via aka" | ||
fill_in "Aliases", with: "aaib.gov.uk,aaib.com" | ||
end | ||
|
||
Then(/^I should be on the new transition site page for the (.*) organisation$/) do |organisation_title| | ||
organisation = Organisation.find_by(title: organisation_title) | ||
i_should_be_on_the_path new_organisation_site_path(organisation) | ||
end | ||
|
||
Then(/^I should be redirected to the new site$/) do | ||
i_should_be_on_the_path site_path(Site.last) | ||
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
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,48 @@ | ||
require "rails_helper" | ||
|
||
describe "Site creation", type: :request do | ||
let!(:gds_bob) { create(:gds_editor, name: "Bob Terwhilliger") } | ||
let(:organisation) { create(:organisation, whitehall_slug: "air-accidents-investigation-branch") } | ||
let(:params) { attributes_for :site_form, :with_optional_fields, :with_aliases, organisation_slug: "air-accidents-investigation-branch" } | ||
|
||
it "redirects to the new site path" do | ||
post organisation_sites_path(organisation), params: { create_site: params } | ||
|
||
expect(response).to redirect_to(site_path(Site.last)) | ||
end | ||
|
||
it "creates the new site" do | ||
post organisation_sites_path(organisation), params: { create_site: params } | ||
|
||
attributes = { | ||
abbr: "aaib", | ||
global_new_url: "https://www.gov.uk/government/organisations/air-accidents-investigation-branch/about", | ||
global_redirect_append_path: true, | ||
global_type: "redirect", | ||
homepage: "https://www.gov.uk/government/organisations/air-accidents-investigation-branch", | ||
homepage_furl: "www.gov.uk/aaib", | ||
homepage_title: "Air accidents investigation branch", | ||
query_params: "file", | ||
special_redirect_strategy: "via_aka", | ||
tna_timestamp: Time.strptime("20141104112824", "%Y%m%d%H%M%S"), | ||
} | ||
|
||
expect(Site.last.attributes.with_indifferent_access).to include attributes | ||
expect(Site.last.organisation).to eq organisation | ||
end | ||
|
||
it "creates related hosts and aka hosts" do | ||
post organisation_sites_path(organisation), params: { create_site: params } | ||
|
||
alias_site_1 = Host.where(hostname: "www.aaib.gov.uk") | ||
alias_site_2 = Host.where(hostname: "aaib.gov.uk") | ||
alias_site_3 = Host.where(hostname: "aaib.com") | ||
|
||
expect(alias_site_1).to exist | ||
expect(alias_site_2).to exist | ||
expect(alias_site_3).to exist | ||
expect(Host.where(hostname: "aka.aaib.gov.uk", canonical_host: alias_site_1)).to exist | ||
expect(Host.where(hostname: "aka-aaib.gov.uk", canonical_host: alias_site_2)).to exist | ||
expect(Host.where(hostname: "aka-aaib.com", canonical_host: alias_site_3)).to exist | ||
end | ||
end |