-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change tda to non tda and vice versa #4367
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a0862ee
Ensure TDA defauls are handled when change the qualification
tomas-stefano 7981a2a
Don't show the TDA option when the course is non TDA and published
tomas-stefano 3bf9a85
Add methods that looks like a course model
tomas-stefano d63292c
Make sure you can't edit qualification when is published TDA
tomas-stefano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,7 +6,6 @@ class Course < ApplicationRecord | |
include ChangedAt | ||
include TouchProvider | ||
include Courses::EditOptions | ||
include StudyModeVacancyMapper | ||
include TimeFormat | ||
|
||
after_initialize :set_defaults | ||
|
@@ -811,8 +810,27 @@ def find_a_level_subject_requirement!(uuid) | |
requirement.with_indifferent_access | ||
end | ||
|
||
def ensure_site_statuses_match_full_time | ||
site_statuses.each do |site_status| | ||
update_vac_status('full_time', site_status) | ||
end | ||
end | ||
|
||
private | ||
|
||
def update_vac_status(study_mode, site_status) | ||
case study_mode | ||
when 'full_time' | ||
site_status.update(vac_status: :full_time_vacancies) | ||
when 'part_time' | ||
site_status.update(vac_status: :part_time_vacancies) | ||
when 'full_time_or_part_time' | ||
site_status.update(vac_status: :both_full_time_and_part_time_vacancies) | ||
else | ||
raise "Unexpected study mode #{study_mode}" | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method was in a controller concern and was included in the Course model (only on course) so I remove the module and move the code here. |
||
|
||
def add_site!(site:) | ||
is_course_new = ucas_status == :new | ||
site_status = site_statuses.find_or_initialize_by(site:) | ||
|
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
127 changes: 127 additions & 0 deletions
127
spec/controllers/publish/courses/outcome_controller_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,127 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Publish::Courses::OutcomeController do | ||
let(:recruitment_cycle) { create(:recruitment_cycle, year: 2025) } | ||
let(:user) { create(:user, providers: [build(:provider, recruitment_cycle:)]) } | ||
let(:provider) { user.providers.first } | ||
|
||
before do | ||
allow(controller).to receive(:authenticate).and_return(true) | ||
controller.instance_variable_set(:@current_user, user) | ||
allow(Settings.features).to receive(:teacher_degree_apprenticeship).and_return(true) | ||
end | ||
|
||
describe '#edit' do | ||
context 'when teacher degree apprenticeship published course' do | ||
it 'redirects to the course page' do | ||
course = create( | ||
:course, | ||
:resulting_in_undergraduate_degree_with_qts, | ||
:with_teacher_degree_apprenticeship, | ||
:published, | ||
provider:, | ||
study_mode: :part_time, | ||
site_statuses: [build(:site_status, :part_time_vacancies, :findable)] | ||
) | ||
|
||
get :edit, params: { | ||
provider_code: provider.provider_code, | ||
recruitment_cycle_year: provider.recruitment_cycle_year, | ||
code: course.course_code | ||
} | ||
|
||
expect(response).to redirect_to( | ||
publish_provider_recruitment_cycle_course_path( | ||
provider.provider_code, | ||
provider.recruitment_cycle_year, | ||
course.course_code | ||
) | ||
) | ||
end | ||
end | ||
|
||
context 'when teacher degree apprenticeship draft course' do | ||
it 'renders the edit outcome' do | ||
course = create( | ||
:course, | ||
:resulting_in_undergraduate_degree_with_qts, | ||
:with_teacher_degree_apprenticeship, | ||
:draft_enrichment, | ||
provider:, | ||
study_mode: :part_time, | ||
site_statuses: [build(:site_status, :part_time_vacancies, :findable)] | ||
) | ||
|
||
get :edit, params: { | ||
provider_code: provider.provider_code, | ||
recruitment_cycle_year: provider.recruitment_cycle_year, | ||
code: course.course_code | ||
} | ||
|
||
expect(response).to render_template(:edit) | ||
end | ||
end | ||
end | ||
|
||
describe '#update' do | ||
context 'when changing from a QTS to teacher degree apprenticeship course' do | ||
it 'assigns teacher degree apprenticeship course defaults' do | ||
course = create( | ||
:course, | ||
:resulting_in_qts, | ||
provider:, | ||
study_mode: :part_time, | ||
site_statuses: [build(:site_status, :part_time_vacancies, :findable)] | ||
) | ||
create(:course_enrichment, :initial_draft, course_length: :TwoYears, course:) | ||
|
||
put :update, params: { | ||
course: { qualification: 'undergraduate_degree_with_qts' }, | ||
provider_code: provider.provider_code, | ||
recruitment_cycle_year: provider.recruitment_cycle_year, | ||
code: course.course_code | ||
} | ||
|
||
course.reload | ||
|
||
expect(course.funding_type).to eq('apprenticeship') | ||
expect(course.can_sponsor_skilled_worker_visa).to be(false) | ||
expect(course.can_sponsor_student_visa).to be(false) | ||
expect(course.additional_degree_subject_requirements).to be(false) | ||
expect(course.degree_subject_requirements).to be_nil | ||
expect(course.degree_grade).to eq('not_required') | ||
expect(course.study_mode).to eq('full_time') | ||
expect(course.site_statuses.map(&:vac_status).uniq.first).to eq('full_time_vacancies') | ||
expect(course.enrichments.max_by(&:created_at).course_length).to eq('4 years') | ||
end | ||
end | ||
|
||
context 'when changing from teacher degree apprenticeship to a QTS course' do | ||
it 'clear teacher degree specific defaults' do | ||
course = create( | ||
:course, | ||
:with_teacher_degree_apprenticeship, | ||
:resulting_in_undergraduate_degree_with_qts, | ||
:with_a_level_requirements, | ||
provider: | ||
) | ||
|
||
put :update, params: { | ||
course: { qualification: 'qts' }, | ||
provider_code: provider.provider_code, | ||
recruitment_cycle_year: provider.recruitment_cycle_year, | ||
code: course.course_code | ||
} | ||
|
||
course.reload | ||
|
||
expect(course.a_level_subject_requirements).to eq([]) | ||
expect(course.accept_a_level_equivalency).to be_nil | ||
expect(course.accept_pending_a_level).to be_nil | ||
expect(course.additional_a_level_equivalencies).to be_nil | ||
end | ||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really wish one day to refactor the whole Edit options code because at least to me sounds wrong changing this module to remove an option in the view. And changing this module will affect different screens that uses the edit options.
I think the EditOption abstraction is bringing more problems than solutions. But maybe is just me.
To solve this bug I have to add the condition above.