Remove unused SubmissionsController#stop action
This commit is contained in:
@ -163,12 +163,11 @@ CodeOceanEditorSubmissions = {
|
|||||||
|
|
||||||
runSubmission: function (submission) {
|
runSubmission: function (submission) {
|
||||||
//Run part starts here
|
//Run part starts here
|
||||||
$('#stop').data('url', submission.stop_url);
|
|
||||||
this.running = true;
|
this.running = true;
|
||||||
this.showSpinner($('#run'));
|
this.showSpinner($('#run'));
|
||||||
$('#score_div').addClass('d-none');
|
$('#score_div').addClass('d-none');
|
||||||
this.toggleButtonStates();
|
this.toggleButtonStates();
|
||||||
var url = submission.run_url.replace(this.FILENAME_URL_PLACEHOLDER, CodeOceanEditor.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor
|
const url = submission.run_url.replace(this.FILENAME_URL_PLACEHOLDER, CodeOceanEditor.active_file.filename.replace(/#$/,'')); // remove # if it is the last character, this is not part of the filename and just an anchor
|
||||||
this.initializeSocketForRunning(url);
|
this.initializeSocketForRunning(url);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -412,16 +412,6 @@ class SubmissionsController < ApplicationController
|
|||||||
def statistics
|
def statistics
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop
|
|
||||||
Rails.logger.debug('stopping submission ' + @submission.id.to_s)
|
|
||||||
container = Docker::Container.get(params[:container_id])
|
|
||||||
DockerClient.destroy_container(container)
|
|
||||||
rescue Docker::Error::NotFoundError => error
|
|
||||||
Sentry.capture_exception(error)
|
|
||||||
ensure
|
|
||||||
head :ok
|
|
||||||
end
|
|
||||||
|
|
||||||
def test
|
def test
|
||||||
hijack do |tubesock|
|
hijack do |tubesock|
|
||||||
unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
json.extract! @submission, :id, :files
|
json.extract! @submission, :id, :files
|
||||||
json.download_url download_submission_path(@submission, format: :json)
|
json.download_url download_submission_path(@submission, format: :json)
|
||||||
json.score_url score_submission_path(@submission, format: :json)
|
json.score_url score_submission_path(@submission, format: :json)
|
||||||
json.stop_url stop_submission_path(@submission, format: :json)
|
|
||||||
json.download_file_url download_file_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/, '{filename}.json')
|
json.download_file_url download_file_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/, '{filename}.json')
|
||||||
json.render_url render_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/, '{filename}.json')
|
json.render_url render_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/, '{filename}.json')
|
||||||
json.run_url run_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/, '{filename}.json')
|
json.run_url run_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/, '{filename}.json')
|
||||||
|
@ -148,7 +148,6 @@ Rails.application.routes.draw do
|
|||||||
get 'run/:filename', as: :run, constraints: {filename: FILENAME_REGEXP}, action: :run
|
get 'run/:filename', as: :run, constraints: {filename: FILENAME_REGEXP}, action: :run
|
||||||
get :score
|
get :score
|
||||||
get :statistics
|
get :statistics
|
||||||
post :stop
|
|
||||||
get 'test/:filename', as: :test, constraints: {filename: FILENAME_REGEXP}, action: :test
|
get 'test/:filename', as: :test, constraints: {filename: FILENAME_REGEXP}, action: :test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -191,13 +191,11 @@ describe SubmissionsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[:score, :stop].each do |action|
|
describe "#score_url" do
|
||||||
describe "##{action}_url" do
|
let(:url) { JSON.parse(response.body).with_indifferent_access.fetch("score_url") }
|
||||||
let(:url) { JSON.parse(response.body).with_indifferent_access.fetch("#{action}_url") }
|
|
||||||
|
|
||||||
it "corresponds to the #{action} path" do
|
it "corresponds to the score path" do
|
||||||
expect(url).to eq(Rails.application.routes.url_helpers.send(:"#{action}_submission_path", submission, format: :json))
|
expect(url).to eq(Rails.application.routes.url_helpers.score_submission_path(submission, format: :json))
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -209,37 +207,6 @@ describe SubmissionsController do
|
|||||||
pending("todo: mock puma webserver or encapsulate tubesock call (Tubesock::HijackNotAvailable)")
|
pending("todo: mock puma webserver or encapsulate tubesock call (Tubesock::HijackNotAvailable)")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #stop' do
|
|
||||||
let(:perform_request) { proc { post :stop, params: { container_id: CONTAINER.id, id: submission.id } } }
|
|
||||||
|
|
||||||
context 'when the container can be found' do
|
|
||||||
before(:each) do
|
|
||||||
expect(Docker::Container).to receive(:get).and_return(CONTAINER)
|
|
||||||
#expect(Rails.logger).to receive(:debug).at_least(:once).and_call_original
|
|
||||||
perform_request.call
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'renders nothing' do
|
|
||||||
expect(response.body).to be_blank
|
|
||||||
end
|
|
||||||
|
|
||||||
expect_status(200)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when the container cannot be found' do
|
|
||||||
before(:each) do
|
|
||||||
expect(Docker::Container).to receive(:get).and_raise(Docker::Error::NotFoundError)
|
|
||||||
perform_request.call
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'renders nothing' do
|
|
||||||
expect(response.body).to be_blank
|
|
||||||
end
|
|
||||||
|
|
||||||
expect_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #test' do
|
describe 'GET #test' do
|
||||||
let(:filename) { submission.collect_files.detect(&:teacher_defined_assessment?).name_with_extension }
|
let(:filename) { submission.collect_files.detect(&:teacher_defined_assessment?).name_with_extension }
|
||||||
let(:output) { {} }
|
let(:output) { {} }
|
||||||
|
Reference in New Issue
Block a user