Skip to content

Commit

Permalink
Merge pull request #4383 from mishaschwartz/v1.8.4
Browse files Browse the repository at this point in the history
v1.8.4
  • Loading branch information
mishaschwartz authored Feb 18, 2020
2 parents 5183c06 + eb08ebe commit b2af0bf
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## [v1.8.4]
- Fixed bug where test output was not being properly hidden from students (#4379)
- Fixed bug where certain fonts were not rendered properly using pdfjs (#4382)

## [v1.8.3]
- Fixed bug where grace credits were not displayed to Graders viewing the submissions table (#4332)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/Components/Result/pdf_viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class PDFViewer extends React.Component {
if (this.props.url) {
this.pdfViewer = new pdfjsViewer.PDFViewer({
container: this.pdfContainer.current,
renderer: 'svg',
// renderer: 'svg', TODO: investigate why some fonts don't render with SVG
});
this.loadPDFFile();
window.pdfViewer = this.pdfViewer; // For fixing display when pane width changes
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/grader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
cursor: crosshair;
opacity: 0.2;
position: absolute;
z-index: 1;
}

.code_scroller {
Expand Down
6 changes: 3 additions & 3 deletions app/models/grouping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ def test_runs_instructors_released(submission)
filtered = filter_test_runs(filters: { 'users.type': 'Admin', 'test_runs.submission': submission })
plucked = Grouping.pluck_test_runs(filtered)
plucked.map! do |data|
if data['test_groups.display_output'] == 'instructors_and_student_tests' ||
data['test_groups.display_output'] == 'instructors'
if data['test_groups.display_output'] == TestGroup.display_outputs[:instructors_and_student_tests] ||
data['test_groups.display_output'] == TestGroup.display_outputs[:instructors]
data.delete('test_results.output')
end
data.delete('test_group_results.extra_info')
Expand All @@ -729,7 +729,7 @@ def test_runs_students
filtered = filter_test_runs(filters: { 'test_runs.user': self.accepted_students })
plucked = Grouping.pluck_test_runs(filtered)
plucked.map! do |data|
if data['test_groups.display_output'] == 'instructors'
if data['test_groups.display_output'] == TestGroup.display_outputs[:instructors]
data.delete('test_results.output')
end
data.delete('test_group_results.extra_info')
Expand Down
11 changes: 11 additions & 0 deletions spec/factories/test_results.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FactoryBot.define do
factory :test_result do
name { Faker::Lorem.word }
status { 'pass' }
marks_earned { 1 }
output { Faker::TvShows::HeyArnold.quote }
marks_total { 1 }
association :test_group_result
time { Faker::Number.number(digits: 4) }
end
end
102 changes: 102 additions & 0 deletions spec/models/grouping_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1098,4 +1098,106 @@ def expect_updated_criteria_coverage_count_eq(expected_count)
end
end
end

shared_examples 'test run data' do |return_data, show_output, show_extra|
if return_data
it 'should return data for the test run' do
expect(data.length).to eq 1
expect(data[0]['test_runs.id']).to eq test_run.id
end

it 'should return data for the test result' do
test_result_data = data[0]['test_data']
expect(test_result_data.length).to eq 1
expect(test_result_data[0]['test_runs.id']).to eq test_run.id
end

if show_extra
it 'should show extra info' do
expect(data[0]['test_data'][0]['test_group_results.extra_info']).not_to be_nil
end
else
it 'should not show extra info' do
expect(data[0]['test_data'][0]['test_group_results.extra_info']).to be_nil
end
end

if show_output
it 'should show output data' do
expect(data[0]['test_data'][0]['test_results.output']).not_to be_nil
end
else
it 'should not show output data' do
expect(data[0]['test_data'][0]['test_results.output']).to be_nil
end
end
else
it 'should not return data' do
expect(data).to be_empty
end
end
end

context 'getting test run data' do
let(:grouping) { create :grouping_with_inviter }
let(:test_run) { create :test_run, grouping: grouping, user: test_runner, submission: submission }
let(:display_output) { 'instructors' }
let(:test_group) { create :test_group, assignment: grouping.assignment, display_output: display_output }
let(:test_group_result) { create :test_group_result, test_run: test_run, test_group: test_group, extra_info: 'AAA' }
let!(:test_result) { create :test_result, test_group_result: test_group_result }

context 'tests run by instructors' do
let(:test_runner) { create :admin }
let(:submission) { create :version_used_submission }
describe '#test_runs_instructors' do
let(:data) { grouping.test_runs_instructors(submission) }
it_behaves_like 'test run data', true, true, true
end
describe '#test_runs_instructors_released' do
let(:data) { grouping.test_runs_instructors_released(submission) }
context 'when display_output is instructors' do
it_behaves_like 'test run data', true, false
end
context 'when display_output is instructors_and_student_tests' do
let(:display_output) { 'instructors_and_student_tests' }
it_behaves_like 'test run data', true, false
end
context 'when display_output is instructors_and_students' do
let(:display_output) { 'instructors_and_students' }
it_behaves_like 'test run data', true, true
end
end
describe '#test_runs_students' do
let(:data) { grouping.test_runs_students }
it_behaves_like 'test run data', false
end
end

context 'tests run by students' do
let(:submission) { nil }
let(:test_runner) { grouping.inviter }
describe '#test_runs_instructors' do
let(:data) { grouping.test_runs_instructors(submission) }
it_behaves_like 'test run data', false
end
describe '#test_runs_instructors_released' do
let(:data) { grouping.test_runs_instructors_released(submission) }
it_behaves_like 'test run data', false
end
describe '#test_runs_students' do
let(:data) { grouping.test_runs_students }
context 'when display_output is instructors' do
it_behaves_like 'test run data', true, false
end
context 'when display_output is instructors_and_student_tests' do
let(:display_output) { 'instructors_and_student_tests' }
it_behaves_like 'test run data', true, true
end
context 'when display_output is instructors_and_students' do
let(:display_output) { 'instructors_and_students' }
it_behaves_like 'test run data', true, true
end
end
end
end
end

0 comments on commit b2af0bf

Please sign in to comment.