Skip to content

Commit

Permalink
chore(test): add live feedback settings test
Browse files Browse the repository at this point in the history
- for assessment edit page
  • Loading branch information
bivanalhar committed Sep 14, 2024
1 parent e83feb9 commit 6ff1bbb
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def autograded_params
end

def live_feedback_params
params.required(:live_feedback_settings).permit(:enabled, assessment_ids: [])
params.required(:live_feedback_settings).permit(:enabled)
end

# Randomized Assessment is temporarily hidden (PR#5406)
Expand Down
68 changes: 68 additions & 0 deletions spec/controllers/course/assessment/assessments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,73 @@
end
end
end

describe '#live_feedback_settings' do
render_views
let(:assessment) { create(:assessment, course: course) }
let(:lang_valid_for_codaveri) { Coursemology::Polyglot::Language::Python::Python3Point12.instance }
let(:lang_invalid_for_codaveri) { Coursemology::Polyglot::Language::Java::Java8.instance }
let!(:programming_qn1) do
create(:course_assessment_question_programming, assessment: assessment,
language: lang_valid_for_codaveri,
template_package: true)
end
let!(:programming_qn2) do
create(:course_assessment_question_programming, assessment: assessment,
language: lang_invalid_for_codaveri,
template_package: true)
end

subject do
get :live_feedback_settings, as: :json, params: {
course_id: course.id,
id: assessment.id
}
end

context 'on fetching the live feedback settings for this assessment' do
it 'returns programming languages that has valid languages for codaveri' do
subject

json_result = JSON.parse(response.body)
expect(json_result['assessments'][0]['programmingQuestions'].count).to eq(1)
end
end
end

describe '#update_live_feedback_settings' do
let(:assessment) { create(:assessment, course: course) }
let(:lang_valid_for_codaveri) { Coursemology::Polyglot::Language::Python::Python3Point12.instance }
let(:lang_invalid_for_codaveri) { Coursemology::Polyglot::Language::Java::Java8.instance }
let!(:programming_qn1) do
create(:course_assessment_question_programming, assessment: assessment,
language: lang_valid_for_codaveri,
template_package: true)
end
let!(:programming_qn2) do
create(:course_assessment_question_programming, assessment: assessment,
language: lang_valid_for_codaveri,
template_package: true)
end

subject do
patch :update_live_feedback_settings, params: {
course_id: course.id,
id: assessment.id,
live_feedback_settings: {
enabled: true
}
}
end

context 'on fetching the live feedback settings for this assessment' do
it 'returns programming languages that has valid languages for codaveri' do
subject

expect(programming_qn1.reload.live_feedback_enabled).to eq(true)
expect(programming_qn2.reload.live_feedback_enabled).to eq(true)
end
end
end
end
end

0 comments on commit 6ff1bbb

Please sign in to comment.