Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
CatalinVoineag committed Jul 10, 2024
1 parent b26c791 commit f721c15
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 25 deletions.
10 changes: 0 additions & 10 deletions app/controllers/publish/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ def provider_params
)
end

def provider_params
params
.require(param_form_key)
.except(:goto_preview, :course_code, :goto_provider, :goto_training_with_disabilities)
.permit(
*AboutYourOrganisationForm::FIELDS,
accredited_bodies: %i[provider_name provider_code description]
)
end

def param_form_key = :publish_about_your_organisation_form

def redirect_params
Expand Down
13 changes: 8 additions & 5 deletions app/forms/publish/about_your_organisation_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

module Publish
class AboutYourOrganisationForm < BaseProviderForm
# validates :train_with_us, presence: { message: 'Enter details about training with you' }, if: :train_with_us_changed?
# validates :train_with_disability, presence: { message: 'Enter details about training with a disability' }, if: :train_with_disability_changed?
include Rails.application.routes.url_helpers

# validates :train_with_us, words_count: { maximum: 250, message: 'Reduce the word count for training with you' }
# validates :train_with_disability, words_count: { maximum: 250, message: 'Reduce the word count for training with disabilities and other needs' }
validates :train_with_us, presence: { message: 'Enter details about training with you' }, if: :train_with_us_changed?
validates :train_with_disability, presence: { message: 'Enter details about training with a disability' }, if: :train_with_disability_changed?

validates :train_with_us, words_count: { maximum: 250, message: 'Reduce the word count for training with you' }
validates :train_with_disability, words_count: { maximum: 250, message: 'Reduce the word count for training with disabilities and other needs' }

validate :add_enrichment_errors

# validate :add_enrichment_errors
def initialize(model, params: {}, redirect_params: {}, course_code: nil)
super(model, params:)
@redirect_params = redirect_params
Expand Down
3 changes: 1 addition & 2 deletions app/views/find/courses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@

<% if @provider.train_with_disability.present? %>
<h2 class="govuk-heading-l" id="section-train-with-disabilities">
<%= t('.training_with_disabilities') %>
<%= t(".training_with_disabilities") %>
</h2>


<p class="govuk-body">
<%= govuk_link_to(
t(".training_with_disabilities_link", provider_name: @course.provider_name),
Expand Down
2 changes: 1 addition & 1 deletion app/views/publish/courses/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<%= render Find::Courses::InternationalStudentsComponent::View.new(course:) %>

<h2 class="govuk-heading-l" id="section-train-with-disabilities">
<%= t('.training_with_disabilities') %>
<%= t(".training_with_disabilities") %>
</h2>

<p class="govuk-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module CoursePreview
how_school_placements_work:
school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true),
train_with_disability:
"#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true)}#train-with-disability",
"#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_training_with_disabilities: true)}#train-with-disability",
train_with_us:
"#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true)}#train-with-us",
about_accrediting_provider:
Expand Down
25 changes: 23 additions & 2 deletions spec/features/find/search/viewing_a_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

feature 'Viewing a findable course' do
include PublishHelper
include Rails.application.routes.url_helpers

before do
Timecop.travel(Find::CycleTimetable.mid_cycle)
Expand Down Expand Up @@ -89,6 +90,15 @@
then_i_should_be_on_the_course_page
end

scenario 'user views the training with disabilities page' do
given_there_is_a_findable_course
when_i_visit_the_course_page
when_i_click("Find out about training with disabilities and other needs at #{@course.provider_name}")
then_i_should_be_on_the_training_with_disabilities_page
when_i_click("Back to #{@course.name} (#{course.course_code})")
then_i_should_be_on_the_course_page
end

private

def given_there_is_a_findable_course
Expand Down Expand Up @@ -259,8 +269,8 @@ def then_i_should_see_the_course_information
'Certificate must be print in blue ink'
)

expect(find_course_show_page.train_with_disability).to have_content(
provider.train_with_disability
expect(find_course_show_page).to have_content(
'Training with disabilities and other needs'
)

expect(find_course_show_page.school_placements).to have_no_content('Suspended site with vacancies')
Expand Down Expand Up @@ -379,4 +389,15 @@ def then_i_should_be_on_the_course_page
).to_s
)
end

def then_i_should_be_on_the_training_with_disabilities_page
expect(find_course_show_page.train_with_disability).to have_content(
provider.train_with_disability
)

expect(page).to have_link(
"Contact #{course.provider_name}",
href: find_provider_path(@course.provider_code, @course.course_code)
)
end
end
27 changes: 23 additions & 4 deletions spec/features/publish/viewing_a_course_preview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'rails_helper'

feature 'Course show', { can_edit_current_and_next_cycles: false } do
include Rails.application.routes.url_helpers
context 'bursaries and scholarships is announced' do
before do
FeatureFlag.activate(:bursaries_and_scholarships_announced)
Expand Down Expand Up @@ -37,14 +38,17 @@
scenario 'blank training with disabilities and other needs' do
given_i_am_authenticated(user: user_with_no_course_enrichments)
when_i_visit_the_publish_course_preview_page
and_i_click_link_or_button("Find out about training with disabilities and other needs at #{@course.provider_name}")
and_i_click_link_or_button('Enter details about training with disabilities and other needs')
then_i_should_be_on_about_your_organisation_page
and_i_click_link_or_button('Back')
then_i_should_be_back_on_the_preview_page
then_i_should_be_on_the_training_with_disabilities_page
and_i_click_link_or_button('Enter details about training with disabilities and other needs')
and_i_submit_a_valid_about_your_organisation
then_i_should_be_back_on_the_preview_page
then_i_should_be_on_the_training_with_disabilities_page
then_i_should_see_the_updated_content('test training with disabilities')
and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})")
then_i_should_be_back_on_the_preview_page
end

scenario 'blank school placements section' do
Expand Down Expand Up @@ -239,8 +243,8 @@ def then_i_see_the_course_preview_details
'Financial support from the training provider'
)

expect(publish_course_preview_page.train_with_disability).to have_content(
provider.train_with_disability
expect(publish_course_preview_page).to have_content(
'Training with disabilities and other needs'
)

expect(publish_course_preview_page).to have_content '2:1 or above, or equivalent'
Expand Down Expand Up @@ -504,4 +508,19 @@ def then_i_should_be_on_the_accrediting_provider_page
decorated_course.about_accrediting_provider
)
end

def then_i_should_be_on_the_training_with_disabilities_page
expect(publish_course_preview_page.train_with_disability).to have_content(
provider.train_with_disability
)

expect(page).to have_link(
"Contact #{course.provider_name}",
href: provider_publish_provider_recruitment_cycle_course_path(
@course.provider_code,
@course.recruitment_cycle_year,
@course.course_code
)
)
end
end

0 comments on commit f721c15

Please sign in to comment.