Fix Rubocop offenses

This commit is contained in:
Sebastian Serth
2024-01-09 00:45:16 +01:00
parent 2152339d3d
commit a230618724
5 changed files with 26 additions and 26 deletions

View File

@ -15,20 +15,20 @@ RSpec.describe 'Authentication' do
context 'with valid credentials' do
it 'allows to sign in' do
click_link(I18n.t('sessions.new.link'))
click_link(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
fill_in('Email', with: user.email)
fill_in('Password', with: password)
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
expect(page).to have_content(I18n.t('sessions.create.success'))
end
end
context 'with invalid credentials' do
it 'does not allow to sign in' do
click_link(I18n.t('sessions.new.link'))
click_link(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
fill_in('Email', with: user.email)
fill_in('Password', with: password.reverse)
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
expect(page).to have_content(I18n.t('sessions.create.failure'))
end
end
@ -49,7 +49,7 @@ RSpec.describe 'Authentication' do
it 'redirects to the desired page immediately after sign-in' do
fill_in('Email', with: user.email)
fill_in('Password', with: password)
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
expect(page).to have_content(exercise.title)
end
@ -59,7 +59,7 @@ RSpec.describe 'Authentication' do
it 'informs the user about missing permissions' do
fill_in('Email', with: user.email)
fill_in('Password', with: password)
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
expect(page).to have_content(I18n.t('application.not_authorized'))
end
end
@ -71,8 +71,8 @@ RSpec.describe 'Authentication' do
it 'denies access to the request for comment' do
visit(rfc_path)
expect(page).not_to have_current_path(rfc_path)
expect(page).not_to have_content(request_for_comment.exercise.title)
expect(page).to have_no_current_path(rfc_path)
expect(page).to have_no_content(request_for_comment.exercise.title)
expect(page).to have_current_path(sign_in_path)
expect(page).to have_content(I18n.t('application.not_signed_in'))
end
@ -105,8 +105,8 @@ RSpec.describe 'Authentication' do
it 'denies access to the request for comment' do
mail.deliver_now
visit(rfc_link)
expect(page).not_to have_current_path(rfc_link)
expect(page).not_to have_content(request_for_comment.exercise.title)
expect(page).to have_no_current_path(rfc_link)
expect(page).to have_no_content(request_for_comment.exercise.title)
expect(page).to have_current_path(sign_in_path)
expect(page).to have_content(I18n.t('application.not_signed_in'))
end
@ -164,7 +164,7 @@ RSpec.describe 'Authentication' do
end
it 'allows to sign out' do
click_link(I18n.t('sessions.destroy.link'))
click_on(I18n.t('sessions.destroy.link'))
expect(page).to have_content(I18n.t('sessions.destroy.success'))
end
end

View File

@ -29,7 +29,7 @@ RSpec.describe 'Editor', :js do
visit(sign_in_path)
fill_in('email', with: contributor.email)
fill_in('password', with: attributes_for(:teacher)[:password])
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
allow_any_instance_of(LtiHelper).to receive(:lti_outcome_service?).and_return(true)
visit(implement_exercise_path(exercise))
end
@ -56,7 +56,7 @@ RSpec.describe 'Editor', :js do
context 'when selecting a file' do
before do
within('#files') { click_link(file.name_with_extension) }
within('#files') { click_on(file.name_with_extension) }
end
context 'when selecting a binary file' do
@ -106,7 +106,7 @@ RSpec.describe 'Editor', :js do
it 'disables the score button' do
visit(implement_exercise_path(exercise_without_test))
expect(page).to have_content(exercise_without_test.title)
expect(page).not_to have_content(I18n.t('exercises.editor.score'))
expect(page).to have_no_content(I18n.t('exercises.editor.score'))
end
end
end

View File

@ -21,7 +21,7 @@ RSpec.describe 'ExternalUserStatistics', :js do
visit(sign_in_path)
fill_in('email', with: user.email)
fill_in('password', with: password)
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
allow_any_instance_of(LtiHelper).to receive(:lti_outcome_service?).and_return(true)
visit(statistics_external_user_exercise_path(id: exercise.id, external_user_id: learner.id))
end
@ -38,8 +38,8 @@ RSpec.describe 'ExternalUserStatistics', :js do
let(:user) { create(:teacher, password:) }
it 'does not display the option to enable autosaves' do
expect(page).not_to have_content(I18n.t('exercises.external_users.statistics.toggle_status_on'))
expect(page).not_to have_content(I18n.t('exercises.external_users.statistics.toggle_status_off'))
expect(page).to have_no_content(I18n.t('exercises.external_users.statistics.toggle_status_on'))
expect(page).to have_no_content(I18n.t('exercises.external_users.statistics.toggle_status_off'))
end
end
end

View File

@ -9,7 +9,7 @@ RSpec.describe 'Request_for_Comments' do
visit(sign_in_path)
fill_in('email', with: user.email)
fill_in('password', with: attributes_for(:teacher)[:password])
click_button(I18n.t('sessions.new.link'))
click_button(I18n.t('sessions.new.link')) # rubocop:disable Capybara/ClickLinkOrButtonStyle
end
it 'does not contain rfcs for unpublished exercises' do
@ -23,7 +23,7 @@ RSpec.describe 'Request_for_Comments' do
visit(request_for_comments_path)
expect(page).to have_content(rfc.exercise.title)
expect(page).not_to have_content(unpublished_rfc.exercise.title)
expect(page).to have_no_content(unpublished_rfc.exercise.title)
end
it 'contains a filter for study group in the view' do
@ -33,7 +33,7 @@ RSpec.describe 'Request_for_Comments' do
it 'works with the pagination' do
submission = create(:submission)
create_list(:rfc, 25, submission:, exercise: submission.exercise)
create_list(:rfc, 25, submission:, exercise: submission.exercise) # rubocop:disable RSpec/FactoryBot/ExcessiveCreateList
visit(request_for_comments_path)
expect(page).to have_css('ul.pagination')
end

View File

@ -26,8 +26,8 @@ RSpec.describe 'Score', :js do
it "does not show an 'exercise finished' notification" do
# Text needs to be split because it includes the embedded URL in the HTML which is not shown in the notification.
# We compare the shown notification text and the URL separately.
expect(page).not_to have_content(I18n.t('exercises.editor.exercise_finished').split('.').first)
expect(page).not_to have_link(nil, href: finalize_submission_path(submission))
expect(page).to have_no_content(I18n.t('exercises.editor.exercise_finished').split('.').first)
expect(page).to have_no_link(nil, href: finalize_submission_path(submission))
end
end
@ -43,7 +43,7 @@ RSpec.describe 'Score', :js do
shared_examples 'no notification' do |message_key|
it "does not show a '#{message_key.split('.').last}' notification" do
expect(page).not_to have_content(I18n.t(message_key))
expect(page).to have_no_content(I18n.t(message_key))
end
end
@ -84,7 +84,7 @@ RSpec.describe 'Score', :js do
allow_any_instance_of(LtiHelper).to receive(:lti_outcome_service?).and_return(lti_outcome_service?)
allow(submission).to receive(:calculate_score).and_return(calculate_response)
allow_any_instance_of(SubmissionsController).to receive(:send_scores).and_return(scoring_response)
click_button(I18n.t('exercises.editor.score'))
click_on(I18n.t('exercises.editor.score'))
end
shared_context 'when full score reached' do
@ -291,7 +291,7 @@ RSpec.describe 'Score', :js do
context 'when the desired runner is already in use' do
before do
allow(submission).to receive(:calculate_score).and_raise(Runner::Error::RunnerInUse)
click_button(I18n.t('exercises.editor.score'))
click_on(I18n.t('exercises.editor.score'))
end
it_behaves_like 'notification', 'exercises.editor.runner_in_use'
@ -304,7 +304,7 @@ RSpec.describe 'Score', :js do
context 'when no runner is available' do
before do
allow(submission).to receive(:calculate_score).and_raise(Runner::Error::NotAvailable)
click_button(I18n.t('exercises.editor.score'))
click_on(I18n.t('exercises.editor.score'))
end
it_behaves_like 'notification', 'exercises.editor.depleted'