submission controller spec - problem with Rails.logger.error

This commit is contained in:
yqbk
2016-06-14 16:07:44 +02:00
parent 4e5c3ba071
commit 195fd9c3f9
4 changed files with 7 additions and 3 deletions

View File

@ -22,7 +22,7 @@ module CodeOcean
path = options[:path].try(:call) || @object
respond_with_valid_object(format, notice: t('shared.object_created', model: @object.class.model_name.human), path: path, status: :created)
else
# i have deleted ".file_extension" due to error "undefined method `file_extension' for nil:NilClass"
# I have deleted ".file_extension" due to error "undefined method `file_extension' for nil:NilClass"
filename = (@object.path || '') + '/' + (@object.name || '') + (@object.file_type.file_extension || '')
format.html { redirect_to(options[:path]); flash[:danger] = t('files.error.filename', name: filename) }
format.json { render(json: @object.errors, status: :unprocessable_entity) }

View File

@ -8,7 +8,7 @@ class ErrorsController < ApplicationController
def create
@error = Error.new(error_params)
authorize @error
authorize!
hint = Whistleblower.new(execution_environment: @error.execution_environment).generate_hint(@error.message)
respond_to do |format|
format.json do

View File

@ -246,7 +246,8 @@ class SubmissionsController < ApplicationController
end
def stop
Rails.logger.debug('stopping submission ' + @submission)
# temporary disabled
# Rails.logger.error('stopping submission ' + @submission)
container = Docker::Container.get(params[:container_id])
DockerClient.destroy_container(container)
rescue Docker::Error::NotFoundError

View File

@ -200,6 +200,8 @@ describe SubmissionsController do
context 'when the container can be found' do
before(:each) do
#not sure where is a correct place for this call. Need to change structure of this test?
#expect(Rails.logger).to receive(:error).with(/error message/)
expect(Docker::Container).to receive(:get).and_return(CONTAINER)
request.call
end
@ -213,6 +215,7 @@ describe SubmissionsController do
context 'when the container cannot be found' do
before(:each) do
#expect(Rails.logger).to receive(:error).with(/error message/)
expect(Docker::Container).to receive(:get).and_raise(Docker::Error::NotFoundError)
request.call
end