Skip to content

Commit

Permalink
Merge pull request #4093 from DFE-Digital/1340-find-improving-the-vis…
Browse files Browse the repository at this point in the history
…ibility-of-fees

[1340] Improve the visibility of fees
  • Loading branch information
avinhurry authored Mar 6, 2024
2 parents 32513be + a43852b commit a8d6a41
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/components/find/courses/summary_component/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<dt class="app-description-list__label">Visa sponsorship</dt>
<dd data-qa="course__visa_sponsorship"><%= visa_sponsorship_row %></dd>

<% unless no_fee? %>
<dt class="app-description-list__label">Course fee</dt>
<dd data-qa="course__fee"><%= course_fee_value %></dd>
<% end %>

<dt class="app-description-list__label">Qualification</dt>
<%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %>
<% if age_range_in_years.present? %>
Expand Down
20 changes: 20 additions & 0 deletions app/components/find/courses/summary_component/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ def visa_sponsorship_row
'Visas cannot be sponsored'
end
end

def course_fee_value
safe_join([formatted_uk_eu_fee_label, tag.br, formatted_international_fee_label])
end

def formatted_uk_eu_fee_label
return if course.fee_uk_eu.blank?

"UK students: #{number_to_currency(course.fee_uk_eu)}"
end

def formatted_international_fee_label
return if course.fee_international.blank?

"International students: #{number_to_currency(course.fee_international)}"
end

def no_fee?
course.fee_international.blank? && course.fee_uk_eu.blank?
end
end
end
end
Expand Down
29 changes: 18 additions & 11 deletions app/components/find/results/search_result_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@
<% end %>
</h2>
<dl class="app-description-list app-description-list--search-result">
<dt class="app-description-list__label">Study type</dt>
<dd data-qa="course__study_mode"><%= course.study_mode.humanize %></dd>

<dt class="app-description-list__label">Fee or salary</dt>
<dd data-qa="course__funding_options"><%= course.funding %>
<br>
<p class="govuk-hint"><%= course.funding_option %>
</dd>

<% unless no_fee? %>
<dt class="app-description-list__label">Course fee</dt>
<dd data-qa="course__fee"><%= course_fee_value %></dd>
<% end %>

<dt class="app-description-list__label">Visa sponsorship</dt>
<dd data-qa="course__visa_sponsorship"><%= visa_sponsorship_status %></dd>

<dt class="app-description-list__label">Qualification</dt>
<dd data-qa="course__qualification">
<% if accredited_provider %>
Expand All @@ -18,6 +31,9 @@
<% end %>
</dd>

<dt class="app-description-list__label">Study type</dt>
<dd data-qa="course__study_mode"><%= course.study_mode.humanize %></dd>

<% if filtered_by_location? && has_sites? %>
<% if course.university_based? %>
<%= render partial: "find/results/university", locals: { course: } %>
Expand All @@ -26,16 +42,7 @@
<% end %>
<% end %>

<dt class="app-description-list__label">Fee or salary</dt>
<dd data-qa="course__funding_options"><%= course.funding %>
<br>
<p class="govuk-hint"><%= course.funding_option %>
</dd>

<dt class="app-description-list__label">Degree required</dt>
<dd data-qa="course__degree_required"><%= degree_required_status %></dd>

<dt class="app-description-list__label">Visa sponsorship</dt>
<dd data-qa="course__visa_sponsorship"><%= visa_sponsorship_status %></dd>
</dl>
</li>
20 changes: 20 additions & 0 deletions app/components/find/results/search_result_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ def visa_sponsorship_status
end
end

def course_fee_value
safe_join([formatted_uk_eu_fee_label, tag.br, formatted_international_fee_label])
end

def formatted_uk_eu_fee_label
return if course.fee_uk_eu.blank?

"UK students: #{number_to_currency(course.fee_uk_eu)}"
end

def formatted_international_fee_label
return if course.fee_international.blank?

