do not render the development environment for exercises without visible files
This commit is contained in:
@ -82,6 +82,7 @@ class ExercisesController < ApplicationController
|
||||
private :handle_file_uploads
|
||||
|
||||
def implement
|
||||
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
|
||||
@submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
||||
@files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible).sort_by(&:name_with_extension)
|
||||
@paths = collect_paths(@files)
|
||||
|
@ -1,3 +1,3 @@
|
||||
#flash data-message-failure=t('shared.message_failure')
|
||||
- %w[danger info notice success warning].each do |severity|
|
||||
p.alert.flash class="alert-#{severity == 'notice' ? 'success' : severity}" id="flash-#{severity}" = flash[severity]
|
||||
- %w[alert danger info notice success warning].each do |severity|
|
||||
p.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}" id="flash-#{severity}" = flash[severity]
|
||||
|
@ -199,6 +199,7 @@ de:
|
||||
feedback: Feedback
|
||||
file: 'Test-Datei <span class="number">%{number}</span> (<span class="filename">%{filename}</span>)'
|
||||
hint: Tipp
|
||||
no_files: Die Aufgabe umfasst noch keine sichtbaren Dateien.
|
||||
no_output: Die letzte Code-Ausführung hat keine Ausgabe erzeugt.
|
||||
no_output_yet: Bisher existiert noch keine Ausgabe.
|
||||
output: Programm-Ausgabe
|
||||
|
@ -199,6 +199,7 @@ en:
|
||||
feedback: Feedback
|
||||
file: 'Test File <span class="number">%{number}</span> (<span class="filename">%{filename}</span>)'
|
||||
hint: Hint
|
||||
no_files: The exercise does not comprise visible files yet.
|
||||
no_output: The last code run has not generated any output.
|
||||
no_output_yet: There is no output yet.
|
||||
output: Program Output
|
||||
|
@ -146,12 +146,15 @@ describe ExercisesController do
|
||||
|
||||
describe 'GET #implement' do
|
||||
let(:request) { proc { get :implement, id: exercise.id } }
|
||||
|
||||
context 'with an exercise with visible files' do
|
||||
let(:exercise) { FactoryGirl.create(:fibonacci) }
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
|
||||
context 'with an existing submission' do
|
||||
let!(:submission) { FactoryGirl.create(:submission, exercise_id: exercise.id, user_id: user.id, user_type: InternalUser.class.name) }
|
||||
let!(:submission) { FactoryGirl.create(:submission, exercise_id: exercise.id, user_id: user.id, user_type: user.class.name) }
|
||||
|
||||
it "populates the editors with the submission's files' content" do
|
||||
request.call
|
||||
@ -169,6 +172,15 @@ describe ExercisesController do
|
||||
expect_template(:implement)
|
||||
end
|
||||
|
||||
context 'with an exercise without visible files' do
|
||||
before(:each) { request.call }
|
||||
|
||||
expect_assigns(exercise: :exercise)
|
||||
expect_flash_message(:alert, :'exercises.implement.no_files')
|
||||
expect_redirect(:exercise)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
let(:scope) { Pundit.policy_scope!(user, Exercise) }
|
||||
before(:all) { FactoryGirl.create_pair(:dummy) }
|
||||
|
Reference in New Issue
Block a user