use shorter notation for creating procs, as suggested by RuboCop

This commit is contained in:
Hauke Klement
2015-02-17 08:21:00 +01:00
parent f6965aff12
commit b21a7ee8e8
15 changed files with 20 additions and 20 deletions

View File

@ -11,7 +11,7 @@ module CodeOcean
def create def create
@file = CodeOcean::File.new(file_params) @file = CodeOcean::File.new(file_params)
authorize! authorize!
create_and_respond(object: @file, path: Proc.new { implement_exercise_path(@file.context.exercise, tab: 2) }) create_and_respond(object: @file, path: proc { implement_exercise_path(@file.context.exercise, tab: 2) })
end end
def destroy def destroy

View File

@ -12,7 +12,7 @@ class HintsController < ApplicationController
def create def create
@hint = Hint.new(hint_params) @hint = Hint.new(hint_params)
authorize! authorize!
create_and_respond(object: @hint, path: Proc.new { execution_environment_hint_path(@execution_environment, @hint) }) create_and_respond(object: @hint, path: proc { execution_environment_hint_path(@execution_environment, @hint) })
end end
def destroy def destroy

View File

@ -13,7 +13,7 @@ describe SubmissionScoring do
before(:each) { controller.instance_variable_set(:@current_user, FactoryGirl.create(:external_user)) } before(:each) { controller.instance_variable_set(:@current_user, FactoryGirl.create(:external_user)) }
describe '#score_submission' do describe '#score_submission' do
let(:score_submission) { Proc.new { controller.score_submission(@submission) } } let(:score_submission) { proc { controller.score_submission(@submission) } }
before(:each) { score_submission.call } before(:each) { score_submission.call }
it 'assigns @assessor' do it 'assigns @assessor' do

View File

