Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete policy groups frontend parts #2526

Merged
merged 2 commits into from Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/stylesheets/frontend/base.scss
Expand Up @@ -117,7 +117,6 @@
@import "views/_operational-field";
@import "views/_organisations";
@import "views/_people";
@import "views/_policy_groups";
@import "views/_publications";
@import "views/_search";
@import "views/_services-and-information";
Expand Down
51 changes: 0 additions & 51 deletions app/assets/stylesheets/frontend/views/_policy_groups.scss

This file was deleted.

8 changes: 3 additions & 5 deletions app/controllers/policy_groups_controller.rb
Expand Up @@ -4,14 +4,12 @@ def index
end

def show
# Routes matching /policy/[ID] still fall through to Whitehall rather than
# government-frontend. We redirect them.
# Return 301 and redirect in case a URL uses the group's ID rather than slug
@policy_group = PolicyGroup.friendly.find(params[:id])

#return 301 and redirect in case a URL uses the group's ID rather than slug
if params[:id] != @policy_group.to_param
redirect_to @policy_group, status: :moved_permanently
else
@policies = @policy_group.published_policies
set_meta_description(@policy_group.summary)
end
end
end
62 changes: 0 additions & 62 deletions app/views/policy_groups/show.html.erb

This file was deleted.

1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -142,6 +142,7 @@ def external_redirect(path_prefix, target)
resources :ministerial_roles, path: 'ministers', only: [:index, :show], localised: true
resources :people, only: [:index, :show], localised: true

# TODO: Remove `:show` when policy group paths can be otherwise generated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a 'plan' for this to happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resources :policy_groups, path: 'groups', only: [:index, :show]
resources :operational_fields, path: 'fields-of-operation', only: [:index, :show]
get 'world/organisations/:organisation_id/office' => redirect('/world/organisations/%{organisation_id}')
Expand Down
6 changes: 3 additions & 3 deletions features/policy-groups.feature
Expand Up @@ -20,10 +20,10 @@ Feature: Policy groups
Background:
Given I am an editor

Scenario: Policy groups have their own page
Scenario: Policy groups appear in the public index
Given a policy group "ABC Advisories" exists
When I visit the policy group "ABC Advisories"
Then I should see the policy group "ABC Advisories"
When I visit the policy group index
Then I should see the policy group "ABC Advisories" in the index

Scenario:
Given a policy group "Panel" exists
Expand Down
8 changes: 3 additions & 5 deletions features/step_definitions/policy_group_steps.rb
Expand Up @@ -2,17 +2,16 @@
create(:policy_group, name: group_name)
end

Then /^I should see the policy group "([^"]*)"$/ do |group_name|
Then /^I should see the policy group "([^"]*)" in the index$/ do |group_name|
assert page.has_text?(group_name)
end

Then /^I should see a link to the policy group "([^"]*)"$/ do |group_name|
assert page.has_css?('a', text: group_name)
end

When /^I visit the policy group "([^"]*)"$/ do |group_name|
group = PolicyGroup.where(name: group_name).first
visit policy_group_path(group)
When /^I visit the policy group index$/ do
visit policy_groups_path
end

When /^I delete the policy group "([^"]*)"$/ do |group_name|
Expand All @@ -33,5 +32,4 @@
group = PolicyGroup.find_by(name: group_name)
attachment = upload_pdf_to_policy_group(group)
insert_attachment_markdown_into_policy_group_description(attachment, group)
check_attachment_appears_on_policy_group(attachment, group)
end
5 changes: 0 additions & 5 deletions features/support/policy_group_helper.rb
Expand Up @@ -11,11 +11,6 @@ def insert_attachment_markdown_into_policy_group_description(attachment, group)
fill_in 'Description', with: group.description.to_s + "\n\n" + markdown
click_button 'Save'
end

def check_attachment_appears_on_policy_group(attachment, group)
visit policy_group_path(group)
assert page_has_attachment?(attachment)
end
end

World(PolicyGroupHelper)
26 changes: 0 additions & 26 deletions test/functional/policy_groups_controller_test.rb
@@ -1,32 +1,6 @@
require 'test_helper'
require "gds_api/test_helpers/rummager"

class PolicyGroupsControllerTest < ActionController::TestCase
include GdsApi::TestHelpers::Rummager

setup do
rummager_has_no_policies_for_any_type
end

test "show sets meta description" do
policy_group = create(:policy_group, summary: 'my meta description')

get :show, id: policy_group

assert_equal 'my meta description', assigns(:meta_description)
end

view_test "should display the group's policies" do
policy_group = create(:policy_group)
rummager_has_policies_for_every_type

get :show, id: policy_group

assert_select ".policies" do
assert_select "a[href='/government/policies/welfare-reform']", text: "Welfare reform"
end
end

test "should redirect to the slug URL if a policy id is provided" do
policy_group = create(:policy_group)

Expand Down