Skip to content

Commit

Permalink
Fix Rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSerth committed Jul 31, 2023
1 parent a8f368b commit 8f446c0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
4 changes: 1 addition & 3 deletions spec/controllers/exercises_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@
before do
create(:lti_parameter, external_user: user, exercise:)
submission = build(:submission, exercise:, user:)
allow(submission).to receive(:normalized_score).and_return(1)
allow(submission).to receive(:calculate_score).and_return(scoring_response)
allow(submission).to receive(:redirect_to_feedback?).and_return(false)
allow(submission).to receive_messages(normalized_score: 1, calculate_score: scoring_response, redirect_to_feedback?: false)
allow(Submission).to receive(:create).and_return(submission)
end

Expand Down
6 changes: 2 additions & 4 deletions spec/controllers/internal_users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@
describe 'GET #forgot_password' do
context 'when no user is logged in' do
before do
allow(controller).to receive(:set_sentry_context).and_return(nil)
allow(controller).to receive_messages(set_sentry_context: nil, current_user: nil)

allow(controller).to receive(:current_user).and_return(nil)
get :forgot_password
end

Expand All @@ -190,9 +189,8 @@

context 'when a user is already logged in' do
before do
allow(controller).to receive(:set_sentry_context).and_return(nil)
allow(controller).to receive_messages(set_sentry_context: nil, current_user: user)

allow(controller).to receive(:current_user).and_return(user)
get :forgot_password
end

Expand Down
6 changes: 2 additions & 4 deletions spec/controllers/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@
describe 'GET #new' do
context 'when no user is logged in' do
before do
allow(controller).to receive(:set_sentry_context).and_return(nil)
allow(controller).to receive_messages(set_sentry_context: nil, current_user: nil)

allow(controller).to receive(:current_user).and_return(nil)
get :new
end

Expand All @@ -239,9 +238,8 @@

context 'when a user is already logged in' do
before do
allow(controller).to receive(:set_sentry_context).and_return(nil)
allow(controller).to receive_messages(set_sentry_context: nil, current_user: build(:teacher))

allow(controller).to receive(:current_user).and_return(build(:teacher))
get :new
end

Expand Down
4 changes: 1 addition & 3 deletions spec/helpers/yaml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
next unless /.*.\.yml/.match?(path)

before do
allow(Rails).to receive(:root).and_return(Pathname.new('/tmp'))

app = instance_double Rails::Application
allow(Rails).to receive(:application).and_return app
allow(Rails).to receive_messages(root: Pathname.new('/tmp'), application: app)
allow(app).to receive(:credentials).and_return({})
end

Expand Down
3 changes: 1 addition & 2 deletions spec/models/execution_environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
let(:execution_environment) { described_class.create.tap {|execution_environment| execution_environment.update(network_enabled: nil, privileged_execution: nil) } }

it 'validates that the Docker image works' do
allow(execution_environment).to receive(:validate_docker_image?).and_return(true)
allow(execution_environment).to receive(:working_docker_image?).and_return(true)
allow(execution_environment).to receive_messages(validate_docker_image?: true, working_docker_image?: true)
execution_environment.update(build(:ruby).attributes)
expect(execution_environment).to have_received(:working_docker_image?)
end
Expand Down
9 changes: 3 additions & 6 deletions spec/models/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
let(:runner) { described_class.create }

before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id)
allow(strategy_class).to receive(:new).and_return(strategy)
allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)
end

it 'delegates to its strategy' do
Expand All @@ -73,8 +72,7 @@
let(:connection) { instance_double(Runner::Connection) }

before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id)
allow(strategy_class).to receive(:new).and_return(strategy)
allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)
allow(event_loop).to receive(:wait)
allow(connection).to receive(:error).and_return(nil)
allow(Runner::EventLoop).to receive(:new).and_return(event_loop)
Expand Down Expand Up @@ -128,8 +126,7 @@
let(:runner) { described_class.create }

before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id)
allow(strategy_class).to receive(:new).and_return(strategy)
allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)
end

it 'delegates to its strategy' do
Expand Down

0 comments on commit 8f446c0

Please sign in to comment.