Skip to content

Commit

Permalink
removed duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
Donny Wong committed Aug 15, 2024
1 parent 9a5b278 commit 21f1147
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 186 deletions.
3 changes: 0 additions & 3 deletions .dockerfiles/entrypoint-dev-rails.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ npm list &> /dev/null || npm ci
# install chromium (for nbconvert webpdf conversion)
./venv/bin/python3 -m playwright install chromium

# install chromium (for nbconvert webpdf conversion)
./venv/bin/python3 -m playwright install chromium

# setup the database (checks for db existence first)
until pg_isready -q; do
echo "waiting for database to start up"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ jobs:
run: bundle exec rails db:migrate
- name: Install chromedriver
uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: '119.0.6045.199'
- name: Run chromedriver
run: chromedriver --whitelisted-ips &
- name: Run rspec tests
Expand Down
19 changes: 0 additions & 19 deletions spec/controllers/api/feedback_files_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,6 @@
).not_to include(*feedback_files_with_test_run.pluck(:id)) # rubocop:disable Rails/PluckId
end
end

context 'when feedback files with no submission exist' do
before do
request.env['HTTP_ACCEPT'] = 'application/json'
feedback_files
feedback_files_with_test_run
end

it 'should not return info about feedback files if not related to the submission' do
get :index, params: {
group_id: grouping.group.id,
assignment_id: grouping.assignment.id,
course_id: course.id
}
expect(
response.parsed_body.pluck('id')
).not_to include(*feedback_files_with_test_run.pluck(:id)) # rubocop:disable Rails/PluckId
end
end
end

context 'GET show' do
Expand Down
73 changes: 0 additions & 73 deletions spec/controllers/api/starter_file_groups_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,25 +355,6 @@
expect(File).not_to exist(File.expand_path(File.join(starter_file_group.path, '../../../a')))
end
end

context 'when the path given is invalid' do
let(:starter_file_group) { create(:starter_file_group_with_entries, assignment: assignment) }

before do
post :create_file, params: { filename: '../../../a',
file_content: 'a',
course_id: course.id,
id: starter_file_group.id }
end

it 'returns a 422 status code' do
expect(response).to have_http_status(:unprocessable_entity)
end

it 'does not create the file' do
expect(File).not_to exist(File.expand_path(File.join(starter_file_group.path, '../../../a')))
end
end
end

describe '#create_folder' do
Expand Down Expand Up @@ -437,24 +418,6 @@
expect(Dir).not_to exist(File.expand_path(File.join(starter_file_group.path, '../../../a')))
end
end

context 'when the path given is invalid' do
let(:starter_file_group) { create(:starter_file_group_with_entries, assignment: assignment) }

before do
post :create_folder, params: { folder_path: '../../../a',
course_id: course.id,
id: starter_file_group.id }
end

it 'returns a 422 status code' do
expect(response).to have_http_status(:unprocessable_entity)
end

it 'does not create the folder' do
expect(Dir).not_to exist(File.expand_path(File.join(starter_file_group.path, '../../../a')))
end
end
end

describe '#remove_file' do
Expand Down Expand Up @@ -518,24 +481,6 @@
expect(File).to exist(File.expand_path(File.join(starter_file_group.path, '../../../../../LICENSE')))
end
end

context 'when the path given is invalid' do
let(:starter_file_group) { create(:starter_file_group_with_entries, assignment: assignment) }

before do
post :remove_file, params: { filename: '../../../../../LICENSE',
course_id: course.id,
id: starter_file_group.id }
end

it 'returns a 422 status code' do
expect(response).to have_http_status(:unprocessable_entity)
end

it 'does not delete the file' do
expect(File).to exist(File.expand_path(File.join(starter_file_group.path, '../../../../../LICENSE')))
end
end
end

describe '#remove_folder' do
Expand Down Expand Up @@ -602,24 +547,6 @@
expect(Dir).to exist(File.expand_path(File.join(starter_file_group.path, '../../../../../doc')))
end
end

context 'when the path given is invalid' do
let(:starter_file_group) { create(:starter_file_group_with_entries, assignment: assignment) }

before do
post :remove_folder, params: { folder_path: '../../../../../doc',
course_id: course.id,
id: starter_file_group.id }
end

it 'returns a 422 status code' do
expect(response).to have_http_status(:unprocessable_entity)
end

