Fix rubocop offenses

This commit is contained in:
Sebastian Serth
2023-02-27 11:09:34 +01:00
parent a5d42f24f2
commit 05a8e307ce
2 changed files with 25 additions and 25 deletions

View File

@ -414,11 +414,11 @@ describe ExercisesController do
it 'renders the correct contents as json' do it 'renders the correct contents as json' do
post_request post_request
expect(JSON.parse(response.body).symbolize_keys[:message]).to eq('message') expect(response.parsed_body.symbolize_keys[:message]).to eq('message')
expect(JSON.parse(response.body).symbolize_keys[:actions]).to( expect(response.parsed_body.symbolize_keys[:actions]).to(
include('button').and(include('Abort').and(include('Export'))) include('button').and(include('Abort').and(include('Export')))
) )
expect(JSON.parse(response.body).symbolize_keys[:actions]).to( expect(response.parsed_body.symbolize_keys[:actions]).to(
not_include('Retry').and(not_include('Hide')) not_include('Retry').and(not_include('Hide'))
) )
end end
@ -428,11 +428,11 @@ describe ExercisesController do
it 'renders the correct contents as json' do it 'renders the correct contents as json' do
post_request post_request
expect(JSON.parse(response.body).symbolize_keys[:message]).to eq('message') expect(response.parsed_body.symbolize_keys[:message]).to eq('message')
expect(JSON.parse(response.body).symbolize_keys[:actions]).to( expect(response.parsed_body.symbolize_keys[:actions]).to(
include('button').and(include('Abort')).and(include('Retry')) include('button').and(include('Abort')).and(include('Retry'))
) )
expect(JSON.parse(response.body).symbolize_keys[:actions]).to( expect(response.parsed_body.symbolize_keys[:actions]).to(
not_include('Export').and(not_include('Hide')) not_include('Export').and(not_include('Hide'))
) )
end end
@ -443,11 +443,11 @@ describe ExercisesController do
it 'renders the correct contents as json' do it 'renders the correct contents as json' do
post_request post_request
expect(JSON.parse(response.body).symbolize_keys[:message]).to eq('message') expect(response.parsed_body.symbolize_keys[:message]).to eq('message')
expect(JSON.parse(response.body).symbolize_keys[:actions]).to( expect(response.parsed_body.symbolize_keys[:actions]).to(
include('button').and(include('Abort')) include('button').and(include('Abort'))
) )
expect(JSON.parse(response.body).symbolize_keys[:actions]).to( expect(response.parsed_body.symbolize_keys[:actions]).to(
not_include('Retry').and(not_include('Export')).and(not_include('Hide')) not_include('Retry').and(not_include('Export')).and(not_include('Hide'))
) )
end end
@ -471,10 +471,10 @@ describe ExercisesController do
post_request post_request
expect(response).to have_http_status(:success) expect(response).to have_http_status(:success)
expect(JSON.parse(response.body).symbolize_keys[:message]).to(include('successfully exported')) expect(response.parsed_body.symbolize_keys[:message]).to(include('successfully exported'))
expect(JSON.parse(response.body).symbolize_keys[:status]).to(eql('success')) expect(response.parsed_body.symbolize_keys[:status]).to(eql('success'))
expect(JSON.parse(response.body).symbolize_keys[:actions]).to(include('button').and(include('Close'))) expect(response.parsed_body.symbolize_keys[:actions]).to(include('button').and(include('Close')))
expect(JSON.parse(response.body).symbolize_keys[:actions]).to(not_include('Retry').and(not_include('Abort'))) expect(response.parsed_body.symbolize_keys[:actions]).to(not_include('Retry').and(not_include('Abort')))
end end
context 'when an error occurs' do context 'when an error occurs' do
@ -483,10 +483,10 @@ describe ExercisesController do
it 'renders correct response' do it 'renders correct response' do
post_request post_request
expect(response).to have_http_status(:success) expect(response).to have_http_status(:success)
expect(JSON.parse(response.body).symbolize_keys[:message]).to(include('failed').and(include('exampleerror'))) expect(response.parsed_body.symbolize_keys[:message]).to(include('failed').and(include('exampleerror')))
expect(JSON.parse(response.body).symbolize_keys[:status]).to(eql('fail')) expect(response.parsed_body.symbolize_keys[:status]).to(eql('fail'))
expect(JSON.parse(response.body).symbolize_keys[:actions]).to(include('button').and(include('Retry')).and(include('Close'))) expect(response.parsed_body.symbolize_keys[:actions]).to(include('button').and(include('Retry')).and(include('Close')))
expect(JSON.parse(response.body).symbolize_keys[:actions]).to(not_include('Abort')) expect(response.parsed_body.symbolize_keys[:actions]).to(not_include('Abort'))
end end
end end
end end
@ -504,8 +504,8 @@ describe ExercisesController do
post_request post_request
expect(response).to have_http_status(:success) expect(response).to have_http_status(:success)
expect(JSON.parse(response.body).symbolize_keys[:uuid_found]).to be true expect(response.parsed_body.symbolize_keys[:uuid_found]).to be true
expect(JSON.parse(response.body).symbolize_keys[:update_right]).to be true expect(response.parsed_body.symbolize_keys[:update_right]).to be true
end end
context 'when api_key is incorrect' do context 'when api_key is incorrect' do
@ -524,8 +524,8 @@ describe ExercisesController do
post_request post_request
expect(response).to have_http_status(:success) expect(response).to have_http_status(:success)
expect(JSON.parse(response.body).symbolize_keys[:uuid_found]).to be true expect(response.parsed_body.symbolize_keys[:uuid_found]).to be true
expect(JSON.parse(response.body).symbolize_keys[:update_right]).to be false expect(response.parsed_body.symbolize_keys[:update_right]).to be false
end end
end end
@ -536,7 +536,7 @@ describe ExercisesController do
post_request post_request
expect(response).to have_http_status(:success) expect(response).to have_http_status(:success)
expect(JSON.parse(response.body).symbolize_keys[:uuid_found]).to be false expect(response.parsed_body.symbolize_keys[:uuid_found]).to be false
end end
end end
end end

