-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4003 from DFE-Digital/1141-find-remove-reference-…
…to-provider-codes Refactor references to provider codes in view templates
- Loading branch information
Showing
12 changed files
with
362 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Configs | ||
class CourseInformation | ||
def initialize(course) | ||
@db = Rails.application.config_for(:course_information) | ||
@course = course | ||
end | ||
|
||
def show_placement_guidance?(type) | ||
case type | ||
when :provider_type | ||
subtype = @course.provider.provider_type | ||
when :program_type | ||
subtype = @course.program_type | ||
end | ||
|
||
@db.dig(:placements, type, subtype.to_sym, :except_provider_codes)&.exclude?(@course.provider.provider_code) | ||
end | ||
|
||
def contact_form | ||
@db.fetch(:contact_forms).stringify_keys[@course.provider.provider_code] | ||
end | ||
|
||
def contact_form? | ||
@db.fetch(:contact_forms).stringify_keys.include?(@course.provider.provider_code) | ||
end | ||
|
||
def show_address? | ||
@db.dig(:show_address, :only_provider_codes).include?(@course.provider.provider_code) && | ||
@db.dig(:show_address, :only_course_codes).include?(@course.course_code) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
shared: | ||
placements: | ||
provider_type: | ||
university: | ||
except_provider_codes: | ||
- B31 | ||
program_type: | ||
scitt_programme: | ||
except_provider_codes: | ||
- E65 | ||
higher_education_programme: | ||
except_provider_codes: | ||
- B31 | ||
show_address: | ||
only_provider_codes: | ||
- 28T | ||
only_course_codes: | ||
- X104 | ||
contact_forms: | ||
U80: https://www.ucl.ac.uk/prospective-students/graduate/admissions-enquiries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
spec/features/publish/courses/editing_course_information_guidance_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
feature 'Guidance components on course edit page', { can_edit_current_and_next_cycles: false } do | ||
describe 'university providers' do | ||
context 'when provider is excluded via config' do | ||
scenario 'Guidance is not shown' do | ||
given_a_provider_which_does_not_show_guidance | ||
and_the_provider_has_a_course | ||
and_i_am_authenticated_as_a_provider_user | ||
when_i_go_to_edit_a_course | ||
i_do_not_see_the_guidance_text | ||
end | ||
|
||
def given_a_provider_which_does_not_show_guidance | ||
@provider = create(:provider, :university, provider_code: 'B31') | ||
end | ||
end | ||
|
||
context 'when provider is not excluded via config' do | ||
scenario 'Guidance is shown' do | ||
given_a_provider_which_does_show_guidance | ||
and_the_provider_has_a_course | ||
and_i_am_authenticated_as_a_provider_user | ||
when_i_go_to_edit_a_course | ||
i_do_see_the_guidance_text | ||
end | ||
|
||
def given_a_provider_which_does_show_guidance | ||
@provider = create(:provider, :university, provider_code: 'XXX') | ||
end | ||
end | ||
end | ||
|
||
describe 'scitt courses' do | ||
context 'when provider is excluded via config' do | ||
scenario 'Guidance is not shown' do | ||
given_a_provider_which_does_not_show_guidance | ||
and_the_provider_has_a_course | ||
and_i_am_authenticated_as_a_provider_user | ||
when_i_go_to_edit_a_course | ||
i_do_not_see_the_guidance_text | ||
end | ||
|
||
def given_a_provider_which_does_not_show_guidance | ||
@provider = create(:provider, :scitt, provider_code: 'E65') | ||
end | ||
end | ||
|
||
context 'when provider is not excluded via config' do | ||
scenario 'Guidance is shown' do | ||
given_a_provider_which_does_show_guidance | ||
and_the_provider_has_a_course | ||
and_i_am_authenticated_as_a_provider_user | ||
when_i_go_to_edit_a_course | ||
i_do_see_the_guidance_text | ||
end | ||
|
||
def and_the_provider_has_a_course | ||
@course = create(:course, :with_scitt, provider: @provider) | ||
end | ||
|
||
def given_a_provider_which_does_show_guidance | ||
@provider = create(:provider, :scitt, provider_code: 'T92') | ||
end | ||
end | ||
end | ||
|
||
def and_the_provider_has_a_course | ||
@course = create(:course, provider: @provider) | ||
end | ||
|
||
def and_i_am_authenticated_as_a_provider_user | ||
given_i_am_authenticated | ||
@current_user.providers << @provider | ||
end | ||
|
||
def when_i_go_to_edit_a_course | ||
publish_course_information_edit_page.load( | ||
provider_code: @provider.provider_code, recruitment_cycle_year: @provider.recruitment_cycle_year, course_code: @course.course_code | ||
) | ||
end | ||
|
||
def i_do_not_see_the_guidance_text | ||
expect(page).to have_no_content('Where you will train') | ||
end | ||
|
||
def i_do_see_the_guidance_text | ||
expect(page).to have_content('Where you will train') | ||
end | ||
end |
Oops, something went wrong.