diff --git a/app/assets/stylesheets/licence-finder.scss b/app/assets/stylesheets/licence-finder.scss index 26ad8244..207cfd5a 100644 --- a/app/assets/stylesheets/licence-finder.scss +++ b/app/assets/stylesheets/licence-finder.scss @@ -32,17 +32,6 @@ header.page-header hgroup { margin-top: 0.25em; } -/* reset margin on start */ -.start-page header.page-header hgroup { - margin: 0 24em 0 0; - padding: 1em 2em 2em 2em; - - @include media(mobile) { - margin-right: 0; - padding-bottom: 0; - } -} - a.remove, a.add { float: right; diff --git a/app/controllers/licence_finder_controller.rb b/app/controllers/licence_finder_controller.rb index d6636220..1662d482 100644 --- a/app/controllers/licence_finder_controller.rb +++ b/app/controllers/licence_finder_controller.rb @@ -11,23 +11,12 @@ class LicenceFinderController < ApplicationController ].freeze ACTIONS = %w(sectors activities business_location).freeze - # These are the correlation_ids - # POPULAR_LICENCE_IDS = %w(1083741799 1083741393 1084158580 1075329003 1084062657 1075429257 1083741306) - # These are the legal_ref_ids (mapped from the correlation_ids above) - # POPULAR_LICENCE_IDS = %w(1620001 1040001 590001 1520001 1520002 1160001 1170001) - # These are the gds_ids (mapped from the legal_ref_ids above) - POPULAR_LICENCE_IDS = %w(1071-5-1 1071-3-1 390-7-1 521-5-1 521-3-1 860-5-1 860-3-1).freeze - - before_filter :extract_and_validate_sector_ids, except: [:start, :sectors, :browse_sector_index, :browse_sector, :browse_sector_child, :browse_sector_grandchild] - before_filter :extract_and_validate_activity_ids, except: [:start, :sectors, :sectors_submit, :activities, :browse_sector_index, :browse_sector, :browse_sector_child, :browse_sector_grandchild] + before_filter :extract_and_validate_sector_ids, except: [:sectors, :browse_sector_index, :browse_sector, :browse_sector_child, :browse_sector_grandchild] + before_filter :extract_and_validate_activity_ids, except: [:sectors, :sectors_submit, :activities, :browse_sector_index, :browse_sector, :browse_sector_child, :browse_sector_grandchild] before_filter :set_expiry before_filter :setup_navigation_helpers after_action :add_analytics_headers - def start - setup_popular_licences - end - def sectors @picked_sectors = Sector.find_by_public_ids(extract_ids(:sector)).ascending(:name).to_a @sectors = if params[:q].present? @@ -156,11 +145,6 @@ def setup_navigation_helpers end end - def setup_popular_licences - licences = POPULAR_LICENCE_IDS.map { |id| Licence.find_by_gds_id(id) }.compact - @popular_licences = LicenceFacade.create_for_licences(licences).select(&:published?).first(3) - end - def add_analytics_headers if @sectors && params[:q].present? set_slimmer_headers(result_count: @sectors.length) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 99255840..df60e38a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,8 @@ module ApplicationHelper + def start_path + "/#{APP_SLUG}" + end + def current_question(&block) render partial: 'current_question', locals: { body: capture(&block), diff --git a/app/views/licence_finder/start.html.erb b/app/views/licence_finder/start.html.erb deleted file mode 100644 index fa668447..00000000 --- a/app/views/licence_finder/start.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -<% content_for :page_class do %>start-page<% end %> - -
-
-
- -
-
-

You may need a licence for:

- -
    -
  • some business activities
  • -
  • other activities, eg street parties
  • -
- -

Use this tool to find out which licences you may need.

-
- -

- <%= link_to sectors_path, :class => "big button" do %> - Find licences - <% end %> -

