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