Skip to content

Commit

Permalink
Remove HTTP status from mappings form
Browse files Browse the repository at this point in the history
* Update corresponding tests
  • Loading branch information
Paul Hayes committed Nov 14, 2013
1 parent a92e888 commit 62a5440
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
4 changes: 1 addition & 3 deletions app/helpers/mappings_helper.rb
@@ -1,5 +1,3 @@
# encoding=utf-8

module MappingsHelper
def example_url(mapping, options = {})
scheme_and_host = 'http://'+ mapping.site.default_host.hostname
Expand Down Expand Up @@ -51,7 +49,7 @@ def mapping_edit_tabs(options = {})
# e.g. [['301 Moved Permanently', '301'], ['410 Gone', '410']]
def options_for_supported_statuses
Mapping::TYPES.map do |status, type|
["#{type.titleize}#{status}: #{Rack::Utils::HTTP_STATUS_CODES[status.to_i]}", status]
["#{type.titleize}", status]
end
end
end
4 changes: 2 additions & 2 deletions app/views/mappings/_form.html.erb
Expand Up @@ -2,7 +2,7 @@
<%= render 'shared/error_messages', model: f.object %>
<%= f.label :http_status, 'Type' %>
<%= f.select :http_status, options_for_supported_statuses, {}, { class: 'remove-bottom-margin span4 js-http-status' } %>
<%= f.select :http_status, options_for_supported_statuses, {}, { class: 'remove-bottom-margin js-http-status' } %>
<% if @mapping.persisted? # we're editing, show the example URL %>
<div class="add-vertical-margins">
Expand All @@ -18,7 +18,7 @@
<% end %>
<%= field_set_tag nil, class: 'js-for-redirect' do %>
<%= f.label :new_url, 'New URL' %>
<%= f.label :new_url, 'Redirects to' %>
<%= f.text_field :new_url, class: 'span8', placeholder: 'https://www.gov.uk' %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions features/mapping_edit.feature
Expand Up @@ -14,7 +14,7 @@ Feature: Edit a site's mapping

@javascript
Scenario: Editing a site mapping that is a redirect
When I make the mapping a redirect with a new URL of https://gov.uk/new-url
When I make the mapping a redirect to https://gov.uk/new-url
Then I should see redirect fields
But I should not see archive fields
When I save the mapping
Expand All @@ -29,7 +29,7 @@ Feature: Edit a site's mapping
But I should see archive fields

Scenario: Editing a mapping with invalid values
When I make the mapping a redirect with a new URL of not-a-url
When I make the mapping a redirect to not-a-url
And I save the mapping
Then I should still be editing a mapping
And I should see "New URL is not a URL"
Expand Down
2 changes: 1 addition & 1 deletion features/mapping_history.feature
Expand Up @@ -10,7 +10,7 @@ Feature: History of edits to a mapping
| 301 | /about/corporate | http://somewhere.good |
And I visit the path /sites/directgov/mappings
And I click the link "Edit"
And I change the mapping's New URL to http://somewhere.bad
And I change the mapping's redirect to http://somewhere.bad

Scenario: Looking at an edited mapping
When I log in as a SIRO
Expand Down
14 changes: 7 additions & 7 deletions features/step_definitions/mappings_interaction_steps.rb
Expand Up @@ -2,13 +2,13 @@
click_link 'Add mapping'
end

When(/^I make the mapping a redirect with a new URL of (.*)$/) do |new_url|
select '301', from: 'Type'
fill_in 'New URL', with: new_url
When(/^I make the mapping a redirect to (.*)$/) do |new_url|
select 'Redirect', from: 'Type'
fill_in 'Redirects to', with: new_url
end

When(/^I make the mapping an archive$/) do
select '410', from: 'Type'
select 'Archive', from: 'Type'
end

When(/^I (save|create) the mapping$/) do |type|
Expand All @@ -24,12 +24,12 @@
click_button 'Filter'
end

When(/^I change the mapping's (.*) to (.*)$/) do |field_name, value|
fill_in field_name, with: value
When(/^I change the mapping's redirect to (.*)$/) do |value|
fill_in 'Redirects to', with: value
step 'I save the mapping'
end

When(/^I make the mapping a redirect from (.*) to (.*)$/) do |path, new_url|
fill_in 'Old URL', with: path
fill_in 'New URL', with: new_url
fill_in 'Redirects to', with: new_url
end
4 changes: 1 addition & 3 deletions spec/helpers/mappings_helper_spec.rb
@@ -1,5 +1,3 @@
# encoding=utf-8

require 'spec_helper'

describe MappingsHelper do
Expand Down Expand Up @@ -36,7 +34,7 @@

describe '#options_for_supported_statuses' do
it 'provides an array of supported statuses in a form compatible with FormBuilder#select' do
helper.options_for_supported_statuses.should == [['Redirect — 301: Moved Permanently', '301'], ['Archive — 410: Gone', '410']]
helper.options_for_supported_statuses.should == [['Redirect', '301'], ['Archive', '410']]
end
end
end

0 comments on commit 62a5440

Please sign in to comment.