View File

@ -192,7 +192,7 @@ describe SubmissionsController do
%i[run test].each do |action| %i[run test].each do |action|
describe "##{action}_url" do describe "##{action}_url" do
let(:url) { JSON.parse(response.body).with_indifferent_access.fetch("#{action}_url") } let(:url) { response.parsed_body.with_indifferent_access.fetch("#{action}_url") }
it "starts like the #{action} path" do it "starts like the #{action} path" do
filename = File.basename(__FILE__) filename = File.basename(__FILE__)
@ -206,7 +206,7 @@ describe SubmissionsController do
end end
describe '#render_url' do describe '#render_url' do
let(:supported_urls) { JSON.parse(response.body).with_indifferent_access.fetch('render_url') } let(:supported_urls) { response.parsed_body.with_indifferent_access.fetch('render_url') }
let(:file) { submission.collect_files.detect(&:main_file?) } let(:file) { submission.collect_files.detect(&:main_file?) }
let(:url) { supported_urls.find {|hash| hash[:filepath] == file.filepath }['url'] } let(:url) { supported_urls.find {|hash| hash[:filepath] == file.filepath }['url'] }
@ -220,7 +220,7 @@ describe SubmissionsController do
end end
describe '#score_url' do describe '#score_url' do
let(:url) { JSON.parse(response.body).with_indifferent_access.fetch('score_url') } let(:url) { response.parsed_body.with_indifferent_access.fetch('score_url') }
it 'corresponds to the score path' do it 'corresponds to the score path' do
expect(url).to eq(Rails.application.routes.url_helpers.score_submission_path(submission, format: :json)) expect(url).to eq(Rails.application.routes.url_helpers.score_submission_path(submission, format: :json))