Skip to content
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

Make sure degree requirements row doesn't appear for undergraduate #9845

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def start_date_row(application_choice)
end

def degree_required_row(application_choice)
return unless application_choice.current_course.degree_grade?
return if application_choice.current_course.does_not_require_degree?

{
key: 'Degree requirements',
Expand Down
4 changes: 4 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ def course_type
I18n.t('course_types.postgraduate')
end

def does_not_require_degree?
undergraduate? || !degree_grade?
end

private

def touch_application_choices_and_forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,41 @@
end
end
end

describe 'degree requirements' do
let(:application_choice) { create(:application_choice, course_option: create(:course_option, course:)) }

context 'when course is undergraduate but incorrectly has a degree_grade' do
let(:course) do
create(
:course,
:teacher_degree_apprenticeship,
degree_grade: 'two_one',
)
end

it 'does not render row' do
result = render_inline(described_class.new(application_choice:))
expect(result.text).not_to include('Degree requirements')
end
end

context 'when course is postgraduate and degree grade is present' do
let(:course) { create(:course, degree_grade: 'two_one') }

it 'does render row' do
result = render_inline(described_class.new(application_choice:))
expect(result.text).to include('Degree requirements')
end
end

context 'when course is postgraduate and degree grade is blank' do
let(:course) { create(:course, degree_grade: nil) }

it 'does not render row' do
result = render_inline(described_class.new(application_choice:))
expect(result.text).not_to include('Degree requirements')
end
end
end
end
31 changes: 31 additions & 0 deletions spec/models/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,35 @@
end
end
end

describe '#does_not_require_degree?' do
let(:course) { build(:course, program_type:, degree_grade:) }

context 'when the course is undergraduate' do
let(:program_type) { 'teacher_degree_apprenticeship' }
let(:degree_grade) { nil }

it 'returns true' do
expect(course.does_not_require_degree?).to be(true)
end
end

context 'when the course is postgraduate and does not require a degree grade' do
let(:program_type) { 'higher_education_programme' }
let(:degree_grade) { nil }

it 'returns true' do
expect(course.does_not_require_degree?).to be(true)
end
end

context 'when the course is postgraduate and requires a degree grade' do
let(:program_type) { 'higher_education_programme' }
let(:degree_grade) { 'two_one' }

it 'returns false' do
expect(course.does_not_require_degree?).to be(false)
end
end
end
end
Loading