From 93e9ca651b5988d9488f252292dac44bf192078c Mon Sep 17 00:00:00 2001
From: sarahcrack <73823091+sarahcrack@users.noreply.github.com>
Date: Wed, 11 Dec 2024 15:50:36 +0000
Subject: [PATCH] removed show_title and ArgumentError as no longer needed,
added test to check for no title
---
app/components/content/results_box_component.html.erb | 2 +-
app/components/content/results_box_component.rb | 9 ++-------
spec/components/content/results_box_component_spec.rb | 4 +---
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/app/components/content/results_box_component.html.erb b/app/components/content/results_box_component.html.erb
index 8bf630228e..94cd262d2d 100644
--- a/app/components/content/results_box_component.html.erb
+++ b/app/components/content/results_box_component.html.erb
@@ -1,5 +1,5 @@
- <% if show_title %>
+ <% if title %>
<%= title %>
diff --git a/app/components/content/results_box_component.rb b/app/components/content/results_box_component.rb
index e73413b60f..e5bccf38f5 100644
--- a/app/components/content/results_box_component.rb
+++ b/app/components/content/results_box_component.rb
@@ -4,14 +4,10 @@ class ResultsBoxComponent < ViewComponent::Base
include ContentHelper
- def initialize(heading:, fee:, course_length:, funding:, text:, link_text:, link_target:, border_color: :grey, show_title: false, title: nil)
+ def initialize(heading:, fee:, course_length:, funding:, text:, link_text:, link_target:, title: nil, border_color: :grey)
super
- if show_title && title.nil?
- raise ArgumentError, "Title must be provided when show_title is true"
- end
-
- @title = show_title ? substitute_values(title) : nil
+ @title = substitute_values(title)
@heading = substitute_values(heading)
@fee = substitute_values(fee)
@course_length = substitute_values(course_length)
@@ -20,7 +16,6 @@ def initialize(heading:, fee:, course_length:, funding:, text:, link_text:, link
@link_text = link_text
@link_target = link_target
@border_color = border_color
- @show_title = show_title
end
def border_class
diff --git a/spec/components/content/results_box_component_spec.rb b/spec/components/content/results_box_component_spec.rb
index 46671ea51a..233c47b0ae 100644
--- a/spec/components/content/results_box_component_spec.rb
+++ b/spec/components/content/results_box_component_spec.rb
@@ -12,7 +12,6 @@
let(:funding) { "Scholarships or bursaries, as well as student loans, are available if you're eligible" }
let(:text) { "Find out which qualifications you need, what funding you can get and how to train to teach." }
let(:title) { nil }
- let(:show_title) { false }
let(:border_color) { :grey }
let(:link_text) { "Find out more about postgraduate initial teacher training" }
let(:link_target) { "/train-to-be-a-teacher" }
@@ -24,7 +23,6 @@
course_length: course_length,
funding: funding,
text: text,
- show_title: show_title,
title: title,
border_color: border_color,
link_text: link_text,
@@ -38,10 +36,10 @@
it { is_expected.to have_css(".results-box__value", text: course_length) }
it { is_expected.to have_css(".results-box__value", text: funding) }
it { is_expected.to have_css(".results-box--grey") }
+ it { is_expected.to have_no_css(".results-box__title", text: title) }
context "when a title is provided" do
let(:title) { "Most popular route" }
- let(:show_title) { true }
it { is_expected.to have_css(".results-box__title", text: title) }
end