"International students: #{number_to_currency(course.fee_international)}"
end

def no_fee?
course.fee_international.blank? && course.fee_uk_eu.blank?
end

def accredited_provider
return nil if course.accrediting_provider.blank?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def mock_primary_course

class FakeCourse
include ActiveModel::Model
attr_accessor(:provider, :accrediting_provider, :has_bursary, :age_range_in_years, :course_length, :applications_open_from, :start_date, :qualification, :funding_type, :subjects, :level, :can_sponsor_student_visa)
attr_accessor(:provider, :accrediting_provider, :has_bursary, :age_range_in_years, :course_length, :applications_open_from, :start_date, :qualification, :funding_type, :subjects, :level, :can_sponsor_student_visa, :fee_uk_eu, :fee_international)

def has_bursary?
has_bursary
Expand Down
53 changes: 53 additions & 0 deletions spec/components/find/courses/sumary_component/view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,59 @@ module SummaryComponent
expect(result.text).to include('Visas cannot be sponsored')
end
end

context 'when there are UK fees' do
it 'renders the uk fees' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250)]).decorate

result = render_inline(described_class.new(course))
expect(result.text).to include('UK students: £9,250')
expect(result.text).to include('Course fee')
end
end

context 'when there are international fees' do
it 'renders the international fees' do
course = create(:course, enrichments: [create(:course_enrichment, fee_international: 14_000)]).decorate

result = render_inline(described_class.new(course))
expect(result.text).to include('International students: £14,000')
end
end

context 'when there are uk fees but no international fees' do
it 'renders the uk fees and not the internation fee label' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250, fee_international: nil)]).decorate

result = render_inline(described_class.new(course))

expect(result.text).to include('UK students: £9,250')
expect(result.text).not_to include('International students')
end
end

context 'when there are international fees but no uk fees' do
it 'renders the international fees but not the uk fee label' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: 14_000)]).decorate

result = render_inline(described_class.new(course))

expect(result.text).not_to include('UK students')
expect(result.text).to include('International students: £14,000')
end
end

context 'when there are no fees' do
it 'does not render the row' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: nil)]).decorate

result = render_inline(described_class.new(course))

expect(result.text).not_to include('UK students')
expect(result.text).not_to include('International students: £14,000')
expect(result.text).not_to include('Course fee')
end
end
end
end
end
Expand Down
53 changes: 53 additions & 0 deletions spec/components/find/results/search_result_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,58 @@ module Find
expect(result.text).not_to include('QTS ratified by')
end
end

context 'when there are UK fees' do
it 'renders the uk fees' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250)]).decorate

result = render_inline(described_class.new(course:))
expect(result.text).to include('UK students: £9,250')
expect(result.text).to include('Course fee')
end
end

context 'when there are international fees' do
it 'renders the international fees' do
course = create(:course, enrichments: [create(:course_enrichment, fee_international: 14_000)]).decorate

result = render_inline(described_class.new(course:))
expect(result.text).to include('International students: £14,000')
end
end

context 'when there are uk fees but no international fees' do
it 'renders the uk fees and not the internation fee label' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250, fee_international: nil)]).decorate

result = render_inline(described_class.new(course:))

expect(result.text).to include('UK students: £9,250')
expect(result.text).not_to include('International students')
end
end

context 'when there are international fees but no uk fees' do
it 'renders the international fees but not the uk fee label' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: 14_000)]).decorate

result = render_inline(described_class.new(course:))

expect(result.text).not_to include('UK students')
expect(result.text).to include('International students: £14,000')
end
end

context 'when there are no fees' do
it 'does not render the row' do
course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: nil)]).decorate

result = render_inline(described_class.new(course:))

expect(result.text).not_to include('UK students')
expect(result.text).not_to include('International students: £14,000')
expect(result.text).not_to include('Course fee')
end
end
end
end

0 comments on commit a8d6a41

Please sign in to comment.