-
- - <%- if @popular_licences.any? -%> - - <%- end -%> -
-
-
diff --git a/config/routes.rb b/config/routes.rb index 086f4b80..81dee7df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,6 @@ # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". - get "#{APP_SLUG}" => "licence_finder#start", :as => :start get "#{APP_SLUG}/sectors" => "licence_finder#sectors", :as => :sectors get "#{APP_SLUG}/activities" => "licence_finder#activities", :as => :activities get "#{APP_SLUG}/location" => "licence_finder#business_location", :as => :business_location @@ -13,6 +12,4 @@ get "#{APP_SLUG}/browse-sectors/:sector" => "licence_finder#browse_sector", :as => :browse_sector get "#{APP_SLUG}/browse-sectors/:sector_parent/:sector" => "licence_finder#browse_sector_child", :as => :browse_sector_child - root :to => redirect("/#{APP_SLUG}", :status => 302) - end diff --git a/spec/controllers/licence_finder_controller_spec.rb b/spec/controllers/licence_finder_controller_spec.rb index 40379573..9c4f1517 100644 --- a/spec/controllers/licence_finder_controller_spec.rb +++ b/spec/controllers/licence_finder_controller_spec.rb @@ -7,67 +7,6 @@ @question3 = 'Where will you be located?' end - describe "GET 'start'" do - it "returns http success" do - get 'start' - expect(response).to be_success - end - - it "sets correct expiry headers" do - get :start - - expect(response.headers["Cache-Control"]).to eq("max-age=1800, public") - end - - describe "setting up popular licences" do - before :each do - LicenceFinderController::POPULAR_LICENCE_IDS.each_with_index do |gds_id, i| - l = FactoryGirl.create(:licence, gds_id: gds_id) - instance_variable_set("@l#{i}", l) # @l1 = l - end - end - - it "assigns facades for the published licences to @popular_licences" do - lf1 = double("lf1", published?: true) - lf2 = double("lf2", published?: false) - lf3 = double("lf3", published?: false) - lf4 = double("lf4", published?: true) - expect(LicenceFacade).to receive(:create_for_licences).with([@l0, @l1, @l2, @l3, @l4, @l5, @l6]). - and_return([lf1, lf2, lf3, lf4]) - - get :start - - expect(assigns[:popular_licences]).to eq([lf1, lf4]) - end - - it "only assigns the first 3 to @popular_licences" do - lf1 = double("lf1", published?: true) - lf2 = double("lf2", published?: false) - lf3 = double("lf3", published?: true) - lf4 = double("lf4", published?: true) - lf5 = double("lf5", published?: true) - allow(LicenceFacade).to receive(:create_for_licences). - and_return([lf1, lf2, lf3, lf4, lf5]) - - get :start - - expect(assigns[:popular_licences]).to eq([lf1, lf3, lf4]) - end - - it "copes with licences missing from the local database" do - @l1.destroy - @l2.destroy - lf1 = double("lf1", published?: true) - expect(LicenceFacade).to receive(:create_for_licences).with([@l0, @l3, @l4, @l5, @l6]). - and_return([lf1]) - - get :start - - expect(assigns[:popular_licences]).to eq([lf1]) - end - end - end - describe "GET 'sectors'" do it "returns no sectors if no query is provided" do @s1 = FactoryGirl.create(:sector, name: "Alpha") diff --git a/spec/integration/finding_licences_spec.rb b/spec/integration/finding_licences_spec.rb index 6bc77afa..515bdad3 100644 --- a/spec/integration/finding_licences_spec.rb +++ b/spec/integration/finding_licences_spec.rb @@ -31,11 +31,7 @@ $search.index_all rummager_has_licences([], when_searching_for: [l1]) - visit "/#{APP_SLUG}" - - expect(page).to have_link('Find licences') - - click_on 'Find licences' + visit "/#{APP_SLUG}/sectors" i_should_be_on "/#{APP_SLUG}/sectors" diff --git a/spec/integration/root_redirect_spec.rb b/spec/integration/root_redirect_spec.rb deleted file mode 100644 index 57def13e..00000000 --- a/spec/integration/root_redirect_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Redirecting the root URL", type: :request do - specify "visiting the root URL redirects me to the licence-finder start page" do - visit "/" - - i_should_be_on "/#{APP_SLUG}" - end -end diff --git a/spec/integration/start_page_spec.rb b/spec/integration/start_page_spec.rb deleted file mode 100644 index 71cc4fb9..00000000 --- a/spec/integration/start_page_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Start page", type: :request do - include RummagerHelpers - - specify "Inspecting the start page" do - visit "/#{APP_SLUG}" - - within 'article[role=article]' do - within 'section.intro' do - expect(page).to have_link("Find licences", href: sectors_path) - end - end - - expect(page).to have_selector("#test-report_a_problem") - expect(page).to have_css(shared_component_selector('breadcrumbs')) - expect(page).to have_css(shared_component_selector('related_items')) - end - - context "Seeing popular licences on the start page" do - before :each do - @popular_licence_ids = LicenceFinderController::POPULAR_LICENCE_IDS - @popular_licence_ids.each do |gds_id| - FactoryGirl.create(:licence, gds_id: gds_id) - end - @all_licences = Licence - .where(gds_id: { '$in': @popular_licence_ids }) - .sort { |a, b| - @popular_licence_ids.index(a.gds_id) <=> @popular_licence_ids.index(b.gds_id) - } - end - - specify "should not see popular licences section if none of the popular licences are available in Rummager" do - rummager_has_licences([], when_searching_for: @all_licences) - visit "/#{APP_SLUG}" - - expect(page).not_to have_selector('div.popular-licences') - expect(page).not_to have_content('Popular licences') - end - - specify "should display licences available in Rummager" do - licences = Licence.where( - gds_id: { - '$in': [@popular_licence_ids[0], @popular_licence_ids[1]] - } - ) - rummager_has_licences(licences, when_searching_for: @all_licences) - - visit "/#{APP_SLUG}" - - within 'div.popular-licences' do - expect(page).to have_content("Popular licences") - - expect(licences.count).to be > 0 - licences.each do |licence| - expected_title = "Title from search for #{licence.gds_id}" - - expect(page).to have_selector('li a', text: expected_title) - - within_section "list item containing #{expected_title}" do - expect(page).to have_link(expected_title, href: /\/licence-#{licence.gds_id}/) - expect(page).to have_content("Short description for #{licence.gds_id}") - end - end - end - end - - specify "should only display the first 3 that are available" do - expected_licences = Licence.where( - gds_id: { - '$in': [ - @popular_licence_ids[0], - @popular_licence_ids[1], - @popular_licence_ids[3] - ] - } - ) - expect(expected_licences.count).to be > 0 - - rummager_has_licences( - expected_licences, when_searching_for: @all_licences - ) - - visit "/#{APP_SLUG}" - - within 'div.popular-licences' do - expected_licences.each do |licence| - expected_title = "Title from search for #{licence.gds_id}" - - expect(page).to have_selector('li a', text: expected_title) - end - end - end - end -end