Fix in models/exercise_spec.rb, repair average_percentage without submission
This commit is contained in:
4
.rspec
4
.rspec
@ -1,2 +1,6 @@
|
||||
--color
|
||||
--format NyanCatWideFormatter
|
||||
|
||||
--require spec_helper
|
||||
--order random
|
||||
--format documentation
|
||||
|
2
Gemfile
2
Gemfile
@ -49,12 +49,12 @@ group :development do
|
||||
gem 'capistrano-upload-config'
|
||||
gem 'rubocop', require: false
|
||||
gem 'rubocop-rspec'
|
||||
gem 'web-console', '~> 2.0', platform: :ruby
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
gem 'byebug', platform: :ruby
|
||||
gem 'spring'
|
||||
gem 'web-console', '~> 2.0', platform: :ruby
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
@ -30,7 +30,7 @@ class Exercise < ActiveRecord::Base
|
||||
|
||||
|
||||
def average_percentage
|
||||
if average_score and maximum_score != 0.0
|
||||
if average_score and maximum_score != 0.0 and submissions.exists?(cause: 'submit')
|
||||
(average_score / maximum_score * 100).round
|
||||
else
|
||||
0
|
||||
|
@ -121,7 +121,7 @@ describe ExecutionEnvironment do
|
||||
|
||||
describe '#working_docker_image?', docker: true do
|
||||
let(:working_docker_image?) { execution_environment.send(:working_docker_image?) }
|
||||
before(:each) { expect(DockerClient).to receive(:find_image_by_tag).and_return(Object.new) }
|
||||
before(:each) { expect(DockerClient).to receive(:find_image_by_tag) }
|
||||
|
||||
it 'instantiates a Docker client' do
|
||||
expect(DockerClient).to receive(:new).with(execution_environment: execution_environment).and_call_original
|
||||
|
@ -50,7 +50,7 @@ describe Exercise do
|
||||
|
||||
context 'without submissions' do
|
||||
it 'returns nil' do
|
||||
expect(exercise.average_percentage).to be nil
|
||||
expect(exercise.average_percentage).to be 0
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,6 +33,11 @@ RSpec.configure do |config|
|
||||
config.filter_run :focus
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
|
||||
#for --next-failure feature purpose
|
||||
config.example_status_persistence_file_path = "examples.txt"
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
# Many RSpec users commonly either run the entire suite or an individual
|
||||
# file, and it's useful to allow more verbose output when running an
|
||||
# individual spec file.
|
||||
|
Reference in New Issue
Block a user