Upgrade Rails to version 5.2.1 and adopt code & specs where necessary
Signed-off-by: Sebastian Serth <Sebastian.Serth@student.hpi.de>
This commit is contained in:
@ -40,14 +40,14 @@ describe ApplicationController do
|
||||
context "using the 'custom_locale' parameter" do
|
||||
it 'overwrites the session' do
|
||||
expect(session).to receive(:[]=).with(:locale, locale.to_s)
|
||||
get :welcome, custom_locale: locale
|
||||
get :welcome, params: { custom_locale: locale }
|
||||
end
|
||||
end
|
||||
|
||||
context "using the 'locale' parameter" do
|
||||
it 'overwrites the session' do
|
||||
expect(session).to receive(:[]=).with(:locale, locale.to_s)
|
||||
get :welcome, locale: locale
|
||||
get :welcome, params: { locale: locale }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ describe CodeOcean::FilesController do
|
||||
let(:submission) { FactoryBot.create(:submission, user: user) }
|
||||
|
||||
context 'with a valid file' do
|
||||
let(:request) { proc { post :create, code_ocean_file: FactoryBot.build(:file, context: submission).attributes, format: :json } }
|
||||
let(:request) { proc { post :create, params: { code_ocean_file: FactoryBot.build(:file, context: submission).attributes, format: :json } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(file: CodeOcean::File)
|
||||
@ -22,7 +22,7 @@ describe CodeOcean::FilesController do
|
||||
end
|
||||
|
||||
context 'with an invalid file' do
|
||||
before(:each) { post :create, code_ocean_file: {context_id: submission.id, context_type: Submission}, format: :json }
|
||||
before(:each) { post :create, params: { code_ocean_file: {context_id: submission.id, context_type: Submission}, format: :json } }
|
||||
|
||||
expect_assigns(file: CodeOcean::File)
|
||||
expect_json
|
||||
@ -32,7 +32,7 @@ describe CodeOcean::FilesController do
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:exercise) { FactoryBot.create(:fibonacci) }
|
||||
let(:request) { proc { delete :destroy, id: exercise.files.first.id } }
|
||||
let(:request) { proc { delete :destroy, params: { id: exercise.files.first.id } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(file: CodeOcean::File)
|
||||
|
@ -7,7 +7,7 @@ describe ConsumersController do
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with a valid consumer' do
|
||||
let(:request) { proc { post :create, consumer: FactoryBot.attributes_for(:consumer) } }
|
||||
let(:request) { proc { post :create, params: { consumer: FactoryBot.attributes_for(:consumer) } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(consumer: Consumer)
|
||||
@ -20,7 +20,7 @@ describe ConsumersController do
|
||||
end
|
||||
|
||||
context 'with an invalid consumer' do
|
||||
before(:each) { post :create, consumer: {} }
|
||||
before(:each) { post :create, params: { consumer: {} } }
|
||||
|
||||
expect_assigns(consumer: Consumer)
|
||||
expect_status(200)
|
||||
@ -29,20 +29,20 @@ describe ConsumersController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before(:each) { delete :destroy, id: consumer.id }
|
||||
before(:each) { delete :destroy, params: { id: consumer.id } }
|
||||
|
||||
expect_assigns(consumer: Consumer)
|
||||
|
||||
it 'destroys the consumer' do
|
||||
consumer = FactoryBot.create(:consumer)
|
||||
expect { delete :destroy, id: consumer.id }.to change(Consumer, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: consumer.id } }.to change(Consumer, :count).by(-1)
|
||||
end
|
||||
|
||||
expect_redirect(:consumers)
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
before(:each) { get :edit, id: consumer.id }
|
||||
before(:each) { get :edit, params: { id: consumer.id } }
|
||||
|
||||
expect_assigns(consumer: Consumer)
|
||||
expect_status(200)
|
||||
@ -67,7 +67,7 @@ describe ConsumersController do
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
before(:each) { get :show, id: consumer.id }
|
||||
before(:each) { get :show, params: { id: consumer.id } }
|
||||
|
||||
expect_assigns(consumer: :consumer)
|
||||
expect_status(200)
|
||||
@ -76,14 +76,14 @@ describe ConsumersController do
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with a valid consumer' do
|
||||
before(:each) { put :update, consumer: FactoryBot.attributes_for(:consumer), id: consumer.id }
|
||||
before(:each) { put :update, params: { consumer: FactoryBot.attributes_for(:consumer), id: consumer.id } }
|
||||
|
||||
expect_assigns(consumer: Consumer)
|
||||
expect_redirect(:consumer)
|
||||
end
|
||||
|
||||
context 'with an invalid consumer' do
|
||||
before(:each) { put :update, consumer: {name: ''}, id: consumer.id }
|
||||
before(:each) { put :update, params: { consumer: {name: ''}, id: consumer.id } }
|
||||
|
||||
expect_assigns(consumer: Consumer)
|
||||
expect_status(200)
|
||||
|
@ -17,27 +17,27 @@ describe ErrorTemplateAttributesController do
|
||||
end
|
||||
|
||||
it "should create error_template_attribute" do
|
||||
expect { post :create, error_template_attribute: { } }.to change(ErrorTemplateAttribute, :count).by(1)
|
||||
expect { post :create, params: { error_template_attribute: { } } }.to change(ErrorTemplateAttribute, :count).by(1)
|
||||
expect(response).to redirect_to(error_template_attribute_path(assigns(:error_template_attribute)))
|
||||
end
|
||||
|
||||
it "should show error_template_attribute" do
|
||||
get :show, id: error_template_attribute
|
||||
get :show, params: { id: error_template_attribute }
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should get edit" do
|
||||
get :edit, id: error_template_attribute
|
||||
get :edit, params: { id: error_template_attribute }
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should update error_template_attribute" do
|
||||
patch :update, id: error_template_attribute, error_template_attribute: { }
|
||||
patch :update, params: { id: error_template_attribute, error_template_attribute: FactoryBot.attributes_for(:error_template_attribute) }
|
||||
expect(response).to redirect_to(error_template_attribute_path(assigns(:error_template_attribute)))
|
||||
end
|
||||
|
||||
it "should destroy error_template_attribute" do
|
||||
expect { delete :destroy, id: error_template_attribute }.to change(ErrorTemplateAttribute, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: error_template_attribute } }.to change(ErrorTemplateAttribute, :count).by(-1)
|
||||
expect(response).to redirect_to(error_template_attributes_path)
|
||||
end
|
||||
end
|
||||
|
@ -17,27 +17,27 @@ describe ErrorTemplatesController do
|
||||
end
|
||||
|
||||
it "should create error_template" do
|
||||
expect { post :create, error_template: { } }.to change(ErrorTemplate, :count).by(1)
|
||||
expect { post :create, params: {error_template: { execution_environment_id: error_template.execution_environment.id } } }.to change(ErrorTemplate, :count).by(1)
|
||||
expect(response).to redirect_to(error_template_path(assigns(:error_template)))
|
||||
end
|
||||
|
||||
it "should show error_template" do
|
||||
get :show, id: error_template
|
||||
get :show, params: { id: error_template }
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should get edit" do
|
||||
get :edit, id: error_template
|
||||
get :edit, params: { id: error_template }
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should update error_template" do
|
||||
patch :update, id: error_template, error_template: { }
|
||||
patch :update, params: { id: error_template, error_template: FactoryBot.attributes_for(:error_template) }
|
||||
expect(response).to redirect_to(error_template_path(assigns(:error_template)))
|
||||
end
|
||||
|
||||
it "should destroy error_template" do
|
||||
expect { delete :destroy, id: error_template }.to change(ErrorTemplate, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: error_template } }.to change(ErrorTemplate, :count).by(-1)
|
||||
expect(response).to redirect_to(error_templates_path)
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ describe EventsController do
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with a valid event' do
|
||||
let(:request) { proc { post :create, event: {category: 'foo', data: 'bar', exercise_id: exercise.id, file_id: exercise.files[0].id} } }
|
||||
let(:request) { proc { post :create, params: { event: {category: 'foo', data: 'bar', exercise_id: exercise.id, file_id: exercise.files[0].id} } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(event: Event)
|
||||
@ -20,7 +20,7 @@ describe EventsController do
|
||||
end
|
||||
|
||||
context 'with an invalid event' do
|
||||
before(:each) { post :create, event: {exercise_id: 847482} }
|
||||
before(:each) { post :create, params: { event: {exercise_id: 847482} } }
|
||||
expect_assigns(event: Event)
|
||||
expect_status(422)
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ describe ExecutionEnvironmentsController do
|
||||
before(:each) { expect(DockerClient).to receive(:image_tags).at_least(:once).and_return([]) }
|
||||
|
||||
context 'with a valid execution environment' do
|
||||
let(:request) { proc { post :create, execution_environment: FactoryBot.attributes_for(:ruby) } }
|
||||
let(:request) { proc { post :create, params: { execution_environment: FactoryBot.build(:ruby).attributes } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(docker_images: Array)
|
||||
@ -23,7 +23,7 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
context 'with an invalid execution environment' do
|
||||
before(:each) { post :create, execution_environment: {} }
|
||||
before(:each) { post :create, params: { execution_environment: {} } }
|
||||
|
||||
expect_assigns(execution_environment: ExecutionEnvironment)
|
||||
expect_status(200)
|
||||
@ -32,13 +32,13 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before(:each) { delete :destroy, id: execution_environment.id }
|
||||
before(:each) { delete :destroy, params: { id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
|
||||
it 'destroys the execution environment' do
|
||||
execution_environment = FactoryBot.create(:ruby)
|
||||
expect { delete :destroy, id: execution_environment.id }.to change(ExecutionEnvironment, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: execution_environment.id } }.to change(ExecutionEnvironment, :count).by(-1)
|
||||
end
|
||||
|
||||
expect_redirect(:execution_environments)
|
||||
@ -47,7 +47,7 @@ describe ExecutionEnvironmentsController do
|
||||
describe 'GET #edit' do
|
||||
before(:each) do
|
||||
expect(DockerClient).to receive(:image_tags).at_least(:once).and_return([])
|
||||
get :edit, id: execution_environment.id
|
||||
get :edit, params: { id: execution_environment.id }
|
||||
end
|
||||
|
||||
expect_assigns(docker_images: Array)
|
||||
@ -62,7 +62,7 @@ describe ExecutionEnvironmentsController do
|
||||
before(:each) do
|
||||
expect(DockerClient).to receive(:new).with(execution_environment: execution_environment).and_call_original
|
||||
expect_any_instance_of(DockerClient).to receive(:execute_arbitrary_command).with(command)
|
||||
post :execute_command, command: command, id: execution_environment.id
|
||||
post :execute_command, params: { command: command, id: execution_environment.id }
|
||||
end
|
||||
|
||||
expect_assigns(docker_client: DockerClient)
|
||||
@ -123,7 +123,7 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
describe 'GET #shell' do
|
||||
before(:each) { get :shell, id: execution_environment.id }
|
||||
before(:each) { get :shell, params: { id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_status(200)
|
||||
@ -131,7 +131,7 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
describe 'GET #statistics' do
|
||||
before(:each) { get :statistics, id: execution_environment.id }
|
||||
before(:each) { get :statistics, params: { id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_status(200)
|
||||
@ -139,7 +139,7 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
before(:each) { get :show, id: execution_environment.id }
|
||||
before(:each) { get :show, params: { id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_status(200)
|
||||
@ -150,7 +150,7 @@ describe ExecutionEnvironmentsController do
|
||||
context 'with a valid execution environment' do
|
||||
before(:each) do
|
||||
expect(DockerClient).to receive(:image_tags).at_least(:once).and_return([])
|
||||
put :update, execution_environment: FactoryBot.attributes_for(:ruby), id: execution_environment.id
|
||||
put :update, params: { execution_environment: FactoryBot.attributes_for(:ruby), id: execution_environment.id }
|
||||
end
|
||||
|
||||
expect_assigns(docker_images: Array)
|
||||
@ -159,7 +159,7 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
context 'with an invalid execution environment' do
|
||||
before(:each) { put :update, execution_environment: {name: ''}, id: execution_environment.id }
|
||||
before(:each) { put :update, params: { execution_environment: {name: ''}, id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: ExecutionEnvironment)
|
||||
expect_status(200)
|
||||
|
@ -6,8 +6,8 @@ describe ExercisesController do
|
||||
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
|
||||
|
||||
describe 'PUT #batch_update' do
|
||||
let(:attributes) { {public: true} }
|
||||
let(:request) { proc { put :batch_update, exercises: {0 => attributes.merge(id: exercise.id)} } }
|
||||
let(:attributes) { { 'public': 'true'} }
|
||||
let(:request) { proc { put :batch_update, params: { exercises: {0 => attributes.merge(id: exercise.id)} } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
it 'updates the exercises' do
|
||||
@ -20,7 +20,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
describe 'POST #clone' do
|
||||
let(:request) { proc { post :clone, id: exercise.id } }
|
||||
let(:request) { proc { post :clone, params: { id: exercise.id } } }
|
||||
|
||||
context 'when saving succeeds' do
|
||||
before(:each) { request.call }
|
||||
@ -55,7 +55,7 @@ describe ExercisesController do
|
||||
let(:exercise_attributes) { FactoryBot.build(:dummy).attributes }
|
||||
|
||||
context 'with a valid exercise' do
|
||||
let(:request) { proc { post :create, exercise: exercise_attributes } }
|
||||
let(:request) { proc { post :create, params: { exercise: exercise_attributes } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(exercise: Exercise)
|
||||
@ -68,7 +68,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
context 'when including a file' do
|
||||
let(:request) { proc { post :create, exercise: exercise_attributes.merge(files_attributes: files_attributes) } }
|
||||
let(:request) { proc { post :create, params: { exercise: exercise_attributes.merge(files_attributes: files_attributes) } } }
|
||||
|
||||
context 'when specifying the file content within the form' do
|
||||
let(:files_attributes) { {'0' => FactoryBot.build(:file).attributes} }
|
||||
@ -114,7 +114,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
context 'with an invalid exercise' do
|
||||
before(:each) { post :create, exercise: {} }
|
||||
before(:each) { post :create, params: { exercise: { } } }
|
||||
|
||||
expect_assigns(exercise: Exercise)
|
||||
expect_status(200)
|
||||
@ -123,20 +123,20 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before(:each) { delete :destroy, id: exercise.id }
|
||||
before(:each) { delete :destroy, params: { id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
|
||||
it 'destroys the exercise' do
|
||||
exercise = FactoryBot.create(:dummy)
|
||||
expect { delete :destroy, id: exercise.id }.to change(Exercise, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: exercise.id } }.to change(Exercise, :count).by(-1)
|
||||
end
|
||||
|
||||
expect_redirect(:exercises)
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
before(:each) { get :edit, id: exercise.id }
|
||||
before(:each) { get :edit, params: { id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
expect_status(200)
|
||||
@ -144,7 +144,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
describe 'GET #implement' do
|
||||
let(:request) { proc { get :implement, id: exercise.id } }
|
||||
let(:request) { proc { get :implement, params: { id: exercise.id } } }
|
||||
|
||||
context 'with an exercise with visible files' do
|
||||
let(:exercise) { FactoryBot.create(:fibonacci) }
|
||||
@ -201,7 +201,7 @@ describe ExercisesController do
|
||||
|
||||
describe 'GET #show' do
|
||||
context 'as admin' do
|
||||
before(:each) { get :show, id: exercise.id }
|
||||
before(:each) { get :show, params: { id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
expect_status(200)
|
||||
@ -211,7 +211,7 @@ describe ExercisesController do
|
||||
|
||||
describe 'GET #reload' do
|
||||
context 'as anyone' do
|
||||
before(:each) { get :reload, format: :json, id: exercise.id }
|
||||
before(:each) { get :reload, format: :json, params: { id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
expect_status(200)
|
||||
@ -220,7 +220,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
describe 'GET #statistics' do
|
||||
before(:each) { get :statistics, id: exercise.id }
|
||||
before(:each) { get :statistics, params: { id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
expect_status(200)
|
||||
@ -229,7 +229,7 @@ describe ExercisesController do
|
||||
|
||||
describe 'POST #submit' do
|
||||
let(:output) { {} }
|
||||
let(:request) { post :submit, format: :json, id: exercise.id, submission: {cause: 'submit', exercise_id: exercise.id} }
|
||||
let(:request) { post :submit, format: :json, params: { id: exercise.id, submission: {cause: 'submit', exercise_id: exercise.id} } }
|
||||
let!(:external_user) { FactoryBot.create(:external_user) }
|
||||
let!(:lti_parameter) { FactoryBot.create(:lti_parameter, external_user: external_user, exercise: exercise) }
|
||||
|
||||
@ -299,14 +299,14 @@ describe ExercisesController do
|
||||
describe 'PUT #update' do
|
||||
context 'with a valid exercise' do
|
||||
let(:exercise_attributes) { FactoryBot.build(:dummy).attributes }
|
||||
before(:each) { put :update, exercise: exercise_attributes, id: exercise.id }
|
||||
before(:each) { put :update, params: { exercise: exercise_attributes, id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: Exercise)
|
||||
expect_redirect(:exercise)
|
||||
end
|
||||
|
||||
context 'with an invalid exercise' do
|
||||
before(:each) { put :update, exercise: {title: ''}, id: exercise.id }
|
||||
before(:each) { put :update, params: { exercise: {title: ''}, id: exercise.id } }
|
||||
|
||||
expect_assigns(exercise: Exercise)
|
||||
expect_status(200)
|
||||
|
@ -14,7 +14,7 @@ describe ExternalUsersController do
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
before(:each) { get :show, id: users.first.id }
|
||||
before(:each) { get :show, params: { id: users.first.id } }
|
||||
|
||||
expect_assigns(user: ExternalUser)
|
||||
expect_status(200)
|
||||
|
@ -7,7 +7,7 @@ describe FileTypesController do
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with a valid file type' do
|
||||
let(:request) { proc { post :create, file_type: FactoryBot.attributes_for(:dot_rb) } }
|
||||
let(:request) { proc { post :create, params: { file_type: FactoryBot.attributes_for(:dot_rb) } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(editor_modes: Array)
|
||||
@ -21,7 +21,7 @@ describe FileTypesController do
|
||||
end
|
||||
|
||||
context 'with an invalid file type' do
|
||||
before(:each) { post :create, file_type: {} }
|
||||
before(:each) { post :create, params: { file_type: { } } }
|
||||
|
||||
expect_assigns(editor_modes: Array)
|
||||
expect_assigns(file_type: FileType)
|
||||
@ -31,20 +31,20 @@ describe FileTypesController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before(:each) { delete :destroy, id: file_type.id }
|
||||
before(:each) { delete :destroy, params: { id: file_type.id } }
|
||||
|
||||
expect_assigns(file_type: FileType)
|
||||
|
||||
it 'destroys the file type' do
|
||||
file_type = FactoryBot.create(:dot_rb)
|
||||
expect { delete :destroy, id: file_type.id }.to change(FileType, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: file_type.id } }.to change(FileType, :count).by(-1)
|
||||
end
|
||||
|
||||
expect_redirect(:file_types)
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
before(:each) { get :edit, id: file_type.id }
|
||||
before(:each) { get :edit, params: { id: file_type.id } }
|
||||
|
||||
expect_assigns(editor_modes: Array)
|
||||
expect_assigns(file_type: FileType)
|
||||
@ -71,7 +71,7 @@ describe FileTypesController do
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
before(:each) { get :show, id: file_type.id }
|
||||
before(:each) { get :show, params: { id: file_type.id } }
|
||||
|
||||
expect_assigns(file_type: :file_type)
|
||||
expect_status(200)
|
||||
@ -80,7 +80,7 @@ describe FileTypesController do
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with a valid file type' do
|
||||
before(:each) { put :update, file_type: FactoryBot.attributes_for(:dot_rb), id: file_type.id }
|
||||
before(:each) { put :update, params: { file_type: FactoryBot.attributes_for(:dot_rb), id: file_type.id } }
|
||||
|
||||
expect_assigns(editor_modes: Array)
|
||||
expect_assigns(file_type: FileType)
|
||||
@ -88,7 +88,7 @@ describe FileTypesController do
|
||||
end
|
||||
|
||||
context 'with an invalid file type' do
|
||||
before(:each) { put :update, file_type: {name: ''}, id: file_type.id }
|
||||
before(:each) { put :update, params: { file_type: {name: ''}, id: file_type.id } }
|
||||
|
||||
expect_assigns(editor_modes: Array)
|
||||
expect_assigns(file_type: FileType)
|
||||
|
@ -8,7 +8,7 @@ describe HintsController do
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with a valid hint' do
|
||||
let(:request) { proc { post :create, execution_environment_id: execution_environment.id, hint: FactoryBot.attributes_for(:ruby_syntax_error) } }
|
||||
let(:request) { proc { post :create, params: { execution_environment_id: execution_environment.id, hint: FactoryBot.attributes_for(:ruby_syntax_error) } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
@ -22,7 +22,7 @@ describe HintsController do
|
||||
end
|
||||
|
||||
context 'with an invalid hint' do
|
||||
before(:each) { post :create, execution_environment_id: execution_environment.id, hint: {} }
|
||||
before(:each) { post :create, params: { execution_environment_id: execution_environment.id, hint: {} } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_assigns(hint: Hint)
|
||||
@ -32,21 +32,21 @@ describe HintsController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before(:each) { delete :destroy, execution_environment_id: execution_environment.id, id: hint.id }
|
||||
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, execution_environment_id: execution_environment.id, id: hint.id }.to change(Hint, :count).by(-1)
|
||||
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, execution_environment_id: execution_environment.id, id: hint.id }
|
||||
before(:each) { get :edit, params: { execution_environment_id: execution_environment.id, id: hint.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_assigns(hint: Hint)
|
||||
@ -56,7 +56,7 @@ describe HintsController do
|
||||
|
||||
describe 'GET #index' do
|
||||
before(:all) { FactoryBot.create_pair(:ruby_syntax_error) }
|
||||
before(:each) { get :index, execution_environment_id: execution_environment.id }
|
||||
before(:each) { get :index, params: { execution_environment_id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_assigns(hints: Hint.all)
|
||||
@ -65,7 +65,7 @@ describe HintsController do
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
before(:each) { get :new, execution_environment_id: execution_environment.id }
|
||||
before(:each) { get :new, params: { execution_environment_id: execution_environment.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_assigns(hint: Hint)
|
||||
@ -74,7 +74,7 @@ describe HintsController do
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
before(:each) { get :show, execution_environment_id: execution_environment.id, id: hint.id }
|
||||
before(:each) { get :show, params: { execution_environment_id: execution_environment.id, id: hint.id } }
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
expect_assigns(hint: :hint)
|
||||
@ -84,7 +84,7 @@ describe HintsController do
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with a valid hint' do
|
||||
before(:each) { put :update, execution_environment_id: execution_environment.id, hint: FactoryBot.attributes_for(:ruby_syntax_error), id: hint.id }
|
||||
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)
|
||||
@ -92,7 +92,7 @@ describe HintsController do
|
||||
end
|
||||
|
||||
context 'with an invalid hint' do
|
||||
before(:each) { put :update, execution_environment_id: execution_environment.id, hint: {name: ''}, id: hint.id }
|
||||
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)
|
||||
|
@ -13,7 +13,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'without a valid activation token' do
|
||||
before(:each) { get :activate, id: user.id }
|
||||
before(:each) { get :activate, params: { id: user.id } }
|
||||
|
||||
expect_redirect(:root)
|
||||
end
|
||||
@ -21,14 +21,14 @@ describe InternalUsersController do
|
||||
context 'with an already activated user' do
|
||||
before(:each) do
|
||||
user.activate!
|
||||
get :activate, id: user.id, token: user.activation_token
|
||||
get :activate, params: { id: user.id, token: user.activation_token }
|
||||
end
|
||||
|
||||
expect_redirect(:root)
|
||||
end
|
||||
|
||||
context 'with valid preconditions' do
|
||||
before(:each) { get :activate, id: user.id, token: user.activation_token }
|
||||
before(:each) { get :activate, params: { id: user.id, token: user.activation_token } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
expect_status(200)
|
||||
@ -37,7 +37,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
describe 'PUT #activate' do
|
||||
let(:user) { InternalUser.create(FactoryBot.attributes_for(:teacher)) }
|
||||
let(:user) { InternalUser.create(FactoryBot.build(:teacher).attributes) }
|
||||
let(:password) { SecureRandom.hex }
|
||||
|
||||
before(:each) do
|
||||
@ -47,7 +47,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'without a valid activation token' do
|
||||
before(:each) { put :activate, id: user.id }
|
||||
before(:each) { put :activate, params: { id: user.id } }
|
||||
|
||||
expect_redirect(:root)
|
||||
end
|
||||
@ -55,14 +55,14 @@ describe InternalUsersController do
|
||||
context 'with an already activated user' do
|
||||
before(:each) do
|
||||
user.activate!
|
||||
put :activate, id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: password}
|
||||
put :activate, params: { id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: password} }
|
||||
end
|
||||
|
||||
expect_redirect(:root)
|
||||
end
|
||||
|
||||
context 'without a password' do
|
||||
before(:each) { put :activate, id: user.id, internal_user: {activation_token: user.activation_token} }
|
||||
before(:each) { put :activate, params: { id: user.id, internal_user: {activation_token: user.activation_token} } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
|
||||
@ -74,7 +74,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'without a valid password confirmation' do
|
||||
before(:each) { put :activate, id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: ''} }
|
||||
before(:each) { put :activate, params: { id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: ''} } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
|
||||
@ -86,7 +86,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'with valid preconditions' do
|
||||
before(:each) { put :activate, id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: password} }
|
||||
before(:each) { put :activate, params: { id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: password} } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
|
||||
@ -103,7 +103,7 @@ describe InternalUsersController do
|
||||
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
|
||||
|
||||
context 'with a valid internal user' do
|
||||
let(:request) { proc { post :create, internal_user: FactoryBot.attributes_for(:teacher) } }
|
||||
let(:request) { proc { post :create, params: { internal_user: FactoryBot.build(:teacher).attributes } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
@ -129,7 +129,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'with an invalid internal user' do
|
||||
before(:each) { post :create, internal_user: {} }
|
||||
before(:each) { post :create, params: { internal_user: {} } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
expect_status(200)
|
||||
@ -140,13 +140,13 @@ describe InternalUsersController do
|
||||
describe 'DELETE #destroy' do
|
||||
before(:each) do
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
delete :destroy, id: users.first.id
|
||||
delete :destroy, params: { id: users.first.id }
|
||||
end
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
|
||||
it 'destroys the internal user' do
|
||||
expect { delete :destroy, id: InternalUser.last.id }.to change(InternalUser, :count).by(-1)
|
||||
expect { delete :destroy, params: { id: InternalUser.last.id } }.to change(InternalUser, :count).by(-1)
|
||||
end
|
||||
|
||||
expect_redirect(:internal_users)
|
||||
@ -155,7 +155,7 @@ describe InternalUsersController do
|
||||
describe 'GET #edit' do
|
||||
before(:each) do
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
get :edit, id: users.first.id
|
||||
get :edit, params: { id: users.first.id }
|
||||
end
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
@ -187,7 +187,7 @@ describe InternalUsersController do
|
||||
|
||||
describe 'POST #forgot_password' do
|
||||
context 'with an email address' do
|
||||
let(:request) { proc { post :forgot_password, email: user.email } }
|
||||
let(:request) { proc { post :forgot_password, params: { email: user.email } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
it 'delivers instructions to reset the password' do
|
||||
@ -233,7 +233,7 @@ describe InternalUsersController do
|
||||
let(:user) { users.first }
|
||||
|
||||
context 'without a valid password reset token' do
|
||||
before(:each) { get :reset_password, id: user.id }
|
||||
before(:each) { get :reset_password, params: { id: user.id } }
|
||||
|
||||
expect_redirect(:root)
|
||||
end
|
||||
@ -241,7 +241,7 @@ describe InternalUsersController do
|
||||
context 'with a valid password reset token' do
|
||||
before(:each) do
|
||||
user.deliver_reset_password_instructions!
|
||||
get :reset_password, id: user.id, token: user.reset_password_token
|
||||
get :reset_password, params: { id: user.id, token: user.reset_password_token }
|
||||
end
|
||||
|
||||
expect_assigns(user: :user)
|
||||
@ -255,7 +255,7 @@ describe InternalUsersController do
|
||||
before(:each) { user.deliver_reset_password_instructions! }
|
||||
|
||||
context 'without a valid password reset token' do
|
||||
before(:each) { put :reset_password, id: user.id }
|
||||
before(:each) { put :reset_password, params: { id: user.id } }
|
||||
|
||||
expect_redirect(:root)
|
||||
end
|
||||
@ -264,7 +264,7 @@ describe InternalUsersController do
|
||||
let(:password) { 'foo' }
|
||||
|
||||
context 'with a matching password confirmation' do
|
||||
let(:request) { proc { put :reset_password, internal_user: {password: password, password_confirmation: password}, id: user.id, token: user.reset_password_token } }
|
||||
let(:request) { proc { put :reset_password, params: { internal_user: {password: password, password_confirmation: password}, id: user.id, token: user.reset_password_token } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(user: :user)
|
||||
@ -278,7 +278,7 @@ describe InternalUsersController do
|
||||
|
||||
context 'without a matching password confirmation' do
|
||||
before(:each) do
|
||||
put :reset_password, internal_user: {password: password, password_confirmation: ''}, id: users.first.id, token: user.reset_password_token
|
||||
put :reset_password, params: { internal_user: {password: password, password_confirmation: ''}, id: users.first.id, token: user.reset_password_token }
|
||||
end
|
||||
|
||||
expect_assigns(user: :user)
|
||||
@ -291,7 +291,7 @@ describe InternalUsersController do
|
||||
describe 'GET #show' do
|
||||
before(:each) do
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
get :show, id: users.first.id
|
||||
get :show, params: { id: users.first.id }
|
||||
end
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
@ -303,14 +303,14 @@ describe InternalUsersController do
|
||||
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
|
||||
|
||||
context 'with a valid internal user' do
|
||||
before(:each) { put :update, internal_user: FactoryBot.attributes_for(:teacher), id: users.first.id }
|
||||
before(:each) { put :update, params: { internal_user: FactoryBot.attributes_for(:teacher), id: users.first.id } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
expect_redirect { user }
|
||||
end
|
||||
|
||||
context 'with an invalid internal user' do
|
||||
before(:each) { put :update, internal_user: {email: ''}, id: users.first.id }
|
||||
before(:each) { put :update, params: { internal_user: {email: ''}, id: users.first.id } }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
expect_status(200)
|
||||
|
@ -4,14 +4,14 @@ describe SessionsController do
|
||||
let(:consumer) { FactoryBot.create(:consumer) }
|
||||
|
||||
describe 'POST #create' do
|
||||
let(:password) { user_attributes[:password] }
|
||||
let(:user) { InternalUser.create(user_attributes) }
|
||||
let(:user_attributes) { FactoryBot.attributes_for(:teacher) }
|
||||
let(:password) { FactoryBot.attributes_for(:teacher)[:password] }
|
||||
let(:user) { InternalUser.create(user_attributes.merge(password: password)) }
|
||||
let(:user_attributes) { FactoryBot.build(:teacher).attributes }
|
||||
|
||||
context 'with valid credentials' do
|
||||
before(:each) do
|
||||
user.activate!
|
||||
post :create, email: user.email, password: password, remember_me: 1
|
||||
post :create, params: { email: user.email, password: password, remember_me: 1 }
|
||||
end
|
||||
|
||||
expect_flash_message(:notice, :'sessions.create.success')
|
||||
@ -19,7 +19,7 @@ describe SessionsController do
|
||||
end
|
||||
|
||||
context 'with invalid credentials' do
|
||||
before(:each) { post :create, email: user.email, password: '', remember_me: 1 }
|
||||
before(:each) { post :create, params: { email: user.email, password: '', remember_me: 1 } }
|
||||
|
||||
expect_flash_message(:danger, :'sessions.create.failure')
|
||||
expect_template(:new)
|
||||
@ -42,14 +42,14 @@ describe SessionsController do
|
||||
context 'without a valid consumer key' do
|
||||
it 'refuses the LTI launch' do
|
||||
expect(controller).to receive(:refuse_lti_launch).with(message: I18n.t('sessions.oauth.invalid_consumer')).and_call_original
|
||||
post :create_through_lti, oauth_consumer_key: SecureRandom.hex, oauth_signature: SecureRandom.hex
|
||||
post :create_through_lti, params: { oauth_consumer_key: SecureRandom.hex, oauth_signature: SecureRandom.hex }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an invalid OAuth signature' do
|
||||
it 'refuses the LTI launch' do
|
||||
expect(controller).to receive(:refuse_lti_launch).with(message: I18n.t('sessions.oauth.invalid_signature')).and_call_original
|
||||
post :create_through_lti, oauth_consumer_key: consumer.oauth_key, oauth_signature: SecureRandom.hex
|
||||
post :create_through_lti, params: { oauth_consumer_key: consumer.oauth_key, oauth_signature: SecureRandom.hex }
|
||||
end
|
||||
end
|
||||
|
||||
@ -58,7 +58,7 @@ describe SessionsController do
|
||||
expect_any_instance_of(IMS::LTI::ToolProvider).to receive(:valid_request?).and_return(true)
|
||||
expect(NonceStore).to receive(:has?).with(nonce).and_return(true)
|
||||
expect(controller).to receive(:refuse_lti_launch).with(message: I18n.t('sessions.oauth.used_nonce')).and_call_original
|
||||
post :create_through_lti, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex
|
||||
post :create_through_lti, params: { oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex }
|
||||
end
|
||||
end
|
||||
|
||||
@ -66,13 +66,13 @@ describe SessionsController do
|
||||
it 'refuses the LTI launch' do
|
||||
expect_any_instance_of(IMS::LTI::ToolProvider).to receive(:valid_request?).and_return(true)
|
||||
expect(controller).to receive(:refuse_lti_launch).with(message: I18n.t('sessions.oauth.invalid_exercise_token')).and_call_original
|
||||
post :create_through_lti, custom_token: '', oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex
|
||||
post :create_through_lti, params: { custom_token: '', oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid launch parameters' do
|
||||
let(:locale) { :de }
|
||||
let(:request) { post :create_through_lti, custom_locale: locale, custom_token: exercise.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id }
|
||||
let(:request) { post :create_through_lti, params: { custom_locale: locale, custom_token: exercise.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id } }
|
||||
let(:user) { FactoryBot.create(:external_user, consumer_id: consumer.id) }
|
||||
before(:each) { expect_any_instance_of(IMS::LTI::ToolProvider).to receive(:valid_request?).and_return(true) }
|
||||
|
||||
@ -134,7 +134,7 @@ describe SessionsController do
|
||||
it 'redirects to recommended exercise if requested token of proxy exercise' do
|
||||
skip 'test is currently oscillating'
|
||||
FactoryBot.create(:proxy_exercise, exercises: [exercise])
|
||||
post :create_through_lti, custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id
|
||||
post :create_through_lti, params: { custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id }
|
||||
expect(controller).to redirect_to(implement_exercise_path(exercise.id))
|
||||
end
|
||||
|
||||
@ -146,7 +146,7 @@ describe SessionsController do
|
||||
exercise.save
|
||||
exercise2.expected_difficulty = 1
|
||||
exercise2.save
|
||||
post :create_through_lti, custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id
|
||||
post :create_through_lti, params: { custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id }
|
||||
expect(controller).to redirect_to(implement_exercise_path(exercise2.id))
|
||||
end
|
||||
end
|
||||
@ -192,7 +192,7 @@ describe SessionsController do
|
||||
end
|
||||
|
||||
describe 'GET #destroy_through_lti' do
|
||||
let(:request) { proc { get :destroy_through_lti, consumer_id: consumer.id, submission_id: submission.id } }
|
||||
let(:request) { proc { get :destroy_through_lti, params: { consumer_id: consumer.id, submission_id: submission.id } } }
|
||||
let(:submission) { FactoryBot.create(:submission, exercise: FactoryBot.create(:dummy)) }
|
||||
|
||||
before(:each) do
|
||||
|
@ -12,7 +12,7 @@ describe SubmissionsController do
|
||||
|
||||
context 'with a valid submission' do
|
||||
let(:exercise) { FactoryBot.create(:hello_world) }
|
||||
let(:request) { proc { post :create, format: :json, submission: FactoryBot.attributes_for(:submission, exercise_id: exercise.id) } }
|
||||
let(:request) { proc { post :create, format: :json, params: { submission: FactoryBot.attributes_for(:submission, exercise_id: exercise.id) } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(submission: Submission)
|
||||
@ -26,7 +26,7 @@ describe SubmissionsController do
|
||||
end
|
||||
|
||||
context 'with an invalid submission' do
|
||||
before(:each) { post :create, submission: {} }
|
||||
before(:each) { post :create, params: { submission: { } } }
|
||||
|
||||
expect_assigns(submission: Submission)
|
||||
expect_json
|
||||
@ -36,21 +36,39 @@ describe SubmissionsController do
|
||||
|
||||
describe 'GET #download_file' do
|
||||
context 'with an invalid filename' do
|
||||
before(:each) { get :download_file, filename: SecureRandom.hex, id: submission.id }
|
||||
before(:each) { get :download_file, params: { filename: SecureRandom.hex, id: submission.id } }
|
||||
|
||||
expect_status(404)
|
||||
end
|
||||
|
||||
context 'with a valid binary filename' do
|
||||
let(:submission) { FactoryBot.create(:submission, exercise: FactoryBot.create(:sql_select)) }
|
||||
before(:each) { get :download_file, params: { filename: file.name_with_extension, id: submission.id } }
|
||||
|
||||
context 'for a binary file' do
|
||||
let(:file) { submission.collect_files.detect { |file| file.name == 'exercise' && file.file_type.file_extension == '.sql' } }
|
||||
|
||||
expect_assigns(file: :file)
|
||||
expect_assigns(submission: :submission)
|
||||
expect_content_type('application/octet-stream')
|
||||
expect_status(200)
|
||||
|
||||
it 'sets the correct filename' do
|
||||
expect(response.headers['Content-Disposition']).to eq("attachment; filename=\"#{file.name_with_extension}\"")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a valid filename' do
|
||||
let(:submission) { FactoryBot.create(:submission, exercise: FactoryBot.create(:audio_video)) }
|
||||
before(:each) { get :download_file, filename: file.name_with_extension, id: submission.id }
|
||||
before(:each) { get :download_file, params: { filename: file.name_with_extension, id: submission.id } }
|
||||
|
||||
context 'for a binary file' do
|
||||
let(:file) { submission.collect_files.detect { |file| file.file_type.file_extension == '.mp4' } }
|
||||
|
||||
expect_assigns(file: :file)
|
||||
expect_assigns(submission: :submission)
|
||||
expect_content_type('application/octet-stream')
|
||||
expect_content_type('video/mp4')
|
||||
expect_status(200)
|
||||
|
||||
it 'sets the correct filename' do
|
||||
@ -86,21 +104,21 @@ describe SubmissionsController do
|
||||
let(:file) { submission.files.first }
|
||||
|
||||
context 'with an invalid filename' do
|
||||
before(:each) { get :render_file, filename: SecureRandom.hex, id: submission.id }
|
||||
before(:each) { get :render_file, params: { filename: SecureRandom.hex, id: submission.id } }
|
||||
|
||||
expect_status(404)
|
||||
end
|
||||
|
||||
context 'with a valid filename' do
|
||||
let(:submission) { FactoryBot.create(:submission, exercise: FactoryBot.create(:audio_video)) }
|
||||
before(:each) { get :render_file, filename: file.name_with_extension, id: submission.id }
|
||||
before(:each) { get :render_file, params: { filename: file.name_with_extension, id: submission.id } }
|
||||
|
||||
context 'for a binary file' do
|
||||
let(:file) { submission.collect_files.detect { |file| file.file_type.file_extension == '.mp4' } }
|
||||
|
||||
expect_assigns(file: :file)
|
||||
expect_assigns(submission: :submission)
|
||||
expect_content_type('application/octet-stream')
|
||||
expect_content_type('video/mp4')
|
||||
expect_status(200)
|
||||
|
||||
it 'renders the file content' do
|
||||
@ -125,7 +143,7 @@ describe SubmissionsController do
|
||||
|
||||
describe 'GET #run' do
|
||||
let(:filename) { submission.collect_files.detect(&:main_file?).name_with_extension }
|
||||
let(:request) { get :run, filename: filename, id: submission.id }
|
||||
let(:request) { get :run, params: { filename: filename }, id: submission.id }
|
||||
|
||||
before(:each) do
|
||||
expect_any_instance_of(ActionController::Live::SSE).to receive(:write).at_least(3).times
|
||||
@ -176,7 +194,7 @@ describe SubmissionsController do
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
before(:each) { get :show, id: submission.id }
|
||||
before(:each) { get :show, params: { id: submission.id } }
|
||||
|
||||
expect_assigns(submission: :submission)
|
||||
expect_status(200)
|
||||
@ -188,7 +206,7 @@ describe SubmissionsController do
|
||||
# https://github.com/rails/jbuilder/issues/32
|
||||
render_views
|
||||
|
||||
before(:each) { get :show, id: submission.id, format: :json }
|
||||
before(:each) { get :show, params: { id: submission.id }, format: :json }
|
||||
expect_assigns(submission: :submission)
|
||||
expect_status(200)
|
||||
|
||||
@ -219,14 +237,14 @@ describe SubmissionsController do
|
||||
end
|
||||
|
||||
describe 'GET #score' do
|
||||
let(:request) { proc { get :score, id: submission.id } }
|
||||
let(:request) { proc { get :score, params: { id: submission.id } } }
|
||||
before(:each) { request.call }
|
||||
|
||||
pending("todo: mock puma webserver or encapsulate tubesock call (Tubesock::HijackNotAvailable)")
|
||||
end
|
||||
|
||||
describe 'POST #stop' do
|
||||
let(:request) { proc { post :stop, container_id: CONTAINER.id, id: submission.id } }
|
||||
let(:request) { proc { post :stop, params: { container_id: CONTAINER.id, id: submission.id } } }
|
||||
|
||||
context 'when the container can be found' do
|
||||
before(:each) do
|
||||
@ -269,7 +287,7 @@ describe SubmissionsController do
|
||||
end
|
||||
|
||||
describe '#with_server_sent_events' do
|
||||
let(:response) { ActionController::TestResponse.new }
|
||||
let(:response) { ActionDispatch::TestResponse.new }
|
||||
before(:each) { allow(controller).to receive(:response).and_return(response) }
|
||||
|
||||
context 'when no error occurs' do
|
||||
|
Reference in New Issue
Block a user