Fix reset of tasks

This commit is contained in:
Jan Renz
2015-04-20 22:30:31 +02:00
parent 30985a249e
commit 9c8d0b01eb
7 changed files with 24 additions and 15 deletions

View File

@ -6,7 +6,7 @@ class ExercisesController < ApplicationController
before_action :handle_file_uploads, only: [:create, :update] before_action :handle_file_uploads, only: [:create, :update]
before_action :set_execution_environments, only: [:create, :edit, :new, :update] before_action :set_execution_environments, only: [:create, :edit, :new, :update]
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit] before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit, :reload]
before_action :set_file_types, only: [:create, :edit, :new, :update] before_action :set_file_types, only: [:create, :edit, :new, :update]
before_action :set_teams, only: [:create, :edit, :new, :update] before_action :set_teams, only: [:create, :edit, :new, :update]
@ -138,6 +138,10 @@ class ExercisesController < ApplicationController
def show def show
end end
#we might want to think about auth here
def reload
end
def statistics def statistics
end end

View File

@ -12,12 +12,12 @@ class ExercisePolicy < AdminOrAuthorPolicy
define_method(action) { admin? || author? || team_member? } define_method(action) { admin? || author? || team_member? }
end end
[:implement?, :submit?].each do |action| [:implement?, :submit?, :reload?].each do |action|
define_method(action) { everyone } define_method(action) { everyone }
end end
def team_member? def team_member?
@record.team.try(:members, []).include?(@user) @record.team.try(:members, []).include?(@user) if @record.team
end end
private :team_member? private :team_member?

View File

@ -4,7 +4,7 @@
- @files.each do |file| - @files.each do |file|
= render('editor_frame', exercise: exercise, file: file) = render('editor_frame', exercise: exercise, file: file)
#editor-buttons.btn-group #editor-buttons.btn-group
= render('editor_button', data: {:'data-message-confirm' => t('exercises.editor.confirm_start_over'), :'data-url' => exercise_path(exercise)}, icon: 'fa fa-history', id: 'start-over', label: t('exercises.editor.start_over')) = render('editor_button', data: {:'data-message-confirm' => t('exercises.editor.confirm_start_over'), :'data-url' => reload_exercise_path(exercise)}, icon: 'fa fa-history', id: 'start-over', label: t('exercises.editor.start_over'))
= render('editor_button', data: {:'data-message-success' => t('submissions.create.success'), :'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-save', id: 'save', label: t('exercises.editor.save'), title: t('.tooltips.save')) = render('editor_button', data: {:'data-message-success' => t('submissions.create.success'), :'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-save', id: 'save', label: t('exercises.editor.save'), title: t('.tooltips.save'))
.btn-group .btn-group
= render('editor_button', disabled: true, icon: 'fa fa-ban', id: 'dummy', label: t('exercises.editor.dummy')) = render('editor_button', disabled: true, icon: 'fa fa-ban', id: 'dummy', label: t('exercises.editor.dummy'))

View File

@ -30,5 +30,12 @@ module CodeOcean
config.autoload_paths << Rails.root.join('lib') config.autoload_paths << Rails.root.join('lib')
config.eager_load_paths << Rails.root.join('lib') config.eager_load_paths << Rails.root.join('lib')
case (RUBY_ENGINE)
when 'ruby'
# ...
when 'jruby'
# plattform specific
java.lang.Class.for_name('javax.crypto.JceSecurity').get_declared_field('isRestricted').tap{|f| f.accessible = true; f.set nil, false}
end
end end
end end

View File

@ -40,6 +40,7 @@ Rails.application.routes.draw do
post :clone post :clone
get :implement get :implement
get :statistics get :statistics
get :reload
post :submit post :submit
end end
end end

View File

@ -202,23 +202,20 @@ describe ExercisesController do
describe 'GET #show' do describe 'GET #show' do
context 'as admin' do context 'as admin' do
before(:each) { get :show, id: exercise.id } before(:each) { get :show, id: exercise.id }
expect_assigns(exercise: :exercise) expect_assigns(exercise: :exercise)
expect_status(200) expect_status(200)
expect_template(:show) expect_template(:show)
end end
context 'as internal user' do end
let(:user) { FactoryGirl.create(:internal_user) }
before(:each) { get :show, id: exercise.id } describe 'GET #reload' do
context 'as anyone' do
before(:each) { get :reload, format: :json, id: exercise.id }
expect_assigns(exercise: :exercise) expect_assigns(exercise: :exercise)
expect_status(200) expect_status(200)
expect_template(:show) expect_template(:reload)
end
context 'as external user' do
let(:user) { FactoryGirl.create(:external_user) }
before(:each) { get :show, id: exercise.id }
expect_assigns(exercise: :exercise)
expect_status(200)
expect_template(:show)
end end
end end