@ -8,7 +8,7 @@ describe CodeOcean::FilesController do
let(:submission) { FactoryGirl.create(:submission, user: user) } let(:submission) { FactoryGirl.create(:submission, user: user) }
context 'with a valid file' do context 'with a valid file' do
let(:request) { Proc.new { post :create, code_ocean_file: FactoryGirl.build(:file, context: submission).attributes, format: :json } } let(:request) { proc { post :create, code_ocean_file: FactoryGirl.build(:file, context: submission).attributes, format: :json } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(file: CodeOcean::File) expect_assigns(file: CodeOcean::File)
@ -32,7 +32,7 @@ describe CodeOcean::FilesController do
describe 'DELETE #destroy' do describe 'DELETE #destroy' do
let(:exercise) { FactoryGirl.create(:fibonacci) } let(:exercise) { FactoryGirl.create(:fibonacci) }
let(:request) { Proc.new { delete :destroy, id: exercise.files.first.id } } let(:request) { proc { delete :destroy, id: exercise.files.first.id } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(file: CodeOcean::File) expect_assigns(file: CodeOcean::File)

View File

@ -7,7 +7,7 @@ describe ConsumersController do
describe 'POST #create' do describe 'POST #create' do
context 'with a valid consumer' do context 'with a valid consumer' do
let(:request) { Proc.new { post :create, consumer: FactoryGirl.attributes_for(:consumer) } } let(:request) { proc { post :create, consumer: FactoryGirl.attributes_for(:consumer) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(consumer: Consumer) expect_assigns(consumer: Consumer)

View File

@ -8,7 +8,7 @@ describe ErrorsController do
describe 'POST #create' do describe 'POST #create' do
context 'with a valid error' do context 'with a valid error' do
let(:request) { Proc.new { post :create, execution_environment_id: FactoryGirl.build(:error).execution_environment.id, error: FactoryGirl.attributes_for(:error), format: :json } } let(:request) { proc { post :create, execution_environment_id: FactoryGirl.build(:error).execution_environment.id, error: FactoryGirl.attributes_for(:error), format: :json } }
context 'when a hint can be matched' do context 'when a hint can be matched' do
let(:hint) { FactoryGirl.build(:ruby_syntax_error).message } let(:hint) { FactoryGirl.build(:ruby_syntax_error).message }

View File

@ -9,7 +9,7 @@ describe ExecutionEnvironmentsController do
before(:each) { expect(DockerClient).to receive(:image_tags).at_least(:once).and_return([]) } before(:each) { expect(DockerClient).to receive(:image_tags).at_least(:once).and_return([]) }
context 'with a valid execution environment' do context 'with a valid execution environment' do
let(:request) { Proc.new { post :create, execution_environment: FactoryGirl.attributes_for(:ruby) } } let(:request) { proc { post :create, execution_environment: FactoryGirl.attributes_for(:ruby) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(docker_images: Array) expect_assigns(docker_images: Array)

View File

@ -9,7 +9,7 @@ describe ExercisesController do
let(:exercise_attributes) { FactoryGirl.build(:dummy).attributes } let(:exercise_attributes) { FactoryGirl.build(:dummy).attributes }
context 'with a valid exercise' do context 'with a valid exercise' do
let(:request) { Proc.new { post :create, exercise: exercise_attributes } } let(:request) { proc { post :create, exercise: exercise_attributes } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(exercise: Exercise) expect_assigns(exercise: Exercise)
@ -23,7 +23,7 @@ describe ExercisesController do
context 'when including a file' do context 'when including a file' do
let(:files_attributes) { {'0' => FactoryGirl.build(:file).attributes} } let(:files_attributes) { {'0' => FactoryGirl.build(:file).attributes} }
let(:request) { Proc.new { post :create, exercise: exercise_attributes.merge(files_attributes: files_attributes) } } let(:request) { proc { post :create, exercise: exercise_attributes.merge(files_attributes: files_attributes) } }
it 'creates the file' do it 'creates the file' do
expect { request.call }.to change(CodeOcean::File, :count) expect { request.call }.to change(CodeOcean::File, :count)
@ -32,7 +32,7 @@ describe ExercisesController do
context "with a file upload" do context "with a file upload" do
let(:files_attributes) { {'0' => FactoryGirl.build(:file, content: fixture_file_upload('upload.rb', 'text/x-ruby')).attributes} } let(:files_attributes) { {'0' => FactoryGirl.build(:file, content: fixture_file_upload('upload.rb', 'text/x-ruby')).attributes} }
let(:request) { Proc.new { post :create, exercise: exercise_attributes.merge(files_attributes: files_attributes) } } let(:request) { proc { post :create, exercise: exercise_attributes.merge(files_attributes: files_attributes) } }
it 'creates the file' do it 'creates the file' do
expect { request.call }.to change(CodeOcean::File, :count) expect { request.call }.to change(CodeOcean::File, :count)
@ -77,7 +77,7 @@ describe ExercisesController do
end end
describe 'GET #implement' do describe 'GET #implement' do
let(:request) { Proc.new { get :implement, id: exercise.id } } let(:request) { proc { get :implement, id: exercise.id } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(exercise: :exercise) expect_assigns(exercise: :exercise)

View File

@ -7,7 +7,7 @@ describe FileTypesController do
describe 'POST #create' do describe 'POST #create' do
context 'with a valid file type' do context 'with a valid file type' do
let(:request) { Proc.new { post :create, file_type: FactoryGirl.attributes_for(:dot_rb) } } let(:request) { proc { post :create, file_type: FactoryGirl.attributes_for(:dot_rb) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(editor_modes: Array) expect_assigns(editor_modes: Array)

View File

@ -8,7 +8,7 @@ describe HintsController do
describe 'POST #create' do describe 'POST #create' do
context 'with a valid hint' do context 'with a valid hint' do
let(:request) { Proc.new { post :create, execution_environment_id: execution_environment.id, hint: FactoryGirl.attributes_for(:ruby_syntax_error) } } let(:request) { proc { post :create, execution_environment_id: execution_environment.id, hint: FactoryGirl.attributes_for(:ruby_syntax_error) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(execution_environment: :execution_environment) expect_assigns(execution_environment: :execution_environment)

View File

@ -103,7 +103,7 @@ describe InternalUsersController do
before(:each) { allow(controller).to receive(:current_user).and_return(user) } before(:each) { allow(controller).to receive(:current_user).and_return(user) }
context 'with a valid internal user' do context 'with a valid internal user' do
let(:request) { Proc.new { post :create, internal_user: FactoryGirl.attributes_for(:teacher) } } let(:request) { proc { post :create, internal_user: FactoryGirl.attributes_for(:teacher) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(user: InternalUser) expect_assigns(user: InternalUser)

View File

@ -162,7 +162,7 @@ describe SessionsController do
end end
describe 'GET #destroy_through_lti' do describe 'GET #destroy_through_lti' do
let(:request) { Proc.new { get :destroy_through_lti, consumer_id: consumer.id, submission_id: submission.id } } let(:request) { proc { get :destroy_through_lti, consumer_id: consumer.id, submission_id: submission.id } }
let(:submission) { FactoryGirl.create(:submission, exercise: FactoryGirl.create(:dummy)) } let(:submission) { FactoryGirl.create(:submission, exercise: FactoryGirl.create(:dummy)) }
before(:each) do before(:each) do

View File

@ -12,7 +12,7 @@ describe SubmissionsController do
context 'with a valid submission' do context 'with a valid submission' do
let(:exercise) { FactoryGirl.create(:hello_world) } let(:exercise) { FactoryGirl.create(:hello_world) }
let(:request) { Proc.new { post :create, format: :json, submission: FactoryGirl.attributes_for(:submission, exercise_id: exercise.id) } } let(:request) { proc { post :create, format: :json, submission: FactoryGirl.attributes_for(:submission, exercise_id: exercise.id) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(submission: Submission) expect_assigns(submission: Submission)
@ -75,7 +75,7 @@ describe SubmissionsController do
context 'with a valid filename' do context 'with a valid filename' do
let(:file) { submission.files.first } let(:file) { submission.files.first }
let(:file_type) { FactoryGirl.create(:dot_xml) } let(:file_type) { FactoryGirl.create(:dot_xml) }
let(:request) { Proc.new { get :render_file, filename: file.name_with_extension, id: submission.id } } let(:request) { proc { get :render_file, filename: file.name_with_extension, id: submission.id } }
before(:each) do before(:each) do
file.update(file_type: file_type) file.update(file_type: file_type)

View File

@ -7,7 +7,7 @@ describe TeamsController do
describe 'POST #create' do describe 'POST #create' do
context 'with a valid team' do context 'with a valid team' do
let(:request) { Proc.new { post :create, team: FactoryGirl.attributes_for(:team) } } let(:request) { proc { post :create, team: FactoryGirl.attributes_for(:team) } }
before(:each) { request.call } before(:each) { request.call }
expect_assigns(team: Team) expect_assigns(team: Team)

View File

@ -243,7 +243,7 @@ describe DockerClient, docker: true do
end end
describe '#send_command' do describe '#send_command' do
let(:block) { Proc.new {} } let(:block) { proc {} }
let(:container) { described_class.create_container(execution_environment) } let(:container) { described_class.create_container(execution_environment) }
let(:send_command) { docker_client.send(:send_command, command, container, &block) } let(:send_command) { docker_client.send(:send_command, command, container, &block) }
after(:each) { send_command } after(:each) { send_command }