rename route
This commit is contained in:
@ -18,9 +18,9 @@ class ExercisesController < ApplicationController
|
||||
before_action :set_course_token, only: [:implement]
|
||||
before_action :set_available_tips, only: %i[implement show new edit]
|
||||
|
||||
skip_before_action :verify_authenticity_token, only: %i[import_exercise import_uuid_check]
|
||||
skip_after_action :verify_authorized, only: %i[import_exercise import_uuid_check]
|
||||
skip_after_action :verify_policy_scoped, only: %i[import_exercise import_uuid_check], raise: false
|
||||
skip_before_action :verify_authenticity_token, only: %i[import_task import_uuid_check]
|
||||
skip_after_action :verify_authorized, only: %i[import_task import_uuid_check]
|
||||
skip_after_action :verify_policy_scoped, only: %i[import_task import_uuid_check], raise: false
|
||||
|
||||
rescue_from Pundit::NotAuthorizedError, with: :not_authorized_for_exercise
|
||||
|
||||
@ -169,7 +169,7 @@ class ExercisesController < ApplicationController
|
||||
render json: {uuid_found: true, update_right: true}
|
||||
end
|
||||
|
||||
def import_exercise
|
||||
def import_task
|
||||
tempfile = Tempfile.new('codeharbor_import.zip')
|
||||
tempfile.write request.body.read.force_encoding('UTF-8')
|
||||
tempfile.rewind
|
||||
|
@ -10,13 +10,13 @@ module ProformaService
|
||||
end
|
||||
|
||||
def execute
|
||||
import_exercise
|
||||
import_task
|
||||
@exercise
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def import_exercise
|
||||
def import_task
|
||||
@exercise.assign_attributes(
|
||||
user: @user,
|
||||
title: @task.title,
|
||||
|
@ -73,7 +73,7 @@ Rails.application.routes.draw do
|
||||
post :sync_all_to_runner_management, on: :collection
|
||||
end
|
||||
|
||||
post '/import_exercise' => 'exercises#import_exercise'
|
||||
post '/import_task' => 'exercises#import_task'
|
||||
post '/import_uuid_check' => 'exercises#import_uuid_check'
|
||||
|
||||
resources :exercises do
|
||||
|
@ -539,10 +539,10 @@ describe ExercisesController do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #import_exercise' do
|
||||
describe 'POST #import_task' do
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let!(:imported_exercise) { create(:fibonacci) }
|
||||
let(:post_request) { post :import_exercise, body: zip_file_content }
|
||||
let(:post_request) { post :import_task, body: zip_file_content }
|
||||
let(:zip_file_content) { 'zipped task xml' }
|
||||
let(:headers) { {'Authorization' => "Bearer #{codeharbor_link.api_key}"} }
|
||||
|
||||
|
Reference in New Issue
Block a user