Completely remove old hints connected to the execution environment

This commit is contained in:
Sebastian Serth
2018-11-27 18:15:12 +01:00
parent 5d13ee0e56
commit efacb5a6a9
29 changed files with 12 additions and 534 deletions

View File

@ -1,103 +0,0 @@
require 'rails_helper'
describe HintsController do
let(:execution_environment) { FactoryBot.create(:ruby) }
let(:hint) { FactoryBot.create(:ruby_syntax_error) }
let(:user) { FactoryBot.create(:admin) }
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
describe 'POST #create' do
context 'with a valid hint' do
let(:perform_request) { proc { post :create, params: { execution_environment_id: execution_environment.id, hint: FactoryBot.attributes_for(:ruby_syntax_error) } } }
before(:each) { perform_request.call }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
it 'creates the hint' do
expect { perform_request.call }.to change(Hint, :count).by(1)
end
expect_redirect(Hint.last)
end
context 'with an invalid hint' do
before(:each) { post :create, params: { execution_environment_id: execution_environment.id, hint: {} } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
expect_status(200)
expect_template(:new)
end
end
describe 'DELETE #destroy' do
before(:each) { delete :destroy, params: { execution_environment_id: execution_environment.id, id: hint.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
it 'destroys the hint' do
hint = FactoryBot.create(:ruby_syntax_error)
expect { delete :destroy, params: { execution_environment_id: execution_environment.id, id: hint.id } }.to change(Hint, :count).by(-1)
end
expect_redirect { execution_environment_hints_path(execution_environment) }
end
describe 'GET #edit' do
before(:each) { get :edit, params: { execution_environment_id: execution_environment.id, id: hint.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
expect_status(200)
expect_template(:edit)
end
describe 'GET #index' do
before(:all) { FactoryBot.create_pair(:ruby_syntax_error) }
before(:each) { get :index, params: { execution_environment_id: execution_environment.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hints: Hint.all)
expect_status(200)
expect_template(:index)
end
describe 'GET #new' do
before(:each) { get :new, params: { execution_environment_id: execution_environment.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
expect_status(200)
expect_template(:new)
end
describe 'GET #show' do
before(:each) { get :show, params: { execution_environment_id: execution_environment.id, id: hint.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: :hint)
expect_status(200)
expect_template(:show)
end
describe 'PUT #update' do
context 'with a valid hint' do
before(:each) { put :update, params: { execution_environment_id: execution_environment.id, hint: FactoryBot.attributes_for(:ruby_syntax_error), id: hint.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
expect_redirect { hint }
end
context 'with an invalid hint' do
before(:each) { put :update, params: { execution_environment_id: execution_environment.id, hint: {name: ''}, id: hint.id } }
expect_assigns(execution_environment: :execution_environment)
expect_assigns(hint: Hint)
expect_status(200)
expect_template(:edit)
end
end
end

View File

@ -167,28 +167,9 @@ describe SubmissionsController do
after(:each) { perform_request }
context 'when the error is covered by a hint' do
let(:hint) { "Your object 'main' of class 'Object' does not understand the method 'foo'." }
before(:each) do
expect_any_instance_of(Whistleblower).to receive(:generate_hint).with(stderr).and_return(hint)
end
it 'does not store the error' do
pending("no server sent events used right now")
expect(CodeOcean::Error).not_to receive(:create)
end
end
context 'when the error is not covered by a hint' do
before(:each) do
expect_any_instance_of(Whistleblower).to receive(:generate_hint).with(stderr)
end
it 'stores the error' do
pending("no server sent events used right now")
expect(CodeOcean::Error).to receive(:create).with(execution_environment_id: submission.exercise.execution_environment_id, message: stderr)
end
it 'stores the error' do
pending("no server sent events used right now")
expect(CodeOcean::Error).to receive(:create).with(execution_environment_id: submission.exercise.execution_environment_id, message: stderr)
end
end
end