From 455399bdba4d5e2858ab597b915cffec63ac3646 Mon Sep 17 00:00:00 2001 From: Anna Buianova Date: Fri, 16 Sep 2022 15:25:48 +0300 Subject: [PATCH] Rubocop fixes (#18461) * Rubocop fixes * Fixed most Capybara/SpecificMatcher violations * Moved flash notice texts to locales --- Guardfile | 1 - app/controllers/passwords_controller.rb | 2 +- app/controllers/stories_controller.rb | 2 +- .../users/notification_settings_controller.rb | 2 +- config/environments/production.rb | 2 +- config/locales/controllers/en.yml | 1 + config/locales/controllers/fr.yml | 1 + config/locales/devise.en.yml | 1 + spec/factories/articles.rb | 2 +- .../comments/community_wellness_query_spec.rb | 2 +- spec/requests/admin/feedback_messages_spec.rb | 4 ++-- spec/requests/admin/navigation_link_spec.rb | 2 +- spec/requests/admin/privileged_reactions_spec.rb | 2 +- spec/requests/admin/response_templates_spec.rb | 8 ++++---- spec/requests/admin/secrets_spec.rb | 6 +++--- spec/requests/admin/tags_spec.rb | 4 ++-- spec/requests/api/v0/health_checks_spec.rb | 12 ++++++------ spec/requests/api/v1/health_checks_spec.rb | 12 ++++++------ spec/requests/dashboard_spec.rb | 2 +- spec/requests/devices_spec.rb | 6 +++--- spec/requests/email_subscriptions_spec.rb | 2 +- spec/requests/profile_field_groups_request_spec.rb | 2 +- spec/requests/stories/tagged_articles_spec.rb | 2 +- spec/requests/stories_index_spec.rb | 4 ++-- spec/requests/user/user_organization_spec.rb | 2 +- spec/requests/user_blocks_spec.rb | 6 +++--- spec/requests/videos_spec.rb | 2 +- spec/support/initializers/capybara.rb | 2 -- .../articles/moderator_moderates_an_article_spec.rb | 5 +++-- .../system/podcasts/user_visits_podcast_page_spec.rb | 2 +- 30 files changed, 52 insertions(+), 51 deletions(-) diff --git a/Guardfile b/Guardfile index a32825002..fbedf0373 100644 --- a/Guardfile +++ b/Guardfile @@ -1,4 +1,3 @@ - ignore([%r{^bin/*}, %r{^config/*}, %r{^db/*}, %r{^lib/*}, %r{^log/*}, %r{^public/*}, %r{^tmp/*}, %r{^node_modules/*}]) rspec_options = { diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index 30c264890..c0faed9ec 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -10,7 +10,7 @@ class PasswordsController < Devise::PasswordsController protected def after_sending_reset_password_instructions_path_for(_resource_name) - flash[:global_notice] = "Your password reset instructions have been sent." + flash[:global_notice] = I18n.t("devise.passwords.reset_instructions_sent") session[:referrer] end end diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index b239368f8..cc2fe2fdc 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -318,7 +318,7 @@ class StoriesController < ApplicationController end def redirect_to_lowercase_username - return unless params[:username] && params[:username]&.match?(/[[:upper:]]/) + return unless params[:username]&.match?(/[[:upper:]]/) redirect_permanently_to("/#{params[:username].downcase}") end diff --git a/app/controllers/users/notification_settings_controller.rb b/app/controllers/users/notification_settings_controller.rb index ccb24bee5..54f594ec5 100644 --- a/app/controllers/users/notification_settings_controller.rb +++ b/app/controllers/users/notification_settings_controller.rb @@ -25,7 +25,7 @@ module Users authorize current_user, policy_class: UserPolicy if current_user.notification_setting.update(users_notification_setting_params) - flash[:settings_notice] = "Your notification settings have been updated." + flash[:settings_notice] = I18n.t("users_controller.notifications_settings_updated") else Honeycomb.add_field("error", current_user.notification_setting.errors.messages.compact_blank) Honeycomb.add_field("errored", true) diff --git a/config/environments/production.rb b/config/environments/production.rb index b35651bfc..4ec8e2fc4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -155,5 +155,5 @@ end # rubocop:enable Metrics/BlockLength Rails.application.routes.default_url_options = { - protocol: (ENV.fetch("APP_PROTOCOL", "http://")).delete_suffix("://") + protocol: ENV.fetch("APP_PROTOCOL", "http://").delete_suffix("://") } diff --git a/config/locales/controllers/en.yml b/config/locales/controllers/en.yml index fcb5f6e94..3a27c3473 100644 --- a/config/locales/controllers/en.yml +++ b/config/locales/controllers/en.yml @@ -117,6 +117,7 @@ en: updated_config: Your config has been updated. Refresh to see all changes. updated_profile: Your profile was successfully updated. token_expired: Your token has expired, please request a new one. Tokens only last for 12 hours after account deletion is initiated. + notifications_settings_updated: Your notifications settings have been updated. video_states_controller: related_article_not_found: Related article not found video_state_updated: Video state updated diff --git a/config/locales/controllers/fr.yml b/config/locales/controllers/fr.yml index 1996c5775..675780bc6 100644 --- a/config/locales/controllers/fr.yml +++ b/config/locales/controllers/fr.yml @@ -117,6 +117,7 @@ fr: updated_config: Your config has been updated. Refresh to see all changes. updated_profile: Your profile was successfully updated. token_expired: Your token has expired, please request a new one. Tokens only last for 12 hours after account deletion is initiated. + notifications_settings_updated: Your notifications settings have been updated. video_states_controller: related_article_not_found: Related article not found video_state_updated: Video state updated diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index e047dfdfc..1f6ecfdc9 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -31,6 +31,7 @@ en: success: Successfully authenticated from %{kind} account. passwords: no_token: You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided. + reset_instructions_sent: Your password reset instructions have been sent. send_instructions: You will receive an email with instructions on how to reset your password in a few minutes. send_paranoid_instructions: If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes. updated: Your password has been changed successfully. You are now signed in. diff --git a/spec/factories/articles.rb b/spec/factories/articles.rb index 877830662..569641bef 100644 --- a/spec/factories/articles.rb +++ b/spec/factories/articles.rb @@ -37,7 +37,7 @@ FactoryBot.define do published: #{published} tags: #{tags if with_tags} date: #{date if with_date} - series: #{with_collection&.slug if with_collection} + series: #{with_collection&.slug} canonical_url: #{canonical_url if with_canonical_url} #{"cover_image: #{Faker::Avatar.image}" if with_main_image && main_image_from_frontmatter} --- diff --git a/spec/queries/comments/community_wellness_query_spec.rb b/spec/queries/comments/community_wellness_query_spec.rb index 450278f9d..1739b7096 100644 --- a/spec/queries/comments/community_wellness_query_spec.rb +++ b/spec/queries/comments/community_wellness_query_spec.rb @@ -37,7 +37,7 @@ RSpec.describe Comments::CommunityWellnessQuery, type: :query do user6 = create(:user) # Add 2 comments per week (including week 0) for `user6` - (0..33).each do |i| + 34.times do |i| num_days_ago = (2 + (i * 7)).days.ago create_comment_time_ago(user6.id, num_days_ago, commentable: articles.sample) create_comment_time_ago(user6.id, num_days_ago, commentable: articles.sample) diff --git a/spec/requests/admin/feedback_messages_spec.rb b/spec/requests/admin/feedback_messages_spec.rb index 941230076..80f501c44 100644 --- a/spec/requests/admin/feedback_messages_spec.rb +++ b/spec/requests/admin/feedback_messages_spec.rb @@ -13,7 +13,7 @@ RSpec.describe "/admin/moderation/reports", type: :request do it "renders with status 200" do sign_in single_resource_admin get admin_reports_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end @@ -23,7 +23,7 @@ RSpec.describe "/admin/moderation/reports", type: :request do create(:reaction, category: "vomit", reactable: user, user: trusted_user) sign_in admin get admin_reports_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end end diff --git a/spec/requests/admin/navigation_link_spec.rb b/spec/requests/admin/navigation_link_spec.rb index 625eaf676..4fb749006 100644 --- a/spec/requests/admin/navigation_link_spec.rb +++ b/spec/requests/admin/navigation_link_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "NavigationLinks", type: :request do it "returns a successful response" do get admin_navigation_links_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end diff --git a/spec/requests/admin/privileged_reactions_spec.rb b/spec/requests/admin/privileged_reactions_spec.rb index 4bb5b6d61..35b22ce3e 100644 --- a/spec/requests/admin/privileged_reactions_spec.rb +++ b/spec/requests/admin/privileged_reactions_spec.rb @@ -21,7 +21,7 @@ RSpec.describe "/admin/moderations/privileged_reactions", type: :request do it "renders with status 200" do sign_in single_resource_admin get admin_moderator_actions_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end diff --git a/spec/requests/admin/response_templates_spec.rb b/spec/requests/admin/response_templates_spec.rb index 9e7ac56b4..31e8d738f 100644 --- a/spec/requests/admin/response_templates_spec.rb +++ b/spec/requests/admin/response_templates_spec.rb @@ -8,14 +8,14 @@ RSpec.describe "/admin/advanced/response_templates", type: :request do describe "GET /admin/advanced/response_templates" do it "renders with status 200" do get admin_response_templates_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end context "when there are response templates to render" do it "renders with status 200" do create(:response_template) get admin_response_templates_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end @@ -25,7 +25,7 @@ RSpec.describe "/admin/advanced/response_templates", type: :request do it "renders with status 200" do sign_in single_resource_admin get admin_response_templates_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end end @@ -33,7 +33,7 @@ RSpec.describe "/admin/advanced/response_templates", type: :request do describe "GET /admin/advanced/response_templates/new" do it "renders with status 200" do get admin_response_templates_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end diff --git a/spec/requests/admin/secrets_spec.rb b/spec/requests/admin/secrets_spec.rb index 29a8c1588..c681e8c20 100644 --- a/spec/requests/admin/secrets_spec.rb +++ b/spec/requests/admin/secrets_spec.rb @@ -25,7 +25,7 @@ RSpec.describe "/admin/advanced/secrets", type: :request do describe "GET /admin/advanced/secrets" do it "renders with status 200" do get admin_secrets_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end it "displays an alert when Vault is not enabled" do @@ -42,14 +42,14 @@ RSpec.describe "/admin/advanced/secrets", type: :request do it "successfully sets a secret and shows flash message" do allow(AppSecrets).to receive(:[]=) put admin_secrets_path, params: valid_params - expect(response.status).to eq 302 + expect(response).to have_http_status :found expect(AppSecrets).to have_received(:[]=).with(valid_secret, "SECRET_VALUE") expect(flash[:success]).to include("Secret #{valid_secret} was successfully updated in Vault") end it "returns a bad_request with invalid params" do put admin_secrets_path, params: {} - expect(response.status).to eq 400 + expect(response).to have_http_status :bad_request end it "creates an audit log" do diff --git a/spec/requests/admin/tags_spec.rb b/spec/requests/admin/tags_spec.rb index cfe1879ff..d36591efe 100644 --- a/spec/requests/admin/tags_spec.rb +++ b/spec/requests/admin/tags_spec.rb @@ -27,14 +27,14 @@ RSpec.describe "/admin/content_manager/tags", type: :request do describe "GET /admin/content_manager/tags" do it "responds with 200 OK" do get admin_tags_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end describe "GET /admin/content_manager/tags/:id" do it "responds with 200 OK" do get edit_admin_tag_path(tag.id) - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end end diff --git a/spec/requests/api/v0/health_checks_spec.rb b/spec/requests/api/v0/health_checks_spec.rb index 55fac0d69..254ebbb9c 100644 --- a/spec/requests/api/v0/health_checks_spec.rb +++ b/spec/requests/api/v0/health_checks_spec.rb @@ -10,14 +10,14 @@ RSpec.describe "HealthCheck", type: :request do it "returns an unauthorized request" do allow_any_instance_of(ActionDispatch::Request).to receive(:remote_addr).and_return("0.0.0.0") # rubocop:disable RSpec/AnyInstance get app_api_health_checks_path - expect(response.status).to eq(401) + expect(response).to have_http_status(:unauthorized) end end describe "GET /api/health_checks/app" do it "returns json success" do get app_api_health_checks_path, headers: headers - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.parsed_body["message"]).to eq("App is up!") end end @@ -25,14 +25,14 @@ RSpec.describe "HealthCheck", type: :request do describe "GET /api/health_checks/database" do it "returns json success if connection check succeeds" do get database_api_health_checks_path, headers: headers - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.parsed_body["message"]).to eq("Database connected") end it "returns json failure if connection check fails" do allow(ActiveRecord::Base).to receive(:connected?).and_return(false) get database_api_health_checks_path, headers: headers - expect(response.status).to eq(500) + expect(response).to have_http_status(:internal_server_error) expect(response.parsed_body["message"]).to eq("Database NOT connected!") end end @@ -40,7 +40,7 @@ RSpec.describe "HealthCheck", type: :request do describe "GET /api/health_checks/cache" do it "returns json success if connection check succeeds" do get cache_api_health_checks_path, headers: headers - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.parsed_body["message"]).to eq("Redis connected") end @@ -52,7 +52,7 @@ RSpec.describe "HealthCheck", type: :request do allow(Redis).to receive(:new).and_return(redis_obj) allow(redis_obj).to receive(:ping).and_return("fail") get cache_api_health_checks_path, headers: headers - expect(response.status).to eq(500) + expect(response).to have_http_status(:internal_server_error) expect(response.parsed_body["message"]).to eq("Redis NOT connected!") end end diff --git a/spec/requests/api/v1/health_checks_spec.rb b/spec/requests/api/v1/health_checks_spec.rb index 70b291884..2bd1a8e8b 100644 --- a/spec/requests/api/v1/health_checks_spec.rb +++ b/spec/requests/api/v1/health_checks_spec.rb @@ -10,14 +10,14 @@ RSpec.describe "HealthCheck", type: :request do it "returns an unauthorized request" do allow_any_instance_of(ActionDispatch::Request).to receive(:remote_addr).and_return("0.0.0.0") # rubocop:disable RSpec/AnyInstance get app_api_health_checks_path - expect(response.status).to eq(401) + expect(response).to have_http_status(:unauthorized) end end describe "GET /api/health_checks/app" do it "returns json success" do get app_api_health_checks_path, headers: headers - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.parsed_body["message"]).to eq("App is up!") end end @@ -25,14 +25,14 @@ RSpec.describe "HealthCheck", type: :request do describe "GET /api/health_checks/database" do it "returns json success if connection check succeeds" do get database_api_health_checks_path, headers: headers - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.parsed_body["message"]).to eq("Database connected") end it "returns json failure if connection check fails" do allow(ActiveRecord::Base).to receive(:connected?).and_return(false) get database_api_health_checks_path, headers: headers - expect(response.status).to eq(500) + expect(response).to have_http_status(:internal_server_error) expect(response.parsed_body["message"]).to eq("Database NOT connected!") end end @@ -40,7 +40,7 @@ RSpec.describe "HealthCheck", type: :request do describe "GET /api/health_checks/cache" do it "returns json success if connection check succeeds" do get cache_api_health_checks_path, headers: headers - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.parsed_body["message"]).to eq("Redis connected") end @@ -52,7 +52,7 @@ RSpec.describe "HealthCheck", type: :request do allow(Redis).to receive(:new).and_return(redis_obj) allow(redis_obj).to receive(:ping).and_return("fail") get cache_api_health_checks_path, headers: headers - expect(response.status).to eq(500) + expect(response).to have_http_status(:internal_server_error) expect(response.parsed_body["message"]).to eq("Redis NOT connected!") end end diff --git a/spec/requests/dashboard_spec.rb b/spec/requests/dashboard_spec.rb index 81521d7e5..c9fd428cc 100644 --- a/spec/requests/dashboard_spec.rb +++ b/spec/requests/dashboard_spec.rb @@ -320,7 +320,7 @@ RSpec.describe "Dashboards", type: :request do sign_in user get "/dashboard/analytics" within "nav" do - expect(page).to have_selector("a[href='/dashboard']") + expect(page).to have_link(href: "/dashboard") end end end diff --git a/spec/requests/devices_spec.rb b/spec/requests/devices_spec.rb index 8c6525c60..1f44bde48 100644 --- a/spec/requests/devices_spec.rb +++ b/spec/requests/devices_spec.rb @@ -58,7 +58,7 @@ RSpec.describe "Devices", type: :request do it "returns an error" do delete device_path(123) - expect(response.status).to eq(404) + expect(response).to have_http_status(:not_found) expect(response.parsed_body["error"]).to eq("Not Found") expect(response.parsed_body["status"]).to eq(404) end @@ -66,7 +66,7 @@ RSpec.describe "Devices", type: :request do it "return an error if device id doesn't match params" do delete device_path(123), params: incomplete_params - expect(response.status).to eq(404) + expect(response).to have_http_status(:not_found) expect(response.parsed_body["error"]).to eq("Not Found") expect(response.parsed_body["status"]).to eq(404) end @@ -85,7 +85,7 @@ RSpec.describe "Devices", type: :request do delete device_path(device.user.id), params: params expect(user.devices.count).to eq(0) - expect(response.status).to eq(204) + expect(response).to have_http_status(:no_content) expect(Device.find_by(id: device.id)).to be_nil end end diff --git a/spec/requests/email_subscriptions_spec.rb b/spec/requests/email_subscriptions_spec.rb index 39598bf91..faf062865 100644 --- a/spec/requests/email_subscriptions_spec.rb +++ b/spec/requests/email_subscriptions_spec.rb @@ -18,7 +18,7 @@ RSpec.describe "EmailSubscriptions", type: :request do describe "GET /email_subscriptions/unsubscribe" do it "returns 200 if valid" do get email_subscriptions_unsubscribe_url(ut: generate_token(user.id)) - expect(response.status).to be(200) + expect(response).to have_http_status(:ok) end it "does unsubscribe the user" do diff --git a/spec/requests/profile_field_groups_request_spec.rb b/spec/requests/profile_field_groups_request_spec.rb index 26fad7d6e..49be4f535 100644 --- a/spec/requests/profile_field_groups_request_spec.rb +++ b/spec/requests/profile_field_groups_request_spec.rb @@ -18,7 +18,7 @@ RSpec.describe "ProfileFieldGroups", type: :request do it "returns a successful response" do get profile_field_groups_path - expect(response.status).to eq 200 + expect(response).to have_http_status :ok end it "returns all groups with all fields by default" do diff --git a/spec/requests/stories/tagged_articles_spec.rb b/spec/requests/stories/tagged_articles_spec.rb index 9512bfb64..5b6df576c 100644 --- a/spec/requests/stories/tagged_articles_spec.rb +++ b/spec/requests/stories/tagged_articles_spec.rb @@ -42,7 +42,7 @@ RSpec.describe "Stories::TaggedArticlesIndex", type: :request do end def renders_page - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.body).to include(tag.name) end diff --git a/spec/requests/stories_index_spec.rb b/spec/requests/stories_index_spec.rb index cd7676322..419dfb298 100644 --- a/spec/requests/stories_index_spec.rb +++ b/spec/requests/stories_index_spec.rb @@ -138,7 +138,7 @@ RSpec.describe "StoriesIndex", type: :request do it "does not set cache-related headers if private" do allow(Settings::UserExperience).to receive(:public).and_return(false) get "/" - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) expect(response.headers["X-Accel-Expires"]).to be_nil expect(response.headers["Cache-Control"]).not_to eq("public, no-cache") @@ -148,7 +148,7 @@ RSpec.describe "StoriesIndex", type: :request do it "sets correct cache headers", :aggregate_failures do get "/" - expect(response.status).to eq(200) + expect(response).to have_http_status(:ok) sets_fastly_headers sets_nginx_headers end diff --git a/spec/requests/user/user_organization_spec.rb b/spec/requests/user/user_organization_spec.rb index eee1ef3bd..452a27a33 100644 --- a/spec/requests/user/user_organization_spec.rb +++ b/spec/requests/user/user_organization_spec.rb @@ -52,7 +52,7 @@ RSpec.describe "UserOrganization", type: :request do it "redirects to the proper org settings page" do create_org - expect(response.status).to eq 302 + expect(response).to have_http_status :found expect(response.redirect_url).to include "/settings/organization/#{Organization.last.id}" end diff --git a/spec/requests/user_blocks_spec.rb b/spec/requests/user_blocks_spec.rb index 828cc4225..3a3a71420 100644 --- a/spec/requests/user_blocks_spec.rb +++ b/spec/requests/user_blocks_spec.rb @@ -11,7 +11,7 @@ RSpec.describe "UserBlock", type: :request do sign_out(blocker) get "/user_blocks/#{blocked.id}" expect(response.media_type).to eq "application/json" - expect(response.status).to eq 401 + expect(response).to have_http_status :unauthorized expect(response.parsed_body["result"]).to eq "not-logged-in" end @@ -34,7 +34,7 @@ RSpec.describe "UserBlock", type: :request do sign_out blocker post "/user_blocks", params: { user_block: { blocked_id: blocked.id } } expect(response.media_type).to eq "application/json" - expect(response.status).to eq 401 + expect(response).to have_http_status :unauthorized expect(response.parsed_body["result"]).to eq "not-logged-in" end @@ -62,7 +62,7 @@ RSpec.describe "UserBlock", type: :request do sign_out blocker delete "/user_blocks/#{blocked.id}", params: { user_block: { blocked_id: blocked.id } } expect(response.media_type).to eq "application/json" - expect(response.status).to eq 401 + expect(response).to have_http_status :unauthorized expect(response.parsed_body["result"]).to eq "not-logged-in" end diff --git a/spec/requests/videos_spec.rb b/spec/requests/videos_spec.rb index 4be7d2e51..e6871d91e 100644 --- a/spec/requests/videos_spec.rb +++ b/spec/requests/videos_spec.rb @@ -67,7 +67,7 @@ RSpec.describe "Videos", type: :request do it "redirects to the article's edit page for the logged in user" do stub_request(:get, %r{dw71fyauz7yz9\.cloudfront\.net/}).to_return(status: 200, body: "", headers: {}) post "/videos", params: { article: { video: "https://www.something.com/something.mp4" } } - expect(response.status).to eq(302) + expect(response).to have_http_status(:found) end end end diff --git a/spec/support/initializers/capybara.rb b/spec/support/initializers/capybara.rb index 2f41d890e..09ec2b3af 100644 --- a/spec/support/initializers/capybara.rb +++ b/spec/support/initializers/capybara.rb @@ -27,7 +27,6 @@ RSpec.configure do |config| end end -# rubocop:disable Style/TopLevelMethodDefinition # adapted from def wait_for_javascript max_time = Capybara::Helpers.monotonic_time + Capybara.default_max_wait_time @@ -43,4 +42,3 @@ def wait_for_javascript raise "wait_for_javascript timeout" unless finished end -# rubocop:enable Style/TopLevelMethodDefinition diff --git a/spec/system/articles/moderator_moderates_an_article_spec.rb b/spec/system/articles/moderator_moderates_an_article_spec.rb index 61f6b0129..fac1876cf 100644 --- a/spec/system/articles/moderator_moderates_an_article_spec.rb +++ b/spec/system/articles/moderator_moderates_an_article_spec.rb @@ -17,14 +17,15 @@ RSpec.describe "Views an article", type: :system do expect(page).to have_content(article.title) end + # rubocop:disable Rspec/Capybara/SpecificMatcher it "lets moderators visit /mod", js: true do visit "/#{user.username}/#{article.slug}/mod" - expect(page).to have_selector('button[data-category="thumbsdown"][data-reactable-type="Article"]') expect(page).to have_selector('button[data-category="vomit"][data-reactable-type="Article"]') expect(page).to have_selector('button[data-category="vomit"][data-reactable-type="User"]') - expect(page).to have_selector("button.level-rating-button") + expect(page).to have_button(class: "level-rating-button") end + # rubocop:enable Rspec/Capybara/SpecificMatcher it "shows hidden comments on /mod" do commenter = create(:user) diff --git a/spec/system/podcasts/user_visits_podcast_page_spec.rb b/spec/system/podcasts/user_visits_podcast_page_spec.rb index 2f8e5e7fc..53ce9ea82 100644 --- a/spec/system/podcasts/user_visits_podcast_page_spec.rb +++ b/spec/system/podcasts/user_visits_podcast_page_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "User visits a podcast page", type: :system do end it "displays podcast episodes", js: true do - expect(page).to have_selector("a.crayons-card", visible: :visible, count: 2) + expect(page).to have_link(class: "crayons-card", visible: :visible, count: 2) end it "displays podcast publish_at" do