From c91d5bd0b962261c638a3c03b41380774c15957a Mon Sep 17 00:00:00 2001 From: Hauke Klement Date: Fri, 6 Mar 2015 10:18:08 +0100 Subject: [PATCH] added tests --- .../submissions_controller_spec.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index e058ec9f..36e20fb5 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -192,6 +192,36 @@ describe SubmissionsController do expect_status(200) end + describe 'POST #stop' do + let(:request) { proc { post :stop, 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) + 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) + request.call + end + + it 'renders nothing' do + expect(response.body).to be_blank + end + + expect_status(200) + end + end + describe 'GET #test' do let(:filename) { submission.collect_files.detect(&:teacher_defined_test?).name_with_extension } let(:output) { {} }