diff --git a/app/controllers/boosts_controller.rb b/app/controllers/boosts_controller.rb
deleted file mode 100644
index 0b58d413..00000000
--- a/app/controllers/boosts_controller.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-class BoostsController < ApplicationController
- def index
- @boosts = Boost.order(:name)
- end
-
- def show
- @boost = Boost.find(params[:id])
- end
-
- def new
- @boost = Boost.new
- end
-
- def create
- @boost = Boost.new(boost_params)
- if @boost.save
- redirect_to @boost, notice: "Boost created successfully"
- else
- render "new", status: :unprocessable_entity
- end
- end
-
- def edit
- @boost = Boost.find(params[:id])
- end
-
- def update
- @boost = Boost.find(params[:id])
- if @boost.update(boost_params)
- redirect_to @boost, notice: "Boost updated successfully"
- else
- render "edit", status: :unprocessable_entity
- end
- end
-
- def destroy
- @boost = Boost.find(params[:id])
-
- if @boost.destroy
- redirect_to boosts_path, notice: "Boost deleted successfully"
- else
- redirect_to @boost, alert: "Boost could not be deleted. Try again later."
- end
- end
-
-private
-
- def boost_params
- params.require(:boost).permit(:name, :active, :boost_amount, :filter)
- end
-end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 62c4a5ff..3304a221 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -8,11 +8,6 @@ def navigation_items
href: recommended_links_path,
active: controller.controller_name == "recommended_links",
},
- {
- text: "Boosts",
- href: boosts_path,
- active: controller.controller_name == "boosts",
- },
{
text: current_user.name,
href: Plek.new.external_url_for("signon"),
diff --git a/app/helpers/boosts_helper.rb b/app/helpers/boosts_helper.rb
deleted file mode 100644
index 2d0a3657..00000000
--- a/app/helpers/boosts_helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module BoostsHelper
- def boost_status_tag(boost)
- if boost.active?
- content_tag(:span, "Active", class: "govuk-tag govuk-tag--blue")
- else
- content_tag(:span, "Not active", class: "govuk-tag govuk-tag--grey")
- end
- end
-
- def filter_expression_code(boost)
- content_tag(:code, boost.filter, class: "app-filter-expression")
- end
-end
diff --git a/app/models/boost.rb b/app/models/boost.rb
deleted file mode 100644
index 671a7675..00000000
--- a/app/models/boost.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class Boost < ApplicationRecord
- validates :name, :filter, presence: true
- validates :boost_amount, numericality: {
- greater_than_or_equal_to: -1.0, less_than_or_equal_to: 1.0
- }
-end
diff --git a/app/views/boosts/_form.html.erb b/app/views/boosts/_form.html.erb
deleted file mode 100644
index 04b3ac57..00000000
--- a/app/views/boosts/_form.html.erb
+++ /dev/null
@@ -1,59 +0,0 @@
-<%= form_for(boost) do |f| %>
- <% if boost.errors.any? %>
- <%= render "govuk_publishing_components/components/error_summary", {
- id: "error-summary",
- title: "There is a problem",
- description: "The boost could not be updated because some fields are missing or incorrect.",
- items: error_summary_items(boost)
- } %>
- <% end %>
-
- <%= render "govuk_publishing_components/components/input", {
- label: {
- text: Boost.human_attribute_name(:name)
- },
- id: "boost_name",
- name: "boost[name]",
- value: boost.name,
- error_items: error_items(boost, :name)
- } %>
-
- <%= render "govuk_publishing_components/components/input", {
- label: {
- text: Boost.human_attribute_name(:boost_amount)
- },
- hint: "A value between -1.0 and 1.0 used to influence the order of search results.",
- id: "boost_boost_amount",
- name: "boost[boost_amount]",
- value: boost.boost_amount,
- error_items: error_items(boost, :boost_amount)
- } %>
-
- <%= render "govuk_publishing_components/components/textarea", {
- label: {
- text: Boost.human_attribute_name(:filter)
- },
- hint: "Determines which documents are affected by this boost. See #{link_to 'Vertex AI Search filter syntax', 'https://cloud.google.com/retail/docs/filter-and-order#filter', class: 'govuk-link'} for details.".html_safe,
- id: "boost_filter",
- name: "boost[filter]",
- value: boost.filter,
- error_items: error_items(boost, :filter)
- } %>
-
- <%= hidden_field_tag "boost[active]", "0" %>
- <%= render "govuk_publishing_components/components/checkboxes", {
- name: "boost[active]",
- items: [
- {
- label: Boost.human_attribute_name(:active),
- hint: "Boosts that are not active will not affect search results.",
- value: "1",
- checked: boost.active?
- }
- ]
- } %>
-
- <%= render "govuk_publishing_components/components/button", {
- text: "Save"
- } %>
-<% end %>
diff --git a/app/views/boosts/edit.html.erb b/app/views/boosts/edit.html.erb
deleted file mode 100644
index a3eb5006..00000000
--- a/app/views/boosts/edit.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-<%= render "govuk_publishing_components/components/breadcrumbs", {
- breadcrumbs: [
- {
- title: "Boosts",
- url: boosts_path
- },
- {
- title: @boost.name,
- url: boost_path(@boost)
- },
- {
- title: "Edit"
- }
- ]
-} %>
-
-<%= render "common/page_title", title: @boost.name %>
-
-<%= render "form", boost: @boost %>
diff --git a/app/views/boosts/index.html.erb b/app/views/boosts/index.html.erb
deleted file mode 100644
index a80aced9..00000000
--- a/app/views/boosts/index.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-<%= render "common/page_title", title: "Boosts" %>
-
-
- <%= render "govuk_publishing_components/components/button", {
- text: "New boost",
- href: new_boost_path,
- inline_layout: true
- } %>
-
-
-
- <% if @boosts.any? %>
- <%= render "govuk_publishing_components/components/table", {
- filterable: true,
- label: "Filter boosts",
- head: [
- { text: Boost.human_attribute_name(:name) },
- { text: "Status" },
- ],
- rows: @boosts.map do |boost|
- [
- { text: link_to(boost.name, boost_path(boost), class:'govuk-link') },
- { text: boost_status_tag(boost) },
- ]
- end
- } %>
- <% else %>
-
No boosts have been set up yet.
- <% end %>
-
diff --git a/app/views/boosts/new.html.erb b/app/views/boosts/new.html.erb
deleted file mode 100644
index a7f66505..00000000
--- a/app/views/boosts/new.html.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-<%= render "govuk_publishing_components/components/breadcrumbs", {
- breadcrumbs: [
- {
- title: "Boosts",
- url: boosts_path
- },
- {
- title: "New boost"
- }
- ]
-} %>
-
-<%= render "common/page_title", title: "New boost" %>
-
-<%= render "form", boost: @boost %>
diff --git a/app/views/boosts/show.html.erb b/app/views/boosts/show.html.erb
deleted file mode 100644
index 5b55338d..00000000
--- a/app/views/boosts/show.html.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<%= render "govuk_publishing_components/components/breadcrumbs", {
- breadcrumbs: [
- {
- title: "Boosts",
- url: boosts_path
- },
- {
- title: @boost.name,
- }
- ]
-} %>
-
-<%= render "common/page_title", title: @boost.name %>
-
-
- <%= render "govuk_publishing_components/components/button", {
- text: "Edit boost",
- href: edit_boost_path(@boost),
- inline_layout: true
- } %>
- <%= delete_button "Delete boost", boost_path(@boost), is_inline: true %>
-
-
-<%= render "govuk_publishing_components/components/summary_list", {
- items: [
- {
- field: "Status",
- value: boost_status_tag(@boost)
- },
- {
- field: Boost.human_attribute_name(:boost_amount),
- value: @boost.boost_amount
- },
- {
- field: Boost.human_attribute_name(:filter),
- value: filter_expression_code(@boost)
- },
- {
- field: Boost.human_attribute_name(:created_at),
- value: @boost.created_at.to_formatted_s(:govuk_date)
- },
- {
- field: Boost.human_attribute_name(:updated_at),
- value: @boost.updated_at.to_formatted_s(:govuk_date)
- }
- ]
-} %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7c891b6f..a9611300 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -32,10 +32,3 @@
en:
activerecord:
attributes:
- boost:
- name: Name
- active: Activate boost
- boost_amount: Boost amount
- filter: Filter expression
- created_at: Created
- updated_at: Updated
diff --git a/config/routes.rb b/config/routes.rb
index f992d460..e4c53a0d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,7 +6,6 @@
)
mount GovukPublishingComponents::Engine, at: "/component-guide" if Rails.env.development?
- resources :boosts
resources :recommended_links, path: "/recommended-links"
root "recommended_links#index"
diff --git a/db/migrate/20250110114733_remove_boosts.rb b/db/migrate/20250110114733_remove_boosts.rb
new file mode 100644
index 00000000..27371c0b
--- /dev/null
+++ b/db/migrate/20250110114733_remove_boosts.rb
@@ -0,0 +1,12 @@
+class RemoveBoosts < ActiveRecord::Migration[8.0]
+ def change
+ drop_table :boosts do |t|
+ t.string :name, null: false
+ t.boolean :active, null: false
+ t.float :boost_amount, null: false
+ t.text :filter, null: false
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e99f369a..c2d25285 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,16 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_06_19_100722) do
- create_table "boosts", charset: "utf8mb3", force: :cascade do |t|
- t.string "name", null: false
- t.boolean "active", null: false
- t.float "boost_amount", null: false
- t.text "filter", null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
+ActiveRecord::Schema[8.0].define(version: 2025_01_10_114733) do
create_table "recommended_links", charset: "utf8mb3", force: :cascade do |t|
t.string "title"
t.string "link"
@@ -42,5 +33,4 @@
t.boolean "disabled", default: false
t.string "organisation_content_id"
end
-
end
diff --git a/spec/factories.rb b/spec/factories.rb
index 61989a37..169b70b0 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -1,11 +1,4 @@
FactoryBot.define do
- factory :boost do
- name { "Boost" }
- active { true }
- boost_amount { 0.5 }
- filter { 'document_type: ANY("press_release")' }
- end
-
factory :recommended_link do
title { "Tax online" }
link { "https://www.tax.service.gov.uk/" }
diff --git a/spec/models/boost_spec.rb b/spec/models/boost_spec.rb
deleted file mode 100644
index 27b97309..00000000
--- a/spec/models/boost_spec.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-RSpec.describe Boost, type: :model do
- let(:boost) { build(:boost) }
-
- describe "validations" do
- describe "name" do
- it "accepts valid values" do
- boost.name = "Test"
-
- expect(boost).to be_valid
- end
-
- it "refuses empty values" do
- boost.name = ""
-
- expect(boost).not_to be_valid
- expect(boost.errors[:name]).not_to be_empty
- end
- end
-
- describe "filter" do
- it "accepts valid values" do
- boost.filter = "something"
-
- expect(boost).to be_valid
- end
-
- it "refuses empty values" do
- boost.filter = ""
-
- expect(boost).not_to be_valid
- expect(boost.errors[:filter]).not_to be_empty
- end
- end
-
- describe "boost_amount" do
- it "accepts valid values" do
- boost.boost_amount = 0.5
-
- expect(boost).to be_valid
- end
-
- it "refuses too low values" do
- boost.boost_amount = -1.1
-
- expect(boost).not_to be_valid
- expect(boost.errors[:boost_amount]).not_to be_empty
- end
-
- it "refuses too high values" do
- boost.boost_amount = 1.1
-
- expect(boost).not_to be_valid
- expect(boost.errors[:boost_amount]).not_to be_empty
- end
-
- it "refuses empty values" do
- boost.boost_amount = nil
-
- expect(boost).not_to be_valid
- expect(boost.errors[:boost_amount]).not_to be_empty
- end
- end
- end
-end
diff --git a/spec/system/boosts_spec.rb b/spec/system/boosts_spec.rb
deleted file mode 100644
index 96bdb2ac..00000000
--- a/spec/system/boosts_spec.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-RSpec.describe "Boosts" do
- scenario "Viewing boosts" do
- given_several_boosts
-
- when_i_visit_the_boosts_page
-
- then_all_boosts_are_displayed
- end
-
- scenario "Viewing a single boost" do
- given_a_boost
-
- when_i_go_to_view_the_boost
-
- then_i_can_see_the_details_of_the_boost
- end
-
- scenario "Creating a new boost" do
- when_i_visit_the_boosts_page
- and_i_choose_to_create_a_new_boost
- and_i_submit_the_form_with_valid_details
-
- then_the_boost_has_been_created
- and_i_can_see_its_details
- end
-
- scenario "Attempting to create a boost with invalid data" do
- when_i_visit_the_boosts_page
- and_i_choose_to_create_a_new_boost
- and_i_submit_the_form_with_invalid_details
-
- then_the_boost_has_not_been_created
- and_i_can_see_what_errors_i_need_to_fix
- end
-
- scenario "Editing an existing boost" do
- given_a_boost
-
- when_i_go_to_view_the_boost
- and_i_choose_to_edit_it
- and_i_submit_the_form_with_updated_details
-
- then_the_boost_has_been_updated
- and_i_can_see_the_new_details
- end
-
- scenario "Attempting to edit a boost with invalid data" do
- given_a_boost
-
- when_i_go_to_view_the_boost
- and_i_choose_to_edit_it
- and_i_submit_the_form_with_invalid_details
-
- then_the_boost_has_not_been_updated
- and_i_can_see_what_errors_i_need_to_fix
- end
-
- scenario "Deleting an existing boost" do
- given_a_boost
-
- when_i_go_to_view_the_boost
- and_i_choose_to_delete_it
-
- then_the_boost_has_been_deleted_locally
- and_i_am_notified_of_the_deletion
- end
-
- def given_several_boosts
- @boost1 = create(:boost, name: "Boost 1")
- @boost2 = create(:boost, name: "Boost 2")
- end
-
- def given_a_boost
- @boost = create(
- :boost,
- name: "Boost",
- active: true,
- boost_amount: 0.42,
- filter: 'foo: ANY("bar")',
- )
- end
-
- def when_i_visit_the_boosts_page
- visit "/"
- click_on "Boosts"
- end
-
- def when_i_go_to_view_the_boost
- visit boosts_path
- click_on "Boost"
- end
-
- def and_i_choose_to_create_a_new_boost
- click_on "New boost"
- end
-
- def and_i_submit_the_form_with_valid_details
- fill_in "Name", with: "New boost"
- fill_in "Boost amount", with: 0.42
- fill_in "Filter", with: 'foo: ANY("bar")'
- check "Activate boost"
- click_on "Save"
- end
-
- def and_i_submit_the_form_with_invalid_details
- fill_in "Name", with: ""
- fill_in "Boost amount", with: 42.0
- fill_in "Filter", with: ""
- check "Activate boost"
- click_on "Save"
- end
-
- def and_i_choose_to_edit_it
- click_on "Edit"
- end
-
- def and_i_submit_the_form_with_updated_details
- fill_in "Name", with: "Updated boost"
- fill_in "Boost amount", with: 0.84
- fill_in "Filter", with: 'foo: ANY("bubble")'
- uncheck "Activate boost"
- click_on "Save"
- end
-
- def and_i_choose_to_delete_it
- click_on "Delete"
- end
-
- def then_the_boost_has_not_been_created
- expect(Boost.count).to eq(0)
- end
-
- def and_i_can_see_what_errors_i_need_to_fix
- expect(page).to have_content("Name can't be blank")
- expect(page).to have_content("Filter expression can't be blank")
- expect(page).to have_content("Boost amount must be less than or equal to 1.0")
- end
-
- def then_all_boosts_are_displayed
- expect(page).to have_link("Boost 1")
- expect(page).to have_link("Boost 2")
- end
-
- def then_i_can_see_the_details_of_the_boost
- expect(page).to have_selector("h1", text: "Boost")
- expect(page).to have_content("Status Active")
- expect(page).to have_content("Boost amount 0.42")
- expect(page).to have_content('Filter expression foo: ANY("bar")')
- end
-
- def then_the_boost_has_been_created
- expect(Boost.count).to eq(1)
-
- boost = Boost.first
- expect(boost.name).to eq("New boost")
- expect(boost).to be_active
- expect(boost.boost_amount).to eq(0.42)
- expect(boost.filter).to eq('foo: ANY("bar")')
- end
-
- def and_i_can_see_its_details
- expect(page).to have_selector("h1", text: "New boost")
- expect(page).to have_content("Status Active")
- expect(page).to have_content("Boost amount 0.42")
- expect(page).to have_content('Filter expression foo: ANY("bar")')
- end
-
- def then_the_boost_has_been_updated
- @boost.reload
-
- expect(@boost.name).to eq("Updated boost")
- expect(@boost).not_to be_active
- expect(@boost.boost_amount).to eq(0.84)
- expect(@boost.filter).to eq('foo: ANY("bubble")')
- end
-
- def and_i_can_see_the_new_details
- expect(page).to have_selector("h1", text: "Updated boost")
- expect(page).to have_content("Status Not active")
- expect(page).to have_content("Boost amount 0.84")
- expect(page).to have_content('Filter expression foo: ANY("bubble")')
- end
-
- def then_the_boost_has_not_been_updated
- @boost.reload
-
- expect(@boost.name).to eq("Boost")
- expect(@boost).to be_active
- expect(@boost.boost_amount).to eq(0.42)
- expect(@boost.filter).to eq('foo: ANY("bar")')
- end
-
- def then_the_boost_has_been_deleted_locally
- expect(Boost.count).to eq(0)
- end
-
- def and_i_am_notified_of_the_deletion
- expect(page).to have_content("Boost deleted successfully")
- end
-end