rename factory_girl_(rails) to factory_bot_(rails)
This commit is contained in:
@ -5,15 +5,15 @@ describe Admin::DashboardPolicy do
|
||||
|
||||
permissions :show? do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), :dashboard)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), :dashboard)
|
||||
end
|
||||
|
||||
it 'does not grant access to teachers' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:teacher), :dashboard)
|
||||
expect(subject).not_to permit(FactoryBot.build(:teacher), :dashboard)
|
||||
end
|
||||
|
||||
it 'does not grant access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), :dashboard)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), :dashboard)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,15 +3,15 @@ require 'rails_helper'
|
||||
describe CodeOcean::FilePolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:exercise) { FactoryGirl.create(:fibonacci) }
|
||||
let(:submission) { FactoryGirl.create(:submission) }
|
||||
let(:exercise) { FactoryBot.create(:fibonacci) }
|
||||
let(:submission) { FactoryBot.create(:submission) }
|
||||
|
||||
permissions :create? do
|
||||
context 'as part of an exercise' do
|
||||
let(:file) { exercise.files.first }
|
||||
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), file)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), file)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -20,7 +20,7 @@ describe CodeOcean::FilePolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), file)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -34,7 +34,7 @@ describe CodeOcean::FilePolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), file)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -45,7 +45,7 @@ describe CodeOcean::FilePolicy do
|
||||
let(:file) { exercise.files.first }
|
||||
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), file)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), file)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -54,7 +54,7 @@ describe CodeOcean::FilePolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), file)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,7 +64,7 @@ describe CodeOcean::FilePolicy do
|
||||
|
||||
it 'does not grant access to anyone' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), file)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,9 +6,9 @@ describe ConsumerPolicy do
|
||||
[:create?, :destroy?, :edit?, :index?, :new?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), Consumer.new)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), Consumer.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), Consumer.new)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), Consumer.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,20 +3,20 @@ require 'rails_helper'
|
||||
describe ErrorPolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:error) { FactoryGirl.build(:error) }
|
||||
let(:error) { FactoryBot.build(:error) }
|
||||
|
||||
[:create?, :index?, :new?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), error)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), error)
|
||||
end
|
||||
|
||||
it 'grants access to teachers' do
|
||||
expect(subject).to permit(FactoryGirl.build(:teacher), error)
|
||||
expect(subject).to permit(FactoryBot.build(:teacher), error)
|
||||
end
|
||||
|
||||
it 'does not grant access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), error)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), error)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ describe ErrorPolicy do
|
||||
[:destroy?, :edit?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), error)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), error)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -33,7 +33,7 @@ describe ErrorPolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), error)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,20 +3,20 @@ require 'rails_helper'
|
||||
describe ExecutionEnvironmentPolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:execution_environment) { FactoryGirl.build(:ruby) }
|
||||
let(:execution_environment) { FactoryBot.build(:ruby) }
|
||||
|
||||
[:create?, :index?, :new?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), execution_environment)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), execution_environment)
|
||||
end
|
||||
|
||||
it 'grants access to teachers' do
|
||||
expect(subject).to permit(FactoryGirl.build(:teacher), execution_environment)
|
||||
expect(subject).to permit(FactoryBot.build(:teacher), execution_environment)
|
||||
end
|
||||
|
||||
it 'does not grant access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), execution_environment)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), execution_environment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ describe ExecutionEnvironmentPolicy do
|
||||
[:execute_command?, :shell?, :statistics?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), execution_environment)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), execution_environment)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -33,7 +33,7 @@ describe ExecutionEnvironmentPolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), execution_environment)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), execution_environment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -42,7 +42,7 @@ describe ExecutionEnvironmentPolicy do
|
||||
[:destroy?, :edit?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), execution_environment)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), execution_environment)
|
||||
end
|
||||
|
||||
it 'does not grant access to authors' do
|
||||
@ -51,7 +51,7 @@ describe ExecutionEnvironmentPolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), execution_environment)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), execution_environment)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,13 +3,13 @@ require 'rails_helper'
|
||||
describe ExercisePolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
let(:exercise) { FactoryBot.build(:dummy) }
|
||||
|
||||
permissions :batch_update? do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), exercise)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), exercise)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), exercise)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), exercise)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -17,15 +17,15 @@ let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
[:create?, :index?, :new?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), exercise)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), exercise)
|
||||
end
|
||||
|
||||
it 'grants access to teachers' do
|
||||
expect(subject).to permit(FactoryGirl.build(:teacher), exercise)
|
||||
expect(subject).to permit(FactoryBot.build(:teacher), exercise)
|
||||
end
|
||||
|
||||
it 'does not grant access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), exercise)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), exercise)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -33,7 +33,7 @@ let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
[:clone?, :destroy?, :edit?, :statistics?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), exercise)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), exercise)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -42,7 +42,7 @@ let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), exercise)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), exercise)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -51,7 +51,7 @@ let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
[:show?].each do |action|
|
||||
permissions(action) do
|
||||
it 'not grants access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), exercise)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), exercise)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -60,7 +60,7 @@ let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
permissions(action) do
|
||||
it 'grants access to anyone' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
expect(subject).to permit(FactoryGirl.build(factory_name), Exercise.new)
|
||||
expect(subject).to permit(FactoryBot.build(factory_name), Exercise.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -69,13 +69,13 @@ let(:exercise) { FactoryGirl.build(:dummy) }
|
||||
describe ExercisePolicy::Scope do
|
||||
describe '#resolve' do
|
||||
before(:all) do
|
||||
@admin = FactoryGirl.create(:admin)
|
||||
@external_user = FactoryGirl.create(:external_user)
|
||||
@teacher = FactoryGirl.create(:teacher)
|
||||
@admin = FactoryBot.create(:admin)
|
||||
@external_user = FactoryBot.create(:external_user)
|
||||
@teacher = FactoryBot.create(:teacher)
|
||||
|
||||
[@admin, @teacher].each do |user|
|
||||
[true, false].each do |public|
|
||||
FactoryGirl.create(:dummy, public: public, user_id: user.id, user_type: InternalUser.class.name)
|
||||
FactoryBot.create(:dummy, public: public, user_id: user.id, user_type: InternalUser.class.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,9 +6,9 @@ describe ExternalUserPolicy do
|
||||
[:create?, :destroy?, :edit?, :index?, :new?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), ExternalUser.new)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), ExternalUser.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), ExternalUser.new)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), ExternalUser.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,20 +3,20 @@ require 'rails_helper'
|
||||
describe FileTypePolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:file_type) { FactoryGirl.build(:dot_rb) }
|
||||
let(:file_type) { FactoryBot.build(:dot_rb) }
|
||||
|
||||
[:create?, :index?, :new?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), file_type)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), file_type)
|
||||
end
|
||||
|
||||
it 'grants access to teachers' do
|
||||
expect(subject).to permit(FactoryGirl.build(:teacher), file_type)
|
||||
expect(subject).to permit(FactoryBot.build(:teacher), file_type)
|
||||
end
|
||||
|
||||
it 'does not grant access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), file_type)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), file_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ describe FileTypePolicy do
|
||||
[:destroy?, :edit?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), file_type)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), file_type)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -33,7 +33,7 @@ describe FileTypePolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), file_type)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,20 +3,20 @@ require 'rails_helper'
|
||||
describe HintPolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:hint) { FactoryGirl.build(:ruby_no_method_error) }
|
||||
let(:hint) { FactoryBot.build(:ruby_no_method_error) }
|
||||
|
||||
[:create?, :index?, :new?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), hint)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), hint)
|
||||
end
|
||||
|
||||
it 'grants access to teachers' do
|
||||
expect(subject).to permit(FactoryGirl.build(:teacher), hint)
|
||||
expect(subject).to permit(FactoryBot.build(:teacher), hint)
|
||||
end
|
||||
|
||||
it 'does not grant access to external users' do
|
||||
expect(subject).not_to permit(FactoryGirl.build(:external_user), hint)
|
||||
expect(subject).not_to permit(FactoryBot.build(:external_user), hint)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ describe HintPolicy do
|
||||
[:destroy?, :edit?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), hint)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), hint)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
@ -33,7 +33,7 @@ describe HintPolicy do
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), hint)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), hint)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,9 +6,9 @@ describe InternalUserPolicy do
|
||||
[:create?, :edit?, :index?, :new?, :show?, :update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), InternalUser.new)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), InternalUser.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), InternalUser.new)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), InternalUser.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -18,16 +18,16 @@ describe InternalUserPolicy do
|
||||
context 'with an admin user' do
|
||||
it 'grants access to no one' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), FactoryGirl.build(:admin))
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), FactoryGirl.build(:admin))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a non-admin user' do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), InternalUser.new)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), InternalUser.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), FactoryGirl.build(:teacher))
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), FactoryGirl.build(:teacher))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ describe SubmissionPolicy do
|
||||
permissions :create? do
|
||||
it 'grants access to anyone' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
expect(subject).to permit(FactoryGirl.build(factory_name), Submission.new)
|
||||
expect(subject).to permit(FactoryBot.build(factory_name), Submission.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -14,21 +14,21 @@ describe SubmissionPolicy do
|
||||
[:download_file?, :render_file?, :run?, :score?, :show?, :statistics?, :stop?, :test?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), Submission.new)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), Submission.new)
|
||||
end
|
||||
|
||||
it 'grants access to authors' do
|
||||
user = FactoryGirl.create(:external_user)
|
||||
expect(subject).to permit(user, FactoryGirl.build(:submission, exercise: Exercise.new, user_id: user.id, user_type: user.class.name))
|
||||
user = FactoryBot.create(:external_user)
|
||||
expect(subject).to permit(user, FactoryBot.build(:submission, exercise: Exercise.new, user_id: user.id, user_type: user.class.name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
permissions :index? do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryGirl.build(:admin), Submission.new)
|
||||
expect(subject).to permit(FactoryBot.build(:admin), Submission.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryGirl.build(factory_name), Submission.new)
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), Submission.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user