rename factory_girl_(rails) to factory_bot_(rails)
This commit is contained in:
@ -12,7 +12,7 @@ describe Consumer do
|
||||
end
|
||||
|
||||
it 'validates the uniqueness of the OAuth key' do
|
||||
consumer.update(oauth_key: FactoryGirl.create(:consumer).oauth_key)
|
||||
consumer.update(oauth_key: FactoryBot.create(:consumer).oauth_key)
|
||||
expect(consumer.errors[:oauth_key]).to be_present
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ describe ExecutionEnvironment do
|
||||
it 'validates that the Docker image works', docker: true do
|
||||
expect(execution_environment).to receive(:validate_docker_image?).and_return(true)
|
||||
expect(execution_environment).to receive(:working_docker_image?)
|
||||
execution_environment.update(docker_image: FactoryGirl.attributes_for(:ruby)[:docker_image])
|
||||
execution_environment.update(docker_image: FactoryBot.attributes_for(:ruby)[:docker_image])
|
||||
end
|
||||
|
||||
it 'validates the presence of a Docker image name' do
|
||||
@ -69,7 +69,7 @@ describe ExecutionEnvironment do
|
||||
|
||||
describe '#valid_test_setup?' do
|
||||
context 'with a test command and a testing framework' do
|
||||
before(:each) { execution_environment.update(test_command: FactoryGirl.attributes_for(:ruby)[:test_command], testing_framework: FactoryGirl.attributes_for(:ruby)[:testing_framework]) }
|
||||
before(:each) { execution_environment.update(test_command: FactoryBot.attributes_for(:ruby)[:test_command], testing_framework: FactoryGirl.attributes_for(:ruby)[:testing_framework]) }
|
||||
|
||||
it 'is valid' do
|
||||
expect(execution_environment.errors[:test_command]).to be_blank
|
||||
@ -77,7 +77,7 @@ describe ExecutionEnvironment do
|
||||
end
|
||||
|
||||
context 'with a test command but no testing framework' do
|
||||
before(:each) { execution_environment.update(test_command: FactoryGirl.attributes_for(:ruby)[:test_command], testing_framework: nil) }
|
||||
before(:each) { execution_environment.update(test_command: FactoryBot.attributes_for(:ruby)[:test_command], testing_framework: nil) }
|
||||
|
||||
it 'is invalid' do
|
||||
expect(execution_environment.errors[:test_command]).to be_present
|
||||
@ -85,7 +85,7 @@ describe ExecutionEnvironment do
|
||||
end
|
||||
|
||||
context 'with no test command but a testing framework' do
|
||||
before(:each) { execution_environment.update(test_command: nil, testing_framework: FactoryGirl.attributes_for(:ruby)[:testing_framework]) }
|
||||
before(:each) { execution_environment.update(test_command: nil, testing_framework: FactoryBot.attributes_for(:ruby)[:testing_framework]) }
|
||||
|
||||
it 'is invalid' do
|
||||
expect(execution_environment.errors[:test_command]).to be_present
|
||||
@ -113,7 +113,7 @@ describe ExecutionEnvironment do
|
||||
end
|
||||
|
||||
it 'is true otherwise' do
|
||||
execution_environment.docker_image = FactoryGirl.attributes_for(:ruby)[:docker_image]
|
||||
execution_environment.docker_image = FactoryBot.attributes_for(:ruby)[:docker_image]
|
||||
allow(Rails.env).to receive(:test?).and_return(false)
|
||||
expect(execution_environment.send(:validate_docker_image?)).to be true
|
||||
end
|
||||
|
@ -2,17 +2,17 @@ require 'rails_helper'
|
||||
|
||||
describe Exercise do
|
||||
let(:exercise) { described_class.create.tap { |exercise| exercise.update(public: nil, token: nil) } }
|
||||
let(:users) { FactoryGirl.create_list(:external_user, 10) }
|
||||
let(:users) { FactoryBot.create_list(:external_user, 10) }
|
||||
|
||||
def create_submissions
|
||||
10.times do
|
||||
FactoryGirl.create(:submission, cause: 'submit', exercise: exercise, score: Forgery(:basic).number, user: users.sample)
|
||||
FactoryBot.create(:submission, cause: 'submit', exercise: exercise, score: Forgery(:basic).number, user: users.sample)
|
||||
end
|
||||
end
|
||||
|
||||
it 'validates the number of main files' do
|
||||
exercise = FactoryGirl.create(:dummy)
|
||||
exercise.files += FactoryGirl.create_pair(:file)
|
||||
exercise = FactoryBot.create(:dummy)
|
||||
exercise.files += FactoryBot.create_pair(:file)
|
||||
expect(exercise).to receive(:valid_main_file?).and_call_original
|
||||
exercise.save
|
||||
expect(exercise.errors[:files]).to be_present
|
||||
@ -46,7 +46,7 @@ describe Exercise do
|
||||
end
|
||||
|
||||
describe '#average_percentage' do
|
||||
let(:exercise) { FactoryGirl.create(:fibonacci) }
|
||||
let(:exercise) { FactoryBot.create(:fibonacci) }
|
||||
|
||||
context 'without submissions' do
|
||||
it 'returns nil' do
|
||||
@ -65,7 +65,7 @@ describe Exercise do
|
||||
end
|
||||
|
||||
describe '#average_score' do
|
||||
let(:exercise) { FactoryGirl.create(:fibonacci) }
|
||||
let(:exercise) { FactoryBot.create(:fibonacci) }
|
||||
|
||||
context 'without submissions' do
|
||||
it 'returns nil' do
|
||||
@ -84,7 +84,7 @@ describe Exercise do
|
||||
end
|
||||
|
||||
describe '#duplicate' do
|
||||
let(:exercise) { FactoryGirl.create(:fibonacci) }
|
||||
let(:exercise) { FactoryBot.create(:fibonacci) }
|
||||
after(:each) { exercise.duplicate }
|
||||
|
||||
it 'duplicates the exercise' do
|
||||
|
@ -13,7 +13,7 @@ describe ExternalUser do
|
||||
|
||||
describe '#admin?' do
|
||||
it 'is false' do
|
||||
expect(FactoryGirl.build(:external_user).admin?).to be false
|
||||
expect(FactoryBot.build(:external_user).admin?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@ -31,7 +31,7 @@ describe ExternalUser do
|
||||
|
||||
describe '#teacher?' do
|
||||
it 'is false' do
|
||||
expect(FactoryGirl.build(:external_user).teacher?).to be false
|
||||
expect(FactoryBot.build(:external_user).teacher?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,12 +9,12 @@ describe InternalUser do
|
||||
end
|
||||
|
||||
it 'validates the uniqueness of the email address' do
|
||||
user.update(email: FactoryGirl.create(:admin).email)
|
||||
user.update(email: FactoryBot.create(:admin).email)
|
||||
expect(user.errors[:email]).to be_present
|
||||
end
|
||||
|
||||
context 'when not activated' do
|
||||
let(:user) { FactoryGirl.create(:teacher) }
|
||||
let(:user) { FactoryBot.create(:teacher) }
|
||||
|
||||
before(:each) do
|
||||
user.send(:setup_activation)
|
||||
@ -33,7 +33,7 @@ describe InternalUser do
|
||||
end
|
||||
|
||||
context 'with a pending password reset' do
|
||||
let(:user) { FactoryGirl.create(:teacher) }
|
||||
let(:user) { FactoryBot.create(:teacher) }
|
||||
before(:each) { user.deliver_reset_password_instructions! }
|
||||
|
||||
it 'validates the confirmation of the password' do
|
||||
@ -48,7 +48,7 @@ describe InternalUser do
|
||||
end
|
||||
|
||||
context 'when complete' do
|
||||
let(:user) { FactoryGirl.create(:teacher, activation_state: 'active') }
|
||||
let(:user) { FactoryBot.create(:teacher, activation_state: 'active') }
|
||||
|
||||
it 'does not validate the confirmation of the password' do
|
||||
user.update(password: password, password_confirmation: '')
|
||||
@ -71,8 +71,8 @@ describe InternalUser do
|
||||
|
||||
describe '#admin?' do
|
||||
it 'is only true for admins' do
|
||||
expect(FactoryGirl.build(:admin).admin?).to be true
|
||||
expect(FactoryGirl.build(:teacher).admin?).to be false
|
||||
expect(FactoryBot.build(:admin).admin?).to be true
|
||||
expect(FactoryBot.build(:teacher).admin?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@ -90,8 +90,8 @@ describe InternalUser do
|
||||
|
||||
describe '#teacher?' do
|
||||
it 'is only true for teachers' do
|
||||
expect(FactoryGirl.build(:admin).teacher?).to be false
|
||||
expect(FactoryGirl.build(:teacher).teacher?).to be true
|
||||
expect(FactoryBot.build(:admin).teacher?).to be false
|
||||
expect(FactoryBot.build(:teacher).teacher?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Submission do
|
||||
let(:submission) { FactoryGirl.create(:submission, exercise: FactoryGirl.create(:dummy)) }
|
||||
let(:submission) { FactoryBot.create(:submission, exercise: FactoryGirl.create(:dummy)) }
|
||||
|
||||
it 'validates the presence of a cause' do
|
||||
expect(described_class.create.errors[:cause]).to be_present
|
||||
@ -17,7 +17,7 @@ describe Submission do
|
||||
end
|
||||
|
||||
describe '#main_file' do
|
||||
let(:submission) { FactoryGirl.create(:submission) }
|
||||
let(:submission) { FactoryBot.create(:submission) }
|
||||
|
||||
it "returns the submission's main file" do
|
||||
expect(submission.main_file).to be_a(CodeOcean::File)
|
||||
@ -27,7 +27,7 @@ describe Submission do
|
||||
|
||||
describe '#normalized_score' do
|
||||
context 'with a score' do
|
||||
let(:submission) { FactoryGirl.create(:submission) }
|
||||
let(:submission) { FactoryBot.create(:submission) }
|
||||
before(:each) { submission.score = submission.exercise.maximum_score / 2 }
|
||||
|
||||
it 'returns the score as a value between 0 and 1' do
|
||||
@ -46,7 +46,7 @@ describe Submission do
|
||||
|
||||
describe '#percentage' do
|
||||
context 'with a score' do
|
||||
let(:submission) { FactoryGirl.create(:submission) }
|
||||
let(:submission) { FactoryBot.create(:submission) }
|
||||
before(:each) { submission.score = submission.exercise.maximum_score / 2 }
|
||||
|
||||
it 'returns the score expressed as a percentage' do
|
||||
@ -65,11 +65,11 @@ describe Submission do
|
||||
|
||||
describe '#siblings' do
|
||||
let(:siblings) { described_class.find_by(user: user).siblings }
|
||||
let(:user) { FactoryGirl.create(:external_user) }
|
||||
let(:user) { FactoryBot.create(:external_user) }
|
||||
|
||||
before(:each) do
|
||||
10.times.each_with_index do |_, index|
|
||||
FactoryGirl.create(:submission, exercise: submission.exercise, user: (index.even? ? user : FactoryGirl.create(:external_user)))
|
||||
FactoryBot.create(:submission, exercise: submission.exercise, user: (index.even? ? user : FactoryGirl.create(:external_user)))
|
||||
end
|
||||
end
|
||||
|
||||
@ -89,9 +89,9 @@ describe Submission do
|
||||
describe '#redirect_to_feedback?' do
|
||||
|
||||
context 'with no exercise feedback' do
|
||||
let(:exercise) {FactoryGirl.create(:dummy)}
|
||||
let(:user) {FactoryGirl.build(:external_user, id: (11 - exercise.created_at.to_i % 10) % 10)}
|
||||
let(:submission) {FactoryGirl.build(:submission, exercise: exercise, user: user)}
|
||||
let(:exercise) {FactoryBot.create(:dummy)}
|
||||
let(:user) {FactoryBot.build(:external_user, id: (11 - exercise.created_at.to_i % 10) % 10)}
|
||||
let(:submission) {FactoryBot.build(:submission, exercise: exercise, user: user)}
|
||||
|
||||
it 'sends 10% of users to feedback page' do
|
||||
expect(submission.send(:redirect_to_feedback?)).to be_truthy
|
||||
@ -99,16 +99,16 @@ describe Submission do
|
||||
|
||||
it 'does not redirect other users' do
|
||||
9.times do |i|
|
||||
submission = FactoryGirl.build(:submission, exercise: exercise, user: FactoryGirl.build(:external_user, id: (11 - exercise.created_at.to_i % 10) - i - 1))
|
||||
submission = FactoryBot.build(:submission, exercise: exercise, user: FactoryGirl.build(:external_user, id: (11 - exercise.created_at.to_i % 10) - i - 1))
|
||||
expect(submission.send(:redirect_to_feedback?)).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with little exercise feedback' do
|
||||
let(:exercise) {FactoryGirl.create(:dummy_with_user_feedbacks)}
|
||||
let(:user) {FactoryGirl.build(:external_user, id: (11 - exercise.created_at.to_i % 10) % 10)}
|
||||
let(:submission) {FactoryGirl.build(:submission, exercise: exercise, user: user)}
|
||||
let(:exercise) {FactoryBot.create(:dummy_with_user_feedbacks)}
|
||||
let(:user) {FactoryBot.build(:external_user, id: (11 - exercise.created_at.to_i % 10) % 10)}
|
||||
let(:submission) {FactoryBot.build(:submission, exercise: exercise, user: user)}
|
||||
|
||||
it 'sends 10% of users to feedback page' do
|
||||
expect(submission.send(:redirect_to_feedback?)).to be_truthy
|
||||
@ -116,19 +116,19 @@ describe Submission do
|
||||
|
||||
it 'does not redirect other users' do
|
||||
9.times do |i|
|
||||
submission = FactoryGirl.build(:submission, exercise: exercise, user: FactoryGirl.build(:external_user, id: (11 - exercise.created_at.to_i % 10) - i - 1))
|
||||
submission = FactoryBot.build(:submission, exercise: exercise, user: FactoryGirl.build(:external_user, id: (11 - exercise.created_at.to_i % 10) - i - 1))
|
||||
expect(submission.send(:redirect_to_feedback?)).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with enough exercise feedback' do
|
||||
let(:exercise) {FactoryGirl.create(:dummy_with_user_feedbacks, user_feedbacks_count: 42)}
|
||||
let(:user) {FactoryGirl.create(:external_user)}
|
||||
let(:exercise) {FactoryBot.create(:dummy_with_user_feedbacks, user_feedbacks_count: 42)}
|
||||
let(:user) {FactoryBot.create(:external_user)}
|
||||
|
||||
it 'sends nobody to feedback page' do
|
||||
30.times do |i|
|
||||
submission = FactoryGirl.create(:submission, exercise: exercise, user: FactoryGirl.create(:external_user))
|
||||
submission = FactoryBot.create(:submission, exercise: exercise, user: FactoryGirl.create(:external_user))
|
||||
expect(submission.send(:redirect_to_feedback?)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user