it 'does not delete the folder' do
expect(Dir).to exist(File.expand_path(File.join(starter_file_group.path, '../../../../../doc')))
end
end
end

describe '#entries' do
Expand Down
28 changes: 0 additions & 28 deletions spec/controllers/exam_templates_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,34 +307,6 @@
end
end
end

describe '#download_generate' do
context 'when the filename is invalid' do
before do
get_as user, :download_generate,
params: { assignment_id: exam_template.assignment.id, course_id: course.id, id: exam_template.id,
file_name: '../../a.pdf' }
end

it 'responds with an error status code' do
expect(response).to have_http_status(:unprocessable_entity)
end
end
end

describe '#download_error_file' do
context 'when the filename is invalid' do
before do
get_as user, :download_error_file,
params: { assignment_id: exam_template.assignment.id, course_id: course.id, id: exam_template.id,
file_name: '../../a.pdf' }
end

it 'responds with an error status code' do
expect(response).to have_http_status(:unprocessable_entity)
end
end
end
end

describe 'When the user is instructor' do
Expand Down
35 changes: 0 additions & 35 deletions spec/controllers/peer_reviews_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,39 +341,4 @@
expect(final_grades).to all eq(max_mark)
end
end

describe 'When listing peer reviews in Peer Reviews tab' do
let(:instructor) { create(:instructor) }
let(:max_mark) { 3 }

before do
PeerReview.create(reviewer_id: @selected_reviewer_group_ids[0],
result_id: Grouping.find(@selected_reviewee_group_ids[1]).current_result.id)
PeerReview.create(reviewer_id: @selected_reviewer_group_ids[1],
result_id: Grouping.find(@selected_reviewee_group_ids[2]).current_result.id)
PeerReview.create(reviewer_id: @selected_reviewer_group_ids[2],
result_id: Grouping.find(@selected_reviewee_group_ids[0]).current_result.id)
end

it 'should list out total marks for each peer review' do
create_list(:flexible_criterion, 1, assignment: @assignment_with_pr.pr_assignment)
@assignment_with_pr.pr_assignment.criteria.first.update(peer_visible: true)
@assignment_with_pr.pr_assignment.criteria.first.update(max_mark: max_mark)

@assignment_with_pr.pr_assignment.groupings.each do |grouping|
result = grouping.peer_reviews_to_others.first.result
@assignment_with_pr.pr_assignment.criteria.each do |c|
mark = c.marks.find_or_create_by(result_id: result.id)
mark.update(mark: max_mark)
end
result.update(marking_state: Result::MARKING_STATES[:complete])
end

response = get_as instructor, :populate_table,
params: { course_id: @assignment_with_pr.pr_assignment.course.id, assignment_id: @pr_id }
response_hash = JSON.parse(response.body)
final_grades = response_hash.pluck('final_grade')
expect(final_grades).to all eq(max_mark)
end
end
end
15 changes: 0 additions & 15 deletions spec/controllers/results_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2086,21 +2086,6 @@ def self.test_unauthorized(route_name)
end
end
end

describe '#run_tests' do
before do
assignment.update!(enable_test: true,
enable_student_tests: true,
unlimited_tokens: true,
token_start_date: 1.day.ago,
remote_autotest_settings_id: 1)
end

it 'enqueues an AutotestRunJob' do
params = { course_id: course.id, id: incomplete_result.id }
expect { post :run_tests, params: params }.to have_enqueued_job(AutotestRunJob)
end
end
end

context 'A TA' do
Expand Down
11 changes: 0 additions & 11 deletions spec/controllers/submissions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1463,17 +1463,6 @@
params: { course_id: course.id, assignment_id: assignment.id, groupings: grouping_ids, print: 'true' }
expect(subject).to respond_with(:success)
end

it 'should pass the print parameter to DownloadSubmissionsJob when given' do
expect(DownloadSubmissionsJob).to receive(:perform_later) do |_gids, _zip_file, _assignment_id, _course_id,
kwargs|
expect(kwargs[:print]).to be true
DownloadSubmissionsJob.new
end
post_as assigned_ta, :zip_groupings_files,
params: { course_id: course.id, assignment_id: assignment.id, groupings: grouping_ids, print: 'true' }
expect(subject).to respond_with(:success)
end
end

describe '#download_zipped_file' do
Expand Down

0 comments on commit 21f1147

Please sign in to comment.