diff --git a/app/controllers/concerns/file_parameters.rb b/app/controllers/concerns/file_parameters.rb index f816a296..0236b1cb 100644 --- a/app/controllers/concerns/file_parameters.rb +++ b/app/controllers/concerns/file_parameters.rb @@ -6,7 +6,7 @@ module FileParameters params.reject do |_, file_attributes| file = CodeOcean::File.find_by(id: file_attributes[:file_id]) # avoid that public files from other contexts can be created - file.nil? || file.hidden || file.read_only || file.context == 'Exercise' && file.context_id != exercise.id + file.nil? || file.hidden || file.read_only || file.context_type == 'Exercise' && file.context_id != exercise.id end else [] diff --git a/spec/concerns/file_parameters_spec.rb b/spec/concerns/file_parameters_spec.rb index c72e3bd5..73383045 100644 --- a/spec/concerns/file_parameters_spec.rb +++ b/spec/concerns/file_parameters_spec.rb @@ -24,7 +24,8 @@ describe FileParameters do end it 'new file' do - new_file = FactoryBot.create(:file, context: hello_world) + submission = FactoryBot.create(:submission, exercise: hello_world, id: 1337) + new_file = FactoryBot.create(:file, context: submission) expect(file_accepted?(new_file)).to be true end end