Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Delete start page template, controller and tests
Browse files Browse the repository at this point in the history
The start page is now a transaction published by Publisher and served
by Frontend
  • Loading branch information
fofr committed Jun 20, 2017
1 parent a384eb8 commit b646fb6
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 242 deletions.
11 changes: 0 additions & 11 deletions app/assets/stylesheets/licence-finder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 2 additions & 18 deletions app/controllers/licence_finder_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module ApplicationHelper
def start_path
"/#{APP_SLUG}"
end

def current_question(&block)
render partial: 'current_question', locals: {
body: capture(&block),
Expand Down
40 changes: 0 additions & 40 deletions app/views/licence_finder/start.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
61 changes: 0 additions & 61 deletions spec/controllers/licence_finder_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 1 addition & 5 deletions spec/integration/finding_licences_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
9 changes: 0 additions & 9 deletions spec/integration/root_redirect_spec.rb

This file was deleted.

95 changes: 0 additions & 95 deletions spec/integration/start_page_spec.rb

This file was deleted.

0 comments on commit b646fb6

Please sign in to comment.