Apply automatic rubocop fixes
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::DashboardPolicy do
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ApplicationPolicy do
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe CodeOcean::FilePolicy do
|
||||
@ -19,7 +21,7 @@ describe CodeOcean::FilePolicy do
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
@ -49,7 +51,7 @@ describe CodeOcean::FilePolicy do
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
%i[admin external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
@ -69,7 +71,7 @@ describe CodeOcean::FilePolicy do
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
@ -79,7 +81,7 @@ describe CodeOcean::FilePolicy do
|
||||
let(:file) { submission.files.first }
|
||||
|
||||
it 'does not grant access to anyone' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
%i[admin external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file)
|
||||
end
|
||||
end
|
||||
|
@ -1,13 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ConsumerPolicy do
|
||||
subject { described_class }
|
||||
|
||||
[:create?, :destroy?, :edit?, :index?, :new?, :show?, :update?].each do |action|
|
||||
%i[create? destroy? edit? index? new? show? update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), Consumer.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), Consumer.new)
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ExecutionEnvironmentPolicy do
|
||||
@ -21,7 +23,7 @@ describe ExecutionEnvironmentPolicy do
|
||||
end
|
||||
end
|
||||
|
||||
[:execute_command?, :shell?, :statistics?, :show?].each do |action|
|
||||
%i[execute_command? shell? statistics? show?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), execution_environment)
|
||||
@ -32,14 +34,14 @@ describe ExecutionEnvironmentPolicy do
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), execution_environment)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[:destroy?, :edit?, :update?, :new?, :create?].each do |action|
|
||||
%i[destroy? edit? update? new? create?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), execution_environment)
|
||||
@ -50,7 +52,7 @@ describe ExecutionEnvironmentPolicy do
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), execution_environment)
|
||||
end
|
||||
end
|
||||
|
@ -1,20 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ExercisePolicy do
|
||||
subject { described_class }
|
||||
|
||||
let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
|
||||
permissions :batch_update? do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), exercise)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), exercise)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[:create?, :index?, :new?, :statistics?, :feedback?, :get_rfcs_for_exercise?].each do |action|
|
||||
%i[create? index? new? statistics? feedback? get_rfcs_for_exercise?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), exercise)
|
||||
@ -30,7 +32,7 @@ let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
end
|
||||
end
|
||||
|
||||
[:clone?, :destroy?, :edit?, :update?].each do |action|
|
||||
%i[clone? destroy? edit? update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), exercise)
|
||||
@ -41,14 +43,14 @@ let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), exercise)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[:export_external_check?, :export_external_confirm?].each do |action|
|
||||
%i[export_external_check? export_external_confirm?].each do |action|
|
||||
permissions(action) do
|
||||
context 'when user is author' do
|
||||
let(:user) { exercise.author }
|
||||
@ -82,7 +84,7 @@ let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
end
|
||||
end
|
||||
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
context "when user is #{factory_name}" do
|
||||
let(:user) { FactoryBot.build(factory_name) }
|
||||
|
||||
@ -110,10 +112,10 @@ let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
end
|
||||
end
|
||||
|
||||
[:implement?, :submit?].each do |action|
|
||||
%i[implement? submit?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to anyone' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
%i[admin external_user teacher].each do |factory_name|
|
||||
expect(subject).to permit(FactoryBot.build(factory_name), Exercise.new)
|
||||
end
|
||||
end
|
||||
@ -151,7 +153,6 @@ let(:exercise) { FactoryBot.build(:dummy, public: true) }
|
||||
end
|
||||
|
||||
context 'for teachers' do
|
||||
|
||||
let(:scope) { Pundit.policy_scope!(@teacher, Exercise) }
|
||||
|
||||
it 'includes all public exercises' do
|
||||
|
@ -1,13 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ExternalUserPolicy do
|
||||
subject { described_class }
|
||||
|
||||
[:create?, :destroy?, :edit?, :new?, :show?, :update?].each do |action|
|
||||
%i[create? destroy? edit? new? show? update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), ExternalUser.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), ExternalUser.new)
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FileTypePolicy do
|
||||
@ -5,7 +7,7 @@ describe FileTypePolicy do
|
||||
|
||||
let(:file_type) { FactoryBot.build(:dot_rb) }
|
||||
|
||||
[:destroy?, :edit?, :update?, :new?, :create?, :index?, :show?].each do |action|
|
||||
%i[destroy? edit? update? new? create? index? show?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), file_type)
|
||||
@ -16,7 +18,7 @@ describe FileTypePolicy do
|
||||
end
|
||||
|
||||
it 'does not grant access to all other users' do
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), file_type)
|
||||
end
|
||||
end
|
||||
|
@ -1,13 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe InternalUserPolicy do
|
||||
subject { described_class }
|
||||
|
||||
[:create?, :edit?, :index?, :new?, :show?, :update?].each do |action|
|
||||
%i[create? edit? index? new? show? update?].each do |action|
|
||||
permissions(action) do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), InternalUser.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), InternalUser.new)
|
||||
end
|
||||
end
|
||||
@ -17,7 +19,7 @@ describe InternalUserPolicy do
|
||||
permissions :destroy? do
|
||||
context 'with an admin user' do
|
||||
it 'grants access to no one' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
%i[admin external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), FactoryBot.build(:admin))
|
||||
end
|
||||
end
|
||||
@ -26,7 +28,7 @@ describe InternalUserPolicy do
|
||||
context 'with a non-admin user' do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), InternalUser.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), FactoryBot.build(:teacher))
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe SubmissionPolicy do
|
||||
@ -5,13 +7,13 @@ describe SubmissionPolicy do
|
||||
|
||||
permissions :create? do
|
||||
it 'grants access to anyone' do
|
||||
[:admin, :external_user, :teacher].each do |factory_name|
|
||||
%i[admin external_user teacher].each do |factory_name|
|
||||
expect(subject).to permit(FactoryBot.build(factory_name), Submission.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[:download_file?, :render_file?, :run?, :score?, :show?, :statistics?, :stop?, :test?].each do |action|
|
||||
%i[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(FactoryBot.build(:admin), Submission.new)
|
||||
@ -27,7 +29,7 @@ describe SubmissionPolicy do
|
||||
permissions :index? do
|
||||
it 'grants access to admins only' do
|
||||
expect(subject).to permit(FactoryBot.build(:admin), Submission.new)
|
||||
[:external_user, :teacher].each do |factory_name|
|
||||
%i[external_user teacher].each do |factory_name|
|
||||
expect(subject).not_to permit(FactoryBot.build(factory_name), Submission.new)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user