Introduce new enabled option for CodeHarbor

* Fix tests to ensure they work independent of config option
This commit is contained in:
Sebastian Serth
2021-02-16 14:24:35 +01:00
parent bcaa3244f4
commit 293bcccc80
8 changed files with 125 additions and 62 deletions

View File

@ -2,10 +2,11 @@
class CodeharborLinksController < ApplicationController
include CommonBehavior
before_action :verify_codeharbor_activation
before_action :set_codeharbor_link, only: %i[show edit update destroy]
def new
base_url = CodeOcean::Config.new(:code_ocean).read[:codeharbor][:url]
base_url = CodeOcean::Config.new(:code_ocean).read[:codeharbor][:url] || ''
@codeharbor_link = CodeharborLink.new(push_url: base_url + '/import_exercise', check_uuid_url: base_url + '/import_uuid_check')
authorize!
end
@ -36,6 +37,10 @@ class CodeharborLinksController < ApplicationController
authorize @codeharbor_link
end
def verify_codeharbor_activation
raise Pundit::NotAuthorizedError unless policy(CodeharborLink).enabled?
end
def set_codeharbor_link
@codeharbor_link = CodeharborLink.find(params[:id])
@codeharbor_link.user = current_user