From dbd8c466553ed6e245368ab6770202c1b4074f9c Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Mon, 27 Sep 2021 09:58:39 -0600 Subject: [PATCH] RuboCop: Lint [skip-stages=Flakey] auto corrections applied: * Lint/AmbiguousOperator * Lint/AmbiguousOperatorPrecedence * Lint/AmbiguousRegexpLiteral * Lint/DeprecatedClassMethods * Lint/DeprecatedOpenSSLConstant * Lint/NonDeterministicRequireOrder * Lint/ParenthesesAsGroupedExpression * Lint/RedundantRequireStatement * Lint/RedundantSafeNavigation * Lint/RedundantSplatExpansion * Lint/RedundantStringCoercion * Lint/RedundantWithIndex * Lint/SendWithMixinArgument * Lint/SymbolConversion Change-Id: I222ec19978033544513bb99755994d109435abad Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274551 Tested-by: Service Cloud Jenkins Reviewed-by: Simon Williams QA-Review: Cody Cutrer Product-Review: Cody Cutrer --- .rubocop.common.yml | 38 +++ app/controllers/accounts_controller.rb | 2 +- app/controllers/application_controller.rb | 6 +- app/controllers/courses_controller.rb | 8 +- .../discussion_topics_controller.rb | 2 +- app/controllers/files_controller.rb | 4 +- .../assessments_controller.rb | 2 +- app/controllers/login/otp_controller.rb | 6 +- .../lti/data_services_controller.rb | 2 +- .../lti/ims/authentication_controller.rb | 2 +- .../lti/ims/providers/memberships_provider.rb | 2 +- app/controllers/profile_controller.rb | 2 +- app/controllers/quizzes/quizzes_controller.rb | 4 +- .../rubric_associations_controller.rb | 2 +- app/controllers/rubrics_controller.rb | 4 +- app/controllers/sub_accounts_controller.rb | 2 +- app/controllers/submissions_api_controller.rb | 2 +- app/controllers/users_controller.rb | 8 +- app/graphql/types/assignment_type.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/attachment_helper.rb | 2 +- app/helpers/avatar_helper.rb | 4 +- app/helpers/context_modules_helper.rb | 18 +- app/helpers/gradebooks_helper.rb | 2 +- app/helpers/quizzes_helper.rb | 6 +- app/helpers/search_helper.rb | 2 +- app/models/account_notification.rb | 2 +- app/models/appointment_group.rb | 6 +- app/models/appointment_group_sub_context.rb | 2 +- app/models/assignment.rb | 2 +- app/models/assignment_override.rb | 2 +- app/models/attachment.rb | 8 +- app/models/attachments/local_storage.rb | 2 +- app/models/attachments/s3_storage.rb | 2 +- app/models/calendar_event.rb | 4 +- app/models/canvadoc.rb | 2 +- app/models/content_migration.rb | 2 +- app/models/context.rb | 2 +- app/models/context_module.rb | 4 +- app/models/conversation_batch.rb | 2 +- app/models/conversation_message.rb | 2 +- app/models/course.rb | 4 +- app/models/discussion_topic.rb | 6 +- app/models/enrollment.rb | 18 +- app/models/enrollment_state.rb | 2 +- app/models/eportfolio_entry.rb | 2 +- app/models/feature_flag.rb | 2 +- app/models/grading_standard.rb | 4 +- .../importers/learning_outcome_importer.rb | 2 +- app/models/importers/link_parser.rb | 10 +- app/models/incoming_mail/message_handler.rb | 2 +- app/models/notification_endpoint.rb | 2 +- .../outcomes_service/migration_extractor.rb | 4 +- .../quiz_statistics/item_analysis/summary.rb | 2 +- app/models/quizzes/quiz_statistics_service.rb | 11 +- app/models/quizzes_next/export_service.rb | 8 +- app/models/role.rb | 2 +- app/models/sis_batch.rb | 2 +- app/models/sis_pseudonym.rb | 2 +- app/models/submission.rb | 4 +- app/models/user.rb | 8 +- app/models/web_conference.rb | 10 +- app/models/wimba_conference.rb | 2 +- .../quizzes/quiz_report_serializer.rb | 4 +- .../quizzes/quiz_statistics_serializer.rb | 78 ++--- config/application.rb | 2 +- config/initializers/active_record.rb | 4 +- config/initializers/broadcast_policy.rb | 2 +- config/initializers/canvas_crummy.rb | 4 +- config/initializers/canvas_sanitize.rb | 2 +- config/initializers/delayed_job.rb | 2 +- config/initializers/i18n.rb | 8 +- config/initializers/inflections.rb | 4 +- config/initializers/no_timeouts_debugging.rb | 4 +- doc/api/fulldoc/html/setup.rb | 4 +- doc/api/topic/html/setup.rb | 4 +- engines/audits/spec/audits_spec.rb | 4 +- .../active_support/callbacks/suspension.rb | 4 +- gems/attachment_fu/lib/attachment_fu.rb | 8 +- .../lib/attachment_fu/railtie.rb | 2 +- .../lib/bookmarked_collection/merge_proxy.rb | 2 +- .../simple_bookmarker.rb | 4 +- .../broadcast_policy/notification_policy.rb | 2 +- gems/canvas_cache/lib/canvas_cache/redis.rb | 2 +- gems/canvas_color/lib/canvas_color.rb | 298 +++++++++--------- .../lib/canvas_dynamodb/batch_builder_base.rb | 2 +- gems/canvas_ext/lib/canvas_ext.rb | 2 +- .../lib/canvas_kaltura/kaltura_client_v3.rb | 2 +- .../lib/canvas_panda_pub/async_worker.rb | 1 - .../canvas_partman/partition_manager/by_id.rb | 2 +- .../concerns/partitioned_spec.rb | 4 +- .../spec/spec_helper.rb | 4 +- .../spec/canvas_slug/canvas_slug_spec.rb | 2 +- gems/canvas_stringex/lib/canvas_stringex.rb | 4 +- gems/dr_diff/lib/dr_diff/manager.rb | 2 +- .../lib/google_drive/connection.rb | 2 +- .../i18nliner_extensions_spec.rb | 4 +- .../lib/i18n_tasks/hash_extensions.rb | 2 +- gems/i18n_tasks/lib/tasks/i18n.rake | 16 +- .../configurable_timeout.rb | 2 +- .../incoming_message_processor_spec.rb | 2 +- .../spec/spec_helper.rb | 2 +- .../lib/live_events/async_worker.rb | 2 - gems/live_events/spec/spec_helper.rb | 2 - .../lib/lti_advantage/messages/jwt_message.rb | 4 +- .../messages/resource_link_request.rb | 4 +- gems/lti_outbound/spec/spec_helper.rb | 4 +- .../account_reports/lib/account_reports.rb | 4 +- .../lib/account_reports/sis_exporter.rb | 4 +- .../spec_canvas/integrations/account_spec.rb | 2 +- .../spec_canvas/outcome_export_spec.rb | 2 +- .../spec_canvas/moodle1_9_converter_spec.rb | 8 +- .../spec_canvas/moodle2_converter_spec.rb | 4 +- .../qti_exporter/lib/qti/html_helper.rb | 4 +- .../spec_canvas/lib/qti/qti_items_spec.rb | 2 +- .../simply_versioned/lib/simply_versioned.rb | 2 +- .../cops/specs/scope_helper_modules.rb | 4 +- .../cops/specs/scope_includes.rb | 4 +- gems/tatl_tael/lib/tatl_tael/linters.rb | 2 +- lib/api.rb | 2 +- lib/api/v1/assignment.rb | 4 +- lib/api/v1/attachment.rb | 4 +- lib/api/v1/context_module.rb | 10 +- lib/api/v1/feature_flag.rb | 2 +- lib/brand_config_regenerator.rb | 2 +- lib/brandable_css.rb | 2 +- lib/canvas.rb | 2 +- lib/canvas/core_ext/oauth2.rb | 2 +- lib/canvas/jwt_workflow.rb | 4 +- lib/canvas/live_events.rb | 2 +- .../migration/worker/zip_file_worker.rb | 2 +- lib/canvas_logger.rb | 2 +- lib/cc/grading_standards.rb | 4 +- lib/cc/importer/standard/converter.rb | 2 +- .../importer/standard/webcontent_converter.rb | 2 +- lib/content_notices.rb | 2 +- lib/course_link_validator.rb | 2 +- .../populate_root_account_id_on_models.rb | 8 +- .../populate_root_account_ids_on_users.rb | 2 +- lib/feature.rb | 10 +- lib/feature_flags.rb | 2 +- lib/grade_calculator.rb | 8 +- lib/has_content_tags.rb | 2 +- lib/lti/plagiarism_subscriptions_helper.rb | 2 +- lib/lti/variable_expander.rb | 2 +- lib/message_bus.rb | 2 +- lib/messageable_user/calculator.rb | 6 +- lib/plannable.rb | 2 +- lib/planner_helper.rb | 2 +- lib/schemas/lti/tool_configuration.rb | 4 +- lib/sis/enrollment_importer.rb | 2 +- lib/sis/section_importer.rb | 2 +- lib/sis/user_importer.rb | 8 +- lib/stats.rb | 8 +- lib/submission_list.rb | 2 +- lib/submittable.rb | 4 +- lib/tasks/canvas.rake | 6 +- lib/tasks/db_create_data.rake | 8 +- lib/user_list_v2.rb | 4 +- lib/user_merge.rb | 10 +- lib/vericite.rb | 2 +- spec/ams_spec_helper.rb | 2 +- spec/apis/auth_spec.rb | 4 +- spec/apis/lti/ims/access_token_helper_spec.rb | 2 +- spec/apis/lti/ims/tool_setting_api_spec.rb | 2 +- spec/apis/lti/logout_service_spec.rb | 8 +- spec/apis/v1/announcements_api_spec.rb | 2 +- spec/apis/v1/assignments_api_spec.rb | 12 +- spec/apis/v1/conversations_api_spec.rb | 18 +- spec/apis/v1/courses_api_spec.rb | 14 +- spec/apis/v1/discussion_topics_api_spec.rb | 54 ++-- spec/apis/v1/enrollments_api_spec.rb | 34 +- spec/apis/v1/external_tools_api_spec.rb | 12 +- spec/apis/v1/files_controller_api_spec.rb | 24 +- spec/apis/v1/folders_controller_api_spec.rb | 24 +- .../apis/v1/polling/poll_sessions_api_spec.rb | 2 +- .../v1/polling/poll_submissions_api_spec.rb | 2 +- spec/apis/v1/pseudonyms_api_spec.rb | 8 +- spec/apis/v1/quizzes/quiz_groups_api_spec.rb | 6 +- .../v1/quizzes/quiz_questions_api_spec.rb | 2 +- spec/apis/v1/quizzes/quizzes_api_spec.rb | 12 +- spec/apis/v1/roles_api_spec.rb | 4 +- spec/apis/v1/terms_api_spec.rb | 6 +- spec/apis/v1/users_api_spec.rb | 8 +- .../api/provider_states_for_consumer.rb | 2 +- .../oauth_provider_states.rb | 44 +-- ...gration_service_get_content_export_spec.rb | 40 +-- ...gration_service_get_content_import_spec.rb | 2 +- ...ration_service_post_content_export_spec.rb | 32 +- ...ration_service_post_content_import_spec.rb | 52 +-- spec/controllers/accounts_controller_spec.rb | 8 +- .../announcements_controller_spec.rb | 2 +- .../application_controller_spec.rb | 35 +- .../conferences_controller_spec.rb | 8 +- spec/controllers/courses_controller_spec.rb | 10 +- .../discussion_topics_controller_spec.rb | 4 +- .../external_tools_controller_spec.rb | 2 +- spec/controllers/files_controller_spec.rb | 2 +- .../controllers/gradebooks_controller_spec.rb | 6 +- spec/controllers/groups_controller_spec.rb | 2 +- .../internet_image_controller_spec.rb | 20 +- .../concerns/lti_services_shared_examples.rb | 2 +- .../lti/ims/deep_linking_controller_spec.rb | 2 +- .../ims/names_and_roles_controller_spec.rb | 4 +- .../lti/public_jwk_controller_spec.rb | 2 +- spec/controllers/lti_api_controllers_spec.rb | 8 +- .../oauth2_provider_controller_spec.rb | 4 +- .../quizzes/quiz_questions_controller_spec.rb | 6 +- .../quizzes/quizzes_controller_spec.rb | 2 +- spec/controllers/search_controller_spec.rb | 4 +- spec/controllers/users_controller_spec.rb | 2 +- spec/factories.rb | 2 +- spec/factories/calendar_event_factory.rb | 2 +- spec/factories/discussion_topic_factory.rb | 2 +- spec/formatters/rerun_formatter.rb | 2 +- spec/graphql/mutation_audit_log_spec.rb | 12 +- spec/graphql/token_scoping_spec.rb | 2 +- spec/graphql/types/assignment_type_spec.rb | 2 +- spec/graphql/types/course_type_spec.rb | 2 +- spec/helpers/application_helper_spec.rb | 28 +- spec/helpers/attachment_helper_spec.rb | 12 +- .../context_external_tools_helper_spec.rb | 2 +- spec/helpers/quizzes_helper_spec.rb | 22 +- spec/helpers/stream_items_helper_spec.rb | 2 +- spec/integration/context_module_spec.rb | 4 +- .../enrollment_date_restrictions_spec.rb | 6 +- spec/integration/files_spec.rb | 2 +- spec/integration/groups_spec.rb | 2 +- spec/integration/security_spec.rb | 112 +++---- spec/integration/session_token_spec.rb | 4 +- spec/integration/users_controller_spec.rb | 8 +- spec/lib/api/v1/sis_assignment_spec.rb | 2 +- spec/lib/api_spec.rb | 16 +- spec/lib/app_center/app_api_spec.rb | 6 +- spec/lib/canvas/apm_spec.rb | 12 +- spec/lib/canvas/errors/reporter_spec.rb | 2 +- spec/lib/canvas/icu_spec.rb | 6 +- spec/lib/cc/basic_lti_links_spec.rb | 2 +- spec/lib/cc/cc_exporter_spec.rb | 2 +- spec/lib/cc/cc_helper_spec.rb | 2 +- .../canvas_cartridge_converter_spec.rb | 2 +- .../cc/importer/common_cartridge_1_3_spec.rb | 2 +- spec/lib/cc/schema_spec.rb | 2 +- spec/lib/content_zipper_spec.rb | 12 +- ...populate_root_account_id_on_models_spec.rb | 2 +- spec/lib/grade_calculator_coffee_spec.rb | 16 +- spec/lib/grade_calculator_spec.rb | 2 +- spec/lib/i18n_spec.rb | 10 +- spec/lib/inst_fs_spec.rb | 2 +- spec/lib/lti/variable_expander_spec.rb | 16 +- spec/lib/math_man_spec.rb | 2 +- .../graph_service_helpers_spec.rb | 4 +- .../microsoft_sync/state_machine_job_spec.rb | 2 +- spec/lib/microsoft_sync/syncer_steps_spec.rb | 2 +- spec/lib/notification_message_creator_spec.rb | 6 +- spec/lib/planner_api_helper_spec.rb | 20 +- spec/lib/session_token_spec.rb | 2 +- spec/lib/sis/csv/admin_importer_spec.rb | 2 +- spec/lib/sis/csv/enrollment_importer_spec.rb | 2 +- spec/lib/sis/csv/user_importer_spec.rb | 6 +- spec/lib/stats_spec.rb | 4 +- spec/lib/user_merge_spec.rb | 5 +- spec/lib/validates_as_url.rb | 2 +- spec/models/active_record_base_spec.rb | 4 +- spec/models/asset_user_access_spec.rb | 2 +- spec/models/assignment_spec.rb | 12 +- spec/models/auditors_spec.rb | 4 +- spec/models/brand_config_spec.rb | 4 +- spec/models/communication_channel_spec.rb | 2 +- .../course_copy_quizzes_spec.rb | 2 +- .../content_migration/course_copy_spec.rb | 4 +- spec/models/course_spec.rb | 38 +-- .../custom_gradebook_column_datum_spec.rb | 54 ++-- spec/models/delayed_message_spec.rb | 4 +- spec/models/group_category_spec.rb | 2 +- spec/models/group_spec.rb | 2 +- .../importers/assignment_importer_spec.rb | 2 +- .../importers/course_content_importer_spec.rb | 6 +- spec/models/learning_outcome_result_spec.rb | 2 +- spec/models/lti/message_handler_spec.rb | 4 +- spec/models/lti/tool_configuration_spec.rb | 16 +- spec/models/lti/tool_setting_spec.rb | 10 +- .../master_courses/child_subscription_spec.rb | 4 +- spec/models/message_spec.rb | 2 +- spec/models/outcome_proficiency_spec.rb | 2 +- .../migration_extractor_spec.rb | 2 +- spec/models/pseudonym_spec.rb | 2 +- .../log_auditing/event_aggregator_spec.rb | 2 +- .../fill_in_multiple_blanks_spec.rb | 4 +- .../quizzes/quiz_regrader/answer_spec.rb | 2 +- spec/models/quizzes/quiz_spec.rb | 2 +- .../quiz_statistics/item_analysis/common.rb | 4 +- .../quiz_statistics/student_analysis_spec.rb | 6 +- .../quizzes/quiz_statistics_service_spec.rb | 2 +- spec/models/quizzes/quiz_submission_spec.rb | 12 +- .../quizzes_next/export_service_spec.rb | 24 +- spec/models/submission_spec.rb | 2 +- spec/models/user_preference_value_spec.rb | 28 +- spec/models/user_profile_spec.rb | 4 +- spec/models/user_spec.rb | 2 +- spec/models/wiki_page_spec.rb | 6 +- .../discussion_topic_presenter_spec.rb | 10 +- .../quizzes/take_quiz_presenter_spec.rb | 20 +- .../admin/account_direct_share_import_spec.rb | 2 +- .../selenium/admin/admin_sub_accounts_spec.rb | 2 +- spec/selenium/alerts_spec.rb | 2 +- .../announcements_student_spec.rb | 4 +- .../announcements_teacher_spec.rb | 2 +- .../assignments_external_tool_spec.rb | 2 +- .../assignments_peer_reviews_spec.rb | 2 +- spec/selenium/assignments/assignments_spec.rb | 2 +- .../assignments_turn_it_in_spec.rb | 2 +- .../calendar/calendar2_event_create_spec.rb | 8 +- .../calendar/calendar2_sidebar_spec.rb | 2 +- .../calendar/calendar2_student_spec.rb | 2 +- spec/selenium/common.rb | 2 +- spec/selenium/content_exports_spec.rb | 2 +- .../conversations_submission_comments_spec.rb | 6 +- spec/selenium/course_settings_spec.rb | 12 +- spec/selenium/course_statistics_spec.rb | 2 +- spec/selenium/courses/courses_spec.rb | 2 +- spec/selenium/courses_spec.rb | 2 +- spec/selenium/cross_listing_spec.rb | 4 +- .../elementary/k5_dashboard_observer_spec.rb | 2 +- spec/selenium/dashboard_coming_up_spec.rb | 2 +- spec/selenium/dashboard_spec.rb | 2 +- spec/selenium/dashboard_teacher_spec.rb | 2 +- spec/selenium/dashboard_todo_spec.rb | 2 +- .../grades/gradebook/gradebook_a11y_spec.rb | 2 +- .../gradebook/gradebook_pagination_spec.rb | 2 +- .../gradebook/gradebook_uploads_spec.rb | 4 +- .../pages/gradebook_individual_view_page.rb | 2 +- .../speedgrader_quiz_submissions_spec.rb | 16 +- .../speedgrader_teacher_submission_spec.rb | 2 +- .../gradebook_student_common.rb | 10 +- spec/selenium/help_dialog_spec.rb | 2 +- .../helpers/basic/question_banks_specs.rb | 2 +- .../helpers/basic/statistics_specs.rb | 2 +- spec/selenium/helpers/scheduler_common.rb | 4 +- spec/selenium/i18n_js_spec.rb | 2 +- spec/selenium/jquery_ui_spec.rb | 2 +- spec/selenium/layout_spec.rb | 2 +- spec/selenium/links_spec.rb | 6 +- spec/selenium/manage_new_groups_spec.rb | 2 - .../selenium/outcomes/outcome_teacher_spec.rb | 2 +- spec/selenium/rcs/alerts_spec.rb | 2 +- spec/selenium/rcs/rce_next_autosave_spec.rb | 4 +- .../custom_wait_methods.rb | 2 +- spec/selenium/user_content_student_spec.rb | 2 +- spec/selenium/users_spec.rb | 4 +- spec/selenium/wiki_pages_spec.rb | 2 +- spec/spec_helper.rb | 10 +- spec/support/spec_time_limit.rb | 2 +- .../confirm.html.erb_spec.rb | 12 +- .../context/undelete_index.html.erb_spec.rb | 4 +- spec/views/courses/settings.html.erb_spec.rb | 8 +- spec/views/files/show.html.erb_spec.rb | 2 +- .../gradebooks/grade_summary.html.erb_spec.rb | 2 +- .../profile/_ways_to_contact.html.erb_spec.rb | 12 +- .../quizzes/_quiz_edit.html.erb_spec.rb | 12 +- .../quizzes/quizzes/history.html.erb_spec.rb | 8 +- spec/views/users/_name.html.erb_spec.rb | 8 +- spec/views/users/admin_merge.html.erb_spec.rb | 6 +- 363 files changed, 1277 insertions(+), 1263 deletions(-) diff --git a/.rubocop.common.yml b/.rubocop.common.yml index 03f69de30b0..899ddbaaab9 100644 --- a/.rubocop.common.yml +++ b/.rubocop.common.yml @@ -31,8 +31,38 @@ Layout: Layout/LineLength: Enabled: false # TODO. Maybe. +Lint/AmbiguousOperator: + Severity: error +Lint/AmbiguousOperatorPrecedence: + Severity: error +Lint/AmbiguousRegexpLiteral: + Severity: error Lint/Debugger: Severity: error +Lint/DeprecatedClassMethods: + Severity: error +Lint/DeprecatedOpenSSLConstant: + Severity: error +Lint/NonDeterministicRequireOrder: + Severity: error +Lint/ParenthesesAsGroupedExpression: + Severity: error +Lint/RedundantRequireStatement: + Severity: error +Lint/RedundantSafeNavigation: + Severity: error +Lint/RedundantSplatExpansion: + Severity: error +Lint/RedundantStringCoercion: + Severity: error +Lint/RedundantWithIndex: + Severity: error +Lint/SendWithMixinArgument: + Severity: error +Lint/SymbolConversion: + Severity: error +Lint/UnifiedInteger: + Severity: error Metrics: Enabled: false # SnR is just too low to have this enabled @@ -102,6 +132,14 @@ Style/SpecialGlobalVars: Lint/AmbiguousBlockAssociation: # TODO Exclude: - spec/**/* +Lint/UnusedBlockArgument: # TODO maually fix these by removing the argument if possible + Severity: warning + AutoCorrect: false +Lint/UnusedMethodArgument: # TODO maually fix these by removing the argument if possible + Severity: warning + AutoCorrect: false +Lint/UselessAssignment: # TODO + Severity: warning Naming/VariableNumber: # TODO Enabled: false diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 7a350f2a4bf..1499ff29193 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -841,7 +841,7 @@ class AccountsController < ApplicationController @account.errors.add(quota_type, t(:quota_integer_required, 'An integer value is required')) else @account.errors.add(quota_type, t(:quota_must_be_positive, 'Value must be positive')) if quota_value.to_i < 0 - @account.errors.add(quota_type, t(:quota_too_large, 'Value too large')) if quota_value.to_i >= 2**62 / 1.megabytes + @account.errors.add(quota_type, t(:quota_too_large, 'Value too large')) if quota_value.to_i >= (2**62) / 1.megabytes end end else diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3d9328fe4a1..46a4de5a00b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -707,7 +707,7 @@ class ApplicationController < ActionController::Base end def tab_enabled?(id, opts = {}) - return true unless @context&.respond_to?(:tabs_available) + return true unless @context.respond_to?(:tabs_available) valid = Rails.cache.fetch(['tab_enabled4', id, @context, @current_user, @domain_root_account, session[:enrollment_uuid]].cache_key) do @context.tabs_available(@current_user, @@ -1504,7 +1504,7 @@ class ApplicationController < ActionController::Base def log_gets if @page_view && !request.xhr? && request.get? && (((response.media_type || "").to_s.match(/html/)) || - (Setting.get('create_get_api_page_views', 'true') == 'true') && api_request?) + ((Setting.get('create_get_api_page_views', 'true') == 'true') && api_request?)) @page_view.render_time ||= (Time.now.utc - @page_before_render) rescue nil @page_view_update = true end @@ -2845,7 +2845,7 @@ class ApplicationController < ActionController::Base }.freeze def show_student_view_button? - return false unless @context&.is_a?(Course) && can_do(@context, @current_user, :use_student_view) + return false unless @context.is_a?(Course) && can_do(@context, @current_user, :use_student_view) controller_action = "#{params[:controller]}##{params[:action]}" STUDENT_VIEW_PAGES.key?(controller_action) && (STUDENT_VIEW_PAGES[controller_action].nil? || !@context.tab_hidden?(STUDENT_VIEW_PAGES[controller_action])) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index cc0d1e5cce6..c6f952c27bc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1697,7 +1697,7 @@ class CoursesController < ApplicationController row = [] row << opc.user.last_name row << opc.user.first_name - row << '="' + opc.code + '"' + row << ('="' + opc.code + '"') row << opc.expires_at csv << row end @@ -1772,7 +1772,7 @@ class CoursesController < ApplicationController enrollment = nil return false end - elsif !@current_user && enrollment.user.registered? || !enrollment.user.email_channel + elsif (!@current_user && enrollment.user.registered?) || !enrollment.user.email_channel session[:return_to] = course_url(@context.id) flash[:notice] = t('notices.login_to_accept', "You'll need to log in before you can accept the enrollment.") return redirect_to login_url(:force_login => 1) if @current_user @@ -2869,8 +2869,8 @@ class CoursesController < ApplicationController end if params_for_update.key?(:template) template = value_to_boolean(params_for_update.delete(:template)) - if template && @course.grants_right?(@current_user, session, :add_course_template) || - !template && @course.grants_right?(@current_user, session, :delete_course_template) + if (template && @course.grants_right?(@current_user, session, :add_course_template)) || + (!template && @course.grants_right?(@current_user, session, :delete_course_template)) @course.template = template end end diff --git a/app/controllers/discussion_topics_controller.rb b/app/controllers/discussion_topics_controller.rb index b8521815dd6..a540c36a81d 100644 --- a/app/controllers/discussion_topics_controller.rb +++ b/app/controllers/discussion_topics_controller.rb @@ -1533,7 +1533,7 @@ class DiscussionTopicsController < ApplicationController def handle_assignment_edit_params(hash) hash[:title] = params[:title] if params[:title] - if params.slice(*[:due_at, :points_possible, :assignment_group_id]).present? + if params.slice(:due_at, :points_possible, :assignment_group_id).present? if hash[:assignment].nil? && @context.respond_to?(:assignments) && @context.assignments.temp_record.grants_right?(@current_user, session, :create) hash[:assignment] ||= {} end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 4ae2633952e..cb248c6dae3 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -634,7 +634,7 @@ class FilesController < ApplicationController [json[:attachment], doc_preview_json(attachment, @current_user), - attachment_json(attachment, @current_user, {}, json_include)].reduce &:merge! + attachment_json(attachment, @current_user, {}, json_include)].reduce(&:merge!) log_asset_access(attachment, "files", "files") end @@ -843,7 +843,7 @@ class FilesController < ApplicationController @context = @attachment.context @attachment.workflow_state = nil - @attachment.uploaded_data = params[:file] || params[:attachment] && params[:attachment][:uploaded_data] + @attachment.uploaded_data = params[:file] || (params[:attachment] && params[:attachment][:uploaded_data]) if @attachment.save # for consistency with the s3 upload client flow, we redirect to the success url here to finish up includes = Array(params[:success_include]) diff --git a/app/controllers/live_assessments/assessments_controller.rb b/app/controllers/live_assessments/assessments_controller.rb index 2530ee24006..cd404ce5766 100644 --- a/app/controllers/live_assessments/assessments_controller.rb +++ b/app/controllers/live_assessments/assessments_controller.rb @@ -96,7 +96,7 @@ module LiveAssessments assessment.save! if @outcome criterion = @outcome.rubric_criterion - mastery_score = criterion && criterion[:mastery_points] / criterion[:points_possible] + mastery_score = criterion && (criterion[:mastery_points] / criterion[:points_possible]) @outcome.align(assessment, @context, mastery_type: "none", mastery_score: mastery_score) end @assessments << assessment diff --git a/app/controllers/login/otp_controller.rb b/app/controllers/login/otp_controller.rb index 585982cda31..f1a1f096b35 100644 --- a/app/controllers/login/otp_controller.rb +++ b/app/controllers/login/otp_controller.rb @@ -34,8 +34,8 @@ class Login::OtpController < ApplicationController def new # if we waiting on OTP for login, but we're not yet configured, start configuring # OR if we're not waiting on OTP, we're configuring - if session[:pending_otp] && !secret_key || - !session[:pending_otp] && !configuring? + if (session[:pending_otp] && !secret_key) || + (!session[:pending_otp] && !configuring?) session[:pending_otp_secret_key] = ROTP::Base32.random @first_reconfiguration = true end @@ -93,7 +93,7 @@ class Login::OtpController < ApplicationController drift = 300 if session[:pending_otp_communication_channel_id] || (!session[:pending_otp_secret_key] && @current_user.otp_communication_channel_id) - if !force_fail && ROTP::TOTP.new(secret_key).verify(verification_code, drift_behind: drift, drift_ahead: drift) || + if (!force_fail && ROTP::TOTP.new(secret_key).verify(verification_code, drift_behind: drift, drift_ahead: drift)) || @current_user.authenticate_one_time_password(verification_code) if configuring? @current_user.one_time_passwords.scope.delete_all diff --git a/app/controllers/lti/data_services_controller.rb b/app/controllers/lti/data_services_controller.rb index 2a50e720eed..961915b31d5 100644 --- a/app/controllers/lti/data_services_controller.rb +++ b/app/controllers/lti/data_services_controller.rb @@ -173,7 +173,7 @@ module Lti def update sub = params.require(:subscription) SubscriptionsValidator.validate_subscription_context!(sub) if sub[:ContextType] - updates = add_updater({ 'Id': params[:id] }.merge(sub.to_unsafe_h)) + updates = add_updater({ Id: params[:id] }.merge(sub.to_unsafe_h)) response = Services::LiveEventsSubscriptionService.update(jwt_body, updates) forward_service_response(response) end diff --git a/app/controllers/lti/ims/authentication_controller.rb b/app/controllers/lti/ims/authentication_controller.rb index 56105a9697b..123d14c83d2 100644 --- a/app/controllers/lti/ims/authentication_controller.rb +++ b/app/controllers/lti/ims/authentication_controller.rb @@ -131,7 +131,7 @@ module Lti def public_course? # Is the context published and public? - context&.is_a?(Course) && context&.available? && context&.is_public? + context.is_a?(Course) && context&.available? && context&.is_public? end def verifier diff --git a/app/controllers/lti/ims/providers/memberships_provider.rb b/app/controllers/lti/ims/providers/memberships_provider.rb index 313a6d86d12..4f39999b2ba 100644 --- a/app/controllers/lti/ims/providers/memberships_provider.rb +++ b/app/controllers/lti/ims/providers/memberships_provider.rb @@ -26,7 +26,7 @@ module Lti::Ims::Providers attr_reader :context, :controller, :tool def self.unwrap(wrapped) - wrapped&.respond_to?(:unwrap) ? wrapped.unwrap : wrapped + wrapped.respond_to?(:unwrap) ? wrapped.unwrap : wrapped end def initialize(context, controller, tool) diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb index 64eafdeb9cb..d010a4b4035 100644 --- a/app/controllers/profile_controller.rb +++ b/app/controllers/profile_controller.rb @@ -347,7 +347,7 @@ class ProfileController < ApplicationController user_params.delete(:short_name) user_params.delete(:sortable_name) end - if !@domain_root_account.can_change_pronouns? || user_params[:pronouns].present? && @domain_root_account.pronouns.exclude?(user_params[:pronouns].strip) + if !@domain_root_account.can_change_pronouns? || (user_params[:pronouns].present? && @domain_root_account.pronouns.exclude?(user_params[:pronouns].strip)) user_params.delete(:pronouns) end if @user.update(user_params) diff --git a/app/controllers/quizzes/quizzes_controller.rb b/app/controllers/quizzes/quizzes_controller.rb index 7115e40190f..a23cfcaa356 100644 --- a/app/controllers/quizzes/quizzes_controller.rb +++ b/app/controllers/quizzes/quizzes_controller.rb @@ -656,8 +656,8 @@ class Quizzes::QuizzesController < ApplicationController @submissions_from_users[student.id].id end - submitted_students_json = @submitted_students.map &:id - unsubmitted_students_json = @unsubmitted_students.map &:id + submitted_students_json = @submitted_students.map(&:id) + unsubmitted_students_json = @unsubmitted_students.map(&:id) else submitted_students_json = @submitted_students.map { |u| user_json(u, @current_user, session) } unsubmitted_students_json = @unsubmitted_students.map { |u| user_json(u, @current_user, session) } diff --git a/app/controllers/rubric_associations_controller.rb b/app/controllers/rubric_associations_controller.rb index 2435d463f58..d072786d9d3 100644 --- a/app/controllers/rubric_associations_controller.rb +++ b/app/controllers/rubric_associations_controller.rb @@ -146,7 +146,7 @@ class RubricAssociationsController < ApplicationController def can_manage_rubrics_or_association_object?(association, association_object) return true if association || @context.grants_right?(@current_user, session, :manage_rubrics) || - association_object && association_object.grants_right?(@current_user, session, :update) + (association_object && association_object.grants_right?(@current_user, session, :update)) render_unauthorized_action false diff --git a/app/controllers/rubrics_controller.rb b/app/controllers/rubrics_controller.rb index 39fb4f0bf2f..558445d0280 100644 --- a/app/controllers/rubrics_controller.rb +++ b/app/controllers/rubrics_controller.rb @@ -222,8 +222,8 @@ class RubricsController < ApplicationController private def can_manage_rubrics_or_association_object?(object) - return true if object && (can_update?(object) || can_read?(object) && can_manage_rubrics_context?) || - !object && can_manage_rubrics_context? + return true if (object && (can_update?(object) || (can_read?(object) && can_manage_rubrics_context?))) || + (!object && can_manage_rubrics_context?) render_unauthorized_action false diff --git a/app/controllers/sub_accounts_controller.rb b/app/controllers/sub_accounts_controller.rb index c6ced263b95..0f1c2b3b7eb 100644 --- a/app/controllers/sub_accounts_controller.rb +++ b/app/controllers/sub_accounts_controller.rb @@ -54,7 +54,7 @@ class SubAccountsController < ApplicationController permissions: [:manage_account_settings, :manage_courses, :manage_courses_admin] ) - @query = params[:account] && params[:account][:name] || params[:term] + @query = (params[:account] && params[:account][:name]) || params[:term] if @query @accounts = [] if @context && @context.is_a?(Account) diff --git a/app/controllers/submissions_api_controller.rb b/app/controllers/submissions_api_controller.rb index 71ee46fe289..038baed450f 100644 --- a/app/controllers/submissions_api_controller.rb +++ b/app/controllers/submissions_api_controller.rb @@ -1224,7 +1224,7 @@ class SubmissionsApiController < ApplicationController def bulk_load_attachments_and_previews(submissions) Submission.bulk_load_versioned_attachments(submissions) - attachments = submissions.flat_map &:versioned_attachments + attachments = submissions.flat_map(&:versioned_attachments) ActiveRecord::Associations::Preloader.new.preload(attachments, [:canvadoc, :crocodoc_document]) Version.preload_version_number(submissions) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bb057433c1b..ffef311dd98 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -322,12 +322,12 @@ class UsersController < ApplicationController Canvas::Errors.capture_exception(:oauth, e, :warn) flash[:error] = e.to_s end - return redirect_to (@current_user ? user_profile_url(@current_user) : root_url) + return redirect_to(@current_user ? user_profile_url(@current_user) : root_url) end if !oauth_request || (request.host_with_port == oauth_request.original_host_with_port && oauth_request.user != @current_user) flash[:error] = t('oauth_fail', "OAuth Request failed. Couldn't find valid request") - redirect_to (@current_user ? user_profile_url(@current_user) : root_url) + redirect_to(@current_user ? user_profile_url(@current_user) : root_url) elsif request.host_with_port != oauth_request.original_host_with_port url = url_for request.parameters.merge(:host => oauth_request.original_host_with_port, :only_path => false) redirect_to url @@ -2883,7 +2883,7 @@ class UsersController < ApplicationController force_validations = value_to_boolean(params[:force_validations]) manage_user_logins = @context.grants_right?(@current_user, session, :manage_user_logins) self_enrollment = params[:self_enrollment].present? - allow_non_email_pseudonyms = !force_validations && manage_user_logins || self_enrollment && params[:pseudonym_type] == 'username' + allow_non_email_pseudonyms = (!force_validations && manage_user_logins) || (self_enrollment && params[:pseudonym_type] == 'username') require_password = self_enrollment && allow_non_email_pseudonyms allow_password = require_password || manage_user_logins || use_pairing_code @@ -3016,7 +3016,7 @@ class UsersController < ApplicationController @cc.confirmation_redirect = cc_confirmation_redirect end - if @recaptcha_errors.nil? && @user.valid? && @pseudonym.valid? && @invalid_observee_creds.nil? & @invalid_observee_code.nil? + if @recaptcha_errors.nil? && @user.valid? && @pseudonym.valid? && (@invalid_observee_creds.nil? & @invalid_observee_code.nil?) # saving the user takes care of the @pseudonym and @cc, so we can't call # save_without_session_maintenance directly. we don't want to auto-log-in # unless the user is registered/pre_registered (if the latter, he still diff --git a/app/graphql/types/assignment_type.rb b/app/graphql/types/assignment_type.rb index b909480b0a8..4f3cf1932cb 100644 --- a/app/graphql/types/assignment_type.rb +++ b/app/graphql/types/assignment_type.rb @@ -124,7 +124,7 @@ module Types if !apply_overrides && course.grants_any_right?(current_user, *RoleOverride::GRANULAR_MANAGE_ASSIGNMENT_PERMISSIONS) assignment.send(field_name) else - OverrideAssignmentLoader.for(current_user).load(assignment).then &field_name + OverrideAssignmentLoader.for(current_user).load(assignment).then(&field_name) end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fb838fcb001..c8269924ec3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -293,7 +293,7 @@ module ApplicationHelper def css_variant(opts = {}) variant = use_responsive_layout? ? 'responsive_layout' : 'new_styles' - use_high_contrast = @current_user && @current_user.prefers_high_contrast? || opts[:force_high_contrast] + use_high_contrast = (@current_user && @current_user.prefers_high_contrast?) || opts[:force_high_contrast] variant + (use_high_contrast ? '_high_contrast' : '_normal_contrast') + (I18n.rtl? ? '_rtl' : '') end diff --git a/app/helpers/attachment_helper.rb b/app/helpers/attachment_helper.rb index 6eca8facb19..58927cf254b 100644 --- a/app/helpers/attachment_helper.rb +++ b/app/helpers/attachment_helper.rb @@ -126,7 +126,7 @@ module AttachmentHelper cancel_cache_buster # set cache to expire whenever the s3 url does (or one day if local or inline proxy), max-age take seconds, and Expires takes a date ttl = direct ? 1.day : attachment.url_ttl - response.headers["Cache-Control"] = "private, max-age=#{ttl.seconds.to_s}" + response.headers["Cache-Control"] = "private, max-age=#{ttl.seconds}" response.headers["Expires"] = ttl.from_now.httpdate end end diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index 0d314fef6da..75fd7d61f21 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -28,7 +28,7 @@ module AvatarHelper if session["reported_#{user_id}"] && !is_admin && !(user && user.avatar_state == :approved) ["/images/messages/avatar-50.png", ''] else - avatar_settings = @domain_root_account && @domain_root_account.settings[:avatars] || 'enabled' + avatar_settings = (@domain_root_account && @domain_root_account.settings[:avatars]) || 'enabled' user_id = Shard.global_id_for(user_id) user_shard = Shard.shard_for(user_id) image_url, alt_tag = user_shard.activate do @@ -103,7 +103,7 @@ module AvatarHelper default_avatar = use_fallback ? User.avatar_fallback_url(User.default_avatar_fallback, request) : nil url = if avatars_enabled_for_user?(user, root_account: root_account) user.avatar_url(nil, - (root_account && root_account.settings[:avatars] || 'enabled'), + ((root_account && root_account.settings[:avatars]) || 'enabled'), default_avatar, request, use_fallback) diff --git a/app/helpers/context_modules_helper.rb b/app/helpers/context_modules_helper.rb index 04a488c98e9..5e860eb7032 100644 --- a/app/helpers/context_modules_helper.rb +++ b/app/helpers/context_modules_helper.rb @@ -23,16 +23,16 @@ module ContextModulesHelper include CyoeHelper TRANSLATED_COMMENT_TYPE = { - 'Announcement': I18n.t('Announcement'), - 'Assignment': I18n.t('Assignment'), - 'Attachment': I18n.t('Attachment'), - 'ContextExternalTool': I18n.t('External Tool'), - 'ContextModuleSubHeader': I18n.t('Context Module Sub Header'), - 'DiscussionTopic': I18n.t('Discussion Topic'), - 'ExternalUrl': I18n.t('External Url'), - 'Quiz': I18n.t('Quiz'), + Announcement: I18n.t('Announcement'), + Assignment: I18n.t('Assignment'), + Attachment: I18n.t('Attachment'), + ContextExternalTool: I18n.t('External Tool'), + ContextModuleSubHeader: I18n.t('Context Module Sub Header'), + DiscussionTopic: I18n.t('Discussion Topic'), + ExternalUrl: I18n.t('External Url'), + Quiz: I18n.t('Quiz'), 'Quizzes::Quiz': I18n.t('Quiz'), - 'WikiPage': I18n.t('Page') + WikiPage: I18n.t('Page') }.freeze def cache_if_module(context_module, editable, is_student, can_view_unpublished, user, context, &block) diff --git a/app/helpers/gradebooks_helper.rb b/app/helpers/gradebooks_helper.rb index 35e70529dc4..12b3f1cec60 100644 --- a/app/helpers/gradebooks_helper.rb +++ b/app/helpers/gradebooks_helper.rb @@ -154,7 +154,7 @@ module GradebooksHelper end def pass_fail_icon(score, grade) - if score && score > 0 || grade == 'complete' + if (score && score > 0) || grade == 'complete' icon_attrs = pass_icon_attributes else icon_attrs = fail_icon_attributes diff --git a/app/helpers/quizzes_helper.rb b/app/helpers/quizzes_helper.rb index 986605c5f68..b9f28754b2c 100644 --- a/app/helpers/quizzes_helper.rb +++ b/app/helpers/quizzes_helper.rb @@ -462,9 +462,9 @@ module QuizzesHelper end if answer_list.empty? - answers.delete_if { |k, v| !k.match /^question_#{hash_get(question, :id)}/ } - answers.each { |k, v| res.sub! /\{\{#{k}\}\}/, h(v) } - res.gsub! /\{\{question_[^}]+\}\}/, "" + answers.delete_if { |k, v| !k.match(/^question_#{hash_get(question, :id)}/) } + answers.each { |k, v| res.sub!(/\{\{#{k}\}\}/, h(v)) } + res.gsub!(/\{\{question_[^}]+\}\}/, "") end # all of our manipulation lost this flag - reset it diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 53b74fcf725..aed658c0753 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -142,7 +142,7 @@ module SearchHelper end def search_contexts_and_users(options = {}) - types = (options[:types] || [] + [options[:type]]).compact + types = (options[:types] || ([] + [options[:type]])).compact types |= [:course, :section, :group] if types.delete('context') types = if types.present? { user: types.delete('user').present?, context: types.present? && types.map(&:to_sym) } diff --git a/app/models/account_notification.rb b/app/models/account_notification.rb index da7cb103222..9866212ad66 100644 --- a/app/models/account_notification.rb +++ b/app/models/account_notification.rb @@ -258,7 +258,7 @@ class AccountNotification < ActiveRecord::Base # we just need a stable reference point, doesn't matter what it is, so # let's use unix epoch start_time = Time.at(0).utc - months_since_start_time = (current_time.year - start_time.year) * 12 + (current_time.month - start_time.month) + months_since_start_time = ((current_time.year - start_time.year) * 12) + (current_time.month - start_time.month) periods_since_start_time = months_since_start_time / months_in_period months_into_current_period = months_since_start_time % months_in_period mod_value = (Random.new(periods_since_start_time).rand(months_in_period) + months_into_current_period) % months_in_period diff --git a/app/models/appointment_group.rb b/app/models/appointment_group.rb index 826ba39c0eb..fa3bc4c1d7a 100644 --- a/app/models/appointment_group.rb +++ b/app/models/appointment_group.rb @@ -36,7 +36,7 @@ class AppointmentGroup < ActiveRecord::Base end def contexts - appointment_group_contexts.map &:context + appointment_group_contexts.map(&:context) end def active_contexts @@ -45,7 +45,7 @@ class AppointmentGroup < ActiveRecord::Base def sub_contexts # I wonder how rails is adding multiples of the same sub_contexts - appointment_group_sub_contexts.map &:sub_context + appointment_group_sub_contexts.map(&:sub_context) end validates_presence_of :workflow_state @@ -184,7 +184,7 @@ class AppointmentGroup < ActiveRecord::Base end def sub_context_codes - appointment_group_sub_contexts.map &:sub_context_code + appointment_group_sub_contexts.map(&:sub_context_code) end # complements :reserve permission diff --git a/app/models/appointment_group_sub_context.rb b/app/models/appointment_group_sub_context.rb index 4ba1d6cd28b..d5134e245e8 100644 --- a/app/models/appointment_group_sub_context.rb +++ b/app/models/appointment_group_sub_context.rb @@ -24,7 +24,7 @@ class AppointmentGroupSubContext < ActiveRecord::Base validates_each :sub_context do |record, attr, value| if record.participant_type == 'User' - record.errors.add(attr, t('errors.invalid_course_section', 'Invalid course section')) unless value.blank? || value.is_a?(CourseSection) && record.appointment_group.contexts.any? { |c| c == value.course } + record.errors.add(attr, t('errors.invalid_course_section', 'Invalid course section')) unless value.blank? || (value.is_a?(CourseSection) && record.appointment_group.contexts.any? { |c| c == value.course }) else record.errors.add(attr, t('errors.missing_group_category', 'Group appointments must have a group category')) unless value.present? && value.is_a?(GroupCategory) record.errors.add(attr, t('errors.invalid_group_category', 'Invalid group category')) unless value && record.appointment_group.contexts.any? { |c| c == value.context } diff --git a/app/models/assignment.rb b/app/models/assignment.rb index 8665f94f651..cb3826a0049 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -2160,7 +2160,7 @@ class Assignment < ActiveRecord::Base raise "Student Required" unless original_student group, students = group_students(original_student) - opts[:author] ||= opts[:commenter] || opts[:user_id].present? && User.find_by(id: opts[:user_id]) + opts[:author] ||= opts[:commenter] || (opts[:user_id].present? && User.find_by(id: opts[:user_id])) res = { comments: [], submissions: [] diff --git a/app/models/assignment_override.rb b/app/models/assignment_override.rb index 08c9ef11583..928c1468256 100644 --- a/app/models/assignment_override.rb +++ b/app/models/assignment_override.rb @@ -370,7 +370,7 @@ class AssignmentOverride < ActiveRecord::Base self.assignment.created_at < 3.hours.ago && (saved_change_to_workflow_state? || saved_change_to_due_at_overridden? || - due_at_overridden && !Assignment.due_dates_equal?(due_at, due_at_before_last_save)) + (due_at_overridden && !Assignment.due_dates_equal?(due_at, due_at_before_last_save))) end def set_title_if_needed diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 747b27c7f39..64127ae3fe4 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -903,9 +903,9 @@ class Attachment < ActiveRecord::Base end def can_be_proxied? - mime_class == 'html' && size < Setting.get('max_inline_html_proxy_size', 128 * 1024).to_i || - mime_class == 'flash' && size < Setting.get('max_swf_proxy_size', 1024 * 1024).to_i || - content_type == 'text/css' && size < Setting.get('max_css_proxy_size', 64 * 1024).to_i + (mime_class == 'html' && size < Setting.get('max_inline_html_proxy_size', 128 * 1024).to_i) || + (mime_class == 'flash' && size < Setting.get('max_swf_proxy_size', 1024 * 1024).to_i) || + (content_type == 'text/css' && size < Setting.get('max_css_proxy_size', 64 * 1024).to_i) end def local_storage_path @@ -1028,7 +1028,7 @@ class Attachment < ActiveRecord::Base block ||= lambda { |str, len| str[0...len] } ext_index = filename.rindex('.') if ext_index - ext = block.call(filename[ext_index..-1], len / 2 + 1) + ext = block.call(filename[ext_index..-1], (len / 2) + 1) base = block.call(filename[0...ext_index], len - ext.length) base + ext else diff --git a/app/models/attachments/local_storage.rb b/app/models/attachments/local_storage.rb index 125e2943c0e..5b10c8c8a5a 100644 --- a/app/models/attachments/local_storage.rb +++ b/app/models/attachments/local_storage.rb @@ -29,7 +29,7 @@ class Attachments::LocalStorage end def exists? - File.exists?(attachment.full_filename) + File.exist?(attachment.full_filename) end def change_namespace(old_full_filename) diff --git a/app/models/attachments/s3_storage.rb b/app/models/attachments/s3_storage.rb index 314fc871431..ff2cdd1acf8 100644 --- a/app/models/attachments/s3_storage.rb +++ b/app/models/attachments/s3_storage.rb @@ -86,7 +86,7 @@ class Attachments::S3Storage def shared_secret(datetime) config = bucket.client.config - sha256 = OpenSSL::Digest::SHA256.new + sha256 = OpenSSL::Digest.new('SHA256') date_key = OpenSSL::HMAC.digest(sha256, "AWS4#{config.secret_access_key}", datetime[0, 8]) date_region_key = OpenSSL::HMAC.digest(sha256, date_key, config.region) date_region_service_key = OpenSSL::HMAC.digest(sha256, date_region_key, "s3") diff --git a/app/models/calendar_event.rb b/app/models/calendar_event.rb index 07842960f75..15bc04e1253 100644 --- a/app/models/calendar_event.rb +++ b/app/models/calendar_event.rb @@ -130,7 +130,7 @@ class CalendarEvent < ActiveRecord::Base end def effective_context - effective_context_code && ActiveRecord::Base.find_all_by_asset_string(effective_context_code).first || context + (effective_context_code && ActiveRecord::Base.find_all_by_asset_string(effective_context_code).first) || context end scope :active, -> { where("calendar_events.workflow_state<>'deleted'") } @@ -661,7 +661,7 @@ class CalendarEvent < ActiveRecord::Base given { |user, session| appointment_group? && ( grants_right?(user, session, :manage) || - context.grants_right?(user, :reserve) && context.participant_for(user).present? + (context.grants_right?(user, :reserve) && context.participant_for(user).present?) ) } can :reserve diff --git a/app/models/canvadoc.rb b/app/models/canvadoc.rb index cf21591836b..94667328526 100644 --- a/app/models/canvadoc.rb +++ b/app/models/canvadoc.rb @@ -54,7 +54,7 @@ class Canvadoc < ActiveRecord::Base def submissions self.canvadocs_submissions .preload(submission: :assignment) - .map &:submission + .map(&:submission) end def available? diff --git a/app/models/content_migration.rb b/app/models/content_migration.rb index e1c508aa130..042bccfdca9 100644 --- a/app/models/content_migration.rb +++ b/app/models/content_migration.rb @@ -615,7 +615,7 @@ class ContentMigration < ActiveRecord::Base self.update_master_migration('failed') if self.for_master_course_import? raise e ensure - File.delete(all_files_path) if all_files_path && File.exists?(all_files_path) + File.delete(all_files_path) if all_files_path && File.exist?(all_files_path) clear_migration_data end end diff --git a/app/models/context.rb b/app/models/context.rb index 9ef56a5dbed..665a4465783 100644 --- a/app/models/context.rb +++ b/app/models/context.rb @@ -96,7 +96,7 @@ module Context context_codes = sharded_course_ids.map { |id| "course_#{id}" } if Shard.current == self.shard context = self - while context && context.respond_to?(:account) || context.respond_to?(:parent_account) + while (context && context.respond_to?(:account)) || context.respond_to?(:parent_account) context = context.respond_to?(:account) ? context.account : context.parent_account context_codes << context.asset_string if context end diff --git a/app/models/context_module.rb b/app/models/context_module.rb index 55120d5e10f..f236a0e191f 100644 --- a/app/models/context_module.rb +++ b/app/models/context_module.rb @@ -241,7 +241,7 @@ class ContextModule < ActiveRecord::Base # kept in the same module. def duplicate_content_tag(original_content_tag) new_tag = duplicate_content_tag_base_model(original_content_tag) - if original_content_tag.content&.respond_to?(:duplicate) + if original_content_tag.content.respond_to?(:duplicate) new_tag.content = original_content_tag.content.duplicate # If we have multiple assignments (e.g.) make sure they each get unused titles. # A title isn't marked used if the assignment hasn't been saved yet. @@ -634,7 +634,7 @@ class ContextModule < ActiveRecord::Base def add_item(params, added_item = nil, opts = {}) params[:type] = params[:type].underscore if params[:type] - position = opts[:position] || (self.content_tags.not_deleted.maximum(:position) || 0) + 1 + position = opts[:position] || ((self.content_tags.not_deleted.maximum(:position) || 0) + 1) position = [position, params[:position].to_i].max if params[:position] if params[:type] == "wiki_page" || params[:type] == "page" item = opts[:wiki_page] || self.context.wiki_pages.where(id: params[:id]).first diff --git a/app/models/conversation_batch.rb b/app/models/conversation_batch.rb index 7f497dbfab3..dd4689ac74c 100644 --- a/app/models/conversation_batch.rb +++ b/app/models/conversation_batch.rb @@ -91,7 +91,7 @@ class ConversationBatch < ActiveRecord::Base # headway. every minute we will advance half of the remainder of # job_start_factor. minutes = (Time.zone.now - created_at).to_i / 60.0 - job_start_factor * (1 - (1 / 2**minutes)) + job_start_factor * (1 - (1 / (2**minutes))) else # the rest of the progress bar is nice and linear job_start_factor + ((1 - job_start_factor) * conversation_message_ids.size / recipient_ids.size) diff --git a/app/models/conversation_message.rb b/app/models/conversation_message.rb index f53d6b7677f..f2194c80523 100644 --- a/app/models/conversation_message.rb +++ b/app/models/conversation_message.rb @@ -302,7 +302,7 @@ class ConversationMessage < ActiveRecord::Base end def forwarded_messages - @forwarded_messages ||= forwarded_message_ids && self.class.unscoped { self.class.where(id: forwarded_message_ids.split(',')).order('created_at DESC').to_a } || [] + @forwarded_messages ||= (forwarded_message_ids && self.class.unscoped { self.class.where(id: forwarded_message_ids.split(',')).order('created_at DESC').to_a }) || [] end def all_forwarded_messages diff --git a/app/models/course.rb b/app/models/course.rb index 80281c28cc2..103c311a461 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1162,7 +1162,7 @@ class Course < ActiveRecord::Base def update_enrolled_users(sis_batch: nil) self.shard.activate do - if self.workflow_state_changed? || sis_batch && self.saved_change_to_workflow_state? + if self.workflow_state_changed? || (sis_batch && self.saved_change_to_workflow_state?) if self.completed? enrollment_info = Enrollment.where(:course_id => self, :workflow_state => ['active', 'invited']).select(:id, :workflow_state).to_a if enrollment_info.any? @@ -1625,7 +1625,7 @@ class Course < ActiveRecord::Base can permission end - given { |user, session| session && session[:enrollment_uuid] && (hash = Enrollment.course_user_state(self, session[:enrollment_uuid]) || {}) && (hash[:enrollment_state] == "invited" || hash[:enrollment_state] == "active" && hash[:user_state].to_s == "pre_registered") && (self.available? || self.completed? || self.claimed? && hash[:is_admin]) } + given { |user, session| session && session[:enrollment_uuid] && (hash = Enrollment.course_user_state(self, session[:enrollment_uuid]) || {}) && (hash[:enrollment_state] == "invited" || (hash[:enrollment_state] == "active" && hash[:user_state].to_s == "pre_registered")) && (self.available? || self.completed? || (self.claimed? && hash[:is_admin])) } can :read and can :read_outcomes given { |user| (self.available? || self.completed?) && user && fetch_on_enrollments("has_not_inactive_enrollment", user) { enrollments.for_user(user).not_inactive_by_date.exists? } } diff --git a/app/models/discussion_topic.rb b/app/models/discussion_topic.rb index 8d9a1bf0a8e..b7167e3801b 100644 --- a/app/models/discussion_topic.rb +++ b/app/models/discussion_topic.rb @@ -992,8 +992,8 @@ class DiscussionTopic < ActiveRecord::Base end def should_clear_all_stream_items? - !self.published? && self.saved_change_to_attribute?(:workflow_state) || - self.is_announcement && self.not_available_yet? && self.saved_change_to_attribute?(:delayed_post_at) + (!self.published? && self.saved_change_to_attribute?(:workflow_state)) || + (self.is_announcement && self.not_available_yet? && self.saved_change_to_attribute?(:delayed_post_at)) end def clear_non_applicable_stream_items @@ -1341,7 +1341,7 @@ class DiscussionTopic < ActiveRecord::Base end def visible_to_admins_only? - self.context.respond_to?(:available?) && !self.context.available? || + (self.context.respond_to?(:available?) && !self.context.available?) || unpublished? || not_available_yet? || not_available_anymore? end diff --git a/app/models/enrollment.rb b/app/models/enrollment.rb index 603f6af4a4b..8a8eb706984 100644 --- a/app/models/enrollment.rb +++ b/app/models/enrollment.rb @@ -1414,10 +1414,10 @@ class Enrollment < ActiveRecord::Base # find it, fall back to the section or course creation date. enrollment_dates.map(&:first).compact.min || start_at || - course_section && course_section.start_at || + (course_section && course_section.start_at) || course.start_at || - course.enrollment_term && course.enrollment_term.start_at || - course_section && course_section.created_at || + (course.enrollment_term && course.enrollment_term.start_at) || + (course_section && course_section.created_at) || course.created_at end @@ -1427,9 +1427,9 @@ class Enrollment < ActiveRecord::Base # looking at the enrollment, section, course, then term. enrollment_dates.map(&:last).compact.max || end_at || - course_section && course_section.end_at || + (course_section && course_section.end_at) || course.conclude_at || - course.enrollment_term && course.enrollment_term.end_at + (course.enrollment_term && course.enrollment_term.end_at) end def self.cross_shard_invitations? @@ -1540,10 +1540,10 @@ class Enrollment < ActiveRecord::Base end def can_delete_via_granular(user, session, context) - self.teacher? && context.grants_right?(user, session, :remove_teacher_from_course) || - self.ta? && context.grants_right?(user, session, :remove_ta_from_course) || - self.designer? && context.grants_right?(user, session, :remove_designer_from_course) || - self.observer? && context.grants_right?(user, session, :remove_observer_from_course) + (self.teacher? && context.grants_right?(user, session, :remove_teacher_from_course)) || + (self.ta? && context.grants_right?(user, session, :remove_ta_from_course)) || + (self.designer? && context.grants_right?(user, session, :remove_designer_from_course)) || + (self.observer? && context.grants_right?(user, session, :remove_observer_from_course)) end def remove_user_as_final_grader? diff --git a/app/models/enrollment_state.rb b/app/models/enrollment_state.rb index c49b686e592..7a236cffbff 100644 --- a/app/models/enrollment_state.rb +++ b/app/models/enrollment_state.rb @@ -52,7 +52,7 @@ class EnrollmentState < ActiveRecord::Base # check if we've manually marked the enrollment state as potentially out of date (or if the stored date trigger has past) def state_needs_recalculation? - !self.state_is_current? || self.state_valid_until && self.state_valid_until < Time.now + !self.state_is_current? || (self.state_valid_until && self.state_valid_until < Time.now) end def ensure_current_state diff --git a/app/models/eportfolio_entry.rb b/app/models/eportfolio_entry.rb index a820236932f..897560dfc9f 100644 --- a/app/models/eportfolio_entry.rb +++ b/app/models/eportfolio_entry.rb @@ -57,7 +57,7 @@ class EportfolioEntry < ActiveRecord::Base protected :update_portfolio def content_sections - (self.content.is_a?(String) && Array(self.content) || self.content || []).map do |section| + ((self.content.is_a?(String) && Array(self.content)) || self.content || []).map do |section| if section.is_a?(Hash) section.with_indifferent_access else diff --git a/app/models/feature_flag.rb b/app/models/feature_flag.rb index 89c244e7617..05756c819e4 100644 --- a/app/models/feature_flag.rb +++ b/app/models/feature_flag.rb @@ -127,7 +127,7 @@ class FeatureFlag < ActiveRecord::Base private def valid_state - unless [Feature::STATE_OFF, Feature::STATE_ON].include?(state) || context.is_a?(Account) && [Feature::STATE_DEFAULT_OFF, Feature::STATE_DEFAULT_ON].include?(state) + unless [Feature::STATE_OFF, Feature::STATE_ON].include?(state) || (context.is_a?(Account) && [Feature::STATE_DEFAULT_OFF, Feature::STATE_DEFAULT_ON].include?(state)) errors.add(:state, "is not valid in context") end end diff --git a/app/models/grading_standard.rb b/app/models/grading_standard.rb index 64492ac9f1d..cd7bf7770e7 100644 --- a/app/models/grading_standard.rb +++ b/app/models/grading_standard.rb @@ -113,9 +113,9 @@ class GradingStandard < ActiveRecord::Base # otherwise, we step down just 1/10th of a point, which is the # granularity we support right now elsif idx && (ordered_scheme[idx].last - ordered_scheme[idx - 1].last).abs >= 0.01.to_d - ordered_scheme[idx - 1].last * 100.0.to_d - 1.0.to_d + (ordered_scheme[idx - 1].last * 100.0.to_d) - 1.0.to_d elsif idx - ordered_scheme[idx - 1].last * 100.0.to_d - 0.1.to_d + (ordered_scheme[idx - 1].last * 100.0.to_d) - 0.1.to_d else nil end diff --git a/app/models/importers/learning_outcome_importer.rb b/app/models/importers/learning_outcome_importer.rb index 505e0ea8cae..d969bbb46e1 100644 --- a/app/models/importers/learning_outcome_importer.rb +++ b/app/models/importers/learning_outcome_importer.rb @@ -158,7 +158,7 @@ module Importers end if asset - options = alignment.slice(*[:mastery_type, :mastery_score]) + options = alignment.slice(:mastery_type, :mastery_score) item.align(asset, context, options) end end diff --git a/app/models/importers/link_parser.rb b/app/models/importers/link_parser.rb index 0a28b46b7ed..45f1a113fb4 100644 --- a/app/models/importers/link_parser.rb +++ b/app/models/importers/link_parser.rb @@ -64,7 +64,7 @@ module Importers return unless node[attr].present? if attr == 'value' - return unless node[attr] && node[attr] =~ %r{IMS(?:-|_)CC(?:-|_)FILEBASE} || node[attr] =~ %r{CANVAS_COURSE_REFERENCE} + return unless (node[attr] && node[attr] =~ %r{IMS(?:-|_)CC(?:-|_)FILEBASE}) || node[attr] =~ %r{CANVAS_COURSE_REFERENCE} end url = node[attr].dup @@ -143,14 +143,14 @@ module Importers elsif url =~ %r{\$IMS(?:-|_)CC(?:-|_)FILEBASE\$/(.*)} rel_path = URI.unescape($1) - if attr == 'href' && node['class'] && node['class'] =~ /instructure_inline_media_comment/ || - attr == 'src' && node.name == 'iframe' && node['data-media-id'] + if (attr == 'href' && node['class'] && node['class'] =~ /instructure_inline_media_comment/) || + (attr == 'src' && node.name == 'iframe' && node['data-media-id']) unresolved(:media_object, :rel_path => rel_path) else unresolved(:file, :rel_path => rel_path) end - elsif attr == 'href' && node['class'] && node['class'] =~ /instructure_inline_media_comment/ || - attr == 'src' && node.name == 'iframe' && node['data-media-id'] + elsif (attr == 'href' && node['class'] && node['class'] =~ /instructure_inline_media_comment/) || + (attr == 'src' && node.name == 'iframe' && node['data-media-id']) # Course copy media reference, leave it alone resolved elsif attr == 'src' && (info_match = url.match(/\Adata:(?[-\w]+\/[-\w\+\.]+)?;base64,(?.*)/m)) diff --git a/app/models/incoming_mail/message_handler.rb b/app/models/incoming_mail/message_handler.rb index 70cdd4f9d3f..317d086c4a0 100644 --- a/app/models/incoming_mail/message_handler.rb +++ b/app/models/incoming_mail/message_handler.rb @@ -160,7 +160,7 @@ module IncomingMail end def parse_tag(tag) - match = tag.match /^(\h+)-([0-9~]+)(?:-([0-9]+))?$/ + match = tag.match(/^(\h+)-([0-9~]+)(?:-([0-9]+))?$/) return match[1], match[2], match[3] if match end diff --git a/app/models/notification_endpoint.rb b/app/models/notification_endpoint.rb index e97b9bfe0dd..5431b340f63 100644 --- a/app/models/notification_endpoint.rb +++ b/app/models/notification_endpoint.rb @@ -106,7 +106,7 @@ class NotificationEndpoint < ActiveRecord::Base # is happening. endpoint_updated = false if retried - raise FailedSnsInteraction, "Unable to create or reassign SNS endpoint for access_token #{access_token.global_id.to_s}" + raise FailedSnsInteraction, "Unable to create or reassign SNS endpoint for access_token #{access_token.global_id}" end retried = true diff --git a/app/models/outcomes_service/migration_extractor.rb b/app/models/outcomes_service/migration_extractor.rb index bd584dab776..f880bdcef6d 100644 --- a/app/models/outcomes_service/migration_extractor.rb +++ b/app/models/outcomes_service/migration_extractor.rb @@ -45,14 +45,14 @@ module OutcomesService def outcome_attributes(learning_outcome) attrs = learning_outcome.attributes.transform_keys(&:to_sym) - attrs[:'$canvas_learning_outcome_id'] = attrs.delete(:id) + attrs[:$canvas_learning_outcome_id] = attrs.delete(:id) attrs[:rubric_criterion] = attrs.delete(:data)[:rubric_criterion] attrs.except(:migration_id_2, :vendor_guid_2, :root_account_id, :context_type, :context_id) end def group_attributes(learning_outcome_group) attrs = learning_outcome_group.attributes.transform_keys(&:to_sym) - attrs[:'$canvas_learning_outcome_group_id'] = attrs.delete(:id) + attrs[:$canvas_learning_outcome_group_id] = attrs.delete(:id) attrs[:parent_outcome_group_id] = attrs.delete(:learning_outcome_group_id) attrs.except(:root_learning_outcome_group_id, :root_account_id, :migration_id_2, :vendor_guid_2) end diff --git a/app/models/quizzes/quiz_statistics/item_analysis/summary.rb b/app/models/quizzes/quiz_statistics/item_analysis/summary.rb index c8b8831ab8a..ab652cd92e5 100644 --- a/app/models/quizzes/quiz_statistics/item_analysis/summary.rb +++ b/app/models/quizzes/quiz_statistics/item_analysis/summary.rb @@ -116,7 +116,7 @@ class Quizzes::QuizStatistics::ItemAnalysis::Summary if size > 1 && variance != 0 variance_sum = items.map(&:variance).sum - size / (size - 1.0) * (1 - variance_sum / variance) + size / (size - 1.0) * (1 - (variance_sum / variance)) else nil end diff --git a/app/models/quizzes/quiz_statistics_service.rb b/app/models/quizzes/quiz_statistics_service.rb index 7cc917a2edc..ad21b13999b 100644 --- a/app/models/quizzes/quiz_statistics_service.rb +++ b/app/models/quizzes/quiz_statistics_service.rb @@ -31,12 +31,9 @@ class Quizzes::QuizStatisticsService # An object ready for API serialization containing (persisted) versions of # the *latest* Student and Item analysis for the quiz. def generate_aggregate_statistics(all_versions, includes_sis_ids = true, options = {}) - Quizzes::QuizStatisticsSerializer::Input.new(quiz, options, *[ - quiz.current_statistics_for('student_analysis', { - includes_all_versions: all_versions, - includes_sis_ids: includes_sis_ids - }), - quiz.current_statistics_for('item_analysis') - ]) + Quizzes::QuizStatisticsSerializer::Input.new(quiz, options, quiz.current_statistics_for('student_analysis', { + includes_all_versions: all_versions, + includes_sis_ids: includes_sis_ids + }), quiz.current_statistics_for('item_analysis')) end end diff --git a/app/models/quizzes_next/export_service.rb b/app/models/quizzes_next/export_service.rb index 9bf8ab072e8..997caebec20 100644 --- a/app/models/quizzes_next/export_service.rb +++ b/app/models/quizzes_next/export_service.rb @@ -33,11 +33,11 @@ module QuizzesNext return if assignments.empty? { - "original_course_uuid": course.uuid, - "assignments": assignments.map do |assignment| + original_course_uuid: course.uuid, + assignments: assignments.map do |assignment| { - "original_resource_link_id": assignment.lti_resource_link_id, - "original_assignment_id": assignment.id, + original_resource_link_id: assignment.lti_resource_link_id, + original_assignment_id: assignment.id, "$canvas_assignment_id": assignment.id # transformed to new id } end diff --git a/app/models/role.rb b/app/models/role.rb index 8f411d1b647..a67a9a4b6e0 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -186,7 +186,7 @@ class Role < ActiveRecord::Base # Should order course roles so we get "StudentEnrollment", custom student roles, "Teacher Enrollment", custom teacher roles, etc def display_sort_index if self.course_role? - ENROLLMENT_TYPES.index(self.base_role_type) * 2 + (self.built_in? ? 0 : 1) + (ENROLLMENT_TYPES.index(self.base_role_type) * 2) + (self.built_in? ? 0 : 1) else self.built_in? ? 0 : 1 end diff --git a/app/models/sis_batch.rb b/app/models/sis_batch.rb index d1fb4f9da76..aa272c6e64d 100644 --- a/app/models/sis_batch.rb +++ b/app/models/sis_batch.rb @@ -368,7 +368,7 @@ class SisBatch < ActiveRecord::Base end def file_diff_percent(current_file_size, previous_zip_size) - (1 - current_file_size.to_f / previous_zip_size.to_f).abs * 100 + (1 - (current_file_size.to_f / previous_zip_size.to_f)).abs * 100 end def download_zip diff --git a/app/models/sis_pseudonym.rb b/app/models/sis_pseudonym.rb index 73d38652ac5..db12af347bc 100644 --- a/app/models/sis_pseudonym.rb +++ b/app/models/sis_pseudonym.rb @@ -158,7 +158,7 @@ class SisPseudonym end def use_loaded_collection?(shard) - user.pseudonyms.loaded? && user.shard == shard || + (user.pseudonyms.loaded? && user.shard == shard) || (include_deleted ? user.all_pseudonyms_loaded? : user.all_active_pseudonyms_loaded?) end diff --git a/app/models/submission.rb b/app/models/submission.rb index 2a43b328f2f..ebf727a066a 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -1582,7 +1582,7 @@ class Submission < ActiveRecord::Base def score_late_or_none(late_policy, points_possible, grading_type) raw_score = score_changed? || @regraded ? score : entered_score deducted = late_points_deducted(raw_score, late_policy, points_possible, grading_type) - new_score = raw_score && raw_score - deducted + new_score = raw_score && (raw_score - deducted) self.points_deducted = late? ? deducted : nil self.score = new_score end @@ -1945,7 +1945,7 @@ class Submission < ActiveRecord::Base # since they're all being held on the assignment for now. attachments ||= [] old_ids = (Array(self.attachment_ids || "").join(",")).split(",").map { |id| id.to_i } - write_attribute(:attachment_ids, attachments.select { |a| a && a.id && old_ids.include?(a.id) || (a.recently_created? && a.context == self.assignment) || a.context != self.assignment }.map { |a| a.id }.join(",")) + write_attribute(:attachment_ids, attachments.select { |a| (a && a.id && old_ids.include?(a.id)) || (a.recently_created? && a.context == self.assignment) || a.context != self.assignment }.map { |a| a.id }.join(",")) end # someday code-archaeologists will wonder how this method came to be named diff --git a/app/models/user.rb b/app/models/user.rb index d795c23cfef..8e72182bb94 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1297,13 +1297,13 @@ class User < ActiveRecord::Base (Account.site_admin.grants_right?(user, :reset_any_mfa)) || # an admin can reset another user's MFA only if they can manage *all* # of the user's pseudonyms - self != user && self.pseudonyms.shard(self).all? do |p| + (self != user && self.pseudonyms.shard(self).all? do |p| p.grants_right?(user, :update) || # the account does not have mfa enabled p.account.mfa_settings == :disabled || # they are an admin user and have reset MFA permission p.account.grants_right?(user, :reset_any_mfa) - end + end) end can :reset_mfa @@ -2909,7 +2909,7 @@ class User < ActiveRecord::Base if pseudonym_hint mfa_settings = pseudonym_hint.account.mfa_settings return :required if mfa_settings == :required || - mfa_settings == :required_for_admins && !pseudonym_hint.account.cached_all_account_users_for(self).empty? + (mfa_settings == :required_for_admins && !pseudonym_hint.account.cached_all_account_users_for(self).empty?) end return :required if pseudonym_hint&.authentication_provider&.mfa_required? @@ -2952,7 +2952,7 @@ class User < ActiveRecord::Base # midnight sunday morning the rest of the time. account_bucket = (shard.id.to_i + pseudonym.try(:account_id).to_i) % DelayedMessage::WEEKLY_ACCOUNT_BUCKETS user_bucket = self.id % DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET - account_bucket * DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET + user_bucket + (account_bucket * DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET) + user_bucket end def weekly_notification_time diff --git a/app/models/web_conference.rb b/app/models/web_conference.rb index 5abcd36b2ab..e59e745b5f2 100644 --- a/app/models/web_conference.rb +++ b/app/models/web_conference.rb @@ -177,9 +177,9 @@ class WebConference < ActiveRecord::Base # redirecting through here again in case the url has a short-lived token and needs to be # regenerated) def external_url_for(key, user, url_id = nil) - external_urls[key.to_sym] && + (external_urls[key.to_sym] && respond_to?("#{key}_external_url") && - send("#{key}_external_url", user, url_id) || [] + send("#{key}_external_url", user, url_id)) || [] end def self.external_urls @@ -355,7 +355,7 @@ class WebConference < ActiveRecord::Base def restart self.start_at ||= Time.now - self.end_at = self.duration && self.start_at + self.duration_in_seconds + self.end_at = self.duration && (self.start_at + self.duration_in_seconds) self.started_at ||= self.start_at self.ended_at = nil self.save @@ -374,7 +374,7 @@ class WebConference < ActiveRecord::Base def active?(force_check = false, allow_check = true) if !force_check return false if self.ended_at && Time.now > self.ended_at - return true if self.start_at && (self.end_at.nil? || self.end_at && Time.now > self.start_at && Time.now < self.end_at) + return true if self.start_at && (self.end_at.nil? || (self.end_at && Time.now > self.start_at && Time.now < self.end_at)) return true if self.ended_at && Time.now < self.ended_at return @conference_active unless @conference_active.nil? end @@ -438,7 +438,7 @@ class WebConference < ActiveRecord::Base def craft_url(user = nil, session = nil, return_to = "http://www.instructure.com") user ||= self.user - initiate_conference and touch or return nil + (initiate_conference and touch) or return nil if user == self.user || self.grants_right?(user, session, :initiate) admin_join_url(user, return_to) else diff --git a/app/models/wimba_conference.rb b/app/models/wimba_conference.rb index 9b6426edfbd..f0bdc67f14e 100644 --- a/app/models/wimba_conference.rb +++ b/app/models/wimba_conference.rb @@ -183,7 +183,7 @@ class WimbaConference < WebConference end def admin_settings_url(user, return_to = "http://www.instructure.com") - initiate_conference and touch or return nil + (initiate_conference and touch) or return nil add_user_to_conference(user, :admin) && settings_url(user) end diff --git a/app/serializers/quizzes/quiz_report_serializer.rb b/app/serializers/quizzes/quiz_report_serializer.rb index e7451f7d4de..b37c830eed9 100644 --- a/app/serializers/quizzes/quiz_report_serializer.rb +++ b/app/serializers/quizzes/quiz_report_serializer.rb @@ -30,7 +30,7 @@ module Quizzes def_delegators :object, :quiz - attributes *%w[ + attributes(*%w[ id report_type readable_type @@ -42,7 +42,7 @@ module Quizzes progress_url created_at updated_at - ].map(&:to_sym) + ].map(&:to_sym)) has_one :quiz, embed: :ids, root: :quiz has_one :progress, { diff --git a/app/serializers/quizzes/quiz_statistics_serializer.rb b/app/serializers/quizzes/quiz_statistics_serializer.rb index 19bb5f00501..883e7a8dc6a 100644 --- a/app/serializers/quizzes/quiz_statistics_serializer.rb +++ b/app/serializers/quizzes/quiz_statistics_serializer.rb @@ -31,50 +31,40 @@ module Quizzes root :quiz_statistics - attributes *[ - # the id is really only included in JSON-API and only because the spec - # requires it, this is because the output of this serializer is a mix of - # two entities, an id doesn't make much sense, but we'll use the id of the - # StudentAnalysis when needed - :id, - :url, - :html_url, - - # whether any of the participants has taken the quiz more than one time - :multiple_attempts_exist, - - # the time of the generation of the analysis (the earliest one) - :generated_at, - - # whether the statistics were based on earlier and current quiz submissions - # - # PS: this is always true for item analysis - :includes_all_versions, - - # whether statistics report includes sis ids - # always false for item analysis - :includes_sis_ids, - - :points_possible, - :anonymous_survey, - - :speed_grader_url, - :quiz_submissions_zip_url, - - # an aggregate of question stats from both student and item analysis - :question_statistics, - - # submission-related statistics (extracted from student analysis): - # - # - correct_count_average - # - incorrect_count_average - # - duration_average - # - score_average - # - score_high - # - score_low - # - score_stdev - :submission_statistics, - ] + # the id is really only included in JSON-API and only because the spec + # requires it, this is because the output of this serializer is a mix of + # two entities, an id doesn't make much sense, but we'll use the id of the + # StudentAnalysis when needed + attributes :id, + :url, + :html_url, + # whether any of the participants has taken the quiz more than one time + :multiple_attempts_exist, + # the time of the generation of the analysis (the earliest one) + :generated_at, + # whether the statistics were based on earlier and current quiz submissions + # + # PS: this is always true for item analysis + :includes_all_versions, + # whether statistics report includes sis ids + # always false for item analysis + :includes_sis_ids, + :points_possible, + :anonymous_survey, + :speed_grader_url, + :quiz_submissions_zip_url, + # an aggregate of question stats from both student and item analysis + :question_statistics, + # submission-related statistics (extracted from student analysis): + # + # - correct_count_average + # - incorrect_count_average + # - duration_average + # - score_average + # - score_high + # - score_low + # - score_stdev + :submission_statistics def_delegators :@controller, :course_quiz_statistics_url, diff --git a/config/application.rb b/config/application.rb index 0ed784fb928..cb929aafb6a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -254,7 +254,7 @@ module CanvasRails Autoextend.hook(:"Thor::Option", PatchThorWarning, method: :prepend) # Extend any base classes, even gem classes - Dir.glob("#{Rails.root}/lib/ext/**/*.rb").each { |file| require file } + Dir.glob("#{Rails.root}/lib/ext/**/*.rb").sort.each { |file| require file } # tell Rails to use the native XML parser instead of REXML ActiveSupport::XmlMini.backend = 'Nokogiri' diff --git a/config/initializers/active_record.rb b/config/initializers/active_record.rb index 08012c6b444..11409ced615 100644 --- a/config/initializers/active_record.rb +++ b/config/initializers/active_record.rb @@ -1313,7 +1313,7 @@ ActiveRecord::Relation.class_eval do while ids.first.present? ids.map!(&:to_i) if is_integer - ids << ids.first + batch_size if loose_mode + ids << (ids.first + batch_size) if loose_mode yield(*ids) last_value = ids.last @@ -1747,7 +1747,7 @@ if CANVAS_RAILS6_0 scope.scoping { super } end end - ActiveRecord::Base.send(:include, UnscopeCallbacks) + ActiveRecord::Base.include UnscopeCallbacks end module MatchWithDiscard diff --git a/config/initializers/broadcast_policy.rb b/config/initializers/broadcast_policy.rb index 84181317af6..9351200b6a7 100644 --- a/config/initializers/broadcast_policy.rb +++ b/config/initializers/broadcast_policy.rb @@ -22,4 +22,4 @@ Rails.configuration.to_prepare do BroadcastPolicy.notifier = lambda { Notifier.new } BroadcastPolicy.notification_finder = lambda { NotificationFinder.new(Notification.all_cached) } end -ActiveRecord::Base.send(:extend, BroadcastPolicy::ClassMethods) +ActiveRecord::Base.extend BroadcastPolicy::ClassMethods diff --git a/config/initializers/canvas_crummy.rb b/config/initializers/canvas_crummy.rb index 56cc3f6da91..ebca614d98a 100644 --- a/config/initializers/canvas_crummy.rb +++ b/config/initializers/canvas_crummy.rb @@ -19,5 +19,5 @@ require 'canvas_crummy' -ActionController::Base.send :include, CanvasCrummy::ControllerMethods -ActionView::Base.send :include, CanvasCrummy::ViewMethods +ActionController::Base.include CanvasCrummy::ControllerMethods +ActionView::Base.include CanvasCrummy::ViewMethods diff --git a/config/initializers/canvas_sanitize.rb b/config/initializers/canvas_sanitize.rb index 204d4f16fa9..6fae040e985 100644 --- a/config/initializers/canvas_sanitize.rb +++ b/config/initializers/canvas_sanitize.rb @@ -19,4 +19,4 @@ require 'canvas_sanitize' -ActiveRecord::Base.send :include, CanvasSanitize +ActiveRecord::Base.include CanvasSanitize diff --git a/config/initializers/delayed_job.rb b/config/initializers/delayed_job.rb index a992e316a35..871390c054a 100644 --- a/config/initializers/delayed_job.rb +++ b/config/initializers/delayed_job.rb @@ -227,4 +227,4 @@ module CanvasDelayedMessageSending delay(sender: sender, **kwargs.merge(synchronous: !Rails.env.production?)) end end -Object.send(:include, CanvasDelayedMessageSending) +Object.include CanvasDelayedMessageSending diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 082e85e9b70..06ccd1d9585 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -142,7 +142,7 @@ end if ENV['LOLCALIZE'] require 'i18n_tasks' - I18n.send :extend, I18nTasks::Lolcalize + I18n.extend I18nTasks::Lolcalize end module I18nUtilities @@ -173,9 +173,9 @@ module I18nUtilities end end -ActionView::Base.send(:include, I18nUtilities) -ActionView::Helpers::FormHelper.send(:include, I18nUtilities) -ActionView::Helpers::FormTagHelper.send(:include, I18nUtilities) +ActionView::Base.include I18nUtilities +ActionView::Helpers::FormHelper.include I18nUtilities +ActionView::Helpers::FormTagHelper.include I18nUtilities module I18nFormHelper # a convenience method to put the ":" after the label text (or do whatever diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 90e4b28f704..5a0c056efb8 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -20,7 +20,7 @@ # Be sure to restart your server when you modify this file. ActiveSupport::Inflector.inflections do |inflect| - inflect.singular /(criteri)a$/i, '\1on' - inflect.plural /(criteri)on$/i, '\1a' + inflect.singular(/(criteri)a$/i, '\1on') + inflect.plural(/(criteri)on$/i, '\1a') inflect.acronym "GraphQL" end diff --git a/config/initializers/no_timeouts_debugging.rb b/config/initializers/no_timeouts_debugging.rb index 96baea57b00..f9d618cbc4d 100644 --- a/config/initializers/no_timeouts_debugging.rb +++ b/config/initializers/no_timeouts_debugging.rb @@ -39,8 +39,8 @@ if Rails.env.test? def raise(*args) if defined?(SpecTimeLimit) && args.first == SpecTimeLimit::Error have_ever_run_a_debugger = ( - defined?(Byebug) && Byebug.respond_to?(:started?) || - defined?(Pry) && Pry::InputLock.input_locks.any? + (defined?(Byebug) && Byebug.respond_to?(:started?)) || + (defined?(Pry) && Pry::InputLock.input_locks.any?) ) if have_ever_run_a_debugger Rails.logger.warn "Ignoring timeout because we're debugging" diff --git a/doc/api/fulldoc/html/setup.rb b/doc/api/fulldoc/html/setup.rb index e74432c8cfb..36ea3a31ca8 100644 --- a/doc/api/fulldoc/html/setup.rb +++ b/doc/api/fulldoc/html/setup.rb @@ -23,7 +23,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'api_scopes')) require 'controller_list_view' require 'api_scope_mapping_writer' -Dir.glob("#{Rails.root}/doc/api/data_services/*.rb").each { |file| require file } +Dir.glob("#{Rails.root}/doc/api/data_services/*.rb").sort.each { |file| require file } include Helpers::ModuleHelper include Helpers::FilterHelper @@ -49,7 +49,7 @@ module YARD::Templates::Helpers::BaseHelper html_file = "#{topicize topic.first}.html" action = $2 name = controller.name.to_s - name = "#{controller.namespace.name.to_s}/#{name}" if controller.namespace.name != :root + name = "#{controller.namespace.name}/#{name}" if controller.namespace.name != :root link_url("#{html_file}#method.#{topicize(name).sub("_controller", "")}.#{action}", args[1]) else raise "couldn't find API link for #{args.first}" diff --git a/doc/api/topic/html/setup.rb b/doc/api/topic/html/setup.rb index c758eca01fd..b9547a2cb29 100644 --- a/doc/api/topic/html/setup.rb +++ b/doc/api/topic/html/setup.rb @@ -100,12 +100,12 @@ def render_properties(json) if json['description'].present? result << render_comment(json) end - result << "{\n" + indent( + result << ("{\n" + indent( properties.map do |name, prop| render_comment(prop) + %{"#{name}": } + render_value(prop) end.join(",\n") - ) + "\n}" + ) + "\n}") end rescue puts "error rendering properties for model:\n#{json}" diff --git a/engines/audits/spec/audits_spec.rb b/engines/audits/spec/audits_spec.rb index ccb704de934..1365395c964 100644 --- a/engines/audits/spec/audits_spec.rb +++ b/engines/audits/spec/audits_spec.rb @@ -29,8 +29,8 @@ RSpec.describe Audits do def inject_auditors_settings(yaml_string) DynamicSettings.fallback_data = { - "private": { - "canvas": { + private: { + canvas: { "auditors.yml": yaml_string } } diff --git a/gems/activesupport-suspend_callbacks/lib/active_support/callbacks/suspension.rb b/gems/activesupport-suspend_callbacks/lib/active_support/callbacks/suspension.rb index e182f0adc14..1765d982674 100644 --- a/gems/activesupport-suspend_callbacks/lib/active_support/callbacks/suspension.rb +++ b/gems/activesupport-suspend_callbacks/lib/active_support/callbacks/suspension.rb @@ -82,8 +82,8 @@ module ActiveSupport::Callbacks # end # def suspended_callback?(callback, kind, type = nil) - val = suspended_callbacks_defined? && - suspended_callbacks.include?(callback, kind, type) || + val = (suspended_callbacks_defined? && + suspended_callbacks.include?(callback, kind, type)) || suspended_callback_ancestor&.suspended_callback?(callback, kind, type) val diff --git a/gems/attachment_fu/lib/attachment_fu.rb b/gems/attachment_fu/lib/attachment_fu.rb index 09a802aa3e3..2315d361695 100644 --- a/gems/attachment_fu/lib/attachment_fu.rb +++ b/gems/attachment_fu/lib/attachment_fu.rb @@ -251,7 +251,7 @@ module AttachmentFu # :nodoc: return filename if thumbnail.blank? ext = nil - basename = filename.gsub /\.\w+$/ do |s| + basename = filename.gsub(/\.\w+$/) do |s| ext = s; '' end # ImageScience doesn't create gif thumbnails, only pngs @@ -495,17 +495,17 @@ module AttachmentFu # :nodoc: # Generates a unique filename for a Tempfile. def random_tempfile_filename - "#{rand Time.now.to_i}#{filename && filename.last(50) || 'attachment'}" + "#{rand Time.now.to_i}#{(filename && filename.last(50)) || 'attachment'}" end def sanitize_filename(filename) filename.strip.tap do |name| # NOTE: File.basename doesn't work right with Windows paths on Unix # get only the filename, not the whole path - name.gsub! /^.*(\\|\/)/, '' + name.gsub!(/^.*(\\|\/)/, '') # Finally, replace all non alphanumeric, underscore or periods with underscore - name.gsub! /[^\w\.\-]/, '_' + name.gsub!(/[^\w\.\-]/, '_') end end diff --git a/gems/attachment_fu/lib/attachment_fu/railtie.rb b/gems/attachment_fu/lib/attachment_fu/railtie.rb index fdcf94bd53d..1c99de5867a 100644 --- a/gems/attachment_fu/lib/attachment_fu/railtie.rb +++ b/gems/attachment_fu/lib/attachment_fu/railtie.rb @@ -20,7 +20,7 @@ module AttachmentFu class Railtie < ::Rails::Railtie initializer "attachment_fu.canvas_plugin" do - ActiveRecord::Base.send(:extend, AttachmentFu::ActMethods) + ActiveRecord::Base.extend AttachmentFu::ActMethods AttachmentFu::Railtie.setup_tempfile_path end diff --git a/gems/bookmarked_collection/lib/bookmarked_collection/merge_proxy.rb b/gems/bookmarked_collection/lib/bookmarked_collection/merge_proxy.rb index 49b557878d3..3e7fde3b766 100644 --- a/gems/bookmarked_collection/lib/bookmarked_collection/merge_proxy.rb +++ b/gems/bookmarked_collection/lib/bookmarked_collection/merge_proxy.rb @@ -60,7 +60,7 @@ class BookmarkedCollection::MergeProxy < BookmarkedCollection::CompositeProxy indexed_bookmarks.sort! last_item, last_leaf_bookmark = nil, nil - while indexed_bookmarks.present? && (pager.size < pager.per_page || @merge_proc && indexed_bookmarks.first.first == last_leaf_bookmark) + while indexed_bookmarks.present? && (pager.size < pager.per_page || (@merge_proc && indexed_bookmarks.first.first == last_leaf_bookmark)) # pull the index of the collection with the next lowest bookmark and # pull off its first item leaf_bookmark, index = indexed_bookmarks.shift diff --git a/gems/bookmarked_collection/lib/bookmarked_collection/simple_bookmarker.rb b/gems/bookmarked_collection/lib/bookmarked_collection/simple_bookmarker.rb index d3fc143fcbf..979a5b90c5c 100644 --- a/gems/bookmarked_collection/lib/bookmarked_collection/simple_bookmarker.rb +++ b/gems/bookmarked_collection/lib/bookmarked_collection/simple_bookmarker.rb @@ -117,7 +117,7 @@ module BookmarkedCollection TYPE_MAP = { string: ->(val) { val.is_a?(String) }, integer: ->(val) { val.is_a?(Integer) }, - datetime: ->(val) { val.is_a?(DateTime) || val.is_a?(Time) || val.is_a?(String) && !!(DateTime.parse(val) rescue false) } + datetime: ->(val) { val.is_a?(DateTime) || val.is_a?(Time) || (val.is_a?(String) && !!(DateTime.parse(val) rescue false)) } } def existing_column_definition(col_name) @@ -137,7 +137,7 @@ module BookmarkedCollection columns.each.with_index.all? do |col, i| type = TYPE_MAP[column_definitions[col][:type]] nullable = column_definitions[col][:null] - type && (nullable && bookmark[i].nil? || type.(bookmark[i])) + type && ((nullable && bookmark[i].nil?) || type.(bookmark[i])) end end diff --git a/gems/broadcast_policy/lib/broadcast_policy/notification_policy.rb b/gems/broadcast_policy/lib/broadcast_policy/notification_policy.rb index 7d82fc0a495..30dc2ed3e27 100644 --- a/gems/broadcast_policy/lib/broadcast_policy/notification_policy.rb +++ b/gems/broadcast_policy/lib/broadcast_policy/notification_policy.rb @@ -36,7 +36,7 @@ module BroadcastPolicy # reasons. def broadcast(record) return if record.respond_to?(:skip_broadcasts) && record.skip_broadcasts - return unless record.instance_eval &self.whenever + return unless record.instance_eval(&self.whenever) notification = BroadcastPolicy.notification_finder.by_name(self.dispatch) return if notification.nil? diff --git a/gems/canvas_cache/lib/canvas_cache/redis.rb b/gems/canvas_cache/lib/canvas_cache/redis.rb index 1b6f3c9caf2..a573271a0cd 100644 --- a/gems/canvas_cache/lib/canvas_cache/redis.rb +++ b/gems/canvas_cache/lib/canvas_cache/redis.rb @@ -33,7 +33,7 @@ module CanvasCache raise "Redis is not enabled for this install" unless CanvasCache::Redis.enabled? conf = CanvasCache::Redis.config - if conf == 'cache_store' || conf.is_a?(Hash) && conf['servers'] == 'cache_store' + if conf == 'cache_store' || (conf.is_a?(Hash) && conf['servers'] == 'cache_store') return Rails.cache.redis end diff --git a/gems/canvas_color/lib/canvas_color.rb b/gems/canvas_color/lib/canvas_color.rb index ddf199c433a..46aa0b0dca4 100644 --- a/gems/canvas_color/lib/canvas_color.rb +++ b/gems/canvas_color/lib/canvas_color.rb @@ -49,154 +49,154 @@ module CanvasColor BRIGHTNESS_DEFAULT = 0.2 NAMED_COLORS = { - "aliceblue": "#f0f8ff", - "antiquewhite": "#faebd7", - "aqua": "#00ffff", - "aquamarine": "#7fffd4", - "azure": "#f0ffff", - "beige": "#f5f5dc", - "bisque": "#ffe4c4", - "black": "#000000", - "blanchedalmond": "#ffebcd", - "blue": "#0000ff", - "blueviolet": "#8a2be2", - "brown": "#a52a2a", - "burlywood": "#deb887", - "cadetblue": "#5f9ea0", - "chartreuse": "#7fff00", - "chocolate": "#d2691e", - "coral": "#ff7f50", - "cornflowerblue": "#6495ed", - "cornsilk": "#fff8dc", - "crimson": "#dc143c", - "cyan": "#00ffff", - "darkblue": "#00008b", - "darkcyan": "#008b8b", - "darkgoldenrod": "#b8860b", - "darkgray": "#a9a9a9", - "darkgreen": "#006400", - "darkgrey": "#a9a9a9", - "darkkhaki": "#bdb76b", - "darkmagenta": "#8b008b", - "darkolivegreen": "#556b2f", - "darkorange": "#ff8c00", - "darkorchid": "#9932cc", - "darkred": "#8b0000", - "darksalmon": "#e9967a", - "darkseagreen": "#8fbc8f", - "darkslateblue": "#483d8b", - "darkslategray": "#2f4f4f", - "darkslategrey": "#2f4f4f", - "darkturquoise": "#00ced1", - "darkviolet": "#9400d3", - "deeppink": "#ff1493", - "deepskyblue": "#00bfff", - "dimgray": "#696969", - "dimgrey": "#696969", - "dodgerblue": "#1e90ff", - "firebrick": "#b22222", - "floralwhite": "#fffaf0", - "forestgreen": "#228b22", - "fuchsia": "#ff00ff", - "gainsboro": "#dcdcdc", - "ghostwhite": "#f8f8ff", - "gold": "#ffd700", - "goldenrod": "#daa520", - "gray": "#808080", - "green": "#008000", - "greenyellow": "#adff2f", - "grey": "#808080", - "honeydew": "#f0fff0", - "hotpink": "#ff69b4", - "indianred": "#cd5c5c", - "indigo": "#4b0082", - "ivory": "#fffff0", - "khaki": "#f0e68c", - "lavender": "#e6e6fa", - "lavenderblush": "#fff0f5", - "lawngreen": "#7cfc00", - "lemonchiffon": "#fffacd", - "lightblue": "#add8e6", - "lightcoral": "#f08080", - "lightcyan": "#e0ffff", - "lightgoldenrodyellow": "#fafad2", - "lightgray": "#d3d3d3", - "lightgreen": "#90ee90", - "lightgrey": "#d3d3d3", - "lightpink": "#ffb6c1", - "lightsalmon": "#ffa07a", - "lightseagreen": "#20b2aa", - "lightskyblue": "#87cefa", - "lightslategray": "#778899", - "lightslategrey": "#778899", - "lightsteelblue": "#b0c4de", - "lightyellow": "#ffffe0", - "lime": "#00ff00", - "limegreen": "#32cd32", - "linen": "#faf0e6", - "magenta": "#ff00ff", - "maroon": "#800000", - "mediumaquamarine": "#66cdaa", - "mediumblue": "#0000cd", - "mediumorchid": "#ba55d3", - "mediumpurple": "#9370db", - "mediumseagreen": "#3cb371", - "mediumslateblue": "#7b68ee", - "mediumspringgreen": "#00fa9a", - "mediumturquoise": "#48d1cc", - "mediumvioletred": "#c71585", - "midnightblue": "#191970", - "mintcream": "#f5fffa", - "mistyrose": "#ffe4e1", - "moccasin": "#ffe4b5", - "navajowhite": "#ffdead", - "navy": "#000080", - "oldlace": "#fdf5e6", - "olive": "#808000", - "olivedrab": "#6b8e23", - "orange": "#ffa500", - "orangered": "#ff4500", - "orchid": "#da70d6", - "palegoldenrod": "#eee8aa", - "palegreen": "#98fb98", - "paleturquoise": "#afeeee", - "palevioletred": "#db7093", - "papayawhip": "#ffefd5", - "peachpuff": "#ffdab9", - "peru": "#cd853f", - "pink": "#ffc0cb", - "plum": "#dda0dd", - "powderblue": "#b0e0e6", - "purple": "#800080", - "rebeccapurple": "#663399", - "red": "#ff0000", - "rosybrown": "#bc8f8f", - "royalblue": "#4169e1", - "saddlebrown": "#8b4513", - "salmon": "#fa8072", - "sandybrown": "#f4a460", - "seagreen": "#2e8b57", - "seashell": "#fff5ee", - "sienna": "#a0522d", - "silver": "#c0c0c0", - "skyblue": "#87ceeb", - "slateblue": "#6a5acd", - "slategray": "#708090", - "slategrey": "#708090", - "snow": "#fffafa", - "springgreen": "#00ff7f", - "steelblue": "#4682b4", - "tan": "#d2b48c", - "teal": "#008080", - "thistle": "#d8bfd8", - "tomato": "#ff6347", - "turquoise": "#40e0d0", - "violet": "#ee82ee", - "wheat": "#f5deb3", - "white": "#ffffff", - "whitesmoke": "#f5f5f5", - "yellow": "#ffff00", - "yellowgreen": "#9acd32" + aliceblue: "#f0f8ff", + antiquewhite: "#faebd7", + aqua: "#00ffff", + aquamarine: "#7fffd4", + azure: "#f0ffff", + beige: "#f5f5dc", + bisque: "#ffe4c4", + black: "#000000", + blanchedalmond: "#ffebcd", + blue: "#0000ff", + blueviolet: "#8a2be2", + brown: "#a52a2a", + burlywood: "#deb887", + cadetblue: "#5f9ea0", + chartreuse: "#7fff00", + chocolate: "#d2691e", + coral: "#ff7f50", + cornflowerblue: "#6495ed", + cornsilk: "#fff8dc", + crimson: "#dc143c", + cyan: "#00ffff", + darkblue: "#00008b", + darkcyan: "#008b8b", + darkgoldenrod: "#b8860b", + darkgray: "#a9a9a9", + darkgreen: "#006400", + darkgrey: "#a9a9a9", + darkkhaki: "#bdb76b", + darkmagenta: "#8b008b", + darkolivegreen: "#556b2f", + darkorange: "#ff8c00", + darkorchid: "#9932cc", + darkred: "#8b0000", + darksalmon: "#e9967a", + darkseagreen: "#8fbc8f", + darkslateblue: "#483d8b", + darkslategray: "#2f4f4f", + darkslategrey: "#2f4f4f", + darkturquoise: "#00ced1", + darkviolet: "#9400d3", + deeppink: "#ff1493", + deepskyblue: "#00bfff", + dimgray: "#696969", + dimgrey: "#696969", + dodgerblue: "#1e90ff", + firebrick: "#b22222", + floralwhite: "#fffaf0", + forestgreen: "#228b22", + fuchsia: "#ff00ff", + gainsboro: "#dcdcdc", + ghostwhite: "#f8f8ff", + gold: "#ffd700", + goldenrod: "#daa520", + gray: "#808080", + green: "#008000", + greenyellow: "#adff2f", + grey: "#808080", + honeydew: "#f0fff0", + hotpink: "#ff69b4", + indianred: "#cd5c5c", + indigo: "#4b0082", + ivory: "#fffff0", + khaki: "#f0e68c", + lavender: "#e6e6fa", + lavenderblush: "#fff0f5", + lawngreen: "#7cfc00", + lemonchiffon: "#fffacd", + lightblue: "#add8e6", + lightcoral: "#f08080", + lightcyan: "#e0ffff", + lightgoldenrodyellow: "#fafad2", + lightgray: "#d3d3d3", + lightgreen: "#90ee90", + lightgrey: "#d3d3d3", + lightpink: "#ffb6c1", + lightsalmon: "#ffa07a", + lightseagreen: "#20b2aa", + lightskyblue: "#87cefa", + lightslategray: "#778899", + lightslategrey: "#778899", + lightsteelblue: "#b0c4de", + lightyellow: "#ffffe0", + lime: "#00ff00", + limegreen: "#32cd32", + linen: "#faf0e6", + magenta: "#ff00ff", + maroon: "#800000", + mediumaquamarine: "#66cdaa", + mediumblue: "#0000cd", + mediumorchid: "#ba55d3", + mediumpurple: "#9370db", + mediumseagreen: "#3cb371", + mediumslateblue: "#7b68ee", + mediumspringgreen: "#00fa9a", + mediumturquoise: "#48d1cc", + mediumvioletred: "#c71585", + midnightblue: "#191970", + mintcream: "#f5fffa", + mistyrose: "#ffe4e1", + moccasin: "#ffe4b5", + navajowhite: "#ffdead", + navy: "#000080", + oldlace: "#fdf5e6", + olive: "#808000", + olivedrab: "#6b8e23", + orange: "#ffa500", + orangered: "#ff4500", + orchid: "#da70d6", + palegoldenrod: "#eee8aa", + palegreen: "#98fb98", + paleturquoise: "#afeeee", + palevioletred: "#db7093", + papayawhip: "#ffefd5", + peachpuff: "#ffdab9", + peru: "#cd853f", + pink: "#ffc0cb", + plum: "#dda0dd", + powderblue: "#b0e0e6", + purple: "#800080", + rebeccapurple: "#663399", + red: "#ff0000", + rosybrown: "#bc8f8f", + royalblue: "#4169e1", + saddlebrown: "#8b4513", + salmon: "#fa8072", + sandybrown: "#f4a460", + seagreen: "#2e8b57", + seashell: "#fff5ee", + sienna: "#a0522d", + silver: "#c0c0c0", + skyblue: "#87ceeb", + slateblue: "#6a5acd", + slategray: "#708090", + slategrey: "#708090", + snow: "#fffafa", + springgreen: "#00ff7f", + steelblue: "#4682b4", + tan: "#d2b48c", + teal: "#008080", + thistle: "#d8bfd8", + tomato: "#ff6347", + turquoise: "#40e0d0", + violet: "#ee82ee", + wheat: "#f5deb3", + white: "#ffffff", + whitesmoke: "#f5f5f5", + yellow: "#ffff00", + yellowgreen: "#9acd32" }.freeze # Constructor. Inits to white (#FFFFFF) by default, or accepts any params @@ -355,7 +355,7 @@ module CanvasColor # Convert to grayscale, using perception-based weighting def grayscale val = Color.new(self) - val.r = val.g = val.b = (0.2126 * val.r + 0.7152 * val.g + 0.0722 * val.b) + val.r = val.g = val.b = ((0.2126 * val.r) + (0.7152 * val.g) + (0.0722 * val.b)) val end diff --git a/gems/canvas_dynamodb/lib/canvas_dynamodb/batch_builder_base.rb b/gems/canvas_dynamodb/lib/canvas_dynamodb/batch_builder_base.rb index 12cf0663a6b..0cfda593e6d 100644 --- a/gems/canvas_dynamodb/lib/canvas_dynamodb/batch_builder_base.rb +++ b/gems/canvas_dynamodb/lib/canvas_dynamodb/batch_builder_base.rb @@ -57,7 +57,7 @@ module CanvasDynamoDB tables[pair[0]] ||= [] tables[pair[0]] << pair[1] end - sleep 2**@backoff_exp / 1000 if @backoff_exp > 0 + sleep (2**@backoff_exp) / 1000 if @backoff_exp > 0 resp = @database.send(operation, { request_items: request_items(tables) }) responses << resp until resp.send(unprocessed_attr).empty? diff --git a/gems/canvas_ext/lib/canvas_ext.rb b/gems/canvas_ext/lib/canvas_ext.rb index d066a0b47db..d08188a468c 100644 --- a/gems/canvas_ext/lib/canvas_ext.rb +++ b/gems/canvas_ext/lib/canvas_ext.rb @@ -21,5 +21,5 @@ require 'active_support/all' module CanvasExt project_root = File.dirname(File.absolute_path(__FILE__)) - Dir.glob(project_root + '/canvas_ext/*') { |file| require file } + Dir.glob(project_root + '/canvas_ext/*').sort.each { |file| require file } end diff --git a/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb b/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb index f7abc710198..fb7e1f65cd9 100644 --- a/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb +++ b/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb @@ -149,7 +149,7 @@ module CanvasKaltura sources = sources.sort_by do |a| [a[:hasWarnings] || a[:isOriginal] != '0' ? CanvasSort::Last : CanvasSort::First, a[:isOriginal] == '0' ? CanvasSort::First : CanvasSort::Last, - PREFERENCE.index(a[:fileExt]) || PREFERENCE.size + 1, + PREFERENCE.index(a[:fileExt]) || (PREFERENCE.size + 1), a[:bitrate].to_i < suspicious_bitrate_threshold ? CanvasSort::First : CanvasSort::Last, 0 - a[:bitrate].to_i] end diff --git a/gems/canvas_panda_pub/lib/canvas_panda_pub/async_worker.rb b/gems/canvas_panda_pub/lib/canvas_panda_pub/async_worker.rb index f81f6254c0d..bb77c461eb3 100644 --- a/gems/canvas_panda_pub/lib/canvas_panda_pub/async_worker.rb +++ b/gems/canvas_panda_pub/lib/canvas_panda_pub/async_worker.rb @@ -18,7 +18,6 @@ # with this program. If not, see . # -require 'thread' require 'set' module CanvasPandaPub diff --git a/gems/canvas_partman/lib/canvas_partman/partition_manager/by_id.rb b/gems/canvas_partman/lib/canvas_partman/partition_manager/by_id.rb index 9beb91f9e82..3e861dd0618 100644 --- a/gems/canvas_partman/lib/canvas_partman/partition_manager/by_id.rb +++ b/gems/canvas_partman/lib/canvas_partman/partition_manager/by_id.rb @@ -24,7 +24,7 @@ module CanvasPartman max_id = base_class.maximum(base_class.partitioning_field) return ensure_partitions(advance_partitions) if max_id.nil? - (0..max_id / base_class.partition_size + advance_partitions).each do |index| + (0..(max_id / base_class.partition_size) + advance_partitions).each do |index| create_partition(index * base_class.partition_size, graceful: true) end end diff --git a/gems/canvas_partman/spec/canvas_partman/concerns/partitioned_spec.rb b/gems/canvas_partman/spec/canvas_partman/concerns/partitioned_spec.rb index b1cb4983e50..f3e214e03d7 100644 --- a/gems/canvas_partman/spec/canvas_partman/concerns/partitioned_spec.rb +++ b/gems/canvas_partman/spec/canvas_partman/concerns/partitioned_spec.rb @@ -198,7 +198,7 @@ describe CanvasPartman::Concerns::Partitioned do expect(count_records("partman_trails")).to eq 1 expect(count_records("partman_trails_#{zoo.id / 5}")).to eq 1 - expect(count_records("partman_trails_#{zoo.id / 5 + 1}")).to eq 0 + expect(count_records("partman_trails_#{(zoo.id / 5) + 1}")).to eq 0 end context 'via an association scope' do @@ -210,7 +210,7 @@ describe CanvasPartman::Concerns::Partitioned do expect(count_records("partman_trails")).to eq 1 expect(count_records("partman_trails_#{zoo.id / 5}")).to eq 1 - expect(count_records("partman_trails_#{zoo.id / 5 + 1}")).to eq 0 + expect(count_records("partman_trails_#{(zoo.id / 5) + 1}")).to eq 0 expect(zoo.trails.count).to eq 1 expect(south.zoo).to eq zoo diff --git a/gems/canvas_quiz_statistics/spec/spec_helper.rb b/gems/canvas_quiz_statistics/spec/spec_helper.rb index 83d45c58daa..398c28fd018 100644 --- a/gems/canvas_quiz_statistics/spec/spec_helper.rb +++ b/gems/canvas_quiz_statistics/spec/spec_helper.rb @@ -40,10 +40,10 @@ File.join(File.dirname(__FILE__), 'canvas_quiz_statistics').tap do |cwd| # spec support in support/ Dir.glob(File.join([ cwd, 'support', '**', '*.rb' - ])).each { |file| require file } + ])).sort.each { |file| require file } # specs for shared metrics in analyzers/shared_metrics Dir.glob(File.join([ cwd, 'analyzers', 'shared_metrics', '**', '*.rb' - ])).each { |file| require file } + ])).sort.each { |file| require file } end diff --git a/gems/canvas_slug/spec/canvas_slug/canvas_slug_spec.rb b/gems/canvas_slug/spec/canvas_slug/canvas_slug_spec.rb index 387118584ba..92ecf1ae3d0 100644 --- a/gems/canvas_slug/spec/canvas_slug/canvas_slug_spec.rb +++ b/gems/canvas_slug/spec/canvas_slug/canvas_slug_spec.rb @@ -39,7 +39,7 @@ describe CanvasSlug do end it "prepends a provided purpose" do - expect(subject.generate("foobar")).to match /\Afoobar-\w{4}\z/ + expect(subject.generate("foobar")).to match(/\Afoobar-\w{4}\z/) end end end diff --git a/gems/canvas_stringex/lib/canvas_stringex.rb b/gems/canvas_stringex/lib/canvas_stringex.rb index aad6cff0921..4a24a261a69 100644 --- a/gems/canvas_stringex/lib/canvas_stringex.rb +++ b/gems/canvas_stringex/lib/canvas_stringex.rb @@ -22,12 +22,12 @@ module CanvasStringex require "lucky_sneaks/unidecoder" require "lucky_sneaks/acts_as_url" - String.send :include, LuckySneaks::StringExtensions + String.include LuckySneaks::StringExtensions if defined?(ActiveRecord) # Prevents uninitialized constant ActiveRecord::DatabaseConfigurations::ConnectionUrlResolver::URI # (probably only relevant for specs in practice) require 'uri' - ActiveRecord::Base.send :include, LuckySneaks::ActsAsUrl + ActiveRecord::Base.include LuckySneaks::ActsAsUrl end end diff --git a/gems/dr_diff/lib/dr_diff/manager.rb b/gems/dr_diff/lib/dr_diff/manager.rb index 9acdd6606e5..b1fb0613126 100644 --- a/gems/dr_diff/lib/dr_diff/manager.rb +++ b/gems/dr_diff/lib/dr_diff/manager.rb @@ -71,7 +71,7 @@ module DrDiff path = path[git_dir.length..-1] if git_dir severe = severe?(comment[:severity], severe_levels) next unless heavy || - severe && severe_anywhere || + (severe && severe_anywhere) || diff.relevant?(path, comment[:position], severe: severe) || comment[:corrected] diff --git a/gems/google_drive/lib/google_drive/connection.rb b/gems/google_drive/lib/google_drive/connection.rb index d39f31ddfd0..4e2290938b4 100644 --- a/gems/google_drive/lib/google_drive/connection.rb +++ b/gems/google_drive/lib/google_drive/connection.rb @@ -277,7 +277,7 @@ module GoogleDrive end def file_extension_from_header(headers, entry) - file_extension = entry.extension && !entry.extension.empty? && entry.extension || 'unknown' + file_extension = (entry.extension && !entry.extension.empty? && entry.extension) || 'unknown' if headers['content-disposition'] && headers['content-disposition'].match(/filename=[\"\']?[^;\"\'\.]+\.(?[^;\"\']+)[\"\']?/) diff --git a/gems/i18n_extraction/spec/i18n_extraction/i18nliner_extensions_spec.rb b/gems/i18n_extraction/spec/i18n_extraction/i18nliner_extensions_spec.rb index b127babccd4..bc5e81ff2cb 100644 --- a/gems/i18n_extraction/spec/i18n_extraction/i18nliner_extensions_spec.rb +++ b/gems/i18n_extraction/spec/i18n_extraction/i18nliner_extensions_spec.rb @@ -81,7 +81,7 @@ describe I18nliner::Extractors::RubyExtractor do end it "requires explicit keys if a key is provided and there is no scope" do - expect { extract("t 'foo', 'Foo'", I18nliner::Scope.root) }.to raise_error /ambiguous translation key/ + expect { extract("t 'foo', 'Foo'", I18nliner::Scope.root) }.to raise_error(/ambiguous translation key/) end it "does not require explicit keys if the key is inferred and there is no scope" do @@ -95,7 +95,7 @@ describe I18nliner::Extractors::RubyExtractor do context "sanitization" do it "rejects stuff that looks sufficiently html-y" do - expect { extract "t 'dude', 'this is important'" }.to raise_error /html tags in default translation/ + expect { extract "t 'dude', 'this is important'" }.to raise_error(/html tags in default translation/) end it "generallies be ok with angle brackets" do diff --git a/gems/i18n_tasks/lib/i18n_tasks/hash_extensions.rb b/gems/i18n_tasks/lib/i18n_tasks/hash_extensions.rb index 699cd9d8e20..feeafa77738 100644 --- a/gems/i18n_tasks/lib/i18n_tasks/hash_extensions.rb +++ b/gems/i18n_tasks/lib/i18n_tasks/hash_extensions.rb @@ -47,6 +47,6 @@ module I18nTasks end end - Hash.send(:include, HashExtensions) + Hash.include HashExtensions end end diff --git a/gems/i18n_tasks/lib/tasks/i18n.rake b/gems/i18n_tasks/lib/tasks/i18n.rake index 4f28695ab50..8a959640a93 100755 --- a/gems/i18n_tasks/lib/tasks/i18n.rake +++ b/gems/i18n_tasks/lib/tasks/i18n.rake @@ -7,7 +7,7 @@ require 'shellwords' namespace :i18n do desc "Verifies all translation calls" task :check => :i18n_environment do - Hash.send(:include, I18nTasks::HashExtensions) unless Hash.new.kind_of?(I18nTasks::HashExtensions) + Hash.include I18nTasks::HashExtensions unless Hash.new.kind_of?(I18nTasks::HashExtensions) def I18nliner.manual_translations I18n.available_locales @@ -105,8 +105,8 @@ namespace :i18n do I18n.load_path += Dir[Rails.root.join('config', 'locales', 'locales.yml')] I18n.load_path += Dir[Rails.root.join('config', 'locales', 'community.csv')] - I18n::Backend::Simple.send(:include, I18nTasks::CsvBackend) - I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) + I18n::Backend::Simple.include I18nTasks::CsvBackend + I18n::Backend::Simple.include I18n::Backend::Fallbacks require 'i18nliner/extractors/translation_hash' I18nliner::Extractors::TranslationHash.class_eval do @@ -118,7 +118,7 @@ namespace :i18n do desc "Generates JS bundle i18n files (non-en) and adds them to assets.yml" task :generate_js => :i18n_environment do - Hash.send(:include, I18nTasks::HashExtensions) unless Hash.new.kind_of?(I18nTasks::HashExtensions) + Hash.include I18nTasks::HashExtensions unless Hash.new.kind_of?(I18nTasks::HashExtensions) locales = I18n.available_locales all_translations = I18n.backend.send(:translations) @@ -188,7 +188,7 @@ namespace :i18n do t = Time.now translations = YAML.safe_load(open('config/locales/generated/en.yml')) - I18n.send :extend, I18nTasks::Lolcalize + I18n.extend I18nTasks::Lolcalize lolz_translations = Hash.new lolz_translations['lolz'] = process_lolz.call(translations['en']) puts @@ -217,7 +217,7 @@ namespace :i18n do desc "Exports new/changed English strings to be translated" task :export => :environment do - Hash.send(:include, I18nTasks::HashExtensions) unless Hash.new.kind_of?(I18nTasks::HashExtensions) + Hash.include I18nTasks::HashExtensions unless Hash.new.kind_of?(I18nTasks::HashExtensions) begin base_filename = "config/locales/generated/en.yml" @@ -321,7 +321,7 @@ namespace :i18n do desc "Validates and imports new translations" task :import, [:source_file, :translated_file] => :environment do |t, args| require 'open-uri' - Hash.send(:include, I18nTasks::HashExtensions) unless Hash.new.kind_of?(I18nTasks::HashExtensions) + Hash.include I18nTasks::HashExtensions unless Hash.new.kind_of?(I18nTasks::HashExtensions) if args[:source_file] source_translations = YAML.safe_load(open(args[:source_file])) @@ -401,7 +401,7 @@ namespace :i18n do end def autoimport(source_translations, new_translations) - Hash.send(:include, I18nTasks::HashExtensions) unless Hash.new.kind_of?(I18nTasks::HashExtensions) + Hash.include I18nTasks::HashExtensions unless Hash.new.kind_of?(I18nTasks::HashExtensions) raise "Need source translations" unless source_translations raise "Need translated_file" unless new_translations diff --git a/gems/incoming_mail_processor/lib/incoming_mail_processor/configurable_timeout.rb b/gems/incoming_mail_processor/lib/incoming_mail_processor/configurable_timeout.rb index 1ce652e632b..366ce35ea56 100644 --- a/gems/incoming_mail_processor/lib/incoming_mail_processor/configurable_timeout.rb +++ b/gems/incoming_mail_processor/lib/incoming_mail_processor/configurable_timeout.rb @@ -65,7 +65,7 @@ module IncomingMailProcessor # Raises anything the timeout method raises. def with_timeout(&block) method = @timeout_method || method(:default_timeout_method) - method.call &block + method.call(&block) end # Public: Wrap an object's methods in with_timeout calls. The original diff --git a/gems/incoming_mail_processor/spec/incoming_mail_processor/incoming_message_processor_spec.rb b/gems/incoming_mail_processor/spec/incoming_mail_processor/incoming_message_processor_spec.rb index ad88ad23b2b..2d04c9027f7 100644 --- a/gems/incoming_mail_processor/spec/incoming_mail_processor/incoming_message_processor_spec.rb +++ b/gems/incoming_mail_processor/spec/incoming_mail_processor/incoming_message_processor_spec.rb @@ -236,7 +236,7 @@ describe IncomingMailProcessor::IncomingMessageProcessor do end context "reporting stats" do - let (:message) { Mail.new(content_type: 'text/plain; charset=UTF-8', body: "hello") } + let(:message) { Mail.new(content_type: 'text/plain; charset=UTF-8', body: "hello") } it "increments the processed count" do expect(InstStatsd::Statsd).to receive(:increment).with("incoming_mail_processor.incoming_message_processed.", diff --git a/gems/incoming_mail_processor/spec/spec_helper.rb b/gems/incoming_mail_processor/spec/spec_helper.rb index f917f3e71d5..a93ecfecc3b 100644 --- a/gems/incoming_mail_processor/spec/spec_helper.rb +++ b/gems/incoming_mail_processor/spec/spec_helper.rb @@ -29,7 +29,7 @@ require 'timecop' require 'incoming_mail_processor/mailbox_spec_helper' require 'incoming_mail_processor' -Dir.glob(File.expand_path(File.join(__FILE__, '..', 'support', '*'))).each { |file| require file } +Dir.glob(File.expand_path(File.join(__FILE__, '..', 'support', '*'))).sort.each { |file| require file } RSpec.configure do |config| config.run_all_when_everything_filtered = true diff --git a/gems/live_events/lib/live_events/async_worker.rb b/gems/live_events/lib/live_events/async_worker.rb index 53079a3c3ec..996a1921757 100644 --- a/gems/live_events/lib/live_events/async_worker.rb +++ b/gems/live_events/lib/live_events/async_worker.rb @@ -18,8 +18,6 @@ # with this program. If not, see . # -require 'thread' - module LiveEvents # TODO: Consider refactoring out common functionality from this and # CanvasPandaPub::AsyncWorker. Their semantics are a bit different so diff --git a/gems/live_events/spec/spec_helper.rb b/gems/live_events/spec/spec_helper.rb index 9a0621c563e..2b43a16d6d3 100644 --- a/gems/live_events/spec/spec_helper.rb +++ b/gems/live_events/spec/spec_helper.rb @@ -18,8 +18,6 @@ # with this program. If not, see . require 'live_events' -require 'thread' - RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus diff --git a/gems/lti-advantage/lib/lti_advantage/messages/jwt_message.rb b/gems/lti-advantage/lib/lti_advantage/messages/jwt_message.rb index ec76cc45977..2853a583e72 100644 --- a/gems/lti-advantage/lib/lti_advantage/messages/jwt_message.rb +++ b/gems/lti-advantage/lib/lti_advantage/messages/jwt_message.rb @@ -40,8 +40,8 @@ module LtiAdvantage::Messages lti1p1: LtiAdvantage::Claims::Lti1p1 }.freeze - attr_accessor *(REQUIRED_CLAIMS + OPTIONAL_CLAIMS) - attr_accessor *TYPED_ATTRIBUTES.keys + attr_accessor(*(REQUIRED_CLAIMS + OPTIONAL_CLAIMS)) + attr_accessor(*TYPED_ATTRIBUTES.keys) attr_accessor :address, :birthdate, :custom, diff --git a/gems/lti-advantage/lib/lti_advantage/messages/resource_link_request.rb b/gems/lti-advantage/lib/lti_advantage/messages/resource_link_request.rb index ecff50adeef..6e2648bb89c 100644 --- a/gems/lti-advantage/lib/lti_advantage/messages/resource_link_request.rb +++ b/gems/lti-advantage/lib/lti_advantage/messages/resource_link_request.rb @@ -10,9 +10,9 @@ module LtiAdvantage::Messages resource_link: LtiAdvantage::Claims::ResourceLink ) - attr_accessor *(REQUIRED_CLAIMS + [:resource_link]) + attr_accessor(*(REQUIRED_CLAIMS + [:resource_link])) - validates_presence_of *REQUIRED_CLAIMS + validates_presence_of(*REQUIRED_CLAIMS) validates_with LtiAdvantage::TypeValidator # Returns a new instance of LtiResourceLinkRequest. diff --git a/gems/lti_outbound/spec/spec_helper.rb b/gems/lti_outbound/spec/spec_helper.rb index 9f88bcaba16..3f8b6588397 100644 --- a/gems/lti_outbound/spec/spec_helper.rb +++ b/gems/lti_outbound/spec/spec_helper.rb @@ -33,8 +33,8 @@ end require 'lti_outbound' -Dir.glob("#{File.dirname(__FILE__).gsub(/\\/, "/")}/shared_examples/*.rb").each { |file| require file } -Dir.glob("#{File.dirname(__FILE__).gsub(/\\/, "/")}/support/*.rb").each { |file| require file } +Dir.glob("#{File.dirname(__FILE__).gsub(/\\/, "/")}/shared_examples/*.rb").sort.each { |file| require file } +Dir.glob("#{File.dirname(__FILE__).gsub(/\\/, "/")}/support/*.rb").sort.each { |file| require file } RSpec.configure do |config| config.run_all_when_everything_filtered = true diff --git a/gems/plugins/account_reports/lib/account_reports.rb b/gems/plugins/account_reports/lib/account_reports.rb index fa33371fb27..58fdf33b336 100644 --- a/gems/plugins/account_reports/lib/account_reports.rb +++ b/gems/plugins/account_reports/lib/account_reports.rb @@ -70,8 +70,8 @@ module AccountReports def parallel_proc unless instance_variable_defined?(:@parallel_proc) @parallel_proc = self[:parallel_proc] || - module_class.public_methods.include?(:"parallel_#{type}") && - module_class.method(:"parallel_#{type}") + (module_class.public_methods.include?(:"parallel_#{type}") && + module_class.method(:"parallel_#{type}")) end @parallel_proc end diff --git a/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb b/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb index 577fc5c63e9..48c1cea7a17 100644 --- a/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb +++ b/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb @@ -154,8 +154,8 @@ module AccountReports row << user.unique_id row << nil if @sis_format name_parts = User.name_parts(user.sortable_name, likely_already_surname_first: true) - row << name_parts[0] || '' # first name - row << name_parts[1] || '' # last name + (row << name_parts[0]) || '' # first name + (row << name_parts[1]) || '' # last name row << user.name row << user.sortable_name row << user.short_name diff --git a/gems/plugins/account_reports/spec_canvas/integrations/account_spec.rb b/gems/plugins/account_reports/spec_canvas/integrations/account_spec.rb index a9688d46f59..4e40aa65dae 100644 --- a/gems/plugins/account_reports/spec_canvas/integrations/account_spec.rb +++ b/gems/plugins/account_reports/spec_canvas/integrations/account_spec.rb @@ -47,6 +47,6 @@ describe "Account Reports", type: :request do get "/accounts/#{@account.id}/reports_tab" # debugger expect(response).to be_successful - expect(response.body).to match /someuniquetextstuffgoeshere/ + expect(response.body).to match(/someuniquetextstuffgoeshere/) end end diff --git a/gems/plugins/account_reports/spec_canvas/outcome_export_spec.rb b/gems/plugins/account_reports/spec_canvas/outcome_export_spec.rb index 3ce8560cc2e..5074fba516d 100644 --- a/gems/plugins/account_reports/spec_canvas/outcome_export_spec.rb +++ b/gems/plugins/account_reports/spec_canvas/outcome_export_spec.rb @@ -83,7 +83,7 @@ describe "Outcome Reports" do admin.enable_feature!(:use_semi_colon_field_separators_in_gradebook_exports) preparsed_report = run_report('outcome_export_csv', preparsed_report_options) - actual_headers = parse_report(preparsed_report, preparsed_report_options.merge('col_sep': ';'))[0].headers + actual_headers = parse_report(preparsed_report, preparsed_report_options.merge(col_sep: ';'))[0].headers expect(actual_headers[0..2]).to eq(expected_headers) end diff --git a/gems/plugins/moodle_importer/spec_canvas/moodle1_9_converter_spec.rb b/gems/plugins/moodle_importer/spec_canvas/moodle1_9_converter_spec.rb index df8e84e2bac..f104aafd195 100644 --- a/gems/plugins/moodle_importer/spec_canvas/moodle1_9_converter_spec.rb +++ b/gems/plugins/moodle_importer/spec_canvas/moodle1_9_converter_spec.rb @@ -148,7 +148,7 @@ describe Moodle::Converter do it "converts Moodle Quiz module to a quiz" do quiz = @course.quizzes.where(title: "First Quiz").first expect(quiz).not_to be_nil - expect(quiz.description).to match /Pop quiz hot shot/ + expect(quiz.description).to match(/Pop quiz hot shot/) expect(quiz.quiz_questions.count).to eq 9 end @@ -198,7 +198,7 @@ describe Moodle::Converter do quiz = @course.quizzes.where(title: "First Quiz").first question = quiz.quiz_questions[4] expect(question.question_data[:question_name]).to eq "Embedded Answers Question" - expect(question.question_data[:question_text]).to match /Embedded Answers Question Text/ + expect(question.question_data[:question_text]).to match(/Embedded Answers Question Text/) expect(question.question_data[:question_type]).to eq 'essay_question' expect(question.question_data[:neutral_comments]).to eq 'Embedded Answers Question General Feedback' end @@ -242,7 +242,7 @@ describe Moodle::Converter do it "converts Moodle Questionnaire module to a quiz" do quiz = @course.quizzes.where(title: "My Questionnaire").first expect(quiz).not_to be_nil - expect(quiz.description).to match /Questionnaire Summary/ + expect(quiz.description).to match(/Questionnaire Summary/) expect(quiz.quiz_type).to eq 'survey' expect(quiz.quiz_questions.count).to eq 10 end @@ -337,7 +337,7 @@ describe Moodle::Converter do it "converts Moodle Choice module to a quiz" do quiz = @course.quizzes.where(title: "My Choice").first expect(quiz).not_to be_nil - expect(quiz.description).to match /Which one will you choose\?/ + expect(quiz.description).to match(/Which one will you choose\?/) expect(quiz.quiz_type).to eq 'survey' expect(quiz.quiz_questions.count).to eq 1 question = quiz.quiz_questions.first diff --git a/gems/plugins/moodle_importer/spec_canvas/moodle2_converter_spec.rb b/gems/plugins/moodle_importer/spec_canvas/moodle2_converter_spec.rb index 314e3ca6f5e..20f8903d1b5 100644 --- a/gems/plugins/moodle_importer/spec_canvas/moodle2_converter_spec.rb +++ b/gems/plugins/moodle_importer/spec_canvas/moodle2_converter_spec.rb @@ -92,13 +92,13 @@ describe Moodle::Converter do it "converts Moodle Quiz module to a quiz" do quiz = @course.quizzes.where(title: "Quiz Name").first - expect(quiz.description).to match /Quiz Description/ + expect(quiz.description).to match(/Quiz Description/) expect(quiz.quiz_questions.count).to eq 11 end it "converts Moodle Questionnaire module to a quiz" do quiz = @course.quizzes.where(title: "Questionnaire Name").first - expect(quiz.description).to match /Sumary/ + expect(quiz.description).to match(/Sumary/) expect(quiz.quiz_type).to eq 'survey' expect(quiz.quiz_questions.count).to eq 10 end diff --git a/gems/plugins/qti_exporter/lib/qti/html_helper.rb b/gems/plugins/qti_exporter/lib/qti/html_helper.rb index 32cc6c03796..026ff99a89b 100644 --- a/gems/plugins/qti_exporter/lib/qti/html_helper.rb +++ b/gems/plugins/qti_exporter/lib/qti/html_helper.rb @@ -74,13 +74,13 @@ module Qti if remove_extraneous_nodes while true node.children.each do |child| - break unless child.text? && child.text =~ /\A\s+\z/ || child.element? && child.name.downcase == 'br' + break unless (child.text? && child.text =~ /\A\s+\z/) || (child.element? && child.name.downcase == 'br') child.remove end node.children.reverse_each do |child| - break unless child.text? && child.text =~ /\A\s+\z/ || child.element? && child.name.downcase == 'br' + break unless (child.text? && child.text =~ /\A\s+\z/) || (child.element? && child.name.downcase == 'br') child.remove end diff --git a/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_items_spec.rb b/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_items_spec.rb index 22cb90cae17..d7711420437 100644 --- a/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_items_spec.rb +++ b/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_items_spec.rb @@ -31,7 +31,7 @@ if Qti.migration_executable file_path = File.join(BASE_FIXTURE_DIR, 'qti') question = get_question_hash(file_path, 'sanitize_metadata') expect(question[:question_bank_name]).to eql 'Sad & Broken' - expect(question[:question_text]).not_to match /divp/ + expect(question[:question_text]).not_to match(/divp/) end it "gets answers correctly even when people write gross xml" do diff --git a/gems/plugins/simply_versioned/lib/simply_versioned.rb b/gems/plugins/simply_versioned/lib/simply_versioned.rb index cf6cce54bf2..7758922d511 100644 --- a/gems/plugins/simply_versioned/lib/simply_versioned.rb +++ b/gems/plugins/simply_versioned/lib/simply_versioned.rb @@ -320,4 +320,4 @@ module SimplyVersioned end end -ActiveRecord::Base.send(:include, SimplyVersioned) +ActiveRecord::Base.include SimplyVersioned diff --git a/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_helper_modules.rb b/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_helper_modules.rb index fd0c7632443..b6d62f88ff7 100644 --- a/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_helper_modules.rb +++ b/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_helper_modules.rb @@ -46,8 +46,8 @@ module RuboCop return false unless node.def_type? return false if node.ancestors.any? do |ancestor| ancestor.module_type? || ancestor.class_type? || - ancestor.type == :block && - WHITELISTED_BLOCKS.include?(ancestor.method_name) + (ancestor.type == :block && + WHITELISTED_BLOCKS.include?(ancestor.method_name)) end true diff --git a/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_includes.rb b/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_includes.rb index d4108013092..df91454485a 100644 --- a/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_includes.rb +++ b/gems/rubocop-canvas/lib/rubocop_canvas/cops/specs/scope_includes.rb @@ -54,8 +54,8 @@ module RuboCop ancestor.module_type? || ancestor.class_type? || ancestor.def_type? || - ancestor.block_type? && - WHITELISTED_BLOCKS.include?(ancestor.method_name) + (ancestor.block_type? && + WHITELISTED_BLOCKS.include?(ancestor.method_name)) end end end diff --git a/gems/tatl_tael/lib/tatl_tael/linters.rb b/gems/tatl_tael/lib/tatl_tael/linters.rb index 2080311eed0..70d8ebc6fac 100644 --- a/gems/tatl_tael/lib/tatl_tael/linters.rb +++ b/gems/tatl_tael/lib/tatl_tael/linters.rb @@ -95,4 +95,4 @@ module TatlTael end end -Dir[File.dirname(__FILE__) + "/linters/**/*_linter.rb"].each { |file| require file } +Dir[File.dirname(__FILE__) + "/linters/**/*_linter.rb"].sort.each { |file| require file } diff --git a/lib/api.rb b/lib/api.rb index 6794225f594..5db5da4bce5 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -155,7 +155,7 @@ module Api :scope => 'root_account_id' }.freeze, }.freeze - MAX_ID = (2**63 - 1) + MAX_ID = ((2**63) - 1) MAX_ID_LENGTH = MAX_ID.to_s.length MAX_ID_RANGE = (-MAX_ID...MAX_ID) ID_REGEX = %r{\A\d{1,#{MAX_ID_LENGTH}}\z} diff --git a/lib/api/v1/assignment.rb b/lib/api/v1/assignment.rb index d4a5a550509..352352d2ff6 100644 --- a/lib/api/v1/assignment.rb +++ b/lib/api/v1/assignment.rb @@ -376,8 +376,8 @@ module Api::V1::Assignment if should_show_statistics && (stats = assignment&.score_statistic) hash["score_statistics"] = { 'min' => stats.minimum.to_f.round(1), - 'max': stats.maximum.to_f.round(1), - 'mean': stats.mean.to_f.round(1) + 'max' => stats.maximum.to_f.round(1), + 'mean' => stats.mean.to_f.round(1) } end end diff --git a/lib/api/v1/attachment.rb b/lib/api/v1/attachment.rb index f6a737113c0..595b29e7d1f 100644 --- a/lib/api/v1/attachment.rb +++ b/lib/api/v1/attachment.rb @@ -97,7 +97,7 @@ module Api::V1::Attachment url = thumbnail_url else h = { :download => '1', :download_frd => '1' } - h.merge!(:verifier => attachment.uuid) unless options[:omit_verifier_in_app] && (respond_to?(:in_app?, true) && in_app? || @authenticated_with_jwt) + h.merge!(:verifier => attachment.uuid) unless options[:omit_verifier_in_app] && ((respond_to?(:in_app?, true) && in_app?) || @authenticated_with_jwt) url = file_download_url(attachment, h.merge(url_options)) end # and svg can stand in as its own thumbnail, but let's be reasonable about their size @@ -155,7 +155,7 @@ module Api::V1::Attachment url_opts = { annotate: 0 } - omit_verifier = options[:omit_verifier_in_app] && (respond_to?(:in_app?, true) && in_app? || @authenticated_with_jwt) + omit_verifier = options[:omit_verifier_in_app] && ((respond_to?(:in_app?, true) && in_app?) || @authenticated_with_jwt) if downloadable && !omit_verifier url_opts[:verifier] = attachment.uuid end diff --git a/lib/api/v1/context_module.rb b/lib/api/v1/context_module.rb index e1cfcd22723..3d8f3945004 100644 --- a/lib/api/v1/context_module.rb +++ b/lib/api/v1/context_module.rb @@ -31,12 +31,12 @@ module Api::V1::ContextModule MODULE_ITEM_JSON_ATTRS = %w(id position title indent).freeze ITEM_TYPE = { - 'Assignment': 'assignment', - 'Attachment': 'file', - 'DiscussionTopic': 'topic', - 'Quiz': 'quiz', + Assignment: 'assignment', + Attachment: 'file', + DiscussionTopic: 'topic', + Quiz: 'quiz', 'Quizzes::Quiz': 'quiz', - 'WikiPage': 'page' + WikiPage: 'page' }.freeze # optionally pass progression to include 'state', 'completed_at' diff --git a/lib/api/v1/feature_flag.rb b/lib/api/v1/feature_flag.rb index 2e1aef22a66..c61e82e1e6f 100644 --- a/lib/api/v1/feature_flag.rb +++ b/lib/api/v1/feature_flag.rb @@ -51,7 +51,7 @@ module Api::V1::FeatureFlag # return 'hidden' if the feature is hidden or if this flag is the one that unhides it # (so removing it would re-hide the feature) hash['hidden'] = feature_flag.hidden? || - !feature_flag.default? && feature_flag.context == context && feature_flag.unhides_feature? + (!feature_flag.default? && feature_flag.context == context && feature_flag.unhides_feature?) end # To allow for determinations of when to delete vs update hash['parent_state'] = context.lookup_feature_flag(feature_flag.feature, skip_cache: true, inherited_only: true)&.state diff --git a/lib/brand_config_regenerator.rb b/lib/brand_config_regenerator.rb index a8739807e36..cf429470e15 100644 --- a/lib/brand_config_regenerator.rb +++ b/lib/brand_config_regenerator.rb @@ -97,7 +97,7 @@ class BrandConfigRegenerator config = thing.brand_config return unless config - new_parent_md5 = config.parent_md5 && @new_configs[config.parent_md5].try(:md5) || @account.brand_config_md5 + new_parent_md5 = (config.parent_md5 && @new_configs[config.parent_md5].try(:md5)) || @account.brand_config_md5 new_config = config.clone_with_new_parent(new_parent_md5) new_config.save_unless_dup! diff --git a/lib/brandable_css.rb b/lib/brandable_css.rb index f7ee5183ab2..2b8955882f1 100644 --- a/lib/brandable_css.rb +++ b/lib/brandable_css.rb @@ -22,7 +22,7 @@ require 'yaml' require 'open3' module BrandableCSS - APP_ROOT = defined?(Rails) && Rails.root || Pathname.pwd + APP_ROOT = (defined?(Rails) && Rails.root) || Pathname.pwd CONFIG = YAML.load_file(APP_ROOT.join('config/brandable_css.yml')).freeze BRANDABLE_VARIABLES = JSON.parse(File.read(APP_ROOT.join(CONFIG['paths']['brandable_variables_json']))).freeze MIGRATION_NAME = 'RegenerateBrandFilesBasedOnNewDefaults'.freeze diff --git a/lib/canvas.rb b/lib/canvas.rb index 35c307669e7..b38b9a0f58e 100644 --- a/lib/canvas.rb +++ b/lib/canvas.rb @@ -145,7 +145,7 @@ module Canvas } DEFAULT_RETRIABLE_OPTIONS = { - interval: ->(attempts) { 0.5 + 4**(attempts - 1) }, # Sleeps: 0.5, 4.5, 16.5 + interval: ->(attempts) { 0.5 + (4**(attempts - 1)) }, # Sleeps: 0.5, 4.5, 16.5 on_retry: DEFAULT_RETRY_CALLBACK, tries: 3, }.freeze diff --git a/lib/canvas/core_ext/oauth2.rb b/lib/canvas/core_ext/oauth2.rb index 52861f158db..0e0e1338e14 100644 --- a/lib/canvas/core_ext/oauth2.rb +++ b/lib/canvas/core_ext/oauth2.rb @@ -32,7 +32,7 @@ module AcceptOpenIDConnectParamAsValidResponse opts[:headers].merge!(headers) response = request(options[:token_method], token_url, opts) # only change is on this line; Microsoft doesn't send back an access_token if you're doing a pure OpenID Connect auth - if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'] || response.parsed['id_token']) + if options[:raise_errors] && !((response.parsed.is_a?(Hash) && response.parsed['access_token']) || response.parsed['id_token']) error = ::OAuth2::Error.new(response) raise(error) end diff --git a/lib/canvas/jwt_workflow.rb b/lib/canvas/jwt_workflow.rb index 49d00cc61e3..e98fc9f41d9 100644 --- a/lib/canvas/jwt_workflow.rb +++ b/lib/canvas/jwt_workflow.rb @@ -49,10 +49,10 @@ module Canvas # passed around with every request in the service workflow. # register(:rich_content) do |context, user| - tool_context = context&.is_a?(Group) ? context.context : context + tool_context = context.is_a?(Group) ? context.context : context { usage_rights_required: ( - tool_context&.respond_to?(:usage_rights_required?) && + tool_context.respond_to?(:usage_rights_required?) && tool_context&.usage_rights_required? ) || false, can_upload_files: ( diff --git a/lib/canvas/live_events.rb b/lib/canvas/live_events.rb index 6343fc007c3..184420d89f0 100644 --- a/lib/canvas/live_events.rb +++ b/lib/canvas/live_events.rb @@ -607,7 +607,7 @@ module Canvas::LiveEvents end enrollment_data = {} - if context_membership&.is_a?(Enrollment) + if context_membership.is_a?(Enrollment) enrollment_data = { enrollment_id: context_membership.id, section_id: context_membership.course_section_id diff --git a/lib/canvas/migration/worker/zip_file_worker.rb b/lib/canvas/migration/worker/zip_file_worker.rb index cbe92e1b2d0..7324f5254d6 100644 --- a/lib/canvas/migration/worker/zip_file_worker.rb +++ b/lib/canvas/migration/worker/zip_file_worker.rb @@ -44,7 +44,7 @@ class Canvas::Migration::Worker::ZipFileWorker < Canvas::Migration::Worker::Base scaled = percent_complete if cm.import_immediately? - scaled = scaled / 2 + 50 + scaled = (scaled / 2) + 50 end # Only update if progress has incremented 1 percent diff --git a/lib/canvas_logger.rb b/lib/canvas_logger.rb index f7e6e030fb1..b563a936405 100644 --- a/lib/canvas_logger.rb +++ b/lib/canvas_logger.rb @@ -94,7 +94,7 @@ class CanvasLogger < ActiveSupport::Logger return if level > severity message = (message || (block && block.call) || progname).to_s - captured_message = "[#{Time.now.to_s}] #{message}" + captured_message = "[#{Time.now}] #{message}" captured_message_stack.each do |messages| messages << captured_message if messages.length < CAPTURE_LIMIT end diff --git a/lib/cc/grading_standards.rb b/lib/cc/grading_standards.rb index 983c00c8055..b6be9899a86 100644 --- a/lib/cc/grading_standards.rb +++ b/lib/cc/grading_standards.rb @@ -22,8 +22,8 @@ module CC def add_referenced_grading_standards @course.assignments.active.where('grading_standard_id IS NOT NULL').each do |assignment| next unless export_object?(assignment) || - assignment.quiz && export_object?(assignment.quiz) || - assignment.discussion_topic && export_object?(assignment.discussion_topic) + (assignment.quiz && export_object?(assignment.quiz)) || + (assignment.discussion_topic && export_object?(assignment.discussion_topic)) gs = assignment.grading_standard add_item_to_export(gs) if gs && gs.context_type == 'Course' && gs.context_id == @course.id diff --git a/lib/cc/importer/standard/converter.rb b/lib/cc/importer/standard/converter.rb index 0b83f286704..529c81e2723 100644 --- a/lib/cc/importer/standard/converter.rb +++ b/lib/cc/importer/standard/converter.rb @@ -104,7 +104,7 @@ module CC::Importer::Standard unless mig_id full_path = @package_root.item_path(path) - if File.exists?(full_path) + if File.exist?(full_path) # try to make it work even if the file wasn't technically included in the manifest :/ mig_id = Digest::MD5.hexdigest(path) file = { :path_name => path, :migration_id => mig_id, diff --git a/lib/cc/importer/standard/webcontent_converter.rb b/lib/cc/importer/standard/webcontent_converter.rb index 91223c248b7..e8adc098e6c 100644 --- a/lib/cc/importer/standard/webcontent_converter.rb +++ b/lib/cc/importer/standard/webcontent_converter.rb @@ -28,7 +28,7 @@ module CC::Importer::Standard resources_by_type(WEBCONTENT, "associatedcontent").each do |res| if res[:intended_use] || @convert_html_to_pages path = get_full_path(res[:href]) - if path && File.exists?(path) && Attachment.mimetype(path) =~ /html/ + if path && File.exist?(path) && Attachment.mimetype(path) =~ /html/ case res[:intended_use] when "assignment" new_assignments << { :migration_id => res[:migration_id], :description => File.read(path) } diff --git a/lib/content_notices.rb b/lib/content_notices.rb index ac8c43e88d0..f50f840ade0 100644 --- a/lib/content_notices.rb +++ b/lib/content_notices.rb @@ -22,7 +22,7 @@ module ContentNotices NOTICE_ATTRIBUTES = [:tag, :text, :variant, :link_text, :link_target, :should_show] class ContentNotice - attr_accessor *NOTICE_ATTRIBUTES + attr_accessor(*NOTICE_ATTRIBUTES) end module ClassMethods diff --git a/lib/course_link_validator.rb b/lib/course_link_validator.rb index 70fccfe620e..4600c819e83 100644 --- a/lib/course_link_validator.rb +++ b/lib/course_link_validator.rb @@ -250,7 +250,7 @@ class CourseLinkValidator path = path.chomp("/") @route_set ||= ::Rails.application.routes.set.routes.select { |r| r.verb === "GET" } - @route_set.any? { |r| r.path.match(path) } || (!Pathname(path).each_filename.include?('..') && File.exists?(File.join(Rails.root, "public", path))) + @route_set.any? { |r| r.path.match(path) } || (!Pathname(path).each_filename.include?('..') && File.exist?(File.join(Rails.root, "public", path))) end # makes sure that links to course objects exist and are in a visible state diff --git a/lib/data_fixup/populate_root_account_id_on_models.rb b/lib/data_fixup/populate_root_account_id_on_models.rb index ee106bcc9ee..bc9b33018c4 100644 --- a/lib/data_fixup/populate_root_account_id_on_models.rb +++ b/lib/data_fixup/populate_root_account_id_on_models.rb @@ -277,12 +277,12 @@ module DataFixup::PopulateRootAccountIdOnModels incomplete_tables = [] complete_tables = [] migration_tables.each_with_object({}) do |(table, assoc), memo| - incomplete_tables << table && next unless table.column_names.include?(get_column_name(table)) + (incomplete_tables << table) && next unless table.column_names.include?(get_column_name(table)) next if (tables_in_progress + complete_tables + DONE_TABLES).include?(table) association_hash = hash_association(assoc) direct_relation_associations = replace_polymorphic_associations(table, association_hash) - check_if_table_has_root_account(table, direct_relation_associations.keys) ? complete_tables << table && next : incomplete_tables << table + check_if_table_has_root_account(table, direct_relation_associations.keys) ? (complete_tables << table) && next : incomplete_tables << table all_dependencies = direct_relation_associations.keys + Array(dependencies[table]) prereqs_ready = all_dependencies.all? do |a| @@ -297,7 +297,7 @@ module DataFixup::PopulateRootAccountIdOnModels # and User jobs are complete, we are good to fill in comm channels User.where.not(root_account_ids: nil).any? else - check_if_association_has_root_account(table, assoc_reflection) ? complete_tables << table && true : incomplete_tables << table && false + check_if_association_has_root_account(table, assoc_reflection) ? (complete_tables << table) && true : (incomplete_tables << table) && false end end memo[table] = direct_relation_associations if prereqs_ready @@ -577,7 +577,7 @@ module DataFixup::PopulateRootAccountIdOnModels .update_all("root_account_id = #{Shard.global_id_for(attributes.root_id, foreign_shard) || "null"}") end end - min = scope.where("#{foreign_key} > ?", (min / Shard::IDS_PER_SHARD + 1) * Shard::IDS_PER_SHARD).minimum(foreign_key) + min = scope.where("#{foreign_key} > ?", ((min / Shard::IDS_PER_SHARD) + 1) * Shard::IDS_PER_SHARD).minimum(foreign_key) end end diff --git a/lib/data_fixup/populate_root_account_ids_on_users.rb b/lib/data_fixup/populate_root_account_ids_on_users.rb index fa3b8223927..3d0edab2f7b 100644 --- a/lib/data_fixup/populate_root_account_ids_on_users.rb +++ b/lib/data_fixup/populate_root_account_ids_on_users.rb @@ -62,7 +62,7 @@ module DataFixup::PopulateRootAccountIdsOnUsers # group into one other shard at a time foreign_shard = Shard.lookup(min / Shard::IDS_PER_SHARD) unless foreign_shard - min = User.where("id>?", (min / Shard::IDS_PER_SHARD + 1) * Shard::IDS_PER_SHARD).minimum(:id) + min = User.where("id>?", ((min / Shard::IDS_PER_SHARD) + 1) * Shard::IDS_PER_SHARD).minimum(:id) next if min end scope = UserAccountAssociation.where("user_id>=? AND user_id ([STATE_DEFAULT_OFF, STATE_DEFAULT_ON].include?(state) && (@applies_to == 'RootAccount' && - context.is_a?(Account) && context.root_account? && !context.site_admin? || @applies_to == "SiteAdmin")) } + transitions[state] = { 'locked' => ([STATE_DEFAULT_OFF, STATE_DEFAULT_ON].include?(state) && ((@applies_to == 'RootAccount' && + context.is_a?(Account) && context.root_account? && !context.site_admin?) || @applies_to == "SiteAdmin")) } transitions end end diff --git a/lib/feature_flags.rb b/lib/feature_flags.rb index 89c7bf05b23..74a62ffdf48 100644 --- a/lib/feature_flags.rb +++ b/lib/feature_flags.rb @@ -172,7 +172,7 @@ module FeatureFlags # if this feature requires root account opt-in, reject a default or site admin flag # if the context is beneath a root account if retval && (retval.state == Feature::STATE_DEFAULT_OFF || retval.hidden?) && feature_def.root_opt_in && !is_site_admin && - (retval.default? || retval.context_type == 'Account' && retval.context_id == Account.site_admin.id) + (retval.default? || (retval.context_type == 'Account' && retval.context_id == Account.site_admin.id)) if is_root_account # create a virtual feature flag in corresponding default state state retval = self.feature_flags.temp_record feature: feature, state: 'off' unless retval.hidden? diff --git a/lib/grade_calculator.rb b/lib/grade_calculator.rb index 93b062d827c..8dbe2ebb04a 100644 --- a/lib/grade_calculator.rb +++ b/lib/grade_calculator.rb @@ -920,7 +920,7 @@ class GradeCalculator q_mid = (q_low + q_high) / 2 x, kept = big_f_blk.call(q_mid, submissions, cant_drop, keep) - threshold = 1 / (2 * keep * max_total**2) + threshold = 1 / (2 * keep * (max_total**2)) until q_high - q_low < threshold x < 0 ? q_high = q_mid : @@ -939,12 +939,12 @@ class GradeCalculator def big_f(q, submissions, cant_drop, keep, &sort_blk) kept = submissions.map { |s| - rated_score = s[:score] - q * s[:total] + rated_score = s[:score] - (q * s[:total]) [rated_score, s] }.sort(&sort_blk).first(keep) q_kept = kept.reduce(0) { |sum, (rated_score, _)| sum + rated_score } - q_cant_drop = cant_drop.reduce(0) { |sum, s| sum + (s[:score] - q * s[:total]) } + q_cant_drop = cant_drop.reduce(0) { |sum, s| sum + (s[:score] - (q * s[:total])) } [q_kept + q_cant_drop, kept.map(&:last)] end @@ -995,7 +995,7 @@ class GradeCalculator gs[:possible].zero? || gs[:possible].nil? } final_grade = relevant_group_sums.reduce(0) { |grade, gs| - grade + (gs[:score].to_d / gs[:possible]) * gs[:weight].to_d + grade + ((gs[:score].to_d / gs[:possible]) * gs[:weight].to_d) } # scale the grade up if total weights don't add up to 100% diff --git a/lib/has_content_tags.rb b/lib/has_content_tags.rb index 280a8ba3b89..a29343a5eec 100644 --- a/lib/has_content_tags.rb +++ b/lib/has_content_tags.rb @@ -36,7 +36,7 @@ module HasContentTags @associated_content_tags_need_updating = true if self.respond_to?(:name_changed?) && self.name_changed? @associated_content_tags_need_updating = true if self.respond_to?(:display_name_changed?) && self.display_name_changed? @associated_content_tags_need_updating = true if self.respond_to?(:points_possible_changed?) && self.points_possible_changed? - @associated_content_tags_need_updating = true if self.respond_to?(:workflow_state_changed?) && self.workflow_state_changed? || self.workflow_state == 'deleted' + @associated_content_tags_need_updating = true if (self.respond_to?(:workflow_state_changed?) && self.workflow_state_changed?) || self.workflow_state == 'deleted' @associated_content_tags_need_updating = true if self.is_a?(Attachment) && self.locked_changed? end diff --git a/lib/lti/plagiarism_subscriptions_helper.rb b/lib/lti/plagiarism_subscriptions_helper.rb index ee319f92504..06f14b88e20 100644 --- a/lib/lti/plagiarism_subscriptions_helper.rb +++ b/lib/lti/plagiarism_subscriptions_helper.rb @@ -96,7 +96,7 @@ module Lti end def transport_metadata - { 'Url': submission_event_service&.endpoint } + { Url: submission_event_service&.endpoint } end end end diff --git a/lib/lti/variable_expander.rb b/lib/lti/variable_expander.rb index df9cfdaa68b..c73a6cbcbd3 100644 --- a/lib/lti/variable_expander.rb +++ b/lib/lti/variable_expander.rb @@ -93,7 +93,7 @@ module Lti MEDIA_OBJECT_ID_GUARD = -> { @attachment && (@attachment.media_object || @attachment.media_entry_id) } LTI1_GUARD = -> { @tool.is_a?(ContextExternalTool) } MASQUERADING_GUARD = -> { !!@controller && @controller.logged_in_user != @current_user } - MESSAGE_TOKEN_GUARD = -> { @post_message_token.present? || @launch&.instance_of?(Lti::Launch) } + MESSAGE_TOKEN_GUARD = -> { @post_message_token.present? || @launch.instance_of?(Lti::Launch) } ORIGINALITY_REPORT_GUARD = -> { @originality_report.present? } ORIGINALITY_REPORT_ATTACHMENT_GUARD = -> { @originality_report&.attachment.present? } LTI_ASSIGN_ID = -> { @assignment.present? || @originality_report.present? || @secure_params.present? } diff --git a/lib/message_bus.rb b/lib/message_bus.rb index 2bfbfaf1ef7..413df1a68fd 100644 --- a/lib/message_bus.rb +++ b/lib/message_bus.rb @@ -188,7 +188,7 @@ module MessageBus # like test/beta/edge whatever and not have to provision # other overhead to separate them or deal with the confusion of shared # data in a single topic. - "persistent://#{conf_hash['PULSAR_TENANT']}/#{ns.to_s}/#{app_env}-#{topic_name}" + "persistent://#{conf_hash['PULSAR_TENANT']}/#{ns}/#{app_env}-#{topic_name}" end ## diff --git a/lib/messageable_user/calculator.rb b/lib/messageable_user/calculator.rb index 00da95cff5f..8eaf1274819 100644 --- a/lib/messageable_user/calculator.rb +++ b/lib/messageable_user/calculator.rb @@ -472,8 +472,8 @@ class MessageableUser return unless options[:admin_context] || fully_visible_courses.include?(course) || - section_visible_courses.include?(course) && - visible_section_ids_in_courses([course]).include?(section.id) + (section_visible_courses.include?(course) && + visible_section_ids_in_courses([course]).include?(section.id)) scope = enrollment_scope(options.merge(include_concluded_students: false, course_workflow_state: course.workflow_state)) .where(enrollments: { course_section_id: sections || section }) @@ -499,7 +499,7 @@ class MessageableUser group.shard.activate do if options[:admin_context] || fully_visible_group_ids.include?(group.id) # bail early if user doesn't have permission to message group members - return if group&.context&.is_a?(Course) && !group.context.grants_right?(@user, nil, :send_messages) + return if group&.context.is_a?(Course) && !group.context.grants_right?(@user, nil, :send_messages) group_user_scope.where('group_memberships.group_id' => group.id).merge(active_users_in_group_context.except(:joins)) elsif section_visible_group_ids.include?(group.id) diff --git a/lib/plannable.rb b/lib/plannable.rb index 93cd488d7eb..823a8f12a43 100644 --- a/lib/plannable.rb +++ b/lib/plannable.rb @@ -170,7 +170,7 @@ module Plannable if col type = TYPE_MAP[col.type] nullable = col.null - type && (nullable && bookmark[i].nil? || type.call(bookmark[i])) + type && ((nullable && bookmark[i].nil?) || type.call(bookmark[i])) else true end diff --git a/lib/planner_helper.rb b/lib/planner_helper.rb index 8b67c488a98..c1345f53977 100644 --- a/lib/planner_helper.rb +++ b/lib/planner_helper.rb @@ -75,7 +75,7 @@ module PlannerHelper # until the graded objects are handled more uniformly, # we have to look around for an associated override def self.find_planner_override_for_submission(submission) - return unless submission&.respond_to?(:submission_type) && submission&.respond_to?(:assignment_id) + return unless submission.respond_to?(:submission_type) && submission.respond_to?(:assignment_id) planner_override = case submission.submission_type when "discussion_topic" diff --git a/lib/schemas/lti/tool_configuration.rb b/lib/schemas/lti/tool_configuration.rb index a4e84eb45ed..723cadffb2e 100644 --- a/lib/schemas/lti/tool_configuration.rb +++ b/lib/schemas/lti/tool_configuration.rb @@ -149,7 +149,7 @@ module Schemas::Lti "LtiResourceLinkRequest" ].freeze }.freeze, - "canvas_icon_class": { + "canvas_icon_class" => { "type" => "string", "enum" => [ "icon-lti" @@ -185,7 +185,7 @@ module Schemas::Lti "type" => "string" }.freeze, "custom_fields" => { - "anyOf": [ + "anyOf" => [ { "type" => "string" }.freeze, { "type" => "object" }.freeze ].freeze diff --git a/lib/sis/enrollment_importer.rb b/lib/sis/enrollment_importer.rb index 22f0750bb2f..98a303b22ae 100644 --- a/lib/sis/enrollment_importer.rb +++ b/lib/sis/enrollment_importer.rb @@ -197,7 +197,7 @@ module SIS # reset cached/inferred course and section if they don't match with the opposite piece that was # explicitly provided - @section = @course.default_section(:include_xlists => true) if @section.nil? || enrollment_info.section_id.blank? && !@section.default_section + @section = @course.default_section(:include_xlists => true) if @section.nil? || (enrollment_info.section_id.blank? && !@section.default_section) @course = @section.course if @course.nil? || (enrollment_info.course_id.blank? && @course.id != @section.course_id) || (@course.id != @section.course_id && @section.nonxlist_course_id == @course.id) diff --git a/lib/sis/section_importer.rb b/lib/sis/section_importer.rb index 37462e430ab..aa9014a67d4 100644 --- a/lib/sis/section_importer.rb +++ b/lib/sis/section_importer.rb @@ -90,7 +90,7 @@ module SIS # only update the name on new records, and ones that haven't been changed since the last sis import raise ImportError, "No name given for section #{section_id} in course #{course_id}" if name.blank? && section.new_record? - section.name = name if section.new_record? || !section.stuck_sis_fields.include?(:name) && name.present? + section.name = name if section.new_record? || (!section.stuck_sis_fields.include?(:name) && name.present?) # update the course id if necessary if section.course_id != course.id diff --git a/lib/sis/user_importer.rb b/lib/sis/user_importer.rb index a084dd8b552..2e0dfa1f4e3 100644 --- a/lib/sis/user_importer.rb +++ b/lib/sis/user_importer.rb @@ -139,7 +139,7 @@ module SIS if pseudo_by_integration && status_is_active && pseudo_by_integration != pseudo id_message = pseudo_by_integration.sis_user_id ? I18n.t('SIS ID') : I18n.t('Canvas ID') user_id = pseudo_by_integration.sis_user_id || pseudo_by_integration.user_id - message = I18n.t("An existing Canvas user with the %{user_id} has already claimed %{other_user_id}'s requested integration_id, skipping", user_id: "#{id_message} #{user_id.to_s}", other_user_id: user_row.user_id) + message = I18n.t("An existing Canvas user with the %{user_id} has already claimed %{other_user_id}'s requested integration_id, skipping", user_id: "#{id_message} #{user_id}", other_user_id: user_row.user_id) @messages << SisBatch.build_error(user_row.csv, message, sis_batch: @batch, row: user_row.lineno, row_info: user_row.row) next end @@ -159,11 +159,11 @@ module SIS next end end - if pseudo_by_login && (pseudo != pseudo_by_login && status_is_active || + if pseudo_by_login && ((pseudo != pseudo_by_login && status_is_active) || !Pseudonym.where("LOWER(?)=LOWER(?)", pseudo.unique_id, user_row.login_id).exists?) id_message = pseudo_by_login.sis_user_id ? 'SIS ID' : 'Canvas ID' user_id = pseudo_by_login.sis_user_id || pseudo_by_login.user_id - message = I18n.t("An existing Canvas user with the %{user_id} has already claimed %{other_user_id}'s user_id requested login information, skipping", user_id: "#{id_message} #{user_id.to_s}", other_user_id: user_row.user_id) + message = I18n.t("An existing Canvas user with the %{user_id} has already claimed %{other_user_id}'s user_id requested login information, skipping", user_id: "#{id_message} #{user_id}", other_user_id: user_row.user_id) @messages << SisBatch.build_error(user_row.csv, message, sis_batch: @batch, row: user_row.lineno, row_info: user_row.row) next end @@ -266,7 +266,7 @@ module SIS # if a password is provided, use it only if this is a new user, or the user hasn't changed the password in canvas *AND* the incoming password has changed # otherwise the persistence_token will change even though we're setting to the same password, logging the user out - if !user_row.password.blank? && (pseudo.new_record? || pseudo.password_auto_generated && !pseudo.valid_password?(user_row.password)) + if !user_row.password.blank? && (pseudo.new_record? || (pseudo.password_auto_generated && !pseudo.valid_password?(user_row.password))) pseudo.password = user_row.password pseudo.password_confirmation = user_row.password pseudo.password_auto_generated = true diff --git a/lib/stats.rb b/lib/stats.rb index 5dbc853c218..473ddcfc646 100644 --- a/lib/stats.rb +++ b/lib/stats.rb @@ -100,7 +100,7 @@ module Stats vals = [] # 1st Q - n = (sorted_items.length + 1) / 4.0 - 1 + n = ((sorted_items.length + 1) / 4.0) - 1 if n < 0 # n must be in [0,n] n = 0 @@ -110,13 +110,13 @@ module Stats vals << get_weighted_nth(sorted_items, n, weight) # 2nd Q - n = (sorted_items.length + 1) / 2.0 - 1 + n = ((sorted_items.length + 1) / 2.0) - 1 weight = 1.0 - (n - n.to_i) n = n.to_i vals << get_weighted_nth(sorted_items, n, weight) # 3rd Q - n = (sorted_items.length + 1) * 3.0 / 4.0 - 1 + n = ((sorted_items.length + 1) * 3.0 / 4.0) - 1 if n > sorted_items.length - 1 # n must be in [0,n] n = sorted_items.length - 1 @@ -141,7 +141,7 @@ module Stats ret_val = { :bin_width => bin_width, :bin_base => bin_base } bins = {} @items.each do |i| - bin = ((i - bin_base) / bin_width).floor * bin_width + bin_base + bin = (((i - bin_base) / bin_width).floor * bin_width) + bin_base if bins.has_key?(bin) bins[bin] = bins[bin] + 1 else diff --git a/lib/submission_list.rb b/lib/submission_list.rb index 62c04c26ff7..f3497bc843c 100644 --- a/lib/submission_list.rb +++ b/lib/submission_list.rb @@ -111,7 +111,7 @@ class SubmissionList # An iterator on the day only, not each submission def each_day(&block) - self.list.each &block + self.list.each(&block) end # An array of days with an array of grader open structs for that day and course. diff --git a/lib/submittable.rb b/lib/submittable.rb index 49b37c52856..45da804ef7c 100644 --- a/lib/submittable.rb +++ b/lib/submittable.rb @@ -154,8 +154,8 @@ module Submittable @old_assignment_id = self.assignment_id_was end if self.assignment_id - self.assignment_id = nil unless self.assignment && - self.assignment.context == self.context || + self.assignment_id = nil unless (self.assignment && + self.assignment.context == self.context) || self.try(:root_topic).try(:assignment_id) == self.assignment_id self.old_assignment_id = self.assignment_id if self.assignment_id end diff --git a/lib/tasks/canvas.rake b/lib/tasks/canvas.rake index d9b508f8101..4bd74819fbf 100644 --- a/lib/tasks/canvas.rake +++ b/lib/tasks/canvas.rake @@ -83,7 +83,7 @@ unless $canvas_tasks_loaded combined_time = batch_times.reduce(:+) - puts ( + puts( "Finished compiling assets in #{real_time.round(2)}s. " + "Parallelism saved #{(combined_time - real_time).round(2)}s " + "(#{(real_time.to_f / combined_time.to_f * 100.0).round(2)}%)" @@ -203,9 +203,9 @@ unless $canvas_tasks_loaded Switchman::Rake.filter_database_servers do |servers, block| ENV['REGION']&.split(',')&.each do |region| - method = :"select!" + method = :select! if region[0] == '-' - method = :"reject!" + method = :reject! region = region[1..-1] end if region == 'self' diff --git a/lib/tasks/db_create_data.rake b/lib/tasks/db_create_data.rake index e914f049c31..ca2201be0a0 100644 --- a/lib/tasks/db_create_data.rake +++ b/lib/tasks/db_create_data.rake @@ -37,10 +37,10 @@ def create_user_task menu.prompt = "Select an Account: |#{default}| " end - user_first_name = ask ( "User's first name: ") - user_last_name = ask ("User's last name: ") - user_login = ask ("User's login: ") - user_password = ask ("User's password: ") { |q| q.default = 'useruser' } + user_first_name = ask("User's first name: ") + user_last_name = ask("User's last name: ") + user_login = ask("User's login: ") + user_password = ask("User's password: ") { |q| q.default = 'useruser' } puts %Q{ diff --git a/lib/user_list_v2.rb b/lib/user_list_v2.rb index db49a82556d..1ceb083f8a0 100644 --- a/lib/user_list_v2.rb +++ b/lib/user_list_v2.rb @@ -127,7 +127,7 @@ class UserListV2 if results.count == 1 @resolved_results << results.first elsif results.uniq { |r| Shard.global_id_for(r[:user_id]) }.count == 1 - @resolved_results << results.detect { |r| r[:account_id] == @root_account.id } || results.first # prioritize local result first + (@resolved_results << results.detect { |r| r[:account_id] == @root_account.id }) || results.first # prioritize local result first else @duplicate_results << results end @@ -223,7 +223,7 @@ class UserListV2 if a[:type] == :sms path_header = a[:address].gsub(/[^\d]/, '') sms_path_header_map[path_header] = a[:address] - sms_paths << path_header + "@%" + sms_paths << (path_header + "@%") else email_paths << a[:address].downcase end diff --git a/lib/user_merge.rb b/lib/user_merge.rb index 9205323e753..e9daa863a76 100644 --- a/lib/user_merge.rb +++ b/lib/user_merge.rb @@ -71,11 +71,11 @@ class UserMerge target_user.preferences = target_user.preferences.merge(prefs) target_user.save if target_user.changed? - { 'access_token_ids': from_user.access_tokens.shard(from_user).pluck(:id), - 'conversation_messages_ids': ConversationMessage.where(author_id: from_user, conversation_id: nil).shard(from_user).pluck(:id), - 'conversation_ids': from_user.all_conversations.shard(from_user).pluck(:id), - 'ignore_ids': from_user.ignores.shard(from_user).pluck(:id), - 'user_past_lti_id_ids': from_user.past_lti_ids.shard(from_user).pluck(:id), + { access_token_ids: from_user.access_tokens.shard(from_user).pluck(:id), + conversation_messages_ids: ConversationMessage.where(author_id: from_user, conversation_id: nil).shard(from_user).pluck(:id), + conversation_ids: from_user.all_conversations.shard(from_user).pluck(:id), + ignore_ids: from_user.ignores.shard(from_user).pluck(:id), + user_past_lti_id_ids: from_user.past_lti_ids.shard(from_user).pluck(:id), 'Polling::Poll_ids': from_user.polls.shard(from_user).pluck(:id) }.each do |k, ids| merge_data.items.create!(user: from_user, item_type: k, item: ids) unless ids.empty? end diff --git a/lib/vericite.rb b/lib/vericite.rb index 9862cb551ec..0e754936ed2 100644 --- a/lib/vericite.rb +++ b/lib/vericite.rb @@ -341,7 +341,7 @@ module VeriCite token_user_role = 'Instructor' end # @return [Array] - data, status_code, headers = vericite_client.reports_urls_context_id_get(context_id, assignment_id_filter, consumer, consumer_secret, token_user, token_user_role, { :'user_id_filter' => user_id, :'external_content_id_filter' => args[:oid] }) + data, status_code, headers = vericite_client.reports_urls_context_id_get(context_id, assignment_id_filter, consumer, consumer_secret, token_user, token_user_role, { user_id_filter => user_id, external_content_id_filter => args[:oid] }) # check status code response[:return_code] = status_code if !is_response_success?(response) diff --git a/spec/ams_spec_helper.rb b/spec/ams_spec_helper.rb index b6f428e53c6..54c18136cd1 100644 --- a/spec/ams_spec_helper.rb +++ b/spec/ams_spec_helper.rb @@ -59,6 +59,6 @@ require File.expand_path(File.dirname(__FILE__)) + '/../app/serializers/canvas/a require File.expand_path(File.dirname(__FILE__)) + '/../app/serializers/canvas/api_serializer.rb' require File.expand_path(File.dirname(__FILE__)) + '/../app/serializers/canvas/api_array_serializer.rb' -Dir[File.expand_path(File.dirname(__FILE__) + '/../app/serializers/*.rb')].each do |file| +Dir[File.expand_path(File.dirname(__FILE__) + '/../app/serializers/*.rb')].sort.each do |file| require file end diff --git a/spec/apis/auth_spec.rb b/spec/apis/auth_spec.rb index 787d2777b8c..b5556edd808 100644 --- a/spec/apis/auth_spec.rb +++ b/spec/apis/auth_spec.rb @@ -354,14 +354,14 @@ describe "API Authentication", type: :request do it "requires the developer key to have a redirect_uri" do get "/login/oauth2/auth", params: { :response_type => 'code', :client_id => @client_id, :redirect_uri => "http://www.example.com/oauth2response" } expect(response).to be_client_error - expect(response.body).to match /redirect_uri/ + expect(response.body).to match(/redirect_uri/) end it "requires the redirect_uri domains to match" do @key.update_attribute :redirect_uri, 'http://www.example2.com/oauth2response' get "/login/oauth2/auth", params: { :response_type => 'code', :client_id => @client_id, :redirect_uri => "http://www.example.com/oauth2response" } expect(response).to be_client_error - expect(response.body).to match /redirect_uri/ + expect(response.body).to match(/redirect_uri/) @key.update_attribute :redirect_uri, 'http://www.example.com/oauth2response' get "/login/oauth2/auth", params: { :response_type => 'code', :client_id => @client_id, :redirect_uri => "http://www.example.com/oauth2response" } diff --git a/spec/apis/lti/ims/access_token_helper_spec.rb b/spec/apis/lti/ims/access_token_helper_spec.rb index d377cbaf806..573e354671f 100644 --- a/spec/apis/lti/ims/access_token_helper_spec.rb +++ b/spec/apis/lti/ims/access_token_helper_spec.rb @@ -114,7 +114,7 @@ module Lti let(:access_token_helper) { subject } it 'returns the bearer token for auth header' do - @request.headers['Authorization'] = "Bearer #{dev_key_access_token.to_s}" + @request.headers['Authorization'] = "Bearer #{dev_key_access_token}" expect(access_token_helper.oauth2_request?).to be_truthy end end diff --git a/spec/apis/lti/ims/tool_setting_api_spec.rb b/spec/apis/lti/ims/tool_setting_api_spec.rb index 50e57599b18..080d9e68ff4 100644 --- a/spec/apis/lti/ims/tool_setting_api_spec.rb +++ b/spec/apis/lti/ims/tool_setting_api_spec.rb @@ -25,7 +25,7 @@ module Lti module Ims describe ToolSettingController, type: :request do let(:account) { Account.new } - let (:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) } + let(:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) } let(:tool_proxy) do ToolProxy.create!( context: account, diff --git a/spec/apis/lti/logout_service_spec.rb b/spec/apis/lti/logout_service_spec.rb index c658e511f72..6b96aad91aa 100644 --- a/spec/apis/lti/logout_service_spec.rb +++ b/spec/apis/lti/logout_service_spec.rb @@ -72,7 +72,7 @@ describe LtiApiController, type: :request do it "rejects an invalid secret" do make_call('secret' => 'not secret') expect(response.status).to eql 401 - expect(response.body).to match /Invalid authorization header/ + expect(response.body).to match(/Invalid authorization header/) end it "rejects an invalid token" do @@ -81,7 +81,7 @@ describe LtiApiController, type: :request do token_parts[1] = (token_parts[1].to_i + 1).to_s make_call('path' => api_path(token_parts.join('-'))) expect(response.status).to eql 401 - expect(response.body).to match /Invalid logout service token/ + expect(response.body).to match(/Invalid logout service token/) end it "rejects an expired token" do @@ -90,7 +90,7 @@ describe LtiApiController, type: :request do end make_call('path' => api_path(token)) expect(response.status).to eql 401 - expect(response.body).to match /Logout service token has expired/ + expect(response.body).to match(/Logout service token has expired/) end it "registers callbacks" do @@ -113,7 +113,7 @@ describe LtiApiController, type: :request do expect(response).to be_successful make_call('path' => api_path(token, 'http://logout.notify.example.com/456')) expect(response.status).to eql 401 - expect(response.body).to match /Logout service token has already been used/ + expect(response.body).to match(/Logout service token has already been used/) end end diff --git a/spec/apis/v1/announcements_api_spec.rb b/spec/apis/v1/announcements_api_spec.rb index 4039dd26da7..804f545885d 100644 --- a/spec/apis/v1/announcements_api_spec.rb +++ b/spec/apis/v1/announcements_api_spec.rb @@ -127,7 +127,7 @@ describe "Announcements API", type: :request do :start_date => start_date, :end_date => end_date, :per_page => 1)) expect(json.length).to eq 1 next_link = response.headers['Link'].split(",").detect { |link| link =~ /rel="next"/ } - expect(next_link).to match /\/api\/v1\/announcements/ + expect(next_link).to match(/\/api\/v1\/announcements/) expect(next_link).to include "page=2" end diff --git a/spec/apis/v1/assignments_api_spec.rb b/spec/apis/v1/assignments_api_spec.rb index 5728cb52e3e..0115ee47576 100644 --- a/spec/apis/v1/assignments_api_spec.rb +++ b/spec/apis/v1/assignments_api_spec.rb @@ -985,7 +985,7 @@ describe AssignmentsApiController, type: :request do @assignment = @course.assignments.create!(title: "title", points_possible: '20.0') # Generate an array with min=10, max=18, mean=14 - scores = [10] + [14] * (count - 2) + [18] + scores = [10] + ([14] * (count - 2)) + [18] @students.take(count).each do |student| score = scores.pop().to_s @@ -3139,7 +3139,7 @@ describe AssignmentsApiController, type: :request do :points_possible => 15 }) - api_update_assignment_call(@course, @assignment, { 'points_possible': 10 }) + api_update_assignment_call(@course, @assignment, { points_possible: 10 }) expect(response.code).to eq "401" end @@ -3154,7 +3154,7 @@ describe AssignmentsApiController, type: :request do @assignment.grade_student(@student, grade: 15, grader: @teacher) @user = @teacher - api_update_assignment_call(@course, @assignment, { 'grading_type': 'percent' }) + api_update_assignment_call(@course, @assignment, { grading_type: 'percent' }) expect(response).to be_successful expect(@assignment.grading_type).to eq 'percent' end @@ -3169,7 +3169,7 @@ describe AssignmentsApiController, type: :request do RoleOverride.create!(permission: 'manage_grades', enabled: false, context: @course.account, role: admin_role) account_admin_user(active_all: true) - api_update_assignment_call(@course, @assignment, { 'grading_type': 'percent' }) + api_update_assignment_call(@course, @assignment, { grading_type: 'percent' }) expect(response).to be_successful expect(@assignment.grading_type).to eq 'percent' end @@ -3186,7 +3186,7 @@ describe AssignmentsApiController, type: :request do RoleOverride.create!(permission: 'manage_grades', enabled: false, context: @course.account, role: admin_role) account_admin_user(active_all: true) - api_update_assignment_call(@course, @assignment, { 'grading_type': 'percent' }) + api_update_assignment_call(@course, @assignment, { grading_type: 'percent' }) expect(response.code).to eq "401" end @@ -3755,7 +3755,7 @@ describe AssignmentsApiController, type: :request do end it "updates the assignments grading_type when type is empty" do - @json = api_update_assignment_call(@course, @assignment, { 'grading_type': '' }) + @json = api_update_assignment_call(@course, @assignment, { grading_type: '' }) @assignment.reload expect(@assignment.grading_type).to eq 'points' expect(@json['grading_type']).to eq @assignment.grading_type diff --git a/spec/apis/v1/conversations_api_spec.rb b/spec/apis/v1/conversations_api_spec.rb index 226c1017465..49adccd0870 100644 --- a/spec/apis/v1/conversations_api_spec.rb +++ b/spec/apis/v1/conversations_api_spec.rb @@ -180,9 +180,9 @@ describe ConversationsController, type: :request do links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/conversations/ }).to be_truthy expect(links.all? { |l| l.scan(/scope=default/).size == 1 }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) # get the last page json = api_call(:get, "/api/v1/conversations.json?scope=default&page=3&per_page=3", @@ -191,9 +191,9 @@ describe ConversationsController, type: :request do links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/conversations/ }).to be_truthy expect(links.all? { |l| l.scan(/scope=default/).size == 1 }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end it "filters conversations by scope" do @@ -2442,9 +2442,9 @@ describe ConversationsController, type: :request do links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/conversations\/deleted/ }).to be_truthy - expect(links.find { |l| l.match(/rel="current"/) }).to match /page=1&per_page=10>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=10>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=1&per_page=10>/ + expect(links.find { |l| l.match(/rel="current"/) }).to match(/page=1&per_page=10>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=10>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=1&per_page=10>/) end it 'can respond with multiple users data' do diff --git a/spec/apis/v1/courses_api_spec.rb b/spec/apis/v1/courses_api_spec.rb index 293c9887f9e..b4d3f7d1e4d 100644 --- a/spec/apis/v1/courses_api_spec.rb +++ b/spec/apis/v1/courses_api_spec.rb @@ -995,7 +995,7 @@ describe CoursesController, type: :request do :open_enrollment, :self_enrollment, :license, :sis_course_id, :allow_student_forum_attachments, :public_description, :restrict_enrollments_to_course_dates].each do |attr| - expect(new_course.send(attr)).to eq ([:start_at, :end_at].include?(attr) ? + expect(new_course.send(attr)).to eq([:start_at, :end_at].include?(attr) ? Time.parse(post_params['course'][attr.to_s]) : post_params['course'][attr.to_s]) end @@ -3093,9 +3093,9 @@ describe CoursesController, type: :request do json = api_call(:get, api_url, api_route, :search_term => "SSS", :limit => 1) expect(json.length).to eq 1 link_header = response.headers['Link'].split(',') - expect(link_header[0]).to match /page=1&per_page=1/ # current page - expect(link_header[1]).to match /page=2&per_page=1/ # next page - expect(link_header[2]).to match /page=1&per_page=1/ # first page + expect(link_header[0]).to match(/page=1&per_page=1/) # current page + expect(link_header[1]).to match(/page=2&per_page=1/) # next page + expect(link_header[2]).to match(/page=1&per_page=1/) # first page end it "respects includes" do @@ -3603,9 +3603,9 @@ describe CoursesController, type: :request do expect(json.map { |x| x['id'] }.uniq.length).to eq 5 link_header = response.headers['Link'].split(',') - expect(link_header[0]).to match /page=1&per_page=5/ # current page - expect(link_header[1]).to match /page=2&per_page=5/ # next page - expect(link_header[2]).to match /page=1&per_page=5/ # first page + expect(link_header[0]).to match(/page=1&per_page=5/) # current page + expect(link_header[1]).to match(/page=2&per_page=5/) # next page + expect(link_header[2]).to match(/page=1&per_page=5/) # first page end it "allows jumping to a user's page based on id" do diff --git a/spec/apis/v1/discussion_topics_api_spec.rb b/spec/apis/v1/discussion_topics_api_spec.rb index 603cc3c1940..a350c10e1e3 100644 --- a/spec/apis/v1/discussion_topics_api_spec.rb +++ b/spec/apis/v1/discussion_topics_api_spec.rb @@ -765,7 +765,6 @@ describe DiscussionTopicsController, type: :request do expect(json.first["id"]).to eq @announcement2.id end - # rubocop:disable RSpec/NestedGroups context "as a user that can view all sections" do it "includes all announcements" do json = api_call_as_user( @@ -784,7 +783,6 @@ describe DiscussionTopicsController, type: :request do expect(json.map { |i| i["id"] }).to match_array [@announcement.id, @announcement2.id] end end - # rubocop:enable RSpec/NestedGroups end end end @@ -1576,9 +1574,9 @@ describe DiscussionTopicsController, type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/discussion_topics/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) # get the last page json = api_call(:get, "/api/v1/courses/#{@course.id}/discussion_topics.json?page=3&per_page=3", @@ -1586,9 +1584,9 @@ describe DiscussionTopicsController, type: :request do expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/discussion_topics/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end it "works with groups" do @@ -1679,9 +1677,9 @@ describe DiscussionTopicsController, type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/groups\/#{group.id}\/discussion_topics/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) # get the last page json = api_call(:get, "/api/v1/groups/#{group.id}/discussion_topics.json?page=3&per_page=3", @@ -1689,9 +1687,9 @@ describe DiscussionTopicsController, type: :request do expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/groups\/#{group.id}\/discussion_topics/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end it "fulfills module viewed requirements when marking a topic read" do @@ -1851,7 +1849,7 @@ describe DiscussionTopicsController, type: :request do ) expect(json['attachment']).to be_present new_file = Attachment.find(json['attachment']['id']) - expect(new_file.display_name).to match /txt-[0-9]+\.txt/ + expect(new_file.display_name).to match(/txt-[0-9]+\.txt/) expect(json['attachment']['display_name']).to eq new_file.display_name expect(json['attachment']['url']).to be_include 'verifier=' end @@ -1983,9 +1981,9 @@ describe DiscussionTopicsController, type: :request do expect(json.map { |e| e['id'] }).to eq entries.last(3).reverse.map { |e| e.id } links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/discussion_topics\/#{@topic.id}\/entries/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) # last page json = api_call( @@ -1997,9 +1995,9 @@ describe DiscussionTopicsController, type: :request do expect(json.map { |e| e['id'] }).to eq [entries.first, @entry].map { |e| e.id } links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/discussion_topics\/#{@topic.id}\/entries/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end it "only includes the first 10 replies for each top-level entry" do @@ -2079,9 +2077,9 @@ describe DiscussionTopicsController, type: :request do expect(json.map { |e| e['id'] }).to eq replies.last(3).reverse.map { |e| e.id } links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/discussion_topics\/#{@topic.id}\/entries\/#{@entry.id}\/replies/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) # last page json = api_call( @@ -2093,9 +2091,9 @@ describe DiscussionTopicsController, type: :request do expect(json.map { |e| e['id'] }).to eq [replies.first, @reply].map { |e| e.id } links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/discussion_topics\/#{@topic.id}\/entries\/#{@entry.id}\/replies/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end end @@ -2720,7 +2718,7 @@ describe DiscussionTopicsController, type: :request do @reply_reply1.editor = @teacher @reply_reply1.update(:message => '

censored

') - @all_entries.each &:reload + @all_entries.each(&:reload) # materialized view jobs are now delayed Timecop.travel(Time.zone.now + 20.seconds) do diff --git a/spec/apis/v1/enrollments_api_spec.rb b/spec/apis/v1/enrollments_api_spec.rb index 55b84df061c..9ee9d2b8464 100644 --- a/spec/apis/v1/enrollments_api_spec.rb +++ b/spec/apis/v1/enrollments_api_spec.rb @@ -1256,14 +1256,14 @@ describe EnrollmentsApiController, type: :request do json = api_call(:get, @path, @params) json_user_ids = json.map { |user| user["user_id"] } section_user_ids = @course.course_sections.first.enrollments.map { |e| e.user_id } - expect(json.length).to eq (@course.course_sections.first.enrollments.length) + expect(json.length).to eq(@course.course_sections.first.enrollments.length) expect(json_user_ids).to match_array(section_user_ids) end it "filters by a list of sis_section_ids" do @params[:sis_section_id] = ['SIS123', 'SIS456'] json = api_call(:get, @path, @params) - expect(json.length).to eq (@course.course_sections.first.enrollments.length) + expect(json.length).to eq(@course.course_sections.first.enrollments.length) json_user_ids = json.map { |user| user["user_id"] } section_user_ids = @course.course_sections.first.enrollments.map { |e| e.user_id } expect(json_user_ids).to match_array(section_user_ids) @@ -1284,7 +1284,7 @@ describe EnrollmentsApiController, type: :request do it "filters by a single sis_course_id" do @params[:sis_course_id] = 'SIS123' json = api_call(:get, @path, @params) - expect(json.length).to eq (@course.enrollments.length) + expect(json.length).to eq(@course.enrollments.length) json_user_ids = json.map { |user| user["user_id"] } course_user_ids = @course.enrollments.map { |e| e.user_id } expect(json_user_ids).to match_array(course_user_ids) @@ -1293,7 +1293,7 @@ describe EnrollmentsApiController, type: :request do it "filters by a list of sis_course_ids" do @params[:sis_course_id] = ['SIS123', 'LULZ'] json = api_call(:get, @path, @params) - expect(json.length).to eq (@course.enrollments.length) + expect(json.length).to eq(@course.enrollments.length) json_user_ids = json.map { |user| user["user_id"] } course_user_ids = @course.enrollments.map { |e| e.user_id } expect(json_user_ids).to match_array(course_user_ids) @@ -2312,18 +2312,18 @@ describe EnrollmentsApiController, type: :request do end link_header = response.headers['Link'].split(',') - expect(link_header[0]).to match /page=1&per_page=1/ # current page - expect(link_header[1]).to match /page=2&per_page=1/ # next page - expect(link_header[2]).to match /page=1&per_page=1/ # first page - expect(link_header[3]).to match /page=2&per_page=1/ # last page + expect(link_header[0]).to match(/page=1&per_page=1/) # current page + expect(link_header[1]).to match(/page=2&per_page=1/) # next page + expect(link_header[2]).to match(/page=1&per_page=1/) # first page + expect(link_header[3]).to match(/page=2&per_page=1/) # last page expect(json).to eql [enrollments[0]] json = api_call(:get, "#{@path}?page=2&per_page=1", @params.merge(:page => 2.to_param, :per_page => 1.to_param)) link_header = response.headers['Link'].split(',') - expect(link_header[0]).to match /page=2&per_page=1/ # current page - expect(link_header[1]).to match /page=1&per_page=1/ # prev page - expect(link_header[2]).to match /page=1&per_page=1/ # first page - expect(link_header[3]).to match /page=2&per_page=1/ # last page + expect(link_header[0]).to match(/page=2&per_page=1/) # current page + expect(link_header[1]).to match(/page=1&per_page=1/) # prev page + expect(link_header[2]).to match(/page=1&per_page=1/) # first page + expect(link_header[3]).to match(/page=2&per_page=1/) # last page expect(json).to eql [enrollments[1]] end end @@ -2374,18 +2374,18 @@ describe EnrollmentsApiController, type: :request do h end link_header = response.headers['Link'].split(',') - expect(link_header[0]).to match /page=.*&per_page=1/ # current page + expect(link_header[0]).to match(/page=.*&per_page=1/) # current page md = link_header[1].match(/page=(.*)&per_page=1/) # next page bookmark = md[1] expect(bookmark).to be_present - expect(link_header[2]).to match /page=.*&per_page=1/ # first page + expect(link_header[2]).to match(/page=.*&per_page=1/) # first page expect(json).to eql [enrollments[0]] json = api_call(:get, "#{@path}?page=#{bookmark}&per_page=1", @params.merge(:page => bookmark, :per_page => 1.to_param)) link_header = response.headers['Link'].split(',') - expect(link_header[0]).to match /page=#{bookmark}&per_page=1/ # current page - expect(link_header[1]).to match /page=.*&per_page=1/ # first page - expect(link_header[2]).to match /page=.*&per_page=1/ # last page + expect(link_header[0]).to match(/page=#{bookmark}&per_page=1/) # current page + expect(link_header[1]).to match(/page=.*&per_page=1/) # first page + expect(link_header[2]).to match(/page=.*&per_page=1/) # last page expect(json).to eql [enrollments[1]] end end diff --git a/spec/apis/v1/external_tools_api_spec.rb b/spec/apis/v1/external_tools_api_spec.rb index ea2f37e7bed..7d58ebf2f23 100644 --- a/spec/apis/v1/external_tools_api_spec.rb +++ b/spec/apis/v1/external_tools_api_spec.rb @@ -647,9 +647,9 @@ describe ExternalToolsController, type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/#{type}s\/#{context.id}\/external_tools/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3/) # get the last page json = api_call(:get, "/api/v1/#{type}s/#{context.id}/external_tools.json?page=3&per_page=3", @@ -657,9 +657,9 @@ describe ExternalToolsController, type: :request do expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/#{type}s\/#{context.id}\/external_tools/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3/) end def tool_with_everything(context, opts = {}) diff --git a/spec/apis/v1/files_controller_api_spec.rb b/spec/apis/v1/files_controller_api_spec.rb index 9e9e94f81d4..ca50a91857d 100644 --- a/spec/apis/v1/files_controller_api_spec.rb +++ b/spec/apis/v1/files_controller_api_spec.rb @@ -608,17 +608,17 @@ describe "Files API", type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/folders\/#{@root.id}\/files/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3/) json = api_call(:get, "/api/v1/folders/#{@root.id}/files?per_page=3&page=3", @files_path_options.merge(:id => @root.id.to_param, :per_page => '3', :page => '3'), {}) expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/folders\/#{@root.id}\/files/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3/) end it "only returns names if requested" do @@ -862,17 +862,17 @@ describe "Files API", type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/files/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3/) json = api_call(:get, "/api/v1/courses/#{@course.id}/files?per_page=3&page=3", @files_path_options.merge(:per_page => '3', :page => '3'), {}) expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/files/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3/) end context "content_types" do diff --git a/spec/apis/v1/folders_controller_api_spec.rb b/spec/apis/v1/folders_controller_api_spec.rb index 659ad7bc01a..6ec0daa2ac7 100644 --- a/spec/apis/v1/folders_controller_api_spec.rb +++ b/spec/apis/v1/folders_controller_api_spec.rb @@ -85,17 +85,17 @@ describe "Folders API", type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/folders\/#{@root.id}\/folders/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) json = api_call(:get, @folders_path + "/#{@root.id}/folders?per_page=3&page=3", @folders_path_options.merge(:per_page => '3', :page => '3'), {}) expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/folders\/#{@root.id}\/folders/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end context "student" do @@ -979,18 +979,18 @@ describe "Folders API", type: :request do expect(json.length).to eq 3 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/folders/ }).to be_truthy - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) json = api_call(:get, "/api/v1/courses/#{@course.id}/folders", { :controller => "folders", :action => "list_all_folders", :format => "json", :course_id => @course.id.to_param, :per_page => 3, :page => 3 }) expect(json.length).to eq 1 links = response.headers['Link'].split(",") expect(links.all? { |l| l =~ /api\/v1\/courses\/#{@course.id}\/folders/ }).to be_truthy - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=3>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=3>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=3&per_page=3>/ + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=3>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=3>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=3&per_page=3>/) end end diff --git a/spec/apis/v1/polling/poll_sessions_api_spec.rb b/spec/apis/v1/polling/poll_sessions_api_spec.rb index aa7444a7542..6e173e886d4 100644 --- a/spec/apis/v1/polling/poll_sessions_api_spec.rb +++ b/spec/apis/v1/polling/poll_sessions_api_spec.rb @@ -277,7 +277,7 @@ describe Polling::PollSessionsController, type: :request do post_create({ course_section_id: @section.id + 666, course_id: @course.id }, true) expect(response.code).to eq "404" - expect(response.body).to match /The specified resource does not exist/ + expect(response.body).to match(/The specified resource does not exist/) end end end diff --git a/spec/apis/v1/polling/poll_submissions_api_spec.rb b/spec/apis/v1/polling/poll_submissions_api_spec.rb index f419447ca5d..db8f4e33c3f 100644 --- a/spec/apis/v1/polling/poll_submissions_api_spec.rb +++ b/spec/apis/v1/polling/poll_submissions_api_spec.rb @@ -100,7 +100,7 @@ describe Polling::PollSubmissionsController, type: :request do post_create({ filler: true }, true) expect(response.code).to eq "404" - expect(response.body).to match /The specified resource does not exist/ + expect(response.body).to match(/The specified resource does not exist/) end it "doesn't submit if the student isn't enrolled in the specified section" do diff --git a/spec/apis/v1/pseudonyms_api_spec.rb b/spec/apis/v1/pseudonyms_api_spec.rb index b0960e96f10..6f522644389 100644 --- a/spec/apis/v1/pseudonyms_api_spec.rb +++ b/spec/apis/v1/pseudonyms_api_spec.rb @@ -68,10 +68,10 @@ describe PseudonymsController, type: :request do }) expect(json.count).to eql 1 headers = response.headers['Link'].split(',') - expect(headers[0]).to match /page=1&per_page=1/ # current page - expect(headers[1]).to match /page=2&per_page=1/ # next page - expect(headers[2]).to match /page=1&per_page=1/ # first page - expect(headers[3]).to match /page=2&per_page=1/ # last page + expect(headers[0]).to match(/page=1&per_page=1/) # current page + expect(headers[1]).to match(/page=2&per_page=1/) # next page + expect(headers[2]).to match(/page=1&per_page=1/) # first page + expect(headers[3]).to match(/page=2&per_page=1/) # last page end it "returns all pseudonyms for a user" do diff --git a/spec/apis/v1/quizzes/quiz_groups_api_spec.rb b/spec/apis/v1/quizzes/quiz_groups_api_spec.rb index 9059d36d4cf..aa6a75520b0 100644 --- a/spec/apis/v1/quizzes/quiz_groups_api_spec.rb +++ b/spec/apis/v1/quizzes/quiz_groups_api_spec.rb @@ -35,7 +35,7 @@ describe Quizzes::QuizGroupsController, type: :request do { 'Accept' => 'application/vnd.api+json' }, opts) end - let (:new_quiz_group) { @quiz.reload; @quiz.quiz_groups.first } + let(:new_quiz_group) { @quiz.reload; @quiz.quiz_groups.first } it "creates a question group for a quiz" do api_create_quiz_group('name' => 'testing') @@ -58,7 +58,7 @@ describe Quizzes::QuizGroupsController, type: :request do end it "renders a validation error when the name is too long" do - name = 'a' * ActiveRecord::Base.maximum_string_length + '!' + name = ('a' * ActiveRecord::Base.maximum_string_length) + '!' json = api_create_quiz_group({ 'name' => name }, :expected_status => 422) expect(json).to have_key 'errors' expect(json["errors"]).to have_key "name" @@ -112,7 +112,7 @@ describe Quizzes::QuizGroupsController, type: :request do end it "renders a validation error when the name is too long" do - name = 'a' * ActiveRecord::Base.maximum_string_length + '!' + name = ('a' * ActiveRecord::Base.maximum_string_length) + '!' json = api_update_quiz_group({ 'name' => name }, :expected_status => 422) expect(json).to have_key 'errors' expect(@group.reload.name).to eq 'Test Group' diff --git a/spec/apis/v1/quizzes/quiz_questions_api_spec.rb b/spec/apis/v1/quizzes/quiz_questions_api_spec.rb index d46cbcfbe1c..ed00144b510 100644 --- a/spec/apis/v1/quizzes/quiz_questions_api_spec.rb +++ b/spec/apis/v1/quizzes/quiz_questions_api_spec.rb @@ -113,7 +113,7 @@ describe Quizzes::QuizQuestionsController, type: :request do request_data = { question: { - 'question_text': file_link, + question_text: file_link, } } json = api_call( diff --git a/spec/apis/v1/quizzes/quizzes_api_spec.rb b/spec/apis/v1/quizzes/quizzes_api_spec.rb index 69c48ff568b..2a0a0d8c950 100644 --- a/spec/apis/v1/quizzes/quizzes_api_spec.rb +++ b/spec/apis/v1/quizzes/quizzes_api_spec.rb @@ -278,7 +278,7 @@ describe Quizzes::QuizzesApiController, type: :request do before(:once) { teacher_in_course(:active_all => true) } - let (:new_quiz) { @course.quizzes.first } + let(:new_quiz) { @course.quizzes.first } context "jsonapi style request" do it "renders in a jsonapi style" do @@ -312,7 +312,7 @@ describe Quizzes::QuizzesApiController, type: :request do end it "renders an error when the title is too long" do - title = 'a' * ActiveRecord::Base.maximum_string_length + '!' + title = ('a' * ActiveRecord::Base.maximum_string_length) + '!' json = api_create_quiz({ 'title' => title }, :expected_status => 400) expect(json).to have_key 'errors' expect(new_quiz).to be_nil @@ -571,8 +571,8 @@ describe Quizzes::QuizzesApiController, type: :request do before { teacher_in_course(:active_all => true) } - let (:updated_quiz) { @course.quizzes.first } - let (:quiz_params) { {} } + let(:updated_quiz) { @course.quizzes.first } + let(:quiz_params) { {} } it "updates quiz attributes" do api_update_quiz({ 'title' => 'old title' }, { 'title' => 'new title' }) @@ -614,7 +614,7 @@ describe Quizzes::QuizzesApiController, type: :request do end it "renders an error when the title is too long" do - long_title = 'a' * ActiveRecord::Base.maximum_string_length + '!' + long_title = ('a' * ActiveRecord::Base.maximum_string_length) + '!' json = api_update_quiz({}, { 'title' => long_title }, :expected_status => 400) expect(json).to have_key 'errors' expect(updated_quiz.title).to eq 'title' @@ -772,7 +772,7 @@ describe Quizzes::QuizzesApiController, type: :request do context 'allowed_attempts' do it 'discards values less than -1' do api_update_quiz({ 'allowed_attempts' => -1 }, { 'allowed_attempts' => -25 }) - expect(updated_quiz.allowed_attempts).to eq -1 + expect(updated_quiz.allowed_attempts).to eq(-1) end end end diff --git a/spec/apis/v1/roles_api_spec.rb b/spec/apis/v1/roles_api_spec.rb index 8a734230613..7f77e3d1a49 100644 --- a/spec/apis/v1/roles_api_spec.rb +++ b/spec/apis/v1/roles_api_spec.rb @@ -88,13 +88,13 @@ describe "Roles API", type: :request do { :controller => 'role_overrides', :action => 'api_index', :format => 'json', :account_id => sub_account.id.to_param, :show_inherited => '1' }) - expect(json.map { |r| r['id'] }).to match_array ([role.id] + Role.visible_built_in_roles(root_account_id: @account.id).map(&:id)) + expect(json.map { |r| r['id'] }).to match_array([role.id] + Role.visible_built_in_roles(root_account_id: @account.id).map(&:id)) expect(json.detect { |r| r['id'] == role.id }['account']['id']).to eq @account.id json2 = api_call(:get, "/api/v1/accounts/#{sub_account.id}/roles", { :controller => 'role_overrides', :action => 'api_index', :format => 'json', :account_id => sub_account.id.to_param }) - expect(json2.map { |r| r['id'] }).to match_array (Role.visible_built_in_roles(root_account_id: @account.id).map(&:id)) + expect(json2.map { |r| r['id'] }).to match_array(Role.visible_built_in_roles(root_account_id: @account.id).map(&:id)) end it "paginates" do diff --git a/spec/apis/v1/terms_api_spec.rb b/spec/apis/v1/terms_api_spec.rb index 663330f82b3..dfbc29b89c0 100644 --- a/spec/apis/v1/terms_api_spec.rb +++ b/spec/apis/v1/terms_api_spec.rb @@ -221,7 +221,7 @@ describe TermsApiController, type: :request do it "includes overrides by default if requested" do @term.set_overrides(@account, 'StudentEnrollment' => { end_at: "2017-01-20T00:00:00Z" }) json = get_term - expect(json['overrides']).to eq ({ "StudentEnrollment" => { "start_at" => nil, "end_at" => "2017-01-20T00:00:00Z" } }) + expect(json['overrides']).to eq({ "StudentEnrollment" => { "start_at" => nil, "end_at" => "2017-01-20T00:00:00Z" } }) end describe "authorization" do @@ -458,8 +458,8 @@ describe TermsController, type: :request do api_call(:put, "/api/v1/accounts/#{@account.id}/terms/#{@term1.id}", { controller: 'terms', action: 'update', format: 'json', account_id: @account.to_param, id: @term1.to_param }, - { enrollment_term: { overrides: { 'ObserverEnrollment': { - 'start_at': '2017-01-17T20:00:00Z', 'end_at': '2017-01-17T20:00:00Z' + { enrollment_term: { overrides: { ObserverEnrollment: { + start_at: '2017-01-17T20:00:00Z', end_at: '2017-01-17T20:00:00Z' } } } }, {}, { expected_status: 400 }) diff --git a/spec/apis/v1/users_api_spec.rb b/spec/apis/v1/users_api_spec.rb index f5f133473a6..faa53a60914 100644 --- a/spec/apis/v1/users_api_spec.rb +++ b/spec/apis/v1/users_api_spec.rb @@ -716,8 +716,8 @@ describe "Users API", type: :request do expect(json[0]['created_at']).to be > json[1]['created_at'] expect(json[0]['app_name']).to be_nil expect(json[1]['app_name']).to eq 'User-Generated' - expect(response.headers['Link']).to match /next/ - expect(response.headers['Link']).not_to match /last/ + expect(response.headers['Link']).to match(/next/) + expect(response.headers['Link']).not_to match(/last/) response.headers['Link'].split(',').find { |l| l =~ /<([^>]+)>.+next/ } url = $1 path, querystring = url.split("?") @@ -726,8 +726,8 @@ describe "Users API", type: :request do { :controller => "page_views", :action => "index", :user_id => @student.to_param, :format => 'json', :page => page, :per_page => Setting.get('api_max_per_page', '2') }) expect(json.size).to eq 1 json.each { |j| expect(j['url']).to eq "http://www.example.com/courses/1" } - expect(response.headers['Link']).not_to match /next/ - expect(response.headers['Link']).to match /last/ + expect(response.headers['Link']).not_to match(/next/) + expect(response.headers['Link']).to match(/last/) end it "recognizes start_time parameter" do diff --git a/spec/contracts/service_consumers/api/provider_states_for_consumer.rb b/spec/contracts/service_consumers/api/provider_states_for_consumer.rb index 561edc3043a..b1bbb3f6be2 100644 --- a/spec/contracts/service_consumers/api/provider_states_for_consumer.rb +++ b/spec/contracts/service_consumers/api/provider_states_for_consumer.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License along # with this program. If not, see . -Dir[File.dirname(__FILE__) + "/provider_states_for_consumer/*.rb"].each { |f| require f } +Dir[File.dirname(__FILE__) + "/provider_states_for_consumer/*.rb"].sort.each { |f| require f } require 'spec/factories/course_factory' require 'spec/factories/user_factory' diff --git a/spec/contracts/service_consumers/api/provider_states_for_consumer/oauth_provider_states.rb b/spec/contracts/service_consumers/api/provider_states_for_consumer/oauth_provider_states.rb index 8ec6e340e5f..6a2a437563a 100644 --- a/spec/contracts/service_consumers/api/provider_states_for_consumer/oauth_provider_states.rb +++ b/spec/contracts/service_consumers/api/provider_states_for_consumer/oauth_provider_states.rb @@ -66,8 +66,8 @@ module LtiProviderStateHelper def self.create_external_tool(developer_key) configuration = { - "title": "Canvas Data Services", - "scopes": [ + title: "Canvas Data Services", + scopes: [ "https://canvas.instructure.com/lti/public_jwk/scope/update", "https://canvas.instructure.com/lti/data_services/scope/create", "https://canvas.instructure.com/lti/data_services/scope/show", @@ -77,33 +77,33 @@ module LtiProviderStateHelper "https://canvas.instructure.com/lti/data_services/scope/list_event_types", "https://canvas.instructure.com/lti/feature_flags/scope/show" ], - "public_jwk_url": "http://live-events-lti/api/jwks", - "description": "Data service management for Canvas LMS", - "target_link_uri": "http://live-events-lti/resource_link_request", - "oidc_initiation_url": "http://live-events-lti/login", - "extensions": [ + public_jwk_url: "http://live-events-lti/api/jwks", + description: "Data service management for Canvas LMS", + target_link_uri: "http://live-events-lti/resource_link_request", + oidc_initiation_url: "http://live-events-lti/login", + extensions: [ { - "platform": "canvas.instructure.com", - "domain": "http://live-events-lti", - "privacy_level": "public", - "settings": { - "placements": [ + platform: "canvas.instructure.com", + domain: "http://live-events-lti", + privacy_level: "public", + settings: { + placements: [ { - "text": "Data Services", - "enabled": true, - "placement": "account_navigation", - "target_link_uri": "http://live-events-lti/resource_link_request", - "required_permissions": "manage_data_services" + text: "Data Services", + enabled: true, + placement: "account_navigation", + target_link_uri: "http://live-events-lti/resource_link_request", + required_permissions: "manage_data_services" } ] } } ], - "custom_fields": { - "canvas_account_uuid": "$vnd.Canvas.root_account.uuid", - "canvas_api_domain": "$Canvas.api.domain", - "canvas_user_uuid": "$Canvas.user.globalId", - "canvas_high_contrast_enabled": "$Canvas.user.prefersHighContrast" + custom_fields: { + canvas_account_uuid: "$vnd.Canvas.root_account.uuid", + canvas_api_domain: "$Canvas.api.domain", + canvas_user_uuid: "$Canvas.user.globalId", + canvas_high_contrast_enabled: "$Canvas.user.prefersHighContrast" } } tool_config = Lti::ToolConfiguration.create!(developer_key: developer_key, settings: configuration, privacy_level: 'public') diff --git a/spec/contracts/service_providers/outcomes/migration_service_get_content_export_spec.rb b/spec/contracts/service_providers/outcomes/migration_service_get_content_export_spec.rb index 5813c0676eb..0611168767d 100644 --- a/spec/contracts/service_providers/outcomes/migration_service_get_content_export_spec.rb +++ b/spec/contracts/service_providers/outcomes/migration_service_get_content_export_spec.rb @@ -45,33 +45,33 @@ RSpec.describe 'Outcomes Service - GET Content Export', :pact do end let(:expected_export_get_response_body) do { - "id": Pact.like(5), - "context_type": "course", - "context_id": Pact.like("100"), - "state": "completed", - "export_settings": { - "format": "canvas", - "artifacts": [ + id: Pact.like(5), + context_type: "course", + context_id: Pact.like("100"), + state: "completed", + export_settings: { + format: "canvas", + artifacts: [ { - "external_id": Pact.each_like(1), - "external_type": "canvas.page" + external_id: Pact.each_like(1), + external_type: "canvas.page" } ] }, - "data": { - "format": "canvas", - "alignments": Pact.each_like({ - "artifact": Pact.like({ - "$canvas_wiki_page_id": "1" - }), - "outcomes": Pact.each_like({ - "$canvas_learning_outcome_id": "external-id-1" - }) - }) + data: { + format: "canvas", + alignments: Pact.each_like({ + artifact: Pact.like({ + "$canvas_wiki_page_id": "1" + }), + outcomes: Pact.each_like({ + "$canvas_learning_outcome_id": "external-id-1" + }) + }) } } end - let(:export_data) { { "export_id": "1" } } + let(:export_data) { { export_id: "1" } } before do outcomes.given('artifacts and an export to retrieve') diff --git a/spec/contracts/service_providers/outcomes/migration_service_get_content_import_spec.rb b/spec/contracts/service_providers/outcomes/migration_service_get_content_import_spec.rb index 357a7cc50e2..002a85f0b90 100644 --- a/spec/contracts/service_providers/outcomes/migration_service_get_content_import_spec.rb +++ b/spec/contracts/service_providers/outcomes/migration_service_get_content_import_spec.rb @@ -46,7 +46,7 @@ RSpec.describe 'Outcomes Service - GET Content Import', :pact do end let(:expected_import_get_response_body) do { - "state": "completed" + state: "completed" } end let!(:course) { course_factory(active_course: true) } diff --git a/spec/contracts/service_providers/outcomes/migration_service_post_content_export_spec.rb b/spec/contracts/service_providers/outcomes/migration_service_post_content_export_spec.rb index a5f9142a563..7ffe5666be4 100644 --- a/spec/contracts/service_providers/outcomes/migration_service_post_content_export_spec.rb +++ b/spec/contracts/service_providers/outcomes/migration_service_post_content_export_spec.rb @@ -45,14 +45,14 @@ RSpec.describe 'Outcomes Service - POST Content Export', :pact do end let(:export_post_request_body) do { - "context_id": "100", - "context_type": "course", - "export_settings": { - "format": "canvas", - "artifacts": [ + context_id: "100", + context_type: "course", + export_settings: { + format: "canvas", + artifacts: [ { - "external_type": "canvas.page", - "external_id": [ + external_type: "canvas.page", + external_id: [ 1, 2, 3 @@ -64,16 +64,16 @@ RSpec.describe 'Outcomes Service - POST Content Export', :pact do end let(:expected_export_post_response_body) do { - "id": Pact.like(2), - "context_type": "course", - "context_id": Pact.like("100"), - "state": "created", - "export_settings": { - "format": "canvas", - "artifacts": [ + id: Pact.like(2), + context_type: "course", + context_id: Pact.like("100"), + state: "created", + export_settings: { + format: "canvas", + artifacts: [ { - "external_type": "canvas.page", - "external_id": Pact.each_like(1) + external_type: "canvas.page", + external_id: Pact.each_like(1) } ] } diff --git a/spec/contracts/service_providers/outcomes/migration_service_post_content_import_spec.rb b/spec/contracts/service_providers/outcomes/migration_service_post_content_import_spec.rb index d492caa2c4c..0a31d50d769 100644 --- a/spec/contracts/service_providers/outcomes/migration_service_post_content_import_spec.rb +++ b/spec/contracts/service_providers/outcomes/migration_service_post_content_import_spec.rb @@ -46,13 +46,13 @@ RSpec.describe 'Outcomes Service - POST Content Import', :pact do end let(:import_post_request_body) do { - "format": "canvas", - "alignments": [ + format: "canvas", + alignments: [ { - "artifact": { + artifact: { "$canvas_wiki_page_id": "100" }, - "outcomes": [ + outcomes: [ { "$canvas_learning_outcome_id": "1" }, @@ -62,38 +62,38 @@ RSpec.describe 'Outcomes Service - POST Content Import', :pact do ] } ], - "outcomes": [ + outcomes: [ { "$canvas_learning_outcome_id": "1000", - "title": "outcome_title", - "description": "outcome_description", - "rubric_criterion": { - "description": "scoring method description", - "ratings": [ + title: "outcome_title", + description: "outcome_description", + rubric_criterion: { + description: "scoring method description", + ratings: [ { - "description": "Exceeds Expectations", - "points": 5 + description: "Exceeds Expectations", + points: 5 }, { - "description": "Does Not Meet Expectations", - "points": 0 + description: "Does Not Meet Expectations", + points: 0 } ], - "mastery_points": 1, - "points_possible": 5 + mastery_points: 1, + points_possible: 5 } } ], - "context_type": "course", - "context_id": 100, - "groups": [ + context_type: "course", + context_id: 100, + groups: [ { "$canvas_learning_outcome_group_id": "1001", - "title": "outcome_group_title", - "description": "outcome_group_description" + title: "outcome_group_title", + description: "outcome_group_description" } ], - "edges": [ + edges: [ { "$canvas_learning_outcome_link_id": "1002", "$canvas_learning_outcome_id": "1000", @@ -104,10 +104,10 @@ RSpec.describe 'Outcomes Service - POST Content Import', :pact do end let(:expected_import_post_response_body) do { - "id": Pact.like(1), - "context_type": "course", - "context_id": Pact.like("100"), - "state": "created" + id: Pact.like(1), + context_type: "course", + context_id: Pact.like("100"), + state: "created" } end let!(:course) { course_factory(active_course: true) } diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index ce4857c27fd..6d0992182fa 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -63,7 +63,7 @@ describe AccountsController do it "removes user from the account" do user_with_pseudonym :account => @account post 'remove_user', params: { :account_id => @account.id, :user_id => @user.id } - expect(flash[:notice]).to match /successfully deleted/ + expect(flash[:notice]).to match(/successfully deleted/) expect(response).to redirect_to(account_users_url(@account)) expect(@user.associated_accounts.map(&:id)).not_to include(@account.id) end @@ -93,7 +93,7 @@ describe AccountsController do user_with_pseudonym :account => @account, :username => "nobody@example.com" pseudonym @user, :account => @other_account, :username => "nobody2@example.com" post 'remove_user', params: { :account_id => @account.id, :user_id => @user.id } - expect(flash[:notice]).to match /successfully deleted/ + expect(flash[:notice]).to match(/successfully deleted/) expect(response).to redirect_to(account_users_url(@account)) expect(@user.associated_accounts.map(&:id)).not_to include(@account.id) expect(@user.associated_accounts.map(&:id)).to include(@other_account.id) @@ -117,7 +117,7 @@ describe AccountsController do it "removes users with managed passwords with html" do user_with_managed_pseudonym :account => @account post 'remove_user', params: { :account_id => @account.id, :user_id => @user.id } - expect(flash[:notice]).to match /successfully deleted/ + expect(flash[:notice]).to match(/successfully deleted/) expect(response).to redirect_to(account_users_url(@account)) expect(@user.associated_accounts.map(&:id)).not_to include(@account.id) end @@ -126,7 +126,7 @@ describe AccountsController do Timecop.freeze do user_with_managed_pseudonym :account => @account, :name => "John Doe" post 'remove_user', params: { :account_id => @account.id, :user_id => @user.id }, :format => "json" - expect(flash[:notice]).to match /successfully deleted/ + expect(flash[:notice]).to match(/successfully deleted/) expect(json_parse(response.body)).to eq json_parse(@user.reload.to_json) expect(@user.associated_accounts.map(&:id)).to_not include(@account.id) end diff --git a/spec/controllers/announcements_controller_spec.rb b/spec/controllers/announcements_controller_spec.rb index d092d284815..cc15630ae70 100644 --- a/spec/controllers/announcements_controller_spec.rb +++ b/spec/controllers/announcements_controller_spec.rb @@ -78,7 +78,7 @@ describe AnnouncementsController do it "requires authorization" do get 'public_feed', :format => 'atom', params: { :feed_code => @enrollment.feed_code + 'x' } - expect(assigns[:problem]).to match /The verification code does not match/ + expect(assigns[:problem]).to match(/The verification code does not match/) end it "includes absolute path for rel='self' link" do diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index fdf31269250..17892ae0c1e 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -515,7 +515,7 @@ RSpec.describe ApplicationController do expect(HostUrl).to receive(:file_host_with_shard).with(42, '').and_return(['myfiles', Shard.default]) controller.instance_variable_set(:@domain_root_account, 42) url = controller.send(:safe_domain_file_url, @attachment) - expect(url).to match /myfiles/ + expect(url).to match(/myfiles/) end it "includes :download=>1 in inline urls for relative contexts" do @@ -792,7 +792,7 @@ RSpec.describe ApplicationController do let(:course) { course_model } before do - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) allow(course).to receive(:grants_right?).and_return true Account.site_admin.enable_feature!(:new_quizzes_modules_support) end @@ -901,7 +901,7 @@ RSpec.describe ApplicationController do allow(controller).to receive(:named_context_url).and_return('wrong_url') allow(controller).to receive(:render) allow(controller).to receive_messages(js_env: []) - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) allow(content_tag).to receive(:id).and_return(42) allow(controller).to receive(:require_user) { user_model } allow(controller).to receive(:lti_launch_params) { {} } @@ -993,7 +993,7 @@ RSpec.describe ApplicationController do allow(controller).to receive(:render) allow(controller).to receive_messages(js_env: []) - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) allow(content_tag).to receive(:id).and_return(42) allow(controller).to receive(:require_user) { user_model } controller.instance_variable_set(:@current_user, user) @@ -1132,7 +1132,6 @@ RSpec.describe ApplicationController do end end end - # rubocop:enable RSpec/NestedGroups end it 'creates a basic lti launch request when tool is not configured to use LTI 1.3' do @@ -1148,7 +1147,7 @@ RSpec.describe ApplicationController do context 'return_url' do before do - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) content_tag.update!(context: assignment_model) allow(content_tag.context).to receive(:quiz_lti?).and_return(true) allow(controller).to receive(:render) @@ -1330,7 +1329,7 @@ RSpec.describe ApplicationController do ).and_return('wrong_url') allow(controller).to receive(:render) allow(controller).to receive_messages(js_env: []) - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) controller.send(:content_tag_redirect, course, content_tag, nil) end @@ -1338,7 +1337,7 @@ RSpec.describe ApplicationController do allow(controller).to receive(:named_context_url).and_return('wrong_url') allow(controller).to receive(:render) allow(controller).to receive_messages(js_env: []) - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) allow(content_tag).to receive(:id).and_return(42) controller.send(:content_tag_redirect, course, content_tag, nil) expect(assigns[:lti_launch].params["resource_link_id"]).to eq 'e62d81a8a1587cdf9d3bbc3de0ef303d6bc70d78' @@ -1348,7 +1347,7 @@ RSpec.describe ApplicationController do allow(controller).to receive(:named_context_url).and_return('wrong_url') allow(controller).to receive(:render) allow(controller).to receive_messages(js_env: []) - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) allow(content_tag).to receive(:id).and_return(42) controller.send(:content_tag_redirect, course, content_tag, nil) expect(assigns[:lti_launch].params["custom_test_token"]).to be_present @@ -1359,7 +1358,7 @@ RSpec.describe ApplicationController do allow(controller).to receive(:named_context_url).and_return(tool.url) allow(controller).to receive(:render) allow(controller).to receive_messages(js_env: []) - controller.instance_variable_set(:"@context", course) + controller.instance_variable_set(:@context, course) allow(content_tag).to receive(:id).and_return(42) end @@ -1435,12 +1434,12 @@ RSpec.describe ApplicationController do describe 'external_tool_display_hash' do def tool_settings(setting, include_class = false) settings_hash = { - url: "http://example.com/?#{setting.to_s}", - icon_url: "http://example.com/icon.png?#{setting.to_s}", + url: "http://example.com/?#{setting}", + icon_url: "http://example.com/icon.png?#{setting}", enabled: true } - settings_hash[:canvas_icon_class] = "icon-#{setting.to_s}" if include_class + settings_hash[:canvas_icon_class] = "icon-#{setting}" if include_class settings_hash end @@ -1477,8 +1476,8 @@ RSpec.describe ApplicationController do it 'all settings are correct' do @tool_settings.each do |setting| hash = controller.external_tool_display_hash(@tool, setting) - expect(hash[:base_url]).to eq "http://test.host/courses/#{@course.id}/external_tools/#{@tool.id}?launch_type=#{setting.to_s}" - expect(hash[:icon_url]).to eq "http://example.com/icon.png?#{setting.to_s}" + expect(hash[:base_url]).to eq "http://test.host/courses/#{@course.id}/external_tools/#{@tool.id}?launch_type=#{setting}" + expect(hash[:icon_url]).to eq "http://example.com/icon.png?#{setting}" expect(hash[:canvas_icon_class]).to be nil end end @@ -1497,9 +1496,9 @@ RSpec.describe ApplicationController do @tool.save! hash = controller.external_tool_display_hash(@tool, setting) - expect(hash[:base_url]).to eq "http://test.host/courses/#{@course.id}/external_tools/#{@tool.id}?launch_type=#{setting.to_s}" - expect(hash[:icon_url]).to eq "http://example.com/icon.png?#{setting.to_s}" - expect(hash[:canvas_icon_class]).to eq "icon-#{setting.to_s}" + expect(hash[:base_url]).to eq "http://test.host/courses/#{@course.id}/external_tools/#{@tool.id}?launch_type=#{setting}" + expect(hash[:icon_url]).to eq "http://example.com/icon.png?#{setting}" + expect(hash[:canvas_icon_class]).to eq "icon-#{setting}" end end end diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index 476ebd80c3d..6cbbff0c15f 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -261,7 +261,7 @@ describe ConferencesController do @conference = @course.web_conferences.create!(:conference_type => 'Wimba', :duration => 60, :user => @teacher) post 'join', params: { :course_id => @course.id, :conference_id => @conference.id } expect(response).to be_redirect - expect(response['Location']).to match /wimba\.test/ + expect(response['Location']).to match(/wimba\.test/) end it "lets students join an inactive long running conference" do @@ -272,7 +272,7 @@ describe ConferencesController do allow_any_instance_of(WimbaConference).to receive(:conference_status).and_return(:closed) post 'join', params: { :course_id => @course.id, :conference_id => @conference.id } expect(response).to be_redirect - expect(response['Location']).to match /wimba\.test/ + expect(response['Location']).to match(/wimba\.test/) end describe 'when student is part of the conference' do @@ -289,7 +289,7 @@ describe ConferencesController do expect_any_instance_of(WimbaConference).to receive(:active?).and_return(false) post 'join', params: { :course_id => @course.id, :conference_id => @conference.id } expect(response).to be_redirect - expect(response['Location']).not_to match /wimba\.test/ + expect(response['Location']).not_to match(/wimba\.test/) expect(flash[:notice]).to match(/That conference is not currently active/) end @@ -302,7 +302,7 @@ describe ConferencesController do it "lets students join an active conference" do expect(response).to be_redirect - expect(response['Location']).to match /wimba\.test/ + expect(response['Location']).to match(/wimba\.test/) end it 'logs an asset access record for the discussion topic' do diff --git a/spec/controllers/courses_controller_spec.rb b/spec/controllers/courses_controller_spec.rb index 0d70fbb4dff..5443ce433e1 100644 --- a/spec/controllers/courses_controller_spec.rb +++ b/spec/controllers/courses_controller_spec.rb @@ -2806,10 +2806,10 @@ describe CoursesController do { 'assignment' => { 'content' => '1', 'due_dates' => '1' }, 'quiz' => { 'content' => '1' } } } }, :format => 'json' expect(response).to be_successful template = MasterCourses::MasterTemplate.full_template_for(@course) - expect(template.default_restrictions_by_type).to eq ({ - "Assignment" => { :content => true, :due_dates => true }, - "Quizzes::Quiz" => { :content => true } - }) + expect(template.default_restrictions_by_type).to eq({ + "Assignment" => { :content => true, :due_dates => true }, + "Quizzes::Quiz" => { :content => true } + }) end it "validates default template restrictions by object type" do @@ -3069,7 +3069,7 @@ describe CoursesController do it "requires authorization" do get 'public_feed', params: { :feed_code => @enrollment.feed_code + 'x' }, :format => 'atom' - expect(assigns[:problem]).to match /The verification code does not match/ + expect(assigns[:problem]).to match(/The verification code does not match/) end it "includes absolute path for rel='self' link" do diff --git a/spec/controllers/discussion_topics_controller_spec.rb b/spec/controllers/discussion_topics_controller_spec.rb index 03fefbbd426..e83bd0a1b60 100644 --- a/spec/controllers/discussion_topics_controller_spec.rb +++ b/spec/controllers/discussion_topics_controller_spec.rb @@ -1889,7 +1889,7 @@ describe DiscussionTopicsController do expect(response).to be_successful json = JSON.parse(response.body) new_file = Attachment.find(json['attachments'][0]['id']) - expect(new_file.display_name).to match /txt-[0-9]+\.txt/ + expect(new_file.display_name).to match(/txt-[0-9]+\.txt/) expect(json['attachments'][0]['display_name']).to eq new_file.display_name end @@ -1968,7 +1968,7 @@ describe DiscussionTopicsController do t1, t2, _ = topics post 'reorder', params: { :course_id => @course.id, :order => "#{t2.id},#{t1.id}" }, :format => 'json' expect(response).to be_successful - topics.each &:reload + topics.each(&:reload) expect(topics.map(&:position)).to eq [2, 1, 3] end end diff --git a/spec/controllers/external_tools_controller_spec.rb b/spec/controllers/external_tools_controller_spec.rb index 08aeed0e930..c78f5f76869 100644 --- a/spec/controllers/external_tools_controller_spec.rb +++ b/spec/controllers/external_tools_controller_spec.rb @@ -2324,7 +2324,7 @@ describe ExternalToolsController do it { is_expected.to include "display=borderless" } - it { is_expected.to match /session_token=\w+/ } + it { is_expected.to match(/session_token=\w+/) } end end end diff --git a/spec/controllers/files_controller_spec.rb b/spec/controllers/files_controller_spec.rb index a61e70c6579..f7c2995cea8 100644 --- a/spec/controllers/files_controller_spec.rb +++ b/spec/controllers/files_controller_spec.rb @@ -416,7 +416,7 @@ describe FilesController do user_session(@teacher) get 'show', params: { course_id: @course.id, id: @old_file.id, preview: 1 } expect(response).to be_redirect - expect(response.location).to match /\/courses\/#{@course.id}\/files\/#{@file.id}/ + expect(response.location).to match(/\/courses\/#{@course.id}\/files\/#{@file.id}/) end describe "as a student" do diff --git a/spec/controllers/gradebooks_controller_spec.rb b/spec/controllers/gradebooks_controller_spec.rb index f41622165b2..703c7a5b170 100644 --- a/spec/controllers/gradebooks_controller_spec.rb +++ b/spec/controllers/gradebooks_controller_spec.rb @@ -1586,9 +1586,9 @@ describe GradebooksController do student2 = student_in_course(active_all: true, name: "Ron").user student3 = student_in_course(active_all: true, name: "Don").user @teacher.set_preference(:gradebook_settings, @course.global_id, { - "sort_rows_by_column_id": "student", - "sort_rows_by_setting_key": "name", - "sort_rows_by_direction": "descending" + sort_rows_by_column_id: "student", + sort_rows_by_setting_key: "name", + sort_rows_by_direction: "descending" }) user_session(@teacher) diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index a463ad8d8e2..5365740e26e 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -708,7 +708,7 @@ describe GroupsController do it "requires authorization" do get 'public_feed', params: { :feed_code => @group.feed_code + 'x' }, format: 'atom' - expect(assigns[:problem]).to match /The verification code is invalid/ + expect(assigns[:problem]).to match(/The verification code is invalid/) end it "includes absolute path for rel='self' link" do diff --git a/spec/controllers/internet_image_controller_spec.rb b/spec/controllers/internet_image_controller_spec.rb index 60489bad016..1224080c0e7 100644 --- a/spec/controllers/internet_image_controller_spec.rb +++ b/spec/controllers/internet_image_controller_spec.rb @@ -83,19 +83,19 @@ describe InternetImageController do end it 'sends the app key as a client id header' do - stub_request(:get, "https://api.unsplash.com/search/photos?page=1&per_page=10&query=cats").with(headers: { 'Authorization': 'Client-ID key' }) + stub_request(:get, "https://api.unsplash.com/search/photos?page=1&per_page=10&query=cats").with(headers: { Authorization: 'Client-ID key' }) get 'image_search', params: { query: 'cats' } expect(WebMock).to have_requested(:get, "https://api.unsplash.com/search/photos?content_filter=high&page=1&per_page=10&query=cats") - .with(headers: { 'Authorization': 'Client-ID key' }).once + .with(headers: { Authorization: 'Client-ID key' }).once end it 'reads params back correctly' do begin WebMock::Config.instance.query_values_notation = :flat_array - stub_request(:get, "https://api.unsplash.com/search/photos?page=2&per_page=18&query=cats").with(headers: { 'Authorization': 'Client-ID key' }) + stub_request(:get, "https://api.unsplash.com/search/photos?page=2&per_page=18&query=cats").with(headers: { Authorization: 'Client-ID key' }) get 'image_search', params: { "query" => 'cats', "per_page" => 18, "page" => 2, "orientation" => 'landscape' } expect(WebMock).to have_requested(:get, "https://api.unsplash.com/search/photos?content_filter=high&page=2&per_page=18&query=cats&orientation=landscape") - .with(headers: { 'Authorization': 'Client-ID key' }).once + .with(headers: { Authorization: 'Client-ID key' }).once ensure WebMock::Config.instance.query_values_notation = :subscript end @@ -115,20 +115,20 @@ describe InternetImageController do end it 'shows success message if successful' do - stub_request(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download").with(headers: { 'Authorization': 'Client-ID key' }) + stub_request(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download").with(headers: { Authorization: 'Client-ID key' }) .to_return(status: 200, headers: { 'Content-Type' => 'application/json' }) post 'image_selection', params: { id: "MNXkDmA1CTOTRxPFXAtX59DunVompzL9sdrM_Qa18WkF96Kd9ZlGD6xWDJlNgU4S3RQMdMPX4lrZ~dWUR5iRwMEGydMoD~fCYd8vLgJASKwTKsesSgTQ" } expect(WebMock).to have_requested(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download") - .with(headers: { 'Authorization': 'Client-ID key' }).once + .with(headers: { Authorization: 'Client-ID key' }).once expect(JSON.parse(response.body)).to eq({ "message" => 'Confirmation success. Thank you.' }) end it 'shows Unsplash message if Unsplash gives a 404' do - stub_request(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download").with(headers: { 'Authorization': 'Client-ID key' }) + stub_request(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download").with(headers: { Authorization: 'Client-ID key' }) .to_return(status: 404, body: "{\"errors\": [\"Couldn't find Photo\"]}", headers: { 'Content-Type' => 'application/json' }) post 'image_selection', params: { id: "MNXkDmA1CTOTRxPFXAtX59DunVompzL9sdrM_Qa18WkF96Kd9ZlGD6xWDJlNgU4S3RQMdMPX4lrZ~dWUR5iRwMEGydMoD~fCYd8vLgJASKwTKsesSgTQ" } expect(WebMock).to have_requested(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download") - .with(headers: { 'Authorization': 'Client-ID key' }).once + .with(headers: { Authorization: 'Client-ID key' }).once expect(JSON.parse(response.body)).to eq({ "message" => "Couldn't find Photo" }) end @@ -138,11 +138,11 @@ describe InternetImageController do end it 'shows 500 error if another error happens' do - stub_request(:head, "https://api.unsplash.com/photos/bPxGLgJiMI").with(headers: { 'Authorization': 'Client-ID key' }) + stub_request(:head, "https://api.unsplash.com/photos/bPxGLgJiMI").with(headers: { Authorization: 'Client-ID key' }) .to_return(status: 400) post 'image_selection', params: { id: "MNXkDmA1CTOTRxPFXAtX59DunVompzL9sdrM_Qa18WkF96Kd9ZlGD6xWDJlNgU4S3RQMdMPX4lrZ~dWUR5iRwMEGydMoD~fCYd8vLgJASKwTKsesSgTQ" } expect(WebMock).to have_requested(:head, "https://api.unsplash.com/photos/bPxGLgJiMI/download") - .with(headers: { 'Authorization': 'Client-ID key' }).once + .with(headers: { Authorization: 'Client-ID key' }).once assert_status(500) end end diff --git a/spec/controllers/lti/ims/concerns/lti_services_shared_examples.rb b/spec/controllers/lti/ims/concerns/lti_services_shared_examples.rb index d88f0988b01..0af62ff7f39 100644 --- a/spec/controllers/lti/ims/concerns/lti_services_shared_examples.rb +++ b/spec/controllers/lti/ims/concerns/lti_services_shared_examples.rb @@ -105,7 +105,7 @@ shared_examples_for "lti services" do context 'with "canvas.instructure.com" aud' do let(:universal_grant_host) { 'http://canvas.instructure.com/login/oauth2/token' } - let(:access_token_jwt_hash) { super().merge('aud': universal_grant_host) } + let(:access_token_jwt_hash) { super().merge(aud: universal_grant_host) } it 'returns 200 success' do expect(response).to have_http_status http_success_status diff --git a/spec/controllers/lti/ims/deep_linking_controller_spec.rb b/spec/controllers/lti/ims/deep_linking_controller_spec.rb index 112394d9ec9..cc31cfa748d 100644 --- a/spec/controllers/lti/ims/deep_linking_controller_spec.rb +++ b/spec/controllers/lti/ims/deep_linking_controller_spec.rb @@ -339,7 +339,7 @@ module Lti let(:content_items) { [ { type: 'ltiResourceLink', url: launch_url, title: 'Item 1' }, - { type: 'ltiResourceLink', url: launch_url, title: 'Item 2', custom: { 'mycustom': '123' } }, + { type: 'ltiResourceLink', url: launch_url, title: 'Item 2', custom: { mycustom: '123' } }, { type: 'ltiResourceLink', url: launch_url, title: 'Item 3' } ] } diff --git a/spec/controllers/lti/ims/names_and_roles_controller_spec.rb b/spec/controllers/lti/ims/names_and_roles_controller_spec.rb index cb639814472..889eab6f904 100644 --- a/spec/controllers/lti/ims/names_and_roles_controller_spec.rb +++ b/spec/controllers/lti/ims/names_and_roles_controller_spec.rb @@ -316,7 +316,7 @@ describe Lti::Ims::NamesAndRolesController do let(:action) { :course_index } let(:context) { course } let(:context_param_name) { :course_id } - let(:unknown_context_id) { course && Course.maximum(:id) + 1 } + let(:unknown_context_id) { course && (Course.maximum(:id) + 1) } it_behaves_like 'advantage services' it_behaves_like 'lti services' @@ -871,7 +871,7 @@ describe Lti::Ims::NamesAndRolesController do let(:action) { :group_index } let(:context) { group_record } let(:context_param_name) { :group_id } - let(:unknown_context_id) { group_record && Group.maximum(:id) + 1 } + let(:unknown_context_id) { group_record && (Group.maximum(:id) + 1) } it_behaves_like 'advantage services' it_behaves_like 'lti services' diff --git a/spec/controllers/lti/public_jwk_controller_spec.rb b/spec/controllers/lti/public_jwk_controller_spec.rb index d505c178c68..c09c11ab8f1 100644 --- a/spec/controllers/lti/public_jwk_controller_spec.rb +++ b/spec/controllers/lti/public_jwk_controller_spec.rb @@ -74,7 +74,7 @@ module Lti context 'when pubic jwk is not valid' do let(:params_overrides) do - { developer_key: { public_jwk: { 'hello': 'world' } } } + { developer_key: { public_jwk: { hello: 'world' } } } end before do diff --git a/spec/controllers/lti_api_controllers_spec.rb b/spec/controllers/lti_api_controllers_spec.rb index 0a87519bdf0..c6f9b78741a 100644 --- a/spec/controllers/lti_api_controllers_spec.rb +++ b/spec/controllers/lti_api_controllers_spec.rb @@ -356,7 +356,7 @@ describe LtiApiController, type: :request do expect(response.code.to_i).to eq 422 xml = Nokogiri::XML.parse(response.body) expect(xml.at_css('imsx_codeMajor').content).to eq 'failure' - expect(xml.at_css('imsx_description').content).to match /^No score given/ + expect(xml.at_css('imsx_description').content).to match(/^No score given/) expect(@assignment.submissions.not_placeholder.where(user_id: @student)).not_to be_exists end @@ -366,7 +366,7 @@ describe LtiApiController, type: :request do expect(response.code.to_i).to eq 422 xml = Nokogiri::XML.parse(response.body) expect(xml.at_css('imsx_codeMajor').content).to eq 'failure' - expect(xml.at_css('imsx_description').content).to match /^Score is not between 0 and 1/ + expect(xml.at_css('imsx_description').content).to match(/^Score is not between 0 and 1/) expect(@assignment.submissions.not_placeholder.where(user_id: @student)).not_to be_exists end @@ -377,7 +377,7 @@ describe LtiApiController, type: :request do expect(response.code.to_i).to eq 422 xml = Nokogiri::XML.parse(response.body) expect(xml.at_css('imsx_codeMajor').content).to eq 'failure' - expect(xml.at_css('imsx_description').content).to match /^Assignment has no points possible\./ + expect(xml.at_css('imsx_description').content).to match(/^Assignment has no points possible\./) end it "passes if assignment has 0 points possible" do @@ -511,7 +511,7 @@ describe LtiApiController, type: :request do check_success submission = @assignment.submissions.where(user_id: @student).first expect(submission).to be_present - expect(submission.score).to eq -7 + expect(submission.score).to eq(-7) end end end diff --git a/spec/controllers/oauth2_provider_controller_spec.rb b/spec/controllers/oauth2_provider_controller_spec.rb index 75025805bc6..ffdcc5e1d0c 100644 --- a/spec/controllers/oauth2_provider_controller_spec.rb +++ b/spec/controllers/oauth2_provider_controller_spec.rb @@ -31,14 +31,14 @@ describe Oauth2ProviderController do it 'renders a 401 when there is no client_id' do get :auth assert_status(401) - expect(response.body).to match /unknown client/ + expect(response.body).to match(/unknown client/) expect(response['WWW-Authenticate']).to_not be_blank end it 'renders 400 on a bad redirect_uri' do get :auth, params: { :client_id => key.id } assert_status(400) - expect(response.body).to match /redirect_uri does not match/ + expect(response.body).to match(/redirect_uri does not match/) end context 'with invalid scopes' do diff --git a/spec/controllers/quizzes/quiz_questions_controller_spec.rb b/spec/controllers/quizzes/quiz_questions_controller_spec.rb index 06ee30f6760..4d63e0cf31d 100644 --- a/spec/controllers/quizzes/quiz_questions_controller_spec.rb +++ b/spec/controllers/quizzes/quiz_questions_controller_spec.rb @@ -114,7 +114,7 @@ describe Quizzes::QuizQuestionsController do post 'create', params: { course_id: @course.id, quiz_id: @quiz, question: { question_text: long_data } }, xhr: true - expect(response.body).to match /max length is 16384/ + expect(response.body).to match(/max length is 16384/) end it 'strips the origin from local URLs in answers' do @@ -221,7 +221,7 @@ describe Quizzes::QuizQuestionsController do put 'update', params: { course_id: @course.id, quiz_id: @quiz, id: @question.id, question: { question_text: long_data } }, xhr: true - expect(response.body).to match /max length is 16384/ + expect(response.body).to match(/max length is 16384/) end it "deletes non-html comments if needed" do @@ -254,7 +254,7 @@ describe Quizzes::QuizQuestionsController do translated_text = aq.reload.question_data['question_text'] expect(translated_text).to match %r{/assessment_questions/\d+/files/\d+} - expect(translated_text).to match /verifier=/ + expect(translated_text).to match(/verifier=/) # add the first question directly onto the quiz, so it shouldn't get "randomly" selected from the group linked_question = @quiz.quiz_questions.build(:question_data => aq.question_data) diff --git a/spec/controllers/quizzes/quizzes_controller_spec.rb b/spec/controllers/quizzes/quizzes_controller_spec.rb index c7b20c64ad5..9da00b31a28 100644 --- a/spec/controllers/quizzes/quizzes_controller_spec.rb +++ b/spec/controllers/quizzes/quizzes_controller_spec.rb @@ -525,7 +525,7 @@ describe Quizzes::QuizzesController do course_quiz !!:active get 'show', params: { :course_id => @course.id, :id => @quiz.id, :force_user => 1 } expect(response).to be_redirect - expect(response.location).to match /login/ + expect(response.location).to match(/login/) end it "renders the show page for public courses" do diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index dafce3481bf..c64e5a78a0d 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -88,7 +88,7 @@ describe SearchController do course_with_student_logged_in(:active_all => true) @enrollment.update(workflow_state: 'deleted') get 'recipients', params: { search: 'foo', :context => @course.asset_string } - expect(response.body).to match /\[\]\z/ + expect(response.body).to match(/\[\]\z/) end it "handles groups in courses without messageable enrollments" do @@ -111,7 +111,7 @@ describe SearchController do :type => 'section', :skip_visibility_checks => true, :synthetic_contexts => true, :context => "course_#{@course.id}_sections" } - expect(response.body).to match /\[\]\z/ + expect(response.body).to match(/\[\]\z/) end it "returns sub-contexts" do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 7a9878dad17..97d0afbb164 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1974,7 +1974,7 @@ describe UsersController do it "requires authorization" do get 'public_feed', params: { :feed_code => @user.feed_code + 'x' }, format: 'atom' - expect(assigns[:problem]).to match /The verification code is invalid/ + expect(assigns[:problem]).to match(/The verification code is invalid/) end it "includes absolute path for rel='self' link" do diff --git a/spec/factories.rb b/spec/factories.rb index 12ae5c14ff6..9304e3cbeb7 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -73,7 +73,7 @@ module Factories end legit_global_methods = Object.private_methods -Dir[File.dirname(__FILE__) + "/factories/**/*.rb"].each { |f| require f } +Dir[File.dirname(__FILE__) + "/factories/**/*.rb"].sort.each { |f| require f } crap_factories = (Object.private_methods - legit_global_methods) if crap_factories.present? $stderr.puts "\e[31mError: Don't create global factories/helpers" diff --git a/spec/factories/calendar_event_factory.rb b/spec/factories/calendar_event_factory.rb index 6de014d8c4e..1e3360f22ef 100644 --- a/spec/factories/calendar_event_factory.rb +++ b/spec/factories/calendar_event_factory.rb @@ -42,7 +42,7 @@ module Factories def appointment_model(opts = {}) appointment_group = opts[:appointment_group] || appointment_group_model(:sub_context => opts.delete(:sub_context)) - appointment_group.update(:new_appointments => [[opts[:start_at] || Time.now.utc + 1.hour, opts[:end_at] || Time.now.utc + 1.hour]]) + appointment_group.update(:new_appointments => [[opts[:start_at] || (Time.now.utc + 1.hour), opts[:end_at] || (Time.now.utc + 1.hour)]]) @appointment = appointment_group.new_appointments.first appointment_group.reload @appointment diff --git a/spec/factories/discussion_topic_factory.rb b/spec/factories/discussion_topic_factory.rb index 2c49e12026f..0badac99d58 100644 --- a/spec/factories/discussion_topic_factory.rb +++ b/spec/factories/discussion_topic_factory.rb @@ -65,7 +65,7 @@ module Factories @reply3 = @root2.reply_from(:user => @student, :html => "reply3") @reply1.destroy @all_entries = [@root1, @root2, @reply1, @reply2, @reply_reply1, @reply_reply2, @reply3] - @all_entries.each &:reload + @all_entries.each(&:reload) @topic.reload end diff --git a/spec/formatters/rerun_formatter.rb b/spec/formatters/rerun_formatter.rb index 0f25c82ac39..26f9ed2c22c 100644 --- a/spec/formatters/rerun_formatter.rb +++ b/spec/formatters/rerun_formatter.rb @@ -43,7 +43,7 @@ module RSpec end def modified_specs - @modified_specs ||= ENV["RELEVANT_SPECS"] && ENV["RELEVANT_SPECS"].split("\n") || [] + @modified_specs ||= (ENV["RELEVANT_SPECS"] && ENV["RELEVANT_SPECS"].split("\n")) || [] end end end diff --git a/spec/graphql/mutation_audit_log_spec.rb b/spec/graphql/mutation_audit_log_spec.rb index aa8fd023de2..89c88c1b099 100644 --- a/spec/graphql/mutation_audit_log_spec.rb +++ b/spec/graphql/mutation_audit_log_spec.rb @@ -95,7 +95,7 @@ describe AuditLogFieldExtension::Logger do it "sanitizes arguments" do logger = AuditLogFieldExtension::Logger.new(mutation, {}, { input: { password: "TOP SECRET" } }) - expect(logger.instance_variable_get(:@params)).to eq ({ password: "[FILTERED]" }) + expect(logger.instance_variable_get(:@params)).to eq({ password: "[FILTERED]" }) end it "truncates long text" do @@ -108,11 +108,11 @@ describe AuditLogFieldExtension::Logger do nested_hash: { a: long_string } } }) - expect(logger.instance_variable_get(:@params)).to eq ({ - string: shortened_string, - array: [shortened_string], - nested_hash: { a: shortened_string } - }) + expect(logger.instance_variable_get(:@params)).to eq({ + string: shortened_string, + array: [shortened_string], + nested_hash: { a: shortened_string } + }) end context "#log_entry_ids" do diff --git a/spec/graphql/token_scoping_spec.rb b/spec/graphql/token_scoping_spec.rb index 20de0b01e96..51526d37e4c 100644 --- a/spec/graphql/token_scoping_spec.rb +++ b/spec/graphql/token_scoping_spec.rb @@ -53,7 +53,7 @@ describe "GraphQL Token Scoping" do } } GQL - expect(result.dig("errors", 0, "message")).to match /insufficient scopes/ + expect(result.dig("errors", 0, "message")).to match(/insufficient scopes/) expect(result.dig("data", "createAssignment")).to be_nil end end diff --git a/spec/graphql/types/assignment_type_spec.rb b/spec/graphql/types/assignment_type_spec.rb index 55081033502..35ba1dd1d2a 100644 --- a/spec/graphql/types/assignment_type_spec.rb +++ b/spec/graphql/types/assignment_type_spec.rb @@ -63,7 +63,7 @@ describe Types::AssignmentType do # assignment expect( CanvasSchema.execute(<<~GQL, context: { current_user: student }).dig("data", "assignment") - query { assignment(id: "#{assignment.id.to_s}") { id } } + query { assignment(id: "#{assignment.id}") { id } } GQL ).to be_nil end diff --git a/spec/graphql/types/course_type_spec.rb b/spec/graphql/types/course_type_spec.rb index fd9e431cdf4..7de3bb24d45 100644 --- a/spec/graphql/types/course_type_spec.rb +++ b/spec/graphql/types/course_type_spec.rb @@ -49,7 +49,7 @@ describe Types::CourseType do # course expect( CanvasSchema.execute(<<~GQL, context: { current_user: @student2 }).dig("data", "course") - query { course(id: "#{course.id.to_s}") { id } } + query { course(id: "#{course.id}") { id } } GQL ).to be_nil end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 7a5594522e6..ca5d4e53985 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -44,8 +44,8 @@ describe ApplicationHelper do html = Nokogiri::HTML5.fragment("") expect(html.css('option').count).to eq 5 expect(html.css('option')[0].text).to eq @f.name - expect(html.css('option')[1].text).to match /^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_1.name}/ - expect(html.css('option')[4].text).to match /^\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_2_1_1.name}/ + expect(html.css('option')[1].text).to match(/^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_1.name}/) + expect(html.css('option')[4].text).to match(/^\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_2_1_1.name}/) end it "limits depth" do @@ -54,8 +54,8 @@ describe ApplicationHelper do html = Nokogiri::HTML5.fragment("") expect(html.css('option').count).to eq 3 expect(html.css('option')[0].text).to eq @f.name - expect(html.css('option')[1].text).to match /^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_1.name}/ - expect(html.css('option')[2].text).to match /^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_2.name}/ + expect(html.css('option')[1].text).to match(/^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_1.name}/) + expect(html.css('option')[2].text).to match(/^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_2.name}/) end it "works without supplying all folders" do @@ -64,8 +64,8 @@ describe ApplicationHelper do html = Nokogiri::HTML5.fragment("") expect(html.css('option').count).to eq 5 expect(html.css('option')[0].text).to eq @f.name - expect(html.css('option')[1].text).to match /^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_1.name}/ - expect(html.css('option')[4].text).to match /^\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_2_1_1.name}/ + expect(html.css('option')[1].text).to match(/^\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_1.name}/) + expect(html.css('option')[4].text).to match(/^\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0\xC2\xA0- #{@f_2_1_1.name}/) end end @@ -160,18 +160,18 @@ describe ApplicationHelper do it 'builds a whole time tag with a useful title showing the timezone offset if theres a context' do tag = friendly_datetime(Time.now, context: context) - expect(tag).to match /^$/ - expect(tag).to match /data-html-tooltip-title=/ - expect(tag).to match /Local: Mar 13 at 1:12am/ - expect(tag).to match /Course: Mar 13 at 3:12am/ + expect(tag).to match(/^$/) + expect(tag).to match(/data-html-tooltip-title=/) + expect(tag).to match(/Local: Mar 13 at 1:12am/) + expect(tag).to match(/Course: Mar 13 at 3:12am/) end it 'can produce an alternate tag type' do tag = friendly_datetime(Time.now, context: context, tag_type: :span) - expect(tag).to match /^$/ - expect(tag).to match /data-html-tooltip-title=/ - expect(tag).to match /Local: Mar 13 at 1:12am/ - expect(tag).to match /Course: Mar 13 at 3:12am/ + expect(tag).to match(/^$/) + expect(tag).to match(/data-html-tooltip-title=/) + expect(tag).to match(/Local: Mar 13 at 1:12am/) + expect(tag).to match(/Course: Mar 13 at 3:12am/) end it 'produces no tooltip for a nil datetime' do diff --git a/spec/helpers/attachment_helper_spec.rb b/spec/helpers/attachment_helper_spec.rb index 0fdc2737695..2f769d19106 100644 --- a/spec/helpers/attachment_helper_spec.rb +++ b/spec/helpers/attachment_helper_spec.rb @@ -33,18 +33,18 @@ describe AttachmentHelper do @current_user = @student allow(@att).to receive(:crocodoc_available?).and_return(true) attrs = doc_preview_attributes(@att) - expect(attrs).to match /crocodoc_session/ - expect(attrs).to match /#{@current_user.id}/ - expect(attrs).to match /#{@att.id}/ + expect(attrs).to match(/crocodoc_session/) + expect(attrs).to match(/#{@current_user.id}/) + expect(attrs).to match(/#{@att.id}/) end it "returns a valid canvadoc session url" do @current_user = @student allow(@att).to receive(:canvadocable?).and_return(true) attrs = doc_preview_attributes(@att) - expect(attrs).to match /canvadoc_session/ - expect(attrs).to match /#{@current_user.id}/ - expect(attrs).to match /#{@att.id}/ + expect(attrs).to match(/canvadoc_session/) + expect(attrs).to match(/#{@current_user.id}/) + expect(attrs).to match(/#{@att.id}/) end it "includes anonymous_instructor_annotations in canvadoc url" do diff --git a/spec/helpers/context_external_tools_helper_spec.rb b/spec/helpers/context_external_tools_helper_spec.rb index ba6c1b6ac90..7f660c0c8f2 100644 --- a/spec/helpers/context_external_tools_helper_spec.rb +++ b/spec/helpers/context_external_tools_helper_spec.rb @@ -99,7 +99,7 @@ describe ContextExternalToolsHelper do enabled: true } - settings_hash[:canvas_icon_class] = "icon-#{setting.to_s}" if include_class + settings_hash[:canvas_icon_class] = "icon-#{setting}" if include_class settings_hash end diff --git a/spec/helpers/quizzes_helper_spec.rb b/spec/helpers/quizzes_helper_spec.rb index 69410d155a9..b1121eea3bf 100644 --- a/spec/helpers/quizzes_helper_spec.rb +++ b/spec/helpers/quizzes_helper_spec.rb @@ -230,8 +230,8 @@ describe QuizzesHelper do :answers => @answers ) - expect(html).to match /aria\-label/ - expect(html).to match /Fill in the blank/ + expect(html).to match(/aria\-label/) + expect(html).to match(/Fill in the blank/) end it 'handles equation img tags in the question text' do broken_question_text = "\"

Rubisco is a responsible for the first enzymatic step of carbon .

equation here: \\\"\\sum\\frac{k}{l}\\\"

\"" @@ -244,9 +244,9 @@ describe QuizzesHelper do answer_list: @answer_list, answers: @answers ) - expect(html).to match /"readonly"/ - expect(html).to match /value='fixing'/ - expect(html).to match /value='protein'/ + expect(html).to match(/"readonly"/) + expect(html).to match(/value='fixing'/) + expect(html).to match(/value='protein'/) end it "sanitizes the answer blocks in the noisy question data" do broken_question_text = "

\"Roses are \n, violets are \n\")

" @@ -274,7 +274,7 @@ describe QuizzesHelper do answer_list: ['val'], editable: true }) - expect(html).to eq 'some ' # rubocop:disable Layout/LineLength + expect(html).to eq 'some ' expect(html).to be_html_safe end @@ -286,7 +286,7 @@ describe QuizzesHelper do answer_list: ['val'], editable: true }) - expect(html).to eq 'some ' # rubocop:disable Layout/LineLength + expect(html).to eq 'some ' expect(html).to be_html_safe end @@ -437,7 +437,7 @@ describe QuizzesHelper do quiz_submission = double(last_attempt_completed?: false) message = render_correct_answer_protection(quiz, quiz_submission) - expect(message).to match /last attempt/ + expect(message).to match(/last attempt/) end it 'provides a useful message when "no"' do quiz = double({ @@ -449,7 +449,7 @@ describe QuizzesHelper do quiz_submission = double(last_attempt_completed?: false) message = render_correct_answer_protection(quiz, quiz_submission) - expect(message).to match /are hidden/ + expect(message).to match(/are hidden/) end it 'provides nothing when "yes"' do @@ -475,7 +475,7 @@ describe QuizzesHelper do quiz_submission = double(last_attempt_completed?: false) message = render_correct_answer_protection(quiz, quiz_submission) - expect(message).to match /will be available/ + expect(message).to match(/will be available/) end it 'provides a useful message, and a date, when "hide at" is set' do @@ -488,7 +488,7 @@ describe QuizzesHelper do quiz_submission = double(last_attempt_completed?: false) message = render_correct_answer_protection(quiz, quiz_submission) - expect(message).to match /are available until/ + expect(message).to match(/are available until/) end end diff --git a/spec/helpers/stream_items_helper_spec.rb b/spec/helpers/stream_items_helper_spec.rb index f1a007be297..ddae6825339 100644 --- a/spec/helpers/stream_items_helper_spec.rb +++ b/spec/helpers/stream_items_helper_spec.rb @@ -197,7 +197,7 @@ describe StreamItemsHelper do @categorized = helper.categorize_stream_items(@items, @teacher) expect(@categorized["Announcement"].first.summary).to eq @announcement.title expect(@categorized["Conversation"].first.summary).to eq @participant.last_message.body - expect(@categorized["Assignment"].first.summary).to match /Assignment Created/ + expect(@categorized["Assignment"].first.summary).to match(/Assignment Created/) expect(@categorized["DiscussionTopic"].first.summary).to eq @discussion.title expect(@categorized["DiscussionEntry"].first.summary).to eq "#{@other_user.short_name} mentioned you in #{@discussion.title}." expect(@categorized["AssessmentRequest"].first.summary).to include(@assignment.title) diff --git a/spec/integration/context_module_spec.rb b/spec/integration/context_module_spec.rb index 8de1e25728e..910ab5a9bed 100644 --- a/spec/integration/context_module_spec.rb +++ b/spec/integration/context_module_spec.rb @@ -271,8 +271,8 @@ describe ContextModule do expect(response).to be_successful body2 = Nokogiri::HTML5(response.body) - expect(body1.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /4am/ - expect(body2.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /7am/ + expect(body1.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match(/4am/) + expect(body2.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match(/7am/) end end end diff --git a/spec/integration/enrollment_date_restrictions_spec.rb b/spec/integration/enrollment_date_restrictions_spec.rb index ace0254f765..1b76f569551 100644 --- a/spec/integration/enrollment_date_restrictions_spec.rb +++ b/spec/integration/enrollment_date_restrictions_spec.rb @@ -48,7 +48,7 @@ describe "enrollment_date_restrictions" do active_enrollments = page.css("#my_courses_table tbody tr") expect(active_enrollments.length).to eq 1 # Make sure that the active courses have the star column. - expect(active_enrollments[0].css('td')[0]['class']).to match /star-column/ + expect(active_enrollments[0].css('td')[0]['class']).to match(/star-column/) expect(page.css(".past_enrollments tr")).to be_empty end @@ -100,8 +100,8 @@ describe "enrollment_date_restrictions" do Account.default.account_users.create!(user: @user) @user.reload get "/users/#{@user.id}" - expect(response.body).to match /Completed/ - expect(response.body).to match /Active/ + expect(response.body).to match(/Completed/) + expect(response.body).to match(/Active/) end it "does not included date-inactive courses when searching for pertinent contexts" do diff --git a/spec/integration/files_spec.rb b/spec/integration/files_spec.rb index 87e49a8e8fe..80c96808dcc 100644 --- a/spec/integration/files_spec.rb +++ b/spec/integration/files_spec.rb @@ -163,7 +163,7 @@ describe FilesController do get "http://test.host/users/#{@me.id}/files/#{@att.id}/download?download_frd=1&verifier=#{@att.uuid}" expect(response).to be_redirect get response['Location'] - expect(response.headers['Content-Disposition']).to match /attachment/ + expect(response.headers['Content-Disposition']).to match(/attachment/) end end end diff --git a/spec/integration/groups_spec.rb b/spec/integration/groups_spec.rb index 3ddc372bbc2..cc545b69cb1 100644 --- a/spec/integration/groups_spec.rb +++ b/spec/integration/groups_spec.rb @@ -44,7 +44,7 @@ describe GroupsController do g1 = @course.groups.create!(:name => "some group", :group_category => category1) get "/courses/#{@course.id}/groups/#{g1.id}?join=1" - expect(response.body).not_to match /This group has received your request to join/ + expect(response.body).not_to match(/This group has received your request to join/) end end diff --git a/spec/integration/security_spec.rb b/spec/integration/security_spec.rb index 2b90eba0806..b696b51a7ec 100644 --- a/spec/integration/security_spec.rb +++ b/spec/integration/security_spec.rb @@ -552,7 +552,7 @@ describe "security" do it "role_overrides" do get "/accounts/#{Account.site_admin.id}/settings" expect(response).to be_successful - expect(response.body).not_to match /Permissions/ + expect(response.body).not_to match(/Permissions/) get "/accounts/#{Account.site_admin.id}/role_overrides" assert_status(401) @@ -564,7 +564,7 @@ describe "security" do get "/accounts/#{Account.site_admin.id}/settings" expect(response).to be_successful - expect(response.body).to match /Permissions/ + expect(response.body).to match(/Permissions/) end end @@ -580,7 +580,7 @@ describe "security" do get "/accounts/#{Account.default.id}/statistics" expect(response).to be_successful - expect(response.body).not_to match /Recently Logged-In Users/ + expect(response.body).not_to match(/Recently Logged-In Users/) add_permission :read_roster @@ -592,7 +592,7 @@ describe "security" do get "/accounts/#{Account.default.id}/statistics" expect(response).to be_successful - expect(response.body).to match /Recently Logged-In Users/ + expect(response.body).to match(/Recently Logged-In Users/) end it "read_course_list" do @@ -605,19 +605,19 @@ describe "security" do get "/accounts/#{Account.default.id}/statistics" expect(response).to be_successful - expect(response.body).not_to match /Recently Started Courses/ - expect(response.body).not_to match /Recently Ended Courses/ + expect(response.body).not_to match(/Recently Started Courses/) + expect(response.body).not_to match(/Recently Ended Courses/) add_permission :read_course_list get "/accounts/#{Account.default.id}" expect(response).to be_successful - expect(response.body).to match /Courses/ + expect(response.body).to match(/Courses/) get "/accounts/#{Account.default.id}/statistics" expect(response).to be_successful - expect(response.body).to match /Recently Started Courses/ - expect(response.body).to match /Recently Ended Courses/ + expect(response.body).to match(/Recently Started Courses/) + expect(response.body).to match(/Recently Ended Courses/) end it "view_statistics" do @@ -626,7 +626,7 @@ describe "security" do get "/accounts/#{Account.default.id}/settings" expect(response).to be_successful - expect(response.body).not_to match /Statistics/ + expect(response.body).not_to match(/Statistics/) add_permission :view_statistics @@ -635,7 +635,7 @@ describe "security" do get "/accounts/#{Account.default.id}/settings" expect(response).to be_successful - expect(response.body).to match /Statistics/ + expect(response.body).to match(/Statistics/) end it "manage_user_notes" do @@ -650,7 +650,7 @@ describe "security" do get "/accounts/#{Account.default.id}/settings" expect(response).to be_successful - expect(response.body).not_to match /Faculty Journal/ + expect(response.body).not_to match(/Faculty Journal/) get "/users/#{@student.id}/user_notes" assert_status(401) @@ -671,7 +671,7 @@ describe "security" do get "/accounts/#{Account.default.id}/settings" expect(response).to be_successful - expect(response.body).to match /Faculty Journal/ + expect(response.body).to match(/Faculty Journal/) get "/users/#{@student.id}/user_notes" expect(response).to be_successful @@ -739,7 +739,7 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).not_to match /People/ + expect(response.body).not_to match(/People/) html = Nokogiri::HTML5(response.body) expect(html.css('#tab-users')).to be_empty @@ -747,9 +747,9 @@ describe "security" do get "/courses/#{@course.id}/users" expect(response).to be_successful - expect(response.body).to match /View User Groups/ - expect(response.body).to match /View Prior Enrollments/ - expect(response.body).not_to match /Manage Users/ + expect(response.body).to match(/View User Groups/) + expect(response.body).to match(/View Prior Enrollments/) + expect(response.body).not_to match(/Manage Users/) get "/courses/#{@course.id}/users/prior" expect(response).to be_successful @@ -759,7 +759,7 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /People/ + expect(response.body).to match(/People/) end it "manage_students" do @@ -774,7 +774,7 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).not_to match /People/ + expect(response.body).not_to match(/People/) add_permission :manage_students @@ -788,8 +788,8 @@ describe "security" do get "/courses/#{@course.id}/users" expect(response).to be_successful - expect(response.body).to match /View User Groups/ - expect(response.body).to match /View Prior Enrollments/ + expect(response.body).to match(/View User Groups/) + expect(response.body).to match(/View Prior Enrollments/) get "/courses/#{@course.id}/users/prior" expect(response).to be_successful @@ -799,7 +799,7 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /People/ + expect(response.body).to match(/People/) @course.tab_configuration = [{ :id => Course::TAB_PEOPLE, :hidden => true }] @course.save! @@ -808,7 +808,7 @@ describe "security" do # manage stuff in it get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /People/ + expect(response.body).to match(/People/) end it "Display groups and persons for students" do @@ -891,9 +891,9 @@ describe "security" do expect(html.css('.section .quizzes')).to be_empty expect(html.css('.section .discussions')).to be_empty expect(html.css('.section .files')).to be_empty - expect(response.body).not_to match /Copy this Course/ - expect(response.body).not_to match /Import Course Content/ - expect(response.body).not_to match /Export this Course/ + expect(response.body).not_to match(/Copy this Course/) + expect(response.body).not_to match(/Import Course Content/) + expect(response.body).not_to match(/Export this Course/) add_permission :read_course_content add_permission :read_roster @@ -901,14 +901,14 @@ describe "security" do get "/courses/#{@course.id}" expect(response).to be_successful - expect(response.body).to match /People/ + expect(response.body).to match(/People/) @course.tab_configuration = [{ :id => Course::TAB_PEOPLE, :hidden => true }] @course.save! get "/courses/#{@course.id}/assignments" expect(response).to be_successful - expect(response.body).to match /People/ # still has read_as_admin rights + expect(response.body).to match(/People/) # still has read_as_admin rights get "/courses/#{@course.id}/assignments/syllabus" expect(response).to be_successful @@ -940,11 +940,11 @@ describe "security" do expect(html.css('.section .quizzes')).not_to be_empty expect(html.css('.section .discussions')).not_to be_empty expect(html.css('.section .files')).not_to be_empty - expect(response.body).not_to match /Copy this Course/ - expect(response.body).not_to match /Import Course Content/ - expect(response.body).to match /Export Course Content/ - expect(response.body).not_to match /Delete this Course/ - expect(response.body).not_to match /End this Course/ + expect(response.body).not_to match(/Copy this Course/) + expect(response.body).not_to match(/Import Course Content/) + expect(response.body).to match(/Export Course Content/) + expect(response.body).not_to match(/Delete this Course/) + expect(response.body).not_to match(/End this Course/) expect(html.css('input#course_account_id')).to be_empty expect(html.css('input#course_enrollment_term_id')).to be_empty @@ -958,16 +958,16 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /Copy this Course/ - expect(response.body).not_to match /Import Course Content/ - expect(response.body).to match /Export Course Content/ - expect(response.body).to_not match /Delete this Course/ + expect(response.body).to match(/Copy this Course/) + expect(response.body).not_to match(/Import Course Content/) + expect(response.body).to match(/Export Course Content/) + expect(response.body).to_not match(/Delete this Course/) add_permission :change_course_state get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /Delete this Course/ + expect(response.body).to match(/Delete this Course/) html = Nokogiri::HTML5(response.body) expect(html.css('#course_account_id')).not_to be_empty @@ -1026,9 +1026,9 @@ describe "security" do expect(html.css('.section .quizzes')).to be_empty expect(html.css('.section .discussions')).to be_empty expect(html.css('.section .files')).to be_empty - expect(response.body).not_to match /Copy this Course/ - expect(response.body).not_to match /Import Course Content/ - expect(response.body).not_to match /Export this Course/ + expect(response.body).not_to match(/Copy this Course/) + expect(response.body).not_to match(/Import Course Content/) + expect(response.body).not_to match(/Export this Course/) add_permission :read_course_content add_permission :read_roster @@ -1036,14 +1036,14 @@ describe "security" do get "/courses/#{@course.id}" expect(response).to be_successful - expect(response.body).to match /People/ + expect(response.body).to match(/People/) @course.tab_configuration = [{ :id => Course::TAB_PEOPLE, :hidden => true }] @course.save! get "/courses/#{@course.id}/assignments" expect(response).to be_successful - expect(response.body).to match /People/ # still has read_as_admin rights + expect(response.body).to match(/People/) # still has read_as_admin rights get "/courses/#{@course.id}/assignments/syllabus" expect(response).to be_successful @@ -1075,11 +1075,11 @@ describe "security" do expect(html.css('.section .quizzes')).not_to be_empty expect(html.css('.section .discussions')).not_to be_empty expect(html.css('.section .files')).not_to be_empty - expect(response.body).not_to match /Copy this Course/ - expect(response.body).not_to match /Import Course Content/ - expect(response.body).to match /Export Course Content/ - expect(response.body).not_to match /Delete this Course/ - expect(response.body).not_to match /End this Course/ + expect(response.body).not_to match(/Copy this Course/) + expect(response.body).not_to match(/Import Course Content/) + expect(response.body).to match(/Export Course Content/) + expect(response.body).not_to match(/Delete this Course/) + expect(response.body).not_to match(/End this Course/) expect(html.css('input#course_account_id')).to be_empty expect(html.css('input#course_enrollment_term_id')).to be_empty @@ -1093,16 +1093,16 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /Copy this Course/ - expect(response.body).not_to match /Import Course Content/ - expect(response.body).to match /Export Course Content/ - expect(response.body).to_not match /Delete this Course/ + expect(response.body).to match(/Copy this Course/) + expect(response.body).not_to match(/Import Course Content/) + expect(response.body).to match(/Export Course Content/) + expect(response.body).to_not match(/Delete this Course/) add_permission :manage_courses_admin get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to_not match /Delete this Course/ + expect(response.body).to_not match(/Delete this Course/) html = Nokogiri::HTML5(response.body) expect(html.css('#course_account_id')).not_to be_empty @@ -1115,7 +1115,7 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /Delete this Course/ + expect(response.body).to match(/Delete this Course/) delete "/courses/#{@course.id}", params: { :event => 'delete' } expect(response).to be_redirect @@ -1126,7 +1126,7 @@ describe "security" do it 'manage_content' do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).not_to match /Import Course Content/ + expect(response.body).not_to match(/Import Course Content/) get "/courses/#{@course.id}/content_migrations" assert_status(401) @@ -1135,7 +1135,7 @@ describe "security" do get "/courses/#{@course.id}/details" expect(response).to be_successful - expect(response.body).to match /Import Course Content/ + expect(response.body).to match(/Import Course Content/) get "/courses/#{@course.id}/content_migrations" expect(response).to be_successful diff --git a/spec/integration/session_token_spec.rb b/spec/integration/session_token_spec.rb index 507c830a0ed..1445f9170fd 100644 --- a/spec/integration/session_token_spec.rb +++ b/spec/integration/session_token_spec.rb @@ -63,13 +63,13 @@ describe 'session token', type: :request do token = SessionToken.new(@pseudonym.id) token.created_at = 1.day.ago token.signature = Canvas::Security.hmac_sha1(token.signature_string) - get "http://test1.instructure.com/?session_token=#{token.to_s}" + get "http://test1.instructure.com/?session_token=#{token}" expect(response).to be_redirect expect(response.location).to eq 'http://test1.instructure.com/login' token = SessionToken.new(@pseudonym.id) token.pseudonym_id = @pseudonym.id - 1 - get "http://test1.instructure.com/?session_token=#{token.to_s}" + get "http://test1.instructure.com/?session_token=#{token}" expect(response).to be_redirect expect(response.location).to eq 'http://test1.instructure.com/login' end diff --git a/spec/integration/users_controller_spec.rb b/spec/integration/users_controller_spec.rb index 7e272cf7415..276390f9cce 100644 --- a/spec/integration/users_controller_spec.rb +++ b/spec/integration/users_controller_spec.rb @@ -282,8 +282,8 @@ describe UsersController do get grades_url student_grades = Nokogiri::HTML5(response.body).css('.student_grades tr') expect(student_grades.length).to eq 2 - expect(student_grades.text).to match /#{@first_course.name}/ - expect(student_grades.text).to match /#{@course.name}/ + expect(student_grades.text).to match(/#{@first_course.name}/) + expect(student_grades.text).to match(/#{@course.name}/) end it "lets an admin with view_all_grades view" do @@ -297,8 +297,8 @@ describe UsersController do get "/users/#{@student.id}/grades" student_grades = Nokogiri::HTML5(response.body).css('.student_grades tr') expect(student_grades.length).to eq 2 - expect(student_grades.text).to match /#{@first_course.name}/ - expect(student_grades.text).to match /#{@course.name}/ + expect(student_grades.text).to match(/#{@first_course.name}/) + expect(student_grades.text).to match(/#{@course.name}/) end end diff --git a/spec/lib/api/v1/sis_assignment_spec.rb b/spec/lib/api/v1/sis_assignment_spec.rb index a5aebe333f9..139f073b5f4 100644 --- a/spec/lib/api/v1/sis_assignment_spec.rb +++ b/spec/lib/api/v1/sis_assignment_spec.rb @@ -239,7 +239,7 @@ describe Api::V1::SisAssignment do user_overrides = result[0]["user_overrides"] expect(user_overrides.size).to eq 1 - expect(user_overrides.first).to include({ "id" => @override.id, "due_at": @override.due_at }) + expect(user_overrides.first).to include({ "id" => @override.id, due_at: @override.due_at }) students = user_overrides.first["students"] expect(students).to include({ "user_id" => @student1.id, 'sis_user_id' => nil }) diff --git a/spec/lib/api_spec.rb b/spec/lib/api_spec.rb index 34a8583815d..1b4d4cf7bc0 100644 --- a/spec/lib/api_spec.rb +++ b/spec/lib/api_spec.rb @@ -996,11 +996,11 @@ describe Api do :last => 10, }) expect(links.all? { |l| l =~ /www.example.com\/\?/ }).to be_truthy - expect(links.find { |l| l.match(/rel="current"/) }).to match /page=8&per_page=10>/ - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=4&per_page=10>/ - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=10>/ - expect(links.find { |l| l.match(/rel="first"/) }).to match /page=1&per_page=10>/ - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=10&per_page=10>/ + expect(links.find { |l| l.match(/rel="current"/) }).to match(/page=8&per_page=10>/) + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=4&per_page=10>/) + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=10>/) + expect(links.find { |l| l.match(/rel="first"/) }).to match(/page=1&per_page=10>/) + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=10&per_page=10>/) end it "maintains query parameters" do @@ -1043,10 +1043,10 @@ describe Api do }) expect(links.all? { |l| l =~ /www.example.com\/\?/ }).to be_truthy expect(links.find { |l| l.match(/rel="current"/) }).to be_nil - expect(links.find { |l| l.match(/rel="next"/) }).to match /page=4&per_page=10>/ - expect(links.find { |l| l.match(/rel="prev"/) }).to match /page=2&per_page=10>/ + expect(links.find { |l| l.match(/rel="next"/) }).to match(/page=4&per_page=10>/) + expect(links.find { |l| l.match(/rel="prev"/) }).to match(/page=2&per_page=10>/) expect(links.find { |l| l.match(/rel="first"/) }).to be_nil - expect(links.find { |l| l.match(/rel="last"/) }).to match /page=10&per_page=10>/ + expect(links.find { |l| l.match(/rel="last"/) }).to match(/page=10&per_page=10>/) end end diff --git a/spec/lib/app_center/app_api_spec.rb b/spec/lib/app_center/app_api_spec.rb index 19623d56791..ea9f2e42e71 100644 --- a/spec/lib/app_center/app_api_spec.rb +++ b/spec/lib/app_center/app_api_spec.rb @@ -58,7 +58,7 @@ describe AppCenter::AppApi do endpoint = '/?myparam=value' per_page = 11 page = 3 - expect(CanvasHttp).to receive(:get).with("#{api.app_center.settings['base_url']}#{endpoint}&offset=#{page * per_page - per_page}").and_return(response) + expect(CanvasHttp).to receive(:get).with("#{api.app_center.settings['base_url']}#{endpoint}&offset=#{(page * per_page) - per_page}").and_return(response) api.fetch_app_center_response(endpoint, 11.minutes, page, per_page) end @@ -79,7 +79,7 @@ describe AppCenter::AppApi do endpoint = '/?myparam=value' per_page = 1 page = 1 - offset = page * per_page - per_page + offset = (page * per_page) - per_page expect(CanvasHttp).to receive(:get).with("#{api.app_center.settings['base_url']}#{endpoint}&offset=#{offset}").and_return(response) response = api.fetch_app_center_response(endpoint, 11.minutes, page, per_page) results = response['objects'] @@ -94,7 +94,7 @@ describe AppCenter::AppApi do endpoint = '/?myparam=value' per_page = 5 page = 1 - offset = page * per_page - per_page + offset = (page * per_page) - per_page expect(CanvasHttp).to receive(:get).with("#{api.app_center.settings['base_url']}#{endpoint}&offset=#{offset}").and_return(response) response = api.fetch_app_center_response(endpoint, 11.minutes, page, per_page) results = response['objects'] diff --git a/spec/lib/canvas/apm_spec.rb b/spec/lib/canvas/apm_spec.rb index b8a6a23d1a5..27bfc4c64e7 100644 --- a/spec/lib/canvas/apm_spec.rb +++ b/spec/lib/canvas/apm_spec.rb @@ -29,8 +29,8 @@ describe Canvas::Apm do def inject_apm_settings(yaml_string) Canvas::DynamicSettings.fallback_data = { - "private": { - "canvas": { + private: { + canvas: { "datadog_apm.yml": yaml_string } } @@ -156,8 +156,8 @@ describe Canvas::Apm do around do |example| Canvas::Apm.reset! Canvas::DynamicSettings.fallback_data = { - "private": { - "canvas": { + private: { + canvas: { "datadog_apm.yml": "sample_rate: 1.0\nhost_sample_rate: 1.0" } } @@ -208,8 +208,8 @@ describe Canvas::Apm do it 'still yields if there is no configuration' do Canvas::Apm.reset! Canvas::DynamicSettings.fallback_data = { - "private": { - "canvas": { + private: { + canvas: { "datadog_apm.yml": "sample_rate: 0.0\nhost_sample_rate: 0.0" } } diff --git a/spec/lib/canvas/errors/reporter_spec.rb b/spec/lib/canvas/errors/reporter_spec.rb index 910676deca9..bae96bbb272 100644 --- a/spec/lib/canvas/errors/reporter_spec.rb +++ b/spec/lib/canvas/errors/reporter_spec.rb @@ -47,7 +47,7 @@ describe Canvas::Errors::Reporter do it "has correct backtrace" do new_class = error_instance - expect(new_class.backtrace[0]).to match /typical_usage/ + expect(new_class.backtrace[0]).to match(/typical_usage/) end it "does not mess with existing classes" do diff --git a/spec/lib/canvas/icu_spec.rb b/spec/lib/canvas/icu_spec.rb index 1bf76af50b3..7355684cc53 100644 --- a/spec/lib/canvas/icu_spec.rb +++ b/spec/lib/canvas/icu_spec.rb @@ -44,7 +44,7 @@ describe Canvas::ICU do a_prime = Canvas::ICU.collation_key(a) expect(a.object_id).not_to eq a_prime.object_id b_prime = Canvas::ICU.collation_key(b) - expect(a_prime <=> b_prime).to eq -1 + expect(a_prime <=> b_prime).to eq(-1) end it "pass-thrus CanvasSort::First" do @@ -54,11 +54,11 @@ describe Canvas::ICU do describe ".compare" do it "works" do - expect(Canvas::ICU.compare("a", "b")).to eq -1 + expect(Canvas::ICU.compare("a", "b")).to eq(-1) end it "handles CanvasSort::First" do - expect(Canvas::ICU.compare(CanvasSort::First, "a")).to eq -1 + expect(Canvas::ICU.compare(CanvasSort::First, "a")).to eq(-1) end end diff --git a/spec/lib/cc/basic_lti_links_spec.rb b/spec/lib/cc/basic_lti_links_spec.rb index 1152a5c6145..1eb778a7ebc 100644 --- a/spec/lib/cc/basic_lti_links_spec.rb +++ b/spec/lib/cc/basic_lti_links_spec.rb @@ -23,7 +23,7 @@ require 'nokogiri' describe CC::BasicLTILinks do subject { (Class.new { include CC::BasicLTILinks }).new } - let (:tool) do + let(:tool) do ContextExternalTool.new end diff --git a/spec/lib/cc/cc_exporter_spec.rb b/spec/lib/cc/cc_exporter_spec.rb index b45b27aa7c8..6067f043c95 100644 --- a/spec/lib/cc/cc_exporter_spec.rb +++ b/spec/lib/cc/cc_exporter_spec.rb @@ -45,7 +45,7 @@ describe "Common Cartridge exporting" do expect(content_export.error_messages.length).to eq 1 error = content_export.error_messages.first expect(error.first).to eq "Failed to export wiki pages" - expect(error.last).to match /ErrorReport id: \d*/ + expect(error.last).to match(/ErrorReport id: \d*/) expect(ErrorReport.last.message).to eq message end diff --git a/spec/lib/cc/cc_helper_spec.rb b/spec/lib/cc/cc_helper_spec.rb index 5fb85a713a3..eae5d880b3b 100644 --- a/spec/lib/cc/cc_helper_spec.rb +++ b/spec/lib/cc/cc_helper_spec.rb @@ -200,7 +200,7 @@ describe CC::CCHelper do ME HTML translated = @exporter.html_content(orig) - expect(translated).to match /users\/#{@teacher.id}/ + expect(translated).to match(/users\/#{@teacher.id}/) end it "interprets links to the files page as normal course pages" do diff --git a/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb b/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb index 27ca33fb91a..45cc04fcfcb 100644 --- a/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb +++ b/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb @@ -775,7 +775,7 @@ describe "Canvas Cartridge importing" do Importers::WikiPageImporter.process_migration({ 'wikis' => [hash, nil] }, @migration) @migration.resolve_content_links! - expect(ErrorReport.last.message).to match /nil wiki/ + expect(ErrorReport.last.message).to match(/nil wiki/) page_2 = @copy_to.wiki_pages.where(migration_id: migration_id).first expect(page_2.title).to eq page.title diff --git a/spec/lib/cc/importer/common_cartridge_1_3_spec.rb b/spec/lib/cc/importer/common_cartridge_1_3_spec.rb index b8183df47e1..ebd9f2d470a 100644 --- a/spec/lib/cc/importer/common_cartridge_1_3_spec.rb +++ b/spec/lib/cc/importer/common_cartridge_1_3_spec.rb @@ -137,7 +137,7 @@ describe "Standard Common Cartridge importing" do it "does not loop on circular references" do m = @course.context_modules.first - expect(m.content_tags[4].url).to match /loop(1|2)/ + expect(m.content_tags[4].url).to match(/loop(1|2)/) # also, the import finished executing. :) end end diff --git a/spec/lib/cc/schema_spec.rb b/spec/lib/cc/schema_spec.rb index c14801a502b..5f3bcc4cc7c 100644 --- a/spec/lib/cc/schema_spec.rb +++ b/spec/lib/cc/schema_spec.rb @@ -29,7 +29,7 @@ module CC end it 'returns the full filepath for valid file names' do - expect(Schema.for_version('cccv1p0').to_s).to match /lib\/cc\/xsd\/cccv1p0\.xsd/ + expect(Schema.for_version('cccv1p0').to_s).to match(/lib\/cc\/xsd\/cccv1p0\.xsd/) end end end diff --git a/spec/lib/content_zipper_spec.rb b/spec/lib/content_zipper_spec.rb index 8008edc374f..ae4a469cd29 100644 --- a/spec/lib/content_zipper_spec.rb +++ b/spec/lib/content_zipper_spec.rb @@ -135,7 +135,7 @@ describe ContentZipper do expect(attachment.workflow_state).to eq 'zipped' Zip::File.foreach(attachment.full_filename) do |f| if f.file? - expect(f.name).to match /some9991234guy/ + expect(f.name).to match(/some9991234guy/) expect(f.get_input_stream.read).to match(%r{This submission was a url}) expect(f.get_input_stream.read).to be_include("http://www.instructure.com/") end @@ -278,10 +278,10 @@ describe ContentZipper do zipper = ContentZipper.new filename = zipper.assignment_zip_filename(@assignment) - expect(filename).to match /#{@course.short_name_slug}/ - expect(filename).to match /#{@assignment.title_slug}/ - expect(filename).not_to match /#{@course.short_name}/ - expect(filename).not_to match /#{@assignment.title}/ + expect(filename).to match(/#{@course.short_name_slug}/) + expect(filename).to match(/#{@assignment.title_slug}/) + expect(filename).not_to match(/#{@course.short_name}/) + expect(filename).not_to match(/#{@assignment.title}/) end end @@ -289,7 +289,7 @@ describe ContentZipper do it "still downloads the content" do course_with_teacher @assignment = assignment_model(course: @course) - submissions = 5.times.map.with_index do |i| + submissions = 5.times do |i| attachment = attachment_model(uploaded_data: stub_png_data("file_#{i}.png"), content_type: 'image/png') submission_model(course: @course, assignment: @assignment, submission_type: 'online_upload', attachments: [attachment]) end diff --git a/spec/lib/data_fixup/populate_root_account_id_on_models_spec.rb b/spec/lib/data_fixup/populate_root_account_id_on_models_spec.rb index 26dd6a53b54..5c090890a00 100644 --- a/spec/lib/data_fixup/populate_root_account_id_on_models_spec.rb +++ b/spec/lib/data_fixup/populate_root_account_id_on_models_spec.rb @@ -1089,7 +1089,7 @@ describe DataFixup::PopulateRootAccountIdOnModels do # Cross-shard -- to be ignored (can't tell if it exists or not easily) f3 = Folder.create!(context: @course) - f3.update_columns(context_id: (Shard.last&.id.to_i + 99999) * Shard::IDS_PER_SHARD + 1) + f3.update_columns(context_id: ((Shard.last&.id.to_i + 99999) * Shard::IDS_PER_SHARD) + 1) # Course exists. Not returned. f4 = Folder.create!(context: @course) diff --git a/spec/lib/grade_calculator_coffee_spec.rb b/spec/lib/grade_calculator_coffee_spec.rb index d958ceb5bec..745e5145fd7 100644 --- a/spec/lib/grade_calculator_coffee_spec.rb +++ b/spec/lib/grade_calculator_coffee_spec.rb @@ -413,10 +413,10 @@ describe GradeCalculator do GradeCalculator.new(@user.id, @course.id).compute_and_save_scores enrollment = Enrollment.find_by(user_id: @user.id, course_id: @course.id) score = enrollment.find_score(assignment_group: @group) - expect(score.score_metadata.calculation_details).to eq ({ - 'current' => { 'dropped' => [find_submission(@overridden_middle)] }, - 'final' => { 'dropped' => [find_submission(@overridden_middle)] } - }) + expect(score.score_metadata.calculation_details).to eq({ + 'current' => { 'dropped' => [find_submission(@overridden_middle)] }, + 'final' => { 'dropped' => [find_submission(@overridden_middle)] } + }) end it "does not include muted assignments in the dropped submission list in group score metadata" do @@ -464,10 +464,10 @@ describe GradeCalculator do @group.update_attribute(:rules, 'drop_highest:1') expect { GradeCalculator.new(@user.id, @course.id).compute_and_save_scores }.not_to change { ScoreMetadata.count } metadata.reload - expect(metadata.calculation_details).to eq ({ - 'current' => { 'dropped' => [find_submission(@overridden_highest)] }, - 'final' => { 'dropped' => [find_submission(@overridden_highest)] } - }) + expect(metadata.calculation_details).to eq({ + 'current' => { 'dropped' => [find_submission(@overridden_highest)] }, + 'final' => { 'dropped' => [find_submission(@overridden_highest)] } + }) end end end diff --git a/spec/lib/grade_calculator_spec.rb b/spec/lib/grade_calculator_spec.rb index 78cff0caac1..3ebb8d4fe73 100644 --- a/spec/lib/grade_calculator_spec.rb +++ b/spec/lib/grade_calculator_spec.rb @@ -1848,7 +1848,7 @@ describe GradeCalculator do end GradeCalculator.new(@student.id, @course).compute_and_save_scores scored_enrollment_ids = Score.where(assignment_group_id: @group1.id).map(&:enrollment_id) - expect(scored_enrollment_ids).to contain_exactly *(@student.enrollments.map(&:id)) + expect(scored_enrollment_ids).to contain_exactly(*(@student.enrollments.map(&:id))) end it "creates a course score for the student if one does not exist, but assignment group scores exist" do diff --git a/spec/lib/i18n_spec.rb b/spec/lib/i18n_spec.rb index 7e5eb9715a8..6e2bfd1b479 100644 --- a/spec/lib/i18n_spec.rb +++ b/spec/lib/i18n_spec.rb @@ -79,27 +79,27 @@ describe I18n do it "forms with `'s` in english" do I18n.locale = :en - expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq ("Cody's") + expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq("Cody's") end it "forms with `s` in german generally" do I18n.locale = :de - expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq ("Codys") + expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq("Codys") end it "forms with `'` in german when ending appropriately" do I18n.locale = :de - expect(I18n.form_proper_noun_singular_genitive("Max")).to eq ("Max'") + expect(I18n.form_proper_noun_singular_genitive("Max")).to eq("Max'") end it "forms with `de ` in spanish" do I18n.locale = :es - expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq ("de Cody") + expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq("de Cody") end it "returns it untouched in chinese" do I18n.locale = :"zh-Hant" - expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq ("Cody") + expect(I18n.form_proper_noun_singular_genitive("Cody")).to eq("Cody") end end end diff --git a/spec/lib/inst_fs_spec.rb b/spec/lib/inst_fs_spec.rb index 952846d37ef..6e09fecaba2 100644 --- a/spec/lib/inst_fs_spec.rb +++ b/spec/lib/inst_fs_spec.rb @@ -449,7 +449,7 @@ describe InstFS do context "upload via url" do it "throw ArgumentError when appropriate" do expect { InstFS.upload_preflight_json(default_args.merge({ target_url: "foo" })) }.to raise_error(ArgumentError) - expect { InstFS.upload_preflight_json(default_args.merge({ progress_json: { "foo": 1 } })) }.to raise_error(ArgumentError) + expect { InstFS.upload_preflight_json(default_args.merge({ progress_json: { foo: 1 } })) }.to raise_error(ArgumentError) end it "responds properly when passed target_url and progress_json" do diff --git a/spec/lib/lti/variable_expander_spec.rb b/spec/lib/lti/variable_expander_spec.rb index f547ced134f..bbac61b1869 100644 --- a/spec/lib/lti/variable_expander_spec.rb +++ b/spec/lib/lti/variable_expander_spec.rb @@ -56,8 +56,8 @@ module Lti end let(:available_canvas_resources) { [ - { 'id': '1', 'name': 'item 1' }, - { 'id': '2', 'name': 'item 2' } + { id: '1', name: 'item 1' }, + { id: '2', name: 'item 2' } ] } @@ -68,10 +68,10 @@ module Lti allow(request_mock).to receive(:scheme).and_return('https') allow(request_mock).to receive(:parameters).and_return( { - 'com_instructure_course_accept_canvas_resource_types': ['page', 'module'], - 'com_instructure_course_canvas_resource_type': 'page', - 'com_instructure_course_allow_canvas_resource_selection': 'true', - 'com_instructure_course_available_canvas_resources': available_canvas_resources + com_instructure_course_accept_canvas_resource_types: ['page', 'module'], + com_instructure_course_canvas_resource_type: 'page', + com_instructure_course_allow_canvas_resource_selection: 'true', + com_instructure_course_available_canvas_resources: available_canvas_resources }.with_indifferent_access ) m = double('controller') @@ -149,7 +149,7 @@ module Lti it 'clears the lti_helper instance variable when you set the current_user' do expect(variable_expander.lti_helper).not_to be nil variable_expander.current_user = nil - expect(variable_expander.instance_variable_get(:"@current_user")).to be nil + expect(variable_expander.instance_variable_get(:@current_user)).to be nil end it 'expands registered variables' do @@ -1808,7 +1808,7 @@ module Lti end context 'attachment' do - let (:attachment) do + let(:attachment) do attachment = attachment_obj_with_context(course) attachment.media_object = media_object attachment.usage_rights = usage_rights diff --git a/spec/lib/math_man_spec.rb b/spec/lib/math_man_spec.rb index 7a3cddacc25..47d924f905a 100644 --- a/spec/lib/math_man_spec.rb +++ b/spec/lib/math_man_spec.rb @@ -56,7 +56,7 @@ describe MathMan do it 'must retain the path from base_url setting' do url = MathMan.url_for(latex: latex, target: :mml) parsed = Addressable::URI.parse(url) - expect(parsed.path).to eq ('/beta/mml') + expect(parsed.path).to eq('/beta/mml') end it 'includes target string in generated url' do diff --git a/spec/lib/microsoft_sync/graph_service_helpers_spec.rb b/spec/lib/microsoft_sync/graph_service_helpers_spec.rb index 14ee72c1d12..53eb56cb487 100644 --- a/spec/lib/microsoft_sync/graph_service_helpers_spec.rb +++ b/spec/lib/microsoft_sync/graph_service_helpers_spec.rb @@ -155,7 +155,7 @@ describe MicrosoftSync::GraphServiceHelpers do it 'truncates the description' do expect(graph_service).to \ - receive(:create_education_class).with(hash_including(description: 'a' * 1021 + '...')) + receive(:create_education_class).with(hash_including(description: ('a' * 1021) + '...')) subject.create_education_class(@course) end end @@ -213,7 +213,7 @@ describe MicrosoftSync::GraphServiceHelpers do it 'truncates course descriptions longer than 256 characters' do course_model(public_description: 'a' * 257) - expect_lms_ext_properties(lmsCourseDescription: 'a' * 253 + '...') + expect_lms_ext_properties(lmsCourseDescription: ('a' * 253) + '...') update_group end diff --git a/spec/lib/microsoft_sync/state_machine_job_spec.rb b/spec/lib/microsoft_sync/state_machine_job_spec.rb index fa89dcc0ce6..157584b0c37 100644 --- a/spec/lib/microsoft_sync/state_machine_job_spec.rb +++ b/spec/lib/microsoft_sync/state_machine_job_spec.rb @@ -384,7 +384,7 @@ module MicrosoftSync let(:steps_object) { StateMachineJobTestSteps2.new(2, max_delay + 3.minutes) } it 'clips the delay the maximum' do - expect(run_ats).to eq([nil, nil] + [max_delay.from_now] * 4) + expect(run_ats).to eq([nil, nil] + ([max_delay.from_now] * 4)) end end diff --git a/spec/lib/microsoft_sync/syncer_steps_spec.rb b/spec/lib/microsoft_sync/syncer_steps_spec.rb index ab4ed02ee9e..6f786ae6f75 100644 --- a/spec/lib/microsoft_sync/syncer_steps_spec.rb +++ b/spec/lib/microsoft_sync/syncer_steps_spec.rb @@ -929,7 +929,7 @@ describe MicrosoftSync::SyncerSteps do it 'only serializes the group so other values are reloaded when the job runs' do syncer_steps.send(:account_settings) syncer_steps.send(:tenant) - expect(syncer_steps.instance_variables).to include *%i[@group @account_settings @tenant] + expect(syncer_steps.instance_variables).to include(*%i[@group @account_settings @tenant]) serialized = syncer_steps.to_yaml deserialized = YAML.unsafe_load(serialized) expect(deserialized.instance_variables).to eq %i[@group] diff --git a/spec/lib/notification_message_creator_spec.rb b/spec/lib/notification_message_creator_spec.rb index 3f00a7fbf99..ea64471b181 100644 --- a/spec/lib/notification_message_creator_spec.rb +++ b/spec/lib/notification_message_creator_spec.rb @@ -778,15 +778,15 @@ describe NotificationMessageCreator do it "targets 3 partitions if it's really long" do now = Time.parse("2020-08-24 03:00:00UTC") - Setting.set("pending_duplicate_message_window_hours", 7 * 24 + 6) + Setting.set("pending_duplicate_message_window_hours", (7 * 24) + 6) Timecop.freeze(now) do - set_up_stubs(now - (7 * 24 + 6).hours, "created_at>=?", now - (7 * 24 + 6).hours) + set_up_stubs(now - ((7 * 24) + 6).hours, "created_at>=?", now - ((7 * 24) + 6).hours) set_up_stubs(now - 6.hours) set_up_stubs(now, "created_at<=?", now) subject.send(:cancel_pending_duplicate_messages) end # now verify the in_partition calls will result in what we expect - expect(Message.infer_partition_table_name('created_at' => now - (24 * 7 + 6).hours)).to eq "messages_2020_33" + expect(Message.infer_partition_table_name('created_at' => now - ((24 * 7) + 6).hours)).to eq "messages_2020_33" expect(Message.infer_partition_table_name('created_at' => now - 6.hours)).to eq "messages_2020_34" expect(Message.infer_partition_table_name('created_at' => now)).to eq "messages_2020_35" end diff --git a/spec/lib/planner_api_helper_spec.rb b/spec/lib/planner_api_helper_spec.rb index 9e65f6c672b..8ffd0191868 100644 --- a/spec/lib/planner_api_helper_spec.rb +++ b/spec/lib/planner_api_helper_spec.rb @@ -51,7 +51,7 @@ describe PlannerApiHelper do describe "#sync_module_requirement_done" do it "sets module requirement as done when completed in planner for assignment" do - planner_override_model({ "plannable": @assignment, "marked_complete": true }) + planner_override_model({ plannable: @assignment, marked_complete: true }) sync_module_requirement_done(@assignment, @user, true) progression = @module1.find_or_create_progression(@user) expect(progression.finished_item?(@assignment_tag)).to eq true @@ -59,14 +59,14 @@ describe PlannerApiHelper do it "sets module requirement as not done when un-completed in planner for assignment" do @assignment_tag.context_module_action(@user, :done) - planner_override_model({ "plannable": @assignment, "marked_complete": false }) + planner_override_model({ plannable: @assignment, marked_complete: false }) sync_module_requirement_done(@assignment, @user, false) progression = @module1.find_or_create_progression(@user) expect(progression.finished_item?(@assignment_tag)).to eq false end it "sets module requirement as done when completed in planner for wiki page" do - planner_override_model({ "plannable": @wiki_page, "marked_complete": true }) + planner_override_model({ plannable: @wiki_page, marked_complete: true }) sync_module_requirement_done(@wiki_page, @user, true) progression = @module1.find_or_create_progression(@user) expect(progression.finished_item?(@wiki_page_tag)).to eq true @@ -74,7 +74,7 @@ describe PlannerApiHelper do it "sets module requirement as not done when un-completed in planner for wiki page" do @wiki_page_tag.context_module_action(@user, :done) - planner_override_model({ "plannable": @wiki_page, "marked_complete": false }) + planner_override_model({ plannable: @wiki_page, marked_complete: false }) sync_module_requirement_done(@wiki_page, @user, false) progression = @module1.find_or_create_progression(@user) expect(progression.finished_item?(@wiki_page_tag)).to eq false @@ -87,9 +87,9 @@ describe PlannerApiHelper do describe "#sync_planner_completion" do it "updates existing override for assignment" do - planner_override_model({ "plannable": @assignment, - "marked_complete": false, - "dismissed": false }) + planner_override_model({ plannable: @assignment, + marked_complete: false, + dismissed: false }) override = sync_planner_completion(@assignment, @user, true) expect(override.marked_complete).to eq true @@ -107,9 +107,9 @@ describe PlannerApiHelper do end it "updates existing override for wiki page" do - planner_override_model({ "plannable": @wiki_page, - "marked_complete": false, - "dismissed": false }) + planner_override_model({ plannable: @wiki_page, + marked_complete: false, + dismissed: false }) override = sync_planner_completion(@wiki_page, @user, true) expect(override.marked_complete).to eq true diff --git a/spec/lib/session_token_spec.rb b/spec/lib/session_token_spec.rb index ab331f44f59..17d82a38eea 100644 --- a/spec/lib/session_token_spec.rb +++ b/spec/lib/session_token_spec.rb @@ -72,7 +72,7 @@ describe SessionToken do token.signature = Canvas::Security.hmac_sha1(token.signature_string) expect(SessionToken.parse(token.to_s)).not_to be_valid - token.created_at += (2 * SessionToken::VALIDITY_PERIOD + 10).seconds + token.created_at += ((2 * SessionToken::VALIDITY_PERIOD) + 10).seconds token.signature = Canvas::Security.hmac_sha1(token.signature_string) expect(SessionToken.parse(token.to_s)).not_to be_valid diff --git a/spec/lib/sis/csv/admin_importer_spec.rb b/spec/lib/sis/csv/admin_importer_spec.rb index 0637bcace5b..11a9e65aac6 100644 --- a/spec/lib/sis/csv/admin_importer_spec.rb +++ b/spec/lib/sis/csv/admin_importer_spec.rb @@ -107,7 +107,7 @@ describe SIS::CSV::AdminImporter do before_count = AccountUser.active.count process_csv_data_cleanly( 'user_id,account_id,role_id,status', - "U001,sub1,#{role.id.to_s},active" + "U001,sub1,#{role.id},active" ) expect(AccountUser.active.count).to eq before_count + 1 end diff --git a/spec/lib/sis/csv/enrollment_importer_spec.rb b/spec/lib/sis/csv/enrollment_importer_spec.rb index eac04076f06..2a29742cd65 100644 --- a/spec/lib/sis/csv/enrollment_importer_spec.rb +++ b/spec/lib/sis/csv/enrollment_importer_spec.rb @@ -1195,7 +1195,7 @@ describe SIS::CSV::EnrollmentImporter do "c3,s3,v1,student,active", # invalid course_id "c2,s2,v1,student,active", ) - errors = importer.errors.map &:last + errors = importer.errors.map(&:last) expect(errors).to eq ["An enrollment referenced a non-existent course c3"] a1 = @account.sub_accounts.find_by(sis_source_id: 'a1') a2 = @account.sub_accounts.find_by(sis_source_id: 'a2') diff --git a/spec/lib/sis/csv/user_importer_spec.rb b/spec/lib/sis/csv/user_importer_spec.rb index 168af2efc6e..ee89674e2db 100644 --- a/spec/lib/sis/csv/user_importer_spec.rb +++ b/spec/lib/sis/csv/user_importer_spec.rb @@ -190,19 +190,19 @@ describe SIS::CSV::UserImporter do "user_1,user1,User,One,\"One, User\",user@example.com,active" ) user = CommunicationChannel.by_path('user@example.com').first.user - expect(user.name).to eq ("User One") + expect(user.name).to eq("User One") expect(user.sortable_name).to eql("One, User") process_csv_data_cleanly( "user_id,login_id,first_name,last_name,sortable_name,email,status", "user_1,user1,User,Uno,\"One, User\",user@example.com,active" ) - expect(user.reload.name).to eq ("User Uno") + expect(user.reload.name).to eq("User Uno") expect(user.sortable_name).to eql("One, User") process_csv_data_cleanly( "user_id,login_id,first_name,last_name,status", "user_1,user1,Usero,Uno,active" ) - expect(user.reload.name).to eq ("Usero Uno") + expect(user.reload.name).to eq("Usero Uno") expect(user.sortable_name).to eql("Uno, Usero") end diff --git a/spec/lib/stats_spec.rb b/spec/lib/stats_spec.rb index 96f1360a88d..87a496a53a2 100644 --- a/spec/lib/stats_spec.rb +++ b/spec/lib/stats_spec.rb @@ -63,9 +63,9 @@ describe Stats do c << 6 check_stats(c, 5, 9, 1, 22, 4.4, 8.24, { :bin_width => 1.0, :bin_base => 0.0, :data => { 1.0 => 1, 2.0 => 1, 4.0 => 1, 9.0 => 1, 6.0 => 1 } }) c << -1 - check_stats(c, 6, 9, -1, 21, 3.5, 139.0 / 6 - 12.25, { :bin_width => 1.0, :bin_base => 0.0, :data => { 1.0 => 1, 2.0 => 1, 4.0 => 1, 9.0 => 1, 6.0 => 1, -1.0 => 1 } }) + check_stats(c, 6, 9, -1, 21, 3.5, (139.0 / 6) - 12.25, { :bin_width => 1.0, :bin_base => 0.0, :data => { 1.0 => 1, 2.0 => 1, 4.0 => 1, 9.0 => 1, 6.0 => 1, -1.0 => 1 } }) c << 3 - check_stats(c, 7, 9, -1, 24, 24.0 / 7, 148.0 / 7 - 576.0 / 49, { :bin_width => 1.0, :bin_base => 0.0, :data => { 1.0 => 1, 2.0 => 1, 4.0 => 1, 9.0 => 1, 6.0 => 1, -1.0 => 1, 3.0 => 1 } }) + check_stats(c, 7, 9, -1, 24, 24.0 / 7, (148.0 / 7) - (576.0 / 49), { :bin_width => 1.0, :bin_base => 0.0, :data => { 1.0 => 1, 2.0 => 1, 4.0 => 1, 9.0 => 1, 6.0 => 1, -1.0 => 1, 3.0 => 1 } }) c << 21 check_stats(c, 8, 21, -1, 45, 5.625, 41.984375, { :bin_width => 1.0, :bin_base => 0.0, :data => { 1.0 => 1, 2.0 => 1, 4.0 => 1, 9.0 => 1, 6.0 => 1, -1.0 => 1, 3.0 => 1, 21.0 => 1 } }) end diff --git a/spec/lib/user_merge_spec.rb b/spec/lib/user_merge_spec.rb index 7594e297bae..6f7da60b40c 100644 --- a/spec/lib/user_merge_spec.rb +++ b/spec/lib/user_merge_spec.rb @@ -754,8 +754,9 @@ describe UserMerge do @user2.set_preference(:custom_colors, { "course_#{@shard_course.local_id}" => "#254284", "course_#{course.global_id}" => "#346543" }) UserMerge.from(@user2).into(user1) - expect(user1.reload.get_preference(:custom_colors)).to eq ( - { "course_#{@shard_course.global_id}" => "#254284", "course_#{course.local_id}" => "#346543" }) + expect(user1.reload.get_preference(:custom_colors)).to eq( + { "course_#{@shard_course.global_id}" => "#254284", "course_#{course.local_id}" => "#346543" } + ) end it 'moves nicknames with old format' do diff --git a/spec/lib/validates_as_url.rb b/spec/lib/validates_as_url.rb index a9f89c7aff4..1661392b560 100644 --- a/spec/lib/validates_as_url.rb +++ b/spec/lib/validates_as_url.rb @@ -54,7 +54,7 @@ shared_examples_for "url validation tests" do saved = model.save expect([model.url, saved]).to eq [invalid_url, false] expect(model.errors.size).to eq 1 - expect(model.errors.full_messages.join).to match /not a valid URL/ + expect(model.errors.full_messages.join).to match(/not a valid URL/) end # should work on valid urls diff --git a/spec/models/active_record_base_spec.rb b/spec/models/active_record_base_spec.rb index f06831708b2..4ff1cfeab72 100644 --- a/spec/models/active_record_base_spec.rb +++ b/spec/models/active_record_base_spec.rb @@ -776,8 +776,8 @@ describe ActiveRecord::Base do class MockAccount < Account include RSpec::Matchers before_save do - expect(Account.all.to_sql).not_to match /callbacks something/ - expect(MockAccount.all.to_sql).not_to match /callbacks something/ + expect(Account.all.to_sql).not_to match(/callbacks something/) + expect(MockAccount.all.to_sql).not_to match(/callbacks something/) true end end diff --git a/spec/models/asset_user_access_spec.rb b/spec/models/asset_user_access_spec.rb index a55e3de8b01..6c9bb7b0b0a 100644 --- a/spec/models/asset_user_access_spec.rb +++ b/spec/models/asset_user_access_spec.rb @@ -403,7 +403,7 @@ describe AssetUserAccess do subject.participate_score = 4 allow(subject).to receive(:asset_group_code).and_return('quizzes') - expect(subject.corrected_view_score).to eq -4 + expect(subject.corrected_view_score).to eq(-4) end end diff --git a/spec/models/assignment_spec.rb b/spec/models/assignment_spec.rb index 7601b7b4060..bb07aae4ba8 100644 --- a/spec/models/assignment_spec.rb +++ b/spec/models/assignment_spec.rb @@ -3380,7 +3380,7 @@ describe Assignment do end it "treats negative score with decimals as a number" do - expect(@assignment.interpret_grade("-.2")).to eq (-0.2) + expect(@assignment.interpret_grade("-.2")).to eq(-0.2) end it "treats positive score with decimals as a number" do @@ -5618,7 +5618,7 @@ describe Assignment do expect(@sub2.messages_sent['Submission Graded']).to be_present expect(@sub2.messages_sent['Submission Graded'].first.from_name).to eq @course.name expect(@sub2.messages_sent['Submission Grade Changed']).to be_nil - @sub2.update(:graded_at => Time.zone.now - 60 * 60) + @sub2.update(:graded_at => Time.zone.now - (60 * 60)) @sub2 = @assignment.grade_student(@stu2, grade: 9, grader: @teacher).first expect(@sub2.messages_sent).not_to be_empty expect(@sub2.messages_sent['Submission Graded']).to be_nil @@ -5629,7 +5629,7 @@ describe Assignment do it "does not notify students when their grade is changed when grades are not yet posted" do @assignment.ensure_post_policy(post_manually: true) @sub2 = @assignment.grade_student(@stu2, grade: 8, grader: @teacher).first - @sub2.update(:graded_at => Time.zone.now - 60 * 60) + @sub2.update(:graded_at => Time.zone.now - (60 * 60)) @sub2 = @assignment.grade_student(@stu2, grade: 9, grader: @teacher).first expect(@sub2.messages_sent).to be_empty end @@ -6861,7 +6861,7 @@ describe Assignment do @assignment.title = "a" * 31 expect(@assignment.title.length).to eq 31 expect(@assignment.title_slug.length).to eq 30 - expect(@assignment.title).to match /^#{@assignment.title_slug}/ + expect(@assignment.title).to match(/^#{@assignment.title_slug}/) end it "does not change the title" do @@ -7831,7 +7831,7 @@ describe Assignment do def assignment(group_category = nil) a = @course.assignments.build name: "test" a.group_category = group_category - a.tap &:save! + a.tap(&:save!) end it "lets you change group category attributes before homework is submitted" do @@ -9694,7 +9694,6 @@ describe Assignment do end end - # rubocop:disable RSpec/NestedGroups context 'to a different LTI 1.3 tool' do it_behaves_like 'unchanged line item and resource link check' it_behaves_like 'assignment to line item attribute sync check' @@ -9706,7 +9705,6 @@ describe Assignment do it_behaves_like 'unchanged line item and resource link check' it_behaves_like 'assignment to line item attribute sync check' end - # rubocop:enable RSpec/NestedGroups end context 'and the tool binding is abandoned' do diff --git a/spec/models/auditors_spec.rb b/spec/models/auditors_spec.rb index f1486ec3171..602a41d33b1 100644 --- a/spec/models/auditors_spec.rb +++ b/spec/models/auditors_spec.rb @@ -30,8 +30,8 @@ describe Auditors do def inject_auditors_settings(yaml_string) Canvas::DynamicSettings.fallback_data = { - "private": { - "canvas": { + private: { + canvas: { "auditors.yml": yaml_string } } diff --git a/spec/models/brand_config_spec.rb b/spec/models/brand_config_spec.rb index 4c07121d2bb..eb44142626d 100644 --- a/spec/models/brand_config_spec.rb +++ b/spec/models/brand_config_spec.rb @@ -123,7 +123,7 @@ describe BrandConfig do end it "defines right-looking css in the :root scope" do - expect(@subaccount_bc.to_css).to match /:root \{ + expect(@subaccount_bc.to_css).to match(/:root \{ [\s|\S]*--ic-brand-primary-darkened-5: #312111; --ic-brand-primary-darkened-10: #2E1F10; --ic-brand-primary-darkened-15: #2C1D0F; @@ -136,7 +136,7 @@ describe BrandConfig do --ic-brand-button--secondary-bgd-darkened-15: #27333B; [\s|\S]*--ic-brand-primary: #321; [\s|\S]*--ic-brand-global-nav-bgd: #123; -/ +/) end end diff --git a/spec/models/communication_channel_spec.rb b/spec/models/communication_channel_spec.rb index 601ca36fa98..65503b5c76b 100644 --- a/spec/models/communication_channel_spec.rb +++ b/spec/models/communication_channel_spec.rb @@ -334,7 +334,7 @@ describe CommunicationChannel do @cc.send_confirmation!(account) message = Message.where(:communication_channel_id => @cc, :notification_id => notification).first expect(message).not_to be_nil - expect(message.body).to match /someserver.com/ + expect(message.body).to match(/someserver.com/) end end diff --git a/spec/models/content_migration/course_copy_quizzes_spec.rb b/spec/models/content_migration/course_copy_quizzes_spec.rb index e5a288136f7..1209d31ec26 100644 --- a/spec/models/content_migration/course_copy_quizzes_spec.rb +++ b/spec/models/content_migration/course_copy_quizzes_spec.rb @@ -865,7 +865,7 @@ describe ContentMigration do q2 = @copy_to.quizzes.where(migration_id: mig_id(q)).first answer = q2.quiz_questions[0].question_data["answers"][0] expect(answer["numerical_answer_type"]).to eq "range_answer" - expect(answer["start"]).to eq -1 + expect(answer["start"]).to eq(-1) expect(answer["end"]).to eq 2 end diff --git a/spec/models/content_migration/course_copy_spec.rb b/spec/models/content_migration/course_copy_spec.rb index f5f78626c68..897f2d26262 100644 --- a/spec/models/content_migration/course_copy_spec.rb +++ b/spec/models/content_migration/course_copy_spec.rb @@ -91,7 +91,7 @@ describe ContentMigration do run_course_copy - expect(@copy_to.syllabus_body).to match /#{@copy_from.syllabus_body}/ + expect(@copy_to.syllabus_body).to match(/#{@copy_from.syllabus_body}/) end it "does not migrate a blank syllabus" do @@ -834,7 +834,7 @@ describe ContentMigration do run_course_copy page_to = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first - expect(page_to.body).to eq (body % @copy_to.id.to_s) + expect(page_to.body).to eq(body % @copy_to.id.to_s) end end end diff --git a/spec/models/course_spec.rb b/spec/models/course_spec.rb index b20f73b916b..cb299d74e06 100644 --- a/spec/models/course_spec.rb +++ b/spec/models/course_spec.rb @@ -3453,16 +3453,16 @@ describe Course, 'grade_publishing' do make_student_enrollments expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["published", "error", "unpublishable", "error", "unpublishable", "unpublishable", "unpublished", "unpublished", "unpublished"] expect(@student_enrollments.map(&:grade_publishing_message)).to eq [nil, "cause of this reason", nil, "cause of that reason", nil, nil, nil, nil, nil] - expect(@student_enrollments.map(&:workflow_state)).to eq ["active"] * 6 + ["inactive"] + ["active"] * 2 + expect(@student_enrollments.map(&:workflow_state)).to eq (["active"] * 6) + ["inactive"] + (["active"] * 2) expect(@student_enrollments.map(&:last_publish_attempt_at)).to eq [nil] * 9 grade_publishing_user("U2") expect(@course).to receive(:send_final_grades_to_endpoint).with(@user, nil).and_return(nil) allow(@plugin).to receive(:enabled?).and_return(true) @plugin_settings[:publish_endpoint] = "http://localhost/endpoint" @course.publish_final_grades(@user) - expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["pending"] * 6 + ["unpublished"] + ["pending"] * 2 + expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq (["pending"] * 6) + ["unpublished"] + (["pending"] * 2) expect(@student_enrollments.map(&:grade_publishing_message)).to eq [nil] * 9 - expect(@student_enrollments.map(&:workflow_state)).to eq ["active"] * 6 + ["inactive"] + ["active"] * 2 + expect(@student_enrollments.map(&:workflow_state)).to eq (["active"] * 6) + ["inactive"] + (["active"] * 2) @student_enrollments.map(&:last_publish_attempt_at).each_with_index do |time, i| if i == 6 expect(time).to be_nil @@ -3683,16 +3683,16 @@ describe Course, 'grade_publishing' do it "makes sure grade publishing is enabled" do allow(@plugin).to receive(:enabled?).and_return(false) expect(lambda { @course.send_final_grades_to_endpoint nil }).to raise_error("final grade publishing disabled") - expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["error"] * 6 + ["unpublished"] + ["error"] * 2 - expect(@student_enrollments.map(&:grade_publishing_message)).to eq ["final grade publishing disabled"] * 6 + [nil] + ["final grade publishing disabled"] * 2 + expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq (["error"] * 6) + ["unpublished"] + (["error"] * 2) + expect(@student_enrollments.map(&:grade_publishing_message)).to eq (["final grade publishing disabled"] * 6) + [nil] + (["final grade publishing disabled"] * 2) end it "makes sure an endpoint is defined" do allow(@plugin).to receive(:enabled?).and_return(true) @plugin_settings.merge! :publish_endpoint => "" expect(lambda { @course.send_final_grades_to_endpoint nil }).to raise_error("endpoint undefined") - expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["error"] * 6 + ["unpublished"] + ["error"] * 2 - expect(@student_enrollments.map(&:grade_publishing_message)).to eq ["endpoint undefined"] * 6 + [nil] + ["endpoint undefined"] * 2 + expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq (["error"] * 6) + ["unpublished"] + (["error"] * 2) + expect(@student_enrollments.map(&:grade_publishing_message)).to eq (["endpoint undefined"] * 6) + [nil] + (["endpoint undefined"] * 2) end it "makes sure the publishing user can publish" do @@ -3704,8 +3704,8 @@ describe Course, 'grade_publishing' do allow(@plugin).to receive(:enabled?).and_return(true) @plugin_settings.merge! :publish_endpoint => "http://localhost/endpoint" expect(lambda { @course.send_final_grades_to_endpoint @user }).to raise_error("publishing disallowed for this publishing user") - expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["error"] * 6 + ["unpublished"] + ["error"] * 2 - expect(@student_enrollments.map(&:grade_publishing_message)).to eq ["publishing disallowed for this publishing user"] * 6 + [nil] + ["publishing disallowed for this publishing user"] * 2 + expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq (["error"] * 6) + ["unpublished"] + (["error"] * 2) + expect(@student_enrollments.map(&:grade_publishing_message)).to eq (["publishing disallowed for this publishing user"] * 6) + [nil] + (["publishing disallowed for this publishing user"] * 2) end it "makes sure there's a grading standard" do @@ -3717,16 +3717,16 @@ describe Course, 'grade_publishing' do allow(@plugin).to receive(:enabled?).and_return(true) @plugin_settings.merge! :publish_endpoint => "http://localhost/endpoint" expect(lambda { @course.send_final_grades_to_endpoint @user }).to raise_error("grade publishing requires a grading standard") - expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["error"] * 6 + ["unpublished"] + ["error"] * 2 - expect(@student_enrollments.map(&:grade_publishing_message)).to eq ["grade publishing requires a grading standard"] * 6 + [nil] + ["grade publishing requires a grading standard"] * 2 + expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq (["error"] * 6) + ["unpublished"] + (["error"] * 2) + expect(@student_enrollments.map(&:grade_publishing_message)).to eq (["grade publishing requires a grading standard"] * 6) + [nil] + (["grade publishing requires a grading standard"] * 2) end it "makes sure the format type is supported" do allow(@plugin).to receive(:enabled?).and_return(true) @plugin_settings.merge! :publish_endpoint => "http://localhost/endpoint", :format_type => "invalid_Format" expect(lambda { @course.send_final_grades_to_endpoint @user }).to raise_error("unknown format type: invalid_Format") - expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["error"] * 6 + ["unpublished"] + ["error"] * 2 - expect(@student_enrollments.map(&:grade_publishing_message)).to eq ["unknown format type: invalid_Format"] * 6 + [nil] + ["unknown format type: invalid_Format"] * 2 + expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq (["error"] * 6) + ["unpublished"] + (["error"] * 2) + expect(@student_enrollments.map(&:grade_publishing_message)).to eq (["unknown format type: invalid_Format"] * 6) + [nil] + (["unknown format type: invalid_Format"] * 2) end def sample_grade_publishing_request(published_status) @@ -3817,7 +3817,7 @@ describe Course, 'grade_publishing' do expect(SSLCommon).to receive(:post_data).with("http://localhost/endpoint", "post3", "test/mime3", {}) expect(lambda { @course.send_final_grades_to_endpoint(@user) }).to raise_error("waaah fail") expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["published", "published", "published", "published", "error", "unpublishable", "unpublished", "unpublishable", "error"] - expect(@student_enrollments.map(&:grade_publishing_message)).to eq [nil] * 4 + ["waaah fail"] + [nil] * 3 + ["waaah fail"] + expect(@student_enrollments.map(&:grade_publishing_message)).to eq ([nil] * 4) + ["waaah fail"] + ([nil] * 3) + ["waaah fail"] end it "tries and make all posts even if two of the postings fail" do @@ -3866,7 +3866,7 @@ describe Course, 'grade_publishing' do }) expect(lambda { @course.send_final_grades_to_endpoint(@user) }).to raise_error("waaah fail") expect(@student_enrollments.map(&:reload).map(&:grade_publishing_status)).to eq ["error", "error", "error", "error", "error", "error", "unpublished", "error", "error"] - expect(@student_enrollments.map(&:grade_publishing_message)).to eq ["waaah fail"] * 6 + [nil] + ["waaah fail"] * 2 + expect(@student_enrollments.map(&:grade_publishing_message)).to eq (["waaah fail"] * 6) + [nil] + (["waaah fail"] * 2) end it "passes header parameters to post" do @@ -5484,11 +5484,11 @@ describe Course do expect(c1.self_enrollment_code).to be_nil # normally only set when self_enrollment is enabled c1.update_attribute(:self_enrollment, true) expect(c1.self_enrollment_code).not_to be_nil - expect(c1.self_enrollment_code).to match /\A[A-Z0-9]{6}\z/ + expect(c1.self_enrollment_code).to match(/\A[A-Z0-9]{6}\z/) c2 = course_factory() c2.update_attribute(:self_enrollment, true) - expect(c2.self_enrollment_code).to match /\A[A-Z0-9]{6}\z/ + expect(c2.self_enrollment_code).to match(/\A[A-Z0-9]{6}\z/) expect(c1.self_enrollment_code).not_to eq c2.self_enrollment_code end @@ -5497,7 +5497,7 @@ describe Course do c1.reload expect(c1.read_attribute(:self_enrollment_code)).to be_nil expect(c1.self_enrollment_code).not_to be_nil - expect(c1.self_enrollment_code).to match /\A[A-Z0-9]{6}\z/ + expect(c1.self_enrollment_code).to match(/\A[A-Z0-9]{6}\z/) end end @@ -5966,7 +5966,7 @@ describe Course do @course.short_name = "a" * 31 expect(@course.short_name.length).to eq 31 expect(@course.short_name_slug.length).to eq 30 - expect(@course.short_name).to match /^#{@course.short_name_slug}/ + expect(@course.short_name).to match(/^#{@course.short_name_slug}/) end it "does not change the short_name" do diff --git a/spec/models/custom_gradebook_column_datum_spec.rb b/spec/models/custom_gradebook_column_datum_spec.rb index f9082f76bc3..651f26e02e3 100644 --- a/spec/models/custom_gradebook_column_datum_spec.rb +++ b/spec/models/custom_gradebook_column_datum_spec.rb @@ -33,24 +33,24 @@ describe CustomGradebookColumnDatum do CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [ { - "column_id": @first_col.id.to_s, - "user_id": @first_student.id.to_s, - "content": "first column, first student" + column_id: @first_col.id.to_s, + user_id: @first_student.id.to_s, + content: "first column, first student" }, { - "column_id": @first_col.id.to_s, - "user_id": @second_student.id.to_s, - "content": "first column, second student" + column_id: @first_col.id.to_s, + user_id: @second_student.id.to_s, + content: "first column, second student" }, { - "column_id": @second_col.id.to_s, - "user_id": @first_student.id.to_s, - "content": "second column, first student" + column_id: @second_col.id.to_s, + user_id: @first_student.id.to_s, + content: "second column, first student" }, { - "column_id": @second_col.id.to_s, - "user_id": @second_student.id.to_s, - "content": "second column, second student" + column_id: @second_col.id.to_s, + user_id: @second_student.id.to_s, + content: "second column, second student" } ]) end @@ -91,9 +91,9 @@ describe CustomGradebookColumnDatum do it "does not create new columns when column doesn't exist" do CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [ { - "column_id": (@second_col.id + 1001).to_s, - "user_id": @second_student.id.to_s, - "content": "first column, second student" + column_id: (@second_col.id + 1001).to_s, + user_id: @second_student.id.to_s, + content: "first column, second student" }, ]) @@ -104,9 +104,9 @@ describe CustomGradebookColumnDatum do it "updates the content for existing student and column" do CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [ { - "column_id": @second_col.id.to_s, - "user_id": @second_student.id.to_s, - "content": "2, 2" + column_id: @second_col.id.to_s, + user_id: @second_student.id.to_s, + content: "2, 2" } ]) @@ -118,9 +118,9 @@ describe CustomGradebookColumnDatum do it "can also pass the column ID as a number" do CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [ { - "column_id": @second_col.id, - "user_id": @second_student.id, - "content": "2, 2" + column_id: @second_col.id, + user_id: @second_student.id, + content: "2, 2" } ]) @@ -138,9 +138,9 @@ describe CustomGradebookColumnDatum do CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [ { - "column_id": @second_col.id.to_s, - "user_id": @second_student.id.to_s, - "content": "3, 2" + column_id: @second_col.id.to_s, + user_id: @second_student.id.to_s, + content: "3, 2" }, ]) @@ -151,9 +151,9 @@ describe CustomGradebookColumnDatum do it "destroys data when uploading empty string" do CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [ { - "column_id": @first_col.id.to_s, - "user_id": @first_student.id.to_s, - "content": "" + column_id: @first_col.id.to_s, + user_id: @first_student.id.to_s, + content: "" }, ]) diff --git a/spec/models/delayed_message_spec.rb b/spec/models/delayed_message_spec.rb index 1161aaeee2a..3b03070959d 100644 --- a/spec/models/delayed_message_spec.rb +++ b/spec/models/delayed_message_spec.rb @@ -299,7 +299,7 @@ describe DelayedMessage do @dm.communication_channel.user.pseudonym.account_id = i @dm.send_at = nil @dm.send(:set_send_at) - actual_windows << (@dm.send_at - saturday).to_i / (60 * DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET) + actual_windows << ((@dm.send_at - saturday).to_i / (60 * DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET)) expected_windows << i end @@ -324,7 +324,7 @@ describe DelayedMessage do @dm.send(:set_send_at) window = (@dm.send_at - saturday).to_i / (60 * DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET) windows << window - actual_diffs << @dm.send_at - saturday - (DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET * window).minutes.to_i + actual_diffs << (@dm.send_at - saturday - (DelayedMessage::MINUTES_PER_WEEKLY_ACCOUNT_BUCKET * window).minutes.to_i) expected_diffs << i.minutes end diff --git a/spec/models/group_category_spec.rb b/spec/models/group_category_spec.rb index 0e8ce6f9fef..282751c953d 100644 --- a/spec/models/group_category_spec.rb +++ b/spec/models/group_category_spec.rb @@ -28,7 +28,7 @@ describe GroupCategory do zone = ActiveSupport::TimeZone["America/Denver"] course = Course.new(time_zone: zone) category = GroupCategory.new(context: course) - expect(category.time_zone.to_s).to match /Mountain Time/ + expect(category.time_zone.to_s).to match(/Mountain Time/) end context "protected_name_for_context?" do diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index faa1e75e412..9bdff7c2953 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -59,7 +59,7 @@ describe Group do it 'delegates time_zone through to its context' do zone = ActiveSupport::TimeZone["America/Denver"] @course.time_zone = zone - expect(@group.time_zone.to_s).to match /Mountain Time/ + expect(@group.time_zone.to_s).to match(/Mountain Time/) end it "correctlies identify group as active" do diff --git a/spec/models/importers/assignment_importer_spec.rb b/spec/models/importers/assignment_importer_spec.rb index 6652141792f..575303fe05f 100644 --- a/spec/models/importers/assignment_importer_spec.rb +++ b/spec/models/importers/assignment_importer_spec.rb @@ -845,7 +845,7 @@ describe "Importing assignments" do "title" => "post_to_sis", "post_to_sis" => false, "date_shift_options" => { - "remove_dates": true + remove_dates: true } }.with_indifferent_access end diff --git a/spec/models/importers/course_content_importer_spec.rb b/spec/models/importers/course_content_importer_spec.rb index 56933b9a6f5..77d65ff709f 100644 --- a/spec/models/importers/course_content_importer_spec.rb +++ b/spec/models/importers/course_content_importer_spec.rb @@ -346,7 +346,7 @@ describe Course do end it "sets the course to manually-posted when default_post_policy['post_manually'] is true" do - import_data = { "course": { "default_post_policy": { "post_manually": true } } }.with_indifferent_access + import_data = { course: { default_post_policy: { post_manually: true } } }.with_indifferent_access Importers::CourseContentImporter.import_content(@course, import_data, nil, migration) expect(@course.default_post_policy).to be_post_manually @@ -354,7 +354,7 @@ describe Course do it "sets the course to auto-posted when default_post_policy['post_manually'] is false" do @course.default_post_policy.update!(post_manually: true) - import_data = { "course": { "default_post_policy": { "post_manually": false } } }.with_indifferent_access + import_data = { course: { default_post_policy: { post_manually: false } } }.with_indifferent_access Importers::CourseContentImporter.import_content(@course, import_data, nil, migration) expect(@course.default_post_policy).not_to be_post_manually @@ -362,7 +362,7 @@ describe Course do it "does not update the course's post policy when default_post_policy['post_manually'] is missing" do @course.default_post_policy.update!(post_manually: true) - import_data = { "course": {} }.with_indifferent_access + import_data = { course: {} }.with_indifferent_access Importers::CourseContentImporter.import_content(@course, import_data, nil, migration) expect(@course.default_post_policy).to be_post_manually diff --git a/spec/models/learning_outcome_result_spec.rb b/spec/models/learning_outcome_result_spec.rb index f1cac66eb33..90bcf346450 100644 --- a/spec/models/learning_outcome_result_spec.rb +++ b/spec/models/learning_outcome_result_spec.rb @@ -345,7 +345,7 @@ describe LearningOutcomeResult do it "properly calculates percent based on outcome.mastery_points even if an outcome proficiency object exists" do learning_outcome_result.update(score: 1, possible: nil) learning_outcome_result.calculate_percent! - expect(learning_outcome_result.percent).to eq (1.to_f / learning_outcome_result.learning_outcome.mastery_points.to_f) + expect(learning_outcome_result.percent).to eq(1.to_f / learning_outcome_result.learning_outcome.mastery_points.to_f) end end end diff --git a/spec/models/lti/message_handler_spec.rb b/spec/models/lti/message_handler_spec.rb index 8eb390e1b7a..c7ae6f125cb 100644 --- a/spec/models/lti/message_handler_spec.rb +++ b/spec/models/lti/message_handler_spec.rb @@ -25,8 +25,8 @@ require_dependency "lti/message_handler" module Lti describe MessageHandler do - let (:account) { Account.create } - let (:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) } + let(:account) { Account.create } + let(:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) } describe 'validations' do before(:each) do diff --git a/spec/models/lti/tool_configuration_spec.rb b/spec/models/lti/tool_configuration_spec.rb index 1aed0bee933..d5974a12b4c 100644 --- a/spec/models/lti/tool_configuration_spec.rb +++ b/spec/models/lti/tool_configuration_spec.rb @@ -135,7 +135,7 @@ module Lti end context 'when public_jwk is not present' do - let (:settings) do + let(:settings) do s = super() s.delete('public_jwk') s['public_jwk_url'] = "https://test.com" @@ -150,7 +150,7 @@ module Lti end context 'when public_jwk_url is not present' do - let (:settings) do + let(:settings) do s = super() s.delete('public_jwk_url') s['public_jwk'] = public_jwk @@ -165,7 +165,7 @@ module Lti end context 'when public_jwk_url and public_jwk are not present' do - let (:settings) do + let(:settings) do s = super() s.delete('public_jwk_url') s.delete('public_jwk') @@ -459,7 +459,7 @@ module Lti before { allow(CanvasHttp).to receive(:get).and_raise(Timeout::Error) } it 'raises exception if timeout occurs' do - expect { tool_configuration }.to raise_error /Could not retrieve settings, the server response timed out./ + expect { tool_configuration }.to raise_error(/Could not retrieve settings, the server response timed out./) end end @@ -479,7 +479,7 @@ module Lti end it 'adds a "not found error to the model' do - expect { tool_configuration }.to raise_error /Not found/ + expect { tool_configuration }.to raise_error(/Not found/) end end @@ -490,7 +490,7 @@ module Lti end it 'adds a "unauthorized error to the model' do - expect { tool_configuration }.to raise_error /Unauthorized/ + expect { tool_configuration }.to raise_error(/Unauthorized/) end end @@ -501,7 +501,7 @@ module Lti end it 'adds a "internal server error to the model' do - expect { tool_configuration }.to raise_error /Internal server error/ + expect { tool_configuration }.to raise_error(/Internal server error/) end end @@ -512,7 +512,7 @@ module Lti end it 'adds an error to the model' do - expect { tool_configuration }.to raise_error /Content type must be \"application\/json\"/ + expect { tool_configuration }.to raise_error(/Content type must be \"application\/json\"/) end end end diff --git a/spec/models/lti/tool_setting_spec.rb b/spec/models/lti/tool_setting_spec.rb index 096b73b5473..edb0b543bbc 100644 --- a/spec/models/lti/tool_setting_spec.rb +++ b/spec/models/lti/tool_setting_spec.rb @@ -24,11 +24,11 @@ require_dependency "lti/tool_setting" module Lti describe ToolSetting do - let (:account) { Account.create } - let (:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) } - let (:resource_handler) { ResourceHandler.create(resource_type_code: 'code', name: 'resource name', tool_proxy: tool_proxy) } - let (:message_handler) { MessageHandler.create(message_type: 'basic-lti-launch-request', launch_path: 'https://samplelaunch/blti', resource_handler: resource_handler) } - let (:tool_proxy) { + let(:account) { Account.create } + let(:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) } + let(:resource_handler) { ResourceHandler.create(resource_type_code: 'code', name: 'resource name', tool_proxy: tool_proxy) } + let(:message_handler) { MessageHandler.create(message_type: 'basic-lti-launch-request', launch_path: 'https://samplelaunch/blti', resource_handler: resource_handler) } + let(:tool_proxy) { ToolProxy.create( shared_secret: 'shared_secret', guid: 'guid', diff --git a/spec/models/master_courses/child_subscription_spec.rb b/spec/models/master_courses/child_subscription_spec.rb index a55ba8c01a5..9632c88ae88 100644 --- a/spec/models/master_courses/child_subscription_spec.rb +++ b/spec/models/master_courses/child_subscription_spec.rb @@ -68,8 +68,8 @@ describe MasterCourses::ChildSubscription do expect(child_tag.root_account_id).to eq child_course.root_account_id sub.destroy! - expect(page_copy.reload.migration_id).to eq (sub.deactivation_prefix + mc_tag.migration_id) - expect(child_tag.reload.migration_id).to eq (sub.deactivation_prefix + mc_tag.migration_id) + expect(page_copy.reload.migration_id).to eq(sub.deactivation_prefix + mc_tag.migration_id) + expect(child_tag.reload.migration_id).to eq(sub.deactivation_prefix + mc_tag.migration_id) expect(child_course.reload.syllabus_master_template_id).to be_empty sub.undestroy diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index b3ad8d459e8..61e5e20aac6 100644 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -116,7 +116,7 @@ describe Message do allow(ActiveRecord::Base).to receive(:maximum_text_length).and_return(3) assignment_model(title: 'this is a message') msg = generate_message(:assignment_created, :email, @assignment) - msg.body = msg.body + "1" * 64.kilobyte + msg.body = msg.body + ("1" * 64.kilobyte) expect(msg.valid?).to be_truthy expect(msg.body).to eq 'message preview unavailable' msg.save! diff --git a/spec/models/outcome_proficiency_spec.rb b/spec/models/outcome_proficiency_spec.rb index a0d99cb7102..a5c8816cef0 100644 --- a/spec/models/outcome_proficiency_spec.rb +++ b/spec/models/outcome_proficiency_spec.rb @@ -144,7 +144,7 @@ describe OutcomeProficiency, type: :model do end describe 'interaction with cache' do - let (:account) { account_model } + let(:account) { account_model } it 'clears the account cache on save' do expect(account).to receive(:clear_downstream_caches).with(:resolved_outcome_proficiency) diff --git a/spec/models/outcomes_service/migration_extractor_spec.rb b/spec/models/outcomes_service/migration_extractor_spec.rb index 9136bd20372..cb06fdbeaeb 100644 --- a/spec/models/outcomes_service/migration_extractor_spec.rb +++ b/spec/models/outcomes_service/migration_extractor_spec.rb @@ -67,7 +67,7 @@ describe OutcomesService::MigrationExtractor do cm.add_imported_item(global_outcome) outcomes = subject.learning_outcomes(@course) expect(outcomes.length).to eq 1 - expect(outcomes[0][:'$canvas_learning_outcome_id']).to eq course_outcome.id + expect(outcomes[0][:$canvas_learning_outcome_id]).to eq course_outcome.id end end end diff --git a/spec/models/pseudonym_spec.rb b/spec/models/pseudonym_spec.rb index 73f48234aef..cb4dfc7e2a5 100644 --- a/spec/models/pseudonym_spec.rb +++ b/spec/models/pseudonym_spec.rb @@ -60,7 +60,7 @@ describe Pseudonym do # make sure a password was generated expect(p.password).not_to be_nil - expect(p.password).not_to match /tmp-pw/ + expect(p.password).not_to match(/tmp-pw/) end it "does not allow active duplicates" do diff --git a/spec/models/quizzes/log_auditing/event_aggregator_spec.rb b/spec/models/quizzes/log_auditing/event_aggregator_spec.rb index f5aa7be52bf..dcb659aa756 100644 --- a/spec/models/quizzes/log_auditing/event_aggregator_spec.rb +++ b/spec/models/quizzes/log_auditing/event_aggregator_spec.rb @@ -64,7 +64,7 @@ describe Quizzes::LogAuditing::EventAggregator do } # Build out each event in pairs to test that we are aggregating correctly event_types.each.with_index do |event_type, i| - build_an_event(event_type, event_data_examples[event_type][0], i * 2 - 1) + build_an_event(event_type, event_data_examples[event_type][0], (i * 2) - 1) build_an_event(event_type, event_data_examples[event_type][1], i * 2) end @events = Quizzes::QuizSubmissionEvent.all diff --git a/spec/models/quizzes/quiz_question/answer_serializers/fill_in_multiple_blanks_spec.rb b/spec/models/quizzes/quiz_question/answer_serializers/fill_in_multiple_blanks_spec.rb index cd6fde3c288..87228d31571 100644 --- a/spec/models/quizzes/quiz_question/answer_serializers/fill_in_multiple_blanks_spec.rb +++ b/spec/models/quizzes/quiz_question/answer_serializers/fill_in_multiple_blanks_spec.rb @@ -85,14 +85,14 @@ describe Quizzes::QuizQuestion::AnswerSerializers::FillInMultipleBlanks do ['asdf', nil].each do |bad_input| rc = subject.serialize(bad_input) expect(rc.error).not_to be_nil - expect(rc.error).to match /must be of type hash/i + expect(rc.error).to match(/must be of type hash/i) end end it 'rejects an answer to an unknown blank' do rc = subject.serialize({ foobar: 'yeeeeeeeeee' }) expect(rc.error).not_to be_nil - expect(rc.error).to match /unknown blank/i + expect(rc.error).to match(/unknown blank/i) end end end diff --git a/spec/models/quizzes/quiz_regrader/answer_spec.rb b/spec/models/quizzes/quiz_regrader/answer_spec.rb index c6c350d7b8c..184bd66e59a 100644 --- a/spec/models/quizzes/quiz_regrader/answer_spec.rb +++ b/spec/models/quizzes/quiz_regrader/answer_spec.rb @@ -197,7 +197,7 @@ describe Quizzes::QuizRegrader::Answer do it 'returns -points if prev correct but wrong after regrading' do mark_original_answer_as!(:correct) score_question_as!(:wrong) - expect(wrapper.regrade!).to eq -points + expect(wrapper.regrade!).to eq(-points) assert_answer_has_regrade_option!('current_correct_only') end diff --git a/spec/models/quizzes/quiz_spec.rb b/spec/models/quizzes/quiz_spec.rb index 09c48b0ff72..79acff48f43 100644 --- a/spec/models/quizzes/quiz_spec.rb +++ b/spec/models/quizzes/quiz_spec.rb @@ -2433,7 +2433,7 @@ describe Quizzes::Quiz do end it "excludes quizzes that don't meet either criterion" do - expect(@course.quizzes.due_between_with_overrides(1.hour.ago, 1.hour.from_now)).not_to include (@quiz) + expect(@course.quizzes.due_between_with_overrides(1.hour.ago, 1.hour.from_now)).not_to include(@quiz) end end diff --git a/spec/models/quizzes/quiz_statistics/item_analysis/common.rb b/spec/models/quizzes/quiz_statistics/item_analysis/common.rb index f54e4b8b916..67e7d4e6694 100644 --- a/spec/models/quizzes/quiz_statistics/item_analysis/common.rb +++ b/spec/models/quizzes/quiz_statistics/item_analysis/common.rb @@ -92,7 +92,7 @@ def simple_quiz_with_submissions(answer_key, *submissions) true_false = answer == 'T' || answer == 'F' type = true_false ? 'true_false_question' : 'multiple_choice_question' answers = (true_false ? ['T', 'F'] : 'A'..'D').each_with_index.map do |a, j| - { :answer_text => a, :answer_weight => (a == answer ? 100 : 0), :id => (4 * i + j) } + { :answer_text => a, :answer_weight => (a == answer ? 100 : 0), :id => ((4 * i) + j) } end { :question_data => { :name => "question #{i + 1}", :points_possible => points, :question_type => type, :answers => answers } } @@ -119,7 +119,7 @@ def simple_quiz_with_shuffled_answers(answer_key, *submissions) true_false = answer == 'T' || answer == 'F' type = true_false ? 'true_false_question' : 'multiple_choice_question' answers = (true_false ? ['T', 'F'] : 'A'..'D').each_with_index.map do |a, j| - { :answer_text => a, :answer_weight => (a == answer ? 100 : 0), :id => (4 * i + j) } + { :answer_text => a, :answer_weight => (a == answer ? 100 : 0), :id => ((4 * i) + j) } end { :question_data => { :name => "question #{i + 1}", :points_possible => points, :question_type => type, :answers => answers } } } diff --git a/spec/models/quizzes/quiz_statistics/student_analysis_spec.rb b/spec/models/quizzes/quiz_statistics/student_analysis_spec.rb index f1b5d6221e6..b4ed11e417b 100644 --- a/spec/models/quizzes/quiz_statistics/student_analysis_spec.rb +++ b/spec/models/quizzes/quiz_statistics/student_analysis_spec.rb @@ -122,10 +122,10 @@ describe Quizzes::QuizStatistics::StudentAnalysis do sub.score = 20 sub.with_versioning(true, &:save!) stats = q.statistics - expect(stats[:submission_score_average]).to be_within(0.0000000001).of(17 + 1.0 / 3) + expect(stats[:submission_score_average]).to be_within(0.0000000001).of(17 + (1.0 / 3)) expect(stats[:submission_score_high]).to eq 20 expect(stats[:submission_score_low]).to eq 15 - expect(stats[:submission_score_stdev]).to be_within(0.0000000001).of(Math::sqrt(4 + 2.0 / 9)) + expect(stats[:submission_score_stdev]).to be_within(0.0000000001).of(Math::sqrt(4 + (2.0 / 9))) expect(stats[:submission_scores]).to eq({ 50 => 1, 57 => 1, 67 => 1 }) end @@ -500,7 +500,7 @@ describe Quizzes::QuizStatistics::StudentAnalysis do # calculated field also includes the values for the variables, something like: # "x=>4.3,y=>21,calculated" # so we'll match instead - expect(stats.last[15]).to match /,calculated$/ + expect(stats.last[15]).to match(/,calculated$/) end it 'does not count teacher preview submissions' do diff --git a/spec/models/quizzes/quiz_statistics_service_spec.rb b/spec/models/quizzes/quiz_statistics_service_spec.rb index 60f5b08900d..4a7f81e07a6 100644 --- a/spec/models/quizzes/quiz_statistics_service_spec.rb +++ b/spec/models/quizzes/quiz_statistics_service_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Quizzes::QuizStatisticsService do - let_once (:course) { Course.new.tap { |course| course.id = 1 } } + let_once(:course) { Course.new.tap { |course| course.id = 1 } } let_once :quiz do Quizzes::Quiz.new.tap do |quiz| quiz.workflow_state = 'available' diff --git a/spec/models/quizzes/quiz_submission_spec.rb b/spec/models/quizzes/quiz_submission_spec.rb index 8d9a085bd9e..fbece174be2 100644 --- a/spec/models/quizzes/quiz_submission_spec.rb +++ b/spec/models/quizzes/quiz_submission_spec.rb @@ -156,11 +156,11 @@ describe Quizzes::QuizSubmission do qs.update_scores({ :fudge_points => -5, :question_score_1 => 50 }) expect(qs.score).to eq 45 - expect(qs.fudge_points).to eq -5 + expect(qs.fudge_points).to eq(-5) expect(qs.kept_score).to eq 45 v = qs.versions.current.model expect(v.score).to eq 45 - expect(v.fudge_points).to eq -5 + expect(v.fudge_points).to eq(-5) expect(qs.submission.unread?(@student)).to eq true end @@ -179,11 +179,11 @@ describe Quizzes::QuizSubmission do qs.update_scores({ :fudge_points => -5, :question_score_1 => 50 }) expect(qs.score).to eq 42 - expect(qs.fudge_points).to eq -5 + expect(qs.fudge_points).to eq(-5) expect(qs.kept_score).to eq 42 v = qs.versions.current.model expect(v.score).to eq 42 - expect(v.fudge_points).to eq -5 + expect(v.fudge_points).to eq(-5) end end @@ -386,7 +386,7 @@ describe Quizzes::QuizSubmission do @quiz_sub.reload expect(@quiz_sub.score).to eq 3 expect(@quiz_sub.kept_score).to eq 3 - expect(@quiz_sub.fudge_points).to eq -2 + expect(@quiz_sub.fudge_points).to eq(-2) expect(@quiz_sub.manually_scored).not_to be_truthy @submission.reload @@ -411,7 +411,7 @@ describe Quizzes::QuizSubmission do @quiz_sub.reload expect(@quiz_sub.score).to eq 3 expect(@quiz_sub.kept_score).to eq 3 - expect(@quiz_sub.fudge_points).to eq -1 + expect(@quiz_sub.fudge_points).to eq(-1) expect(@quiz_sub.manually_scored).to be_truthy @submission.reload expect(@submission.score).to eq 3 diff --git a/spec/models/quizzes_next/export_service_spec.rb b/spec/models/quizzes_next/export_service_spec.rb index aa7ce485bcb..2804e785961 100644 --- a/spec/models/quizzes_next/export_service_spec.rb +++ b/spec/models/quizzes_next/export_service_spec.rb @@ -78,10 +78,10 @@ describe QuizzesNext::ExportService do expect(ExportService.begin_export(course, {})).to eq( { - "original_course_uuid": 1234, - "assignments": [ - { "original_resource_link_id": "link-id-0", "$canvas_assignment_id": 0, "original_assignment_id": 0 }, - { "original_resource_link_id": "link-id-1", "$canvas_assignment_id": 1, "original_assignment_id": 1 } + original_course_uuid: 1234, + assignments: [ + { original_resource_link_id: "link-id-0", "$canvas_assignment_id": 0, original_assignment_id: 0 }, + { original_resource_link_id: "link-id-1", "$canvas_assignment_id": 1, original_assignment_id: 1 } ] } ) @@ -104,12 +104,12 @@ describe QuizzesNext::ExportService do let(:old_assignment2) { assignment_model(id: 4) } let(:basic_import_content) do { - 'original_course_uuid': '100005', - 'assignments': [ + original_course_uuid: '100005', + assignments: [ { - 'original_resource_link_id': 'link-1234', + original_resource_link_id: 'link-1234', '$canvas_assignment_id': new_assignment1.id, - 'original_assignment_id': old_assignment1.id + original_assignment_id: old_assignment1.id } ] } @@ -125,9 +125,9 @@ describe QuizzesNext::ExportService do it 'emits live events for each copied assignment' do basic_import_content[:assignments] << { - 'original_resource_link_id': 'link-5678', + original_resource_link_id: 'link-5678', '$canvas_assignment_id': new_assignment2.id, - 'original_assignment_id': old_assignment2.id + original_assignment_id: old_assignment2.id } expect(Canvas::LiveEvents).to receive(:quizzes_next_quiz_duplicated).once @@ -136,7 +136,7 @@ describe QuizzesNext::ExportService do it 'ignores not found assignments' do basic_import_content[:assignments] << { - 'original_resource_link_id': '5678', + original_resource_link_id: '5678', '$canvas_assignment_id': Canvas::Migration::ExternalContent::Translator::NOT_FOUND } @@ -173,7 +173,7 @@ describe QuizzesNext::ExportService do it 'skips assignments that are not duplicates' do basic_import_content[:assignments] << { - 'original_resource_link_id': '5678', + original_resource_link_id: '5678', '$canvas_assignment_id': new_assignment2.id } diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 787f32de398..f369f43593f 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -1304,7 +1304,7 @@ describe Submission do s = submission_spec_model(submit_homework: true) expect(s.url).to eq 'http://www.instructure.com' - long_url = ("a" * 300 + ".com") + long_url = (("a" * 300) + ".com") s.url = long_url s.save! expect(s.url).to eq "http://#{long_url}" diff --git a/spec/models/user_preference_value_spec.rb b/spec/models/user_preference_value_spec.rb index dce34375840..2ea2decc6c0 100644 --- a/spec/models/user_preference_value_spec.rb +++ b/spec/models/user_preference_value_spec.rb @@ -21,18 +21,18 @@ require_relative "../sharding_spec_helper" describe UserPreferenceValue do - let (:regular_key) { :custom_colors } - let (:subbed_key) { :course_nicknames } + let(:regular_key) { :custom_colors } + let(:subbed_key) { :course_nicknames } - let (:sample_preferences) { + let(:sample_preferences) { { regular_key => [:arbitrary_data], subbed_key => { :a => 1, :b => [:other_stuff] } } } - let (:preexisting_user) { + let(:preexisting_user) { User.create!(:preferences => sample_preferences) } - let (:migrated_user) { + let(:migrated_user) { u = User.create!(:preferences => sample_preferences) u.migrate_preferences_if_needed u.save! @@ -121,16 +121,16 @@ describe UserPreferenceValue do context "gradebook_column_size" do specs_require_sharding - let (:course1) { Course.create! } - let (:course2) { Course.create! } - let (:assignment1) { course1.assignments.create! } - let (:assignment2) { course2.assignments.create! } - let (:assignment_group1) { course1.assignment_groups.create! } - let (:assignment_group2) { course2.assignment_groups.create! } - let (:column1) { course1.custom_gradebook_columns.create!(:title => "1") } - let (:column2) { course2.custom_gradebook_columns.create!(:title => "2") } + let(:course1) { Course.create! } + let(:course2) { Course.create! } + let(:assignment1) { course1.assignments.create! } + let(:assignment2) { course2.assignments.create! } + let(:assignment_group1) { course1.assignment_groups.create! } + let(:assignment_group2) { course2.assignment_groups.create! } + let(:column1) { course1.custom_gradebook_columns.create!(:title => "1") } + let(:column2) { course2.custom_gradebook_columns.create!(:title => "2") } - let (:old_format) { + let(:old_format) { { "student" => "100", "assignment_#{assignment1.id}" => "10", diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb index 71b1d0cd14e..3a15782c016 100644 --- a/spec/models/user_profile_spec.rb +++ b/spec/models/user_profile_spec.rb @@ -102,7 +102,7 @@ describe UserProfile do "default" => "enabled", "text" => "LTI or die", "visibility" => visibility, - 'required_permissions': 'manage_data_services' + required_permissions: 'manage_data_services' } }.with_indifferent_access end @@ -180,7 +180,7 @@ describe UserProfile do "default" => "enabled", "text" => "LTI or die", "visibility" => visibility, - 'required_permissions': 'manage_data_services' + required_permissions: 'manage_data_services' } }.with_indifferent_access end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 85737de685b..691bc3f511a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2313,7 +2313,7 @@ describe User do it "sums up associated root account quotas" do @user.associated_root_accounts << Account.create! << (a = Account.create!) a.update_attribute :default_user_storage_quota_mb, a.default_user_storage_quota_mb + 10 - expect(@user.quota).to eql(2 * User.default_storage_quota + 10.megabytes) + expect(@user.quota).to eql((2 * User.default_storage_quota) + 10.megabytes) end end diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 028691d1d4f..f94ba81951d 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -170,7 +170,7 @@ describe WikiPage do p1 = @course.wiki_pages.create!(:title => "a" * WikiPage::TITLE_LENGTH) p2 = @course.wiki_pages.create!(:title => p1.title) p3 = @course.wiki_pages.create!(:title => p1.title) - p4 = @course.wiki_pages.create!(:title => "a" * (WikiPage::TITLE_LENGTH - 2) + "-2") + p4 = @course.wiki_pages.create!(:title => ("a" * (WikiPage::TITLE_LENGTH - 2)) + "-2") expect(p2.title.length).to eq WikiPage::TITLE_LENGTH expect(p2.title.end_with?('-2')).to be_truthy expect(p3.title.length).to eq WikiPage::TITLE_LENGTH @@ -539,7 +539,7 @@ describe WikiPage do end describe "destroy" do - before (:once) { course_factory } + before(:once) { course_factory } it "destroys its assignment if enabled" do @course.enable_feature!(:conditional_release) @@ -567,7 +567,7 @@ describe WikiPage do end describe "restore" do - before (:once) { course_factory } + before(:once) { course_factory } it "restores to unpublished state" do @page = @course.wiki_pages.create! title: 'dot dot dot' diff --git a/spec/presenters/discussion_topic_presenter_spec.rb b/spec/presenters/discussion_topic_presenter_spec.rb index 53afcd140ad..802fdf2f584 100644 --- a/spec/presenters/discussion_topic_presenter_spec.rb +++ b/spec/presenters/discussion_topic_presenter_spec.rb @@ -22,11 +22,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require File.expand_path(File.dirname(__FILE__) + '/../sharding_spec_helper.rb') describe DiscussionTopicPresenter do - let (:topic) { DiscussionTopic.new(:title => 'Test Topic', :assignment => assignment) } - let (:user) { user_model } - let (:presenter) { DiscussionTopicPresenter.new(topic, user) } - let (:course) { course_model } - let (:assignment) { + let(:topic) { DiscussionTopic.new(:title => 'Test Topic', :assignment => assignment) } + let(:user) { user_model } + let(:presenter) { DiscussionTopicPresenter.new(topic, user) } + let(:course) { course_model } + let(:assignment) { Assignment.new(:title => 'Test Topic', :due_at => Time.now, :lock_at => Time.now + 1.week, diff --git a/spec/presenters/quizzes/take_quiz_presenter_spec.rb b/spec/presenters/quizzes/take_quiz_presenter_spec.rb index 15d78612f34..c0dd50a2dc0 100644 --- a/spec/presenters/quizzes/take_quiz_presenter_spec.rb +++ b/spec/presenters/quizzes/take_quiz_presenter_spec.rb @@ -272,8 +272,8 @@ describe Quizzes::TakeQuizPresenter do describe "#question_class" do it "always returns 'list_question'" do - expect(presenter.question_class(question1)).to match /list_question/ - expect(presenter.question_class(question2)).to match /list_question/ + expect(presenter.question_class(question1)).to match(/list_question/) + expect(presenter.question_class(question2)).to match(/list_question/) end it "adds 'answered' if the question was answered" do @@ -282,8 +282,8 @@ describe Quizzes::TakeQuizPresenter do "question_#{question2[:id]}" => nil ) - expect(presenter.question_class(question1)).to match /answered/ - expect(presenter.question_class(question2)).not_to match /answered/ + expect(presenter.question_class(question1)).to match(/answered/) + expect(presenter.question_class(question2)).not_to match(/answered/) end it "adds 'marked' if the question was marked" do @@ -292,21 +292,21 @@ describe Quizzes::TakeQuizPresenter do "question_#{question2[:id]}_marked" => false ) - expect(presenter.question_class(question1)).to match /marked/ - expect(presenter.question_class(question2)).not_to match /marked/ + expect(presenter.question_class(question1)).to match(/marked/) + expect(presenter.question_class(question2)).not_to match(/marked/) end it "adds 'seen' if the question was seen" do - expect(presenter.question_class(question1)).to match /seen/ - expect(presenter.question_class(question2)).not_to match /seen/ + expect(presenter.question_class(question1)).to match(/seen/) + expect(presenter.question_class(question2)).not_to match(/seen/) end it "adds 'text_only' if the question is a text only question" do q2 = question2.dup q2['question_type'] = 'text_only_question' - expect(presenter.question_class(question1)).not_to match /text_only/ - expect(presenter.question_class(q2)).to match /text_only/ + expect(presenter.question_class(question1)).not_to match(/text_only/) + expect(presenter.question_class(q2)).to match(/text_only/) end end diff --git a/spec/selenium/admin/account_direct_share_import_spec.rb b/spec/selenium/admin/account_direct_share_import_spec.rb index 6b2e73be1b0..98cd096e184 100644 --- a/spec/selenium/admin/account_direct_share_import_spec.rb +++ b/spec/selenium/admin/account_direct_share_import_spec.rb @@ -60,7 +60,7 @@ describe "direct share page" do it "notifies on global nav tray" do global_nav_profile_link.click wait_for_ajaximations - expect(profile_tray_menu_items.text).to match /Shared Content/i + expect(profile_tray_menu_items.text).to match(/Shared Content/i) expect(profile_tray_menu_items.text).to include '2 unread.' end diff --git a/spec/selenium/admin/admin_sub_accounts_spec.rb b/spec/selenium/admin/admin_sub_accounts_spec.rb index c26d7c20eb9..9d1e4db1437 100644 --- a/spec/selenium/admin/admin_sub_accounts_spec.rb +++ b/spec/selenium/admin/admin_sub_accounts_spec.rb @@ -49,7 +49,7 @@ describe "admin sub accounts" do wait_for_ajaximations end - before (:each) do + before(:each) do course_with_admin_logged_in end diff --git a/spec/selenium/alerts_spec.rb b/spec/selenium/alerts_spec.rb index 32c0b60e016..40c3782a68e 100644 --- a/spec/selenium/alerts_spec.rb +++ b/spec/selenium/alerts_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/common') describe "Alerts" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do @context = Account.default @context.settings[:enable_alerts] = true @context.save! diff --git a/spec/selenium/announcements/announcements_student_spec.rb b/spec/selenium/announcements/announcements_student_spec.rb index 9d166953144..70aa863aa28 100644 --- a/spec/selenium/announcements/announcements_student_spec.rb +++ b/spec/selenium/announcements/announcements_student_spec.rb @@ -59,7 +59,7 @@ describe "announcements" do end context "announcements as a student" do - before (:each) do + before(:each) do course_with_student_logged_in end @@ -162,7 +162,7 @@ describe "announcements" do end context "section specific announcements" do - before (:once) do + before(:once) do course_with_teacher(active_course: true) @section = @course.course_sections.create!(name: 'test section') diff --git a/spec/selenium/announcements/announcements_teacher_spec.rb b/spec/selenium/announcements/announcements_teacher_spec.rb index 406b848d8a7..28a6cc97635 100644 --- a/spec/selenium/announcements/announcements_teacher_spec.rb +++ b/spec/selenium/announcements/announcements_teacher_spec.rb @@ -72,7 +72,7 @@ describe "announcements" do end context "section specific announcements" do - before (:once) do + before(:once) do course_with_teacher(active_course: true) @section = @course.course_sections.create!(name: 'test section') diff --git a/spec/selenium/assignments/assignments_external_tool_spec.rb b/spec/selenium/assignments/assignments_external_tool_spec.rb index a9f78af8554..edf1f163927 100644 --- a/spec/selenium/assignments/assignments_external_tool_spec.rb +++ b/spec/selenium/assignments/assignments_external_tool_spec.rb @@ -22,7 +22,7 @@ require_relative '../common' describe "external tool assignments" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do course_with_teacher_logged_in @t1 = factory_with_protected_attributes(@course.context_external_tools, :url => "http://www.justanexamplenotarealwebsite.com/tool1", :shared_secret => 'test123', :consumer_key => 'test123', :name => 'tool 1') @t2 = factory_with_protected_attributes(@course.context_external_tools, :url => "http://www.justanexamplenotarealwebsite.com/tool2", :shared_secret => 'test123', :consumer_key => 'test123', :name => 'tool 2') diff --git a/spec/selenium/assignments/assignments_peer_reviews_spec.rb b/spec/selenium/assignments/assignments_peer_reviews_spec.rb index 1708f7da0ee..736b555e800 100644 --- a/spec/selenium/assignments/assignments_peer_reviews_spec.rb +++ b/spec/selenium/assignments/assignments_peer_reviews_spec.rb @@ -44,7 +44,7 @@ describe "assignments" do accept_alert wait_for_ajaximations - expect(fj('.student_reviews:first .peer_reviews').text()).to match /None Assigned/ + expect(fj('.student_reviews:first .peer_reviews').text()).to match(/None Assigned/) keep_trying_until do expect(@assignment.reload.submissions.map(&:assessment_requests).flatten.length).to eq 1 end diff --git a/spec/selenium/assignments/assignments_spec.rb b/spec/selenium/assignments/assignments_spec.rb index bf5930b2d1b..79561a0a30c 100644 --- a/spec/selenium/assignments/assignments_spec.rb +++ b/spec/selenium/assignments/assignments_spec.rb @@ -516,7 +516,7 @@ describe "assignments" do replace_content(fj(".datePickerDateField[data-date-type='due_at']"), 'Sep 20, 2012') end - expect(f('.assignment_dates').text).to match /Sep 20, 2012/ + expect(f('.assignment_dates').text).to match(/Sep 20, 2012/) # some sort of time zone issue is occurring with Sep 20, 2012 - it rolls back a day and an hour locally. expect(@frozen_assign.reload.due_at.to_i).not_to eq old_due_at.to_i end diff --git a/spec/selenium/assignments/assignments_turn_it_in_spec.rb b/spec/selenium/assignments/assignments_turn_it_in_spec.rb index 36a137ace2b..d19173fd378 100644 --- a/spec/selenium/assignments/assignments_turn_it_in_spec.rb +++ b/spec/selenium/assignments/assignments_turn_it_in_spec.rb @@ -22,7 +22,7 @@ require_relative '../common' describe "assignments turn it in" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do course_with_teacher_logged_in account = Account.default account.turnitin_account_id = 'asdf' diff --git a/spec/selenium/calendar/calendar2_event_create_spec.rb b/spec/selenium/calendar/calendar2_event_create_spec.rb index 942db48cf5a..9e026139cc9 100644 --- a/spec/selenium/calendar/calendar2_event_create_spec.rb +++ b/spec/selenium/calendar/calendar2_event_create_spec.rb @@ -71,7 +71,7 @@ describe "calendar2" do expect(title).to be_displayed replace_content(title, event_title) expect_new_page_load { f('.more_options_link').click } - expect(driver.current_url).to match /start_date=\d\d\d\d-\d\d-\d\d/ # passed in ISO format, not localized + expect(driver.current_url).to match(/start_date=\d\d\d\d-\d\d-\d\d/) # passed in ISO format, not localized expect(f('.title')).to have_value event_title expect(f('#editCalendarEventFull .btn-primary').text).to eq "Create Event" replace_content(f('#calendar_event_location_name'), location_name) @@ -194,15 +194,15 @@ describe "calendar2" do expect(CalendarEvent.count).to eq(6) # 2 parent events each with 2 child events s1_events = CalendarEvent.where(:context_code => section1.asset_string) .where.not(:parent_calendar_event_id => nil).order(:start_at).to_a - expect(s1_events[1].start_at.to_date).to eq (s1_events[0].start_at.to_date + 1.week) + expect(s1_events[1].start_at.to_date).to eq(s1_events[0].start_at.to_date + 1.week) s2_events = CalendarEvent.where(:context_code => section2.asset_string) .where.not(:parent_calendar_event_id => nil).order(:start_at).to_a - expect(s2_events[1].start_at.to_date).to eq (s2_events[0].start_at.to_date + 1.week) + expect(s2_events[1].start_at.to_date).to eq(s2_events[0].start_at.to_date + 1.week) end it "queries for all the sections in a course when creating an event" do - 15.times.with_index { |i| add_section("Section #{i}") } + 15.times { |i| add_section("Section #{i}") } num_sections = @course.course_sections.count diff --git a/spec/selenium/calendar/calendar2_sidebar_spec.rb b/spec/selenium/calendar/calendar2_sidebar_spec.rb index 06ad47778be..67b3a5ec3cf 100644 --- a/spec/selenium/calendar/calendar2_sidebar_spec.rb +++ b/spec/selenium/calendar/calendar2_sidebar_spec.rb @@ -161,7 +161,7 @@ describe "calendar2" do wait_for_ajaximations undated_events = ff("#undated-events > ul > li") expect(undated_events.size).to eq 1 - expect(undated_events.first.text).to match /#{e.title}/ + expect(undated_events.first.text).to match(/#{e.title}/) end it "truncates very long undated event titles" do diff --git a/spec/selenium/calendar/calendar2_student_spec.rb b/spec/selenium/calendar/calendar2_student_spec.rb index 6d0494148f9..3f74892c220 100644 --- a/spec/selenium/calendar/calendar2_student_spec.rb +++ b/spec/selenium/calendar/calendar2_student_spec.rb @@ -197,7 +197,7 @@ describe "calendar2" do end context "as a spanish student" do - before (:each) do + before(:each) do # Setup with spanish locale @student = course_with_student_logged_in(:active_all => true).user @student.locale = 'es' diff --git a/spec/selenium/common.rb b/spec/selenium/common.rb index 0aae29336ae..259c05c6f66 100644 --- a/spec/selenium/common.rb +++ b/spec/selenium/common.rb @@ -39,7 +39,7 @@ elsif ENV["TESTRAIL_ENTRY_RUN_ID"] end end -Dir[File.dirname(__FILE__) + '/test_setup/common_helper_methods/*.rb'].each { |file| require file } +Dir[File.dirname(__FILE__) + '/test_setup/common_helper_methods/*.rb'].sort.each { |file| require file } RSpec.configure do |config| config.before :suite do diff --git a/spec/selenium/content_exports_spec.rb b/spec/selenium/content_exports_spec.rb index 72cd74247f6..d1977cdc685 100644 --- a/spec/selenium/content_exports_spec.rb +++ b/spec/selenium/content_exports_spec.rb @@ -25,7 +25,7 @@ describe "content exports" do include_context "in-process server selenium tests" context "as a teacher" do - before (:each) do + before(:each) do course_with_teacher_logged_in end diff --git a/spec/selenium/conversations/conversations_submission_comments_spec.rb b/spec/selenium/conversations/conversations_submission_comments_spec.rb index 3e3cee88a37..2630b4ce757 100644 --- a/spec/selenium/conversations/conversations_submission_comments_spec.rb +++ b/spec/selenium/conversations/conversations_submission_comments_spec.rb @@ -86,8 +86,8 @@ describe "conversations new" do conversation_elements[0].click wait_for_ajaximations reply_to_submission_comment - expect(ffj('.message-item-view').length).to eq (initial_message_count + 1) - expect(@submission.reload.submission_comments.count).to eq (initial_message_count + 1) + expect(ffj('.message-item-view').length).to eq(initial_message_count + 1) + expect(@submission.reload.submission_comments.count).to eq(initial_message_count + 1) end it 'marks unread on click', priority: "2", test_id: 197521 do @@ -133,7 +133,7 @@ describe "conversations new" do it 'shows replies in the submission comments', priority: "2", test_id: pick_test_id(context, student: "2642301", teacher: "2642303") do reply_to_submission_comment - expect(ffj('.message-item-view').length).to eq (3) + expect(ffj('.message-item-view').length).to eq(3) expect(@submission.submission_comments.count).to eq(3) end end diff --git a/spec/selenium/course_settings_spec.rb b/spec/selenium/course_settings_spec.rb index bb384dd2f8b..f26a761f925 100644 --- a/spec/selenium/course_settings_spec.rb +++ b/spec/selenium/course_settings_spec.rb @@ -24,7 +24,7 @@ describe "course settings" do include_context "in-process server selenium tests" include CourseSettingsPage - before (:each) do + before(:each) do course_with_teacher_logged_in :limit_privileges_to_course_section => false @account = @course.account end @@ -438,7 +438,7 @@ describe "course settings" do it "does not include student view student in the statistics count" do @fake_student = @course.student_view_student get "/courses/#{@course.id}/settings" - expect(fj('.summary tr:nth(0)').text).to match /Students:\s*None/ + expect(fj('.summary tr:nth(0)').text).to match(/Students:\s*None/) end it "shows the count of custom role enrollments" do @@ -450,9 +450,9 @@ describe "course settings" do student_role.deactivate! course_with_teacher(:course => @course, :role => teacher_role) get "/courses/#{@course.id}/settings" - expect(fj('.summary tr:nth(1)').text).to match /weirdo \(inactive\):\s*1/ - expect(fj('.summary tr:nth(3)').text).to match /teach:\s*1/ - expect(fj('.summary tr:nth(5)').text).to match /taaaa:\s*None/ + expect(fj('.summary tr:nth(1)').text).to match(/weirdo \(inactive\):\s*1/) + expect(fj('.summary tr:nth(3)').text).to match(/teach:\s*1/) + expect(fj('.summary tr:nth(5)').text).to match(/taaaa:\s*None/) end it "shows publish/unpublish buttons for k5 subject courses", ignore_js_errors: true do @@ -507,7 +507,7 @@ describe "course settings" do end context "link validator" do - before (:each) do + before(:each) do Setting.set('link_validator_poll_timeout', 100) Setting.set('link_validator_poll_timeout_initial', 100) end diff --git a/spec/selenium/course_statistics_spec.rb b/spec/selenium/course_statistics_spec.rb index dfe4778740e..293d8480751 100644 --- a/spec/selenium/course_statistics_spec.rb +++ b/spec/selenium/course_statistics_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/common') describe "course statistics" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do course_with_teacher_logged_in @student1 = student_in_course(:active_all => true, :name => "Sheldon Cooper").user @student2 = student_in_course(:active_all => true, :name => "Leonard Hofstadter").user diff --git a/spec/selenium/courses/courses_spec.rb b/spec/selenium/courses/courses_spec.rb index 554a4ebb4f4..edbdfcf9f2e 100644 --- a/spec/selenium/courses/courses_spec.rb +++ b/spec/selenium/courses/courses_spec.rb @@ -64,7 +64,7 @@ describe "courses" do end context "as a student" do - before (:each) do + before(:each) do course_with_teacher(:active_all => true, :name => 'discussion course') @student = User.create!(:name => "First Student") en = @course.enroll_student(@student) diff --git a/spec/selenium/courses_spec.rb b/spec/selenium/courses_spec.rb index e87e48f9293..ea69a4d2793 100644 --- a/spec/selenium/courses_spec.rb +++ b/spec/selenium/courses_spec.rb @@ -306,7 +306,7 @@ describe "courses" do end end - before (:each) do + before(:each) do course_with_teacher(:active_all => true, :name => 'discussion course') @student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :name => 'student@example.com', :password => 'asdfasdf') Account.default.settings[:allow_invitation_previews] = true diff --git a/spec/selenium/cross_listing_spec.rb b/spec/selenium/cross_listing_spec.rb index 663978d59fb..2d0763daa4e 100644 --- a/spec/selenium/cross_listing_spec.rb +++ b/spec/selenium/cross_listing_spec.rb @@ -55,7 +55,7 @@ describe "cross-listing" do expect(submit_btn).not_to have_class('disabled') submit_form(form) wait_for_ajaximations - keep_trying_until { driver.current_url.match /courses\/#{@course2.id}/ } + keep_trying_until { driver.current_url.match(/courses\/#{@course2.id}/) } # verify teacher doesn't have de-crosslist privileges get "/courses/#{@course2.id}/sections/#{@section.id}" @@ -68,7 +68,7 @@ describe "cross-listing" do expect(f('#uncrosslist_form')).to be_displayed submit_form('#uncrosslist_form') wait_for_ajaximations - keep_trying_until { expect(driver.current_url).to match /courses\/#{@course1.id}/ } + keep_trying_until { expect(driver.current_url).to match(/courses\/#{@course1.id}/) } end it "does not allow cross-listing an invalid section" do diff --git a/spec/selenium/dashboard/elementary/k5_dashboard_observer_spec.rb b/spec/selenium/dashboard/elementary/k5_dashboard_observer_spec.rb index 580734ce651..d2d00154828 100644 --- a/spec/selenium/dashboard/elementary/k5_dashboard_observer_spec.rb +++ b/spec/selenium/dashboard/elementary/k5_dashboard_observer_spec.rb @@ -198,7 +198,7 @@ describe "observer k5 dashboard" do end context 'k5 subject dashboard observee selections' do - let (:wiki_page_data) { "Here's where we have content" } + let(:wiki_page_data) { "Here's where we have content" } before :once do @subject_course.wiki_pages.create!(:title => "K5 Course Front Page", :body => wiki_page_data).set_as_front_page! diff --git a/spec/selenium/dashboard_coming_up_spec.rb b/spec/selenium/dashboard_coming_up_spec.rb index 4094f8c7f38..3f1e5bae000 100644 --- a/spec/selenium/dashboard_coming_up_spec.rb +++ b/spec/selenium/dashboard_coming_up_spec.rb @@ -23,7 +23,7 @@ describe "dashboard" do include_context "in-process server selenium tests" context "as a teacher" do - before (:each) do + before(:each) do course_with_teacher_logged_in(:active_all => true) end diff --git a/spec/selenium/dashboard_spec.rb b/spec/selenium/dashboard_spec.rb index b6101e68b94..4294112864d 100644 --- a/spec/selenium/dashboard_spec.rb +++ b/spec/selenium/dashboard_spec.rb @@ -361,7 +361,7 @@ describe "dashboard" do end context "as a teacher" do - before (:each) do + before(:each) do course_with_teacher_logged_in(:active_cc => true) end diff --git a/spec/selenium/dashboard_teacher_spec.rb b/spec/selenium/dashboard_teacher_spec.rb index f3e5a2884e4..c8c80ecc97e 100644 --- a/spec/selenium/dashboard_teacher_spec.rb +++ b/spec/selenium/dashboard_teacher_spec.rb @@ -25,7 +25,7 @@ describe "dashboard" do include_context "in-process server selenium tests" context "as a teacher" do - before (:each) do + before(:each) do course_with_teacher_logged_in(:active_cc => true) end diff --git a/spec/selenium/dashboard_todo_spec.rb b/spec/selenium/dashboard_todo_spec.rb index 0fb9241b0dc..72761c4ae74 100644 --- a/spec/selenium/dashboard_todo_spec.rb +++ b/spec/selenium/dashboard_todo_spec.rb @@ -23,7 +23,7 @@ describe "dashboard" do include_context "in-process server selenium tests" context "as a student" do - before (:each) do + before(:each) do course_with_student_logged_in(:active_all => true) end diff --git a/spec/selenium/grades/gradebook/gradebook_a11y_spec.rb b/spec/selenium/grades/gradebook/gradebook_a11y_spec.rb index 417f7f77b23..9e5adaf57b6 100644 --- a/spec/selenium/grades/gradebook/gradebook_a11y_spec.rb +++ b/spec/selenium/grades/gradebook/gradebook_a11y_spec.rb @@ -279,7 +279,7 @@ describe "Gradebook" do # toggle to descending sort it 'toggles sort order on student column by name' do cell = Gradebook.student_cell - driver.action.move_to(cell, 0, cell.size.height / 2 - 2).click.perform + driver.action.move_to(cell, 0, (cell.size.height / 2) - 2).click.perform expect(Gradebook.student_grades_link(Gradebook.student_cell(0)).text).to eq(students[0].name) expect(Gradebook.student_grades_link(Gradebook.student_cell(1)).text).to eq(students[1].name) diff --git a/spec/selenium/grades/gradebook/gradebook_pagination_spec.rb b/spec/selenium/grades/gradebook/gradebook_pagination_spec.rb index 0ccb46b8eba..2a58b884650 100644 --- a/spec/selenium/grades/gradebook/gradebook_pagination_spec.rb +++ b/spec/selenium/grades/gradebook/gradebook_pagination_spec.rb @@ -47,6 +47,6 @@ describe "Gradebook" do end it "works for >2 pages" do - test_n_students @page_size * 2 + 1 + test_n_students (@page_size * 2) + 1 end end diff --git a/spec/selenium/grades/gradebook/gradebook_uploads_spec.rb b/spec/selenium/grades/gradebook/gradebook_uploads_spec.rb index 00487bc6ad1..65bdd8c4e97 100644 --- a/spec/selenium/grades/gradebook/gradebook_uploads_spec.rb +++ b/spec/selenium/grades/gradebook/gradebook_uploads_spec.rb @@ -123,7 +123,7 @@ describe "Gradebook - uploads" do assignment_count = @course.assignments.count wait_for_new_page_load(true) { submit_form('#gradebook_grid_form') } run_jobs - expect(@course.assignments.count).to eql (assignment_count + 1) + expect(@course.assignments.count).to eql(assignment_count + 1) assignment = @course.assignments.order(:created_at).last submission = assignment.submissions.last expect(submission.score).to eq 0 @@ -157,7 +157,7 @@ describe "Gradebook - uploads" do assignment_count = @course.assignments.count wait_for_new_page_load { submit_form('#gradebook_grid_form') } run_jobs - expect(@course.assignments.count).to eql (assignment_count + 1) + expect(@course.assignments.count).to eql(assignment_count + 1) assignment = @course.assignments.order(:created_at).last expect(assignment.name).to eq "Assignment 2" expect(assignment.submissions.having_submission.count).to eql 0 diff --git a/spec/selenium/grades/pages/gradebook_individual_view_page.rb b/spec/selenium/grades/pages/gradebook_individual_view_page.rb index 5f105eae079..e4741ed2dae 100644 --- a/spec/selenium/grades/pages/gradebook_individual_view_page.rb +++ b/spec/selenium/grades/pages/gradebook_individual_view_page.rb @@ -197,7 +197,7 @@ class GradebookIndividualViewPage def drop_lowest(course, num_assignment) ag = course.assignment_groups.first - ag.rules_hash = { "drop_lowest": num_assignment } + ag.rules_hash = { drop_lowest: num_assignment } ag.save! end diff --git a/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb b/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb index 4b0a759b87f..d4532fccdca 100644 --- a/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb +++ b/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb @@ -82,15 +82,15 @@ describe "speed grader - quiz submissions" do # create our quiz and our multiple answers question @context = @course @q = quiz_model - answers = [{ 'id': 1, 'text': 'one', 'weight': 100 }, - { 'id': 2, 'text': 'two', 'weight': 100 }, - { 'id': 3, 'text': 'three', 'weight': 100 }, - { 'id': 4, 'text': 'four', 'weight': 0 }] + answers = [{ id: 1, text: 'one', weight: 100 }, + { id: 2, text: 'two', weight: 100 }, + { id: 3, text: 'three', weight: 100 }, + { id: 4, text: 'four', weight: 0 }] @quest1 = @q.quiz_questions.create!( question_data: { name: "first question", - 'question_type': 'multiple_answers_question', - 'answers': answers, + question_type: 'multiple_answers_question', + answers: answers, points_possible: 4 } ) @@ -146,7 +146,7 @@ describe "speed grader - quiz submissions" do @quiz.workflow_state = 'available' @quiz.save! qs = @quiz.generate_submission(@student) - qs.submission_data = { "foo": "bar1" } + qs.submission_data = { foo: "bar1" } Quizzes::SubmissionGrader.new(qs).grade_submission get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}" @@ -178,7 +178,7 @@ describe "speed grader - quiz submissions" do [@student, @teacher].each do @quiz.generate_submission(@student).tap do |qs| - qs.submission_data = { 'foo': 'bar1' } + qs.submission_data = { foo: 'bar1' } Quizzes::SubmissionGrader.new(qs).grade_submission end end diff --git a/spec/selenium/grades/speedgrader/speedgrader_teacher_submission_spec.rb b/spec/selenium/grades/speedgrader/speedgrader_teacher_submission_spec.rb index eab8e34582d..e6e66dc7047 100644 --- a/spec/selenium/grades/speedgrader/speedgrader_teacher_submission_spec.rb +++ b/spec/selenium/grades/speedgrader/speedgrader_teacher_submission_spec.rb @@ -352,7 +352,7 @@ describe "speed grader submissions" do get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}" wait_for_ajaximations - expect(ff('#submission_files_list .turnitin_similarity_score').map(&:text).join).to match /96%/ + expect(ff('#submission_files_list .turnitin_similarity_score').map(&:text).join).to match(/96%/) expect(f('#submission_files_list .submission_pending')).not_to be_nil end diff --git a/spec/selenium/grades/student_grades_page/gradebook_student_common.rb b/spec/selenium/grades/student_grades_page/gradebook_student_common.rb index e4d4d830284..455225311ff 100644 --- a/spec/selenium/grades/student_grades_page/gradebook_student_common.rb +++ b/spec/selenium/grades/student_grades_page/gradebook_student_common.rb @@ -41,7 +41,7 @@ shared_examples 'Arrange By dropdown' do |context| table_rows = ff('#grades_summary tr') title_order.each_with_index do |assign_name, index| - expect(table_rows[4 * index + 1].find_element(:css, 'th')).to include_text assign_name + expect(table_rows[(4 * index) + 1].find_element(:css, 'th')).to include_text assign_name end end @@ -81,7 +81,7 @@ shared_examples 'Arrange By dropdown' do |context| table_rows = ff('#grades_summary tr') title_order.each_with_index do |assign_name, index| - expect(table_rows[4 * index + 1].find_element(:css, 'th')).to include_text assign_name + expect(table_rows[(4 * index) + 1].find_element(:css, 'th')).to include_text assign_name end end @@ -90,7 +90,7 @@ shared_examples 'Arrange By dropdown' do |context| table_rows = ff('#grades_summary tr') due_date_order.each_with_index do |assign_name, index| - expect(table_rows[4 * index + 1].find_element(:css, 'th')).to include_text assign_name + expect(table_rows[(4 * index) + 1].find_element(:css, 'th')).to include_text assign_name end end @@ -100,7 +100,7 @@ shared_examples 'Arrange By dropdown' do |context| table_rows = ff('#grades_summary tr') module_order.each_with_index do |assign_name, index| - expect(table_rows[4 * index + 1].find_element(:css, 'th')).to include_text assign_name + expect(table_rows[(4 * index) + 1].find_element(:css, 'th')).to include_text assign_name end end @@ -110,7 +110,7 @@ shared_examples 'Arrange By dropdown' do |context| table_rows = ff('#grades_summary tr') assign_group_order.each_with_index do |assign_name, index| - expect(table_rows[4 * index + 1].find_element(:css, 'th')).to include_text assign_name + expect(table_rows[(4 * index) + 1].find_element(:css, 'th')).to include_text assign_name end end diff --git a/spec/selenium/help_dialog_spec.rb b/spec/selenium/help_dialog_spec.rb index e78981fad48..9c00d4b69cb 100644 --- a/spec/selenium/help_dialog_spec.rb +++ b/spec/selenium/help_dialog_spec.rb @@ -42,7 +42,7 @@ describe "help dialog" do end context "help as a student" do - before (:each) do + before(:each) do course_with_student_logged_in(:active_all => true) end diff --git a/spec/selenium/helpers/basic/question_banks_specs.rb b/spec/selenium/helpers/basic/question_banks_specs.rb index a4876e67825..d7c13205bcd 100644 --- a/spec/selenium/helpers/basic/question_banks_specs.rb +++ b/spec/selenium/helpers/basic/question_banks_specs.rb @@ -19,7 +19,7 @@ shared_examples_for "question bank basic tests" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do admin_logged_in get url end diff --git a/spec/selenium/helpers/basic/statistics_specs.rb b/spec/selenium/helpers/basic/statistics_specs.rb index b10e56465da..758922d68e4 100644 --- a/spec/selenium/helpers/basic/statistics_specs.rb +++ b/spec/selenium/helpers/basic/statistics_specs.rb @@ -29,7 +29,7 @@ shared_examples_for "statistics basic tests" do end context "with admin initially logged in" do - before (:each) do + before(:each) do @course = Course.create!(:name => 'stats', :account => account) @course.offer! admin_logged_in diff --git a/spec/selenium/helpers/scheduler_common.rb b/spec/selenium/helpers/scheduler_common.rb index 96c47cc9b8c..688e52ccef3 100644 --- a/spec/selenium/helpers/scheduler_common.rb +++ b/spec/selenium/helpers/scheduler_common.rb @@ -100,8 +100,8 @@ module SchedulerCommon title: opts[:title], contexts: opts[:contexts], new_appointments: [ - [opts[:start_at] || Time.zone.now + 1.hour, - opts[:end_at] || Time.zone.now + 3.hours], + [opts[:start_at] || (Time.zone.now + 1.hour), + opts[:end_at] || (Time.zone.now + 3.hours)], ], participants_per_appointment: opts[:participants] || 4 } diff --git a/spec/selenium/i18n_js_spec.rb b/spec/selenium/i18n_js_spec.rb index 0cfe22d7df5..ddc287d6d54 100644 --- a/spec/selenium/i18n_js_spec.rb +++ b/spec/selenium/i18n_js_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + "/common") describe "i18n js" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do course_with_teacher_logged_in get "/" # get I18n global for all the tests diff --git a/spec/selenium/jquery_ui_spec.rb b/spec/selenium/jquery_ui_spec.rb index 0c77573efb1..9d5683f0057 100644 --- a/spec/selenium/jquery_ui_spec.rb +++ b/spec/selenium/jquery_ui_spec.rb @@ -41,7 +41,7 @@ describe "jquery ui" do JS end - before (:each) do + before(:each) do course_with_teacher_logged_in get "/" end diff --git a/spec/selenium/layout_spec.rb b/spec/selenium/layout_spec.rb index 8dc3ed8b1de..99cd17d50ca 100644 --- a/spec/selenium/layout_spec.rb +++ b/spec/selenium/layout_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/common') describe "layout" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do course_with_student_logged_in @user.update_attribute(:name, "evil html & name") get "/" diff --git a/spec/selenium/links_spec.rb b/spec/selenium/links_spec.rb index 80631795e5e..76fa0d5c845 100644 --- a/spec/selenium/links_spec.rb +++ b/spec/selenium/links_spec.rb @@ -22,12 +22,12 @@ require File.expand_path(File.dirname(__FILE__) + '/common') describe "links", priority: "2" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do course_with_teacher_logged_in end describe "course links" do - before (:each) do + before(:each) do get "/courses/#{@course.id}" end @@ -104,7 +104,7 @@ describe "links", priority: "2" do end describe "dashboard links" do - before (:each) do + before(:each) do get "/" end diff --git a/spec/selenium/manage_new_groups_spec.rb b/spec/selenium/manage_new_groups_spec.rb index 4d6b2edfa27..2353686abcc 100644 --- a/spec/selenium/manage_new_groups_spec.rb +++ b/spec/selenium/manage_new_groups_spec.rb @@ -19,8 +19,6 @@ # require File.expand_path(File.dirname(__FILE__) + '/helpers/manage_groups_common') -require 'thread' - describe "manage groups" do include_context "in-process server selenium tests" include ManageGroupsCommon diff --git a/spec/selenium/outcomes/outcome_teacher_spec.rb b/spec/selenium/outcomes/outcome_teacher_spec.rb index 3ba4f3e19c8..ca836d44469 100644 --- a/spec/selenium/outcomes/outcome_teacher_spec.rb +++ b/spec/selenium/outcomes/outcome_teacher_spec.rb @@ -165,7 +165,7 @@ describe "outcomes as a teacher" do end context "moving outcomes tree" do - before (:each) do + before(:each) do course_with_teacher_logged_in who_to_login == 'teacher' ? @context = @course : @context = account end diff --git a/spec/selenium/rcs/alerts_spec.rb b/spec/selenium/rcs/alerts_spec.rb index e0655de2fbc..bd220c12705 100644 --- a/spec/selenium/rcs/alerts_spec.rb +++ b/spec/selenium/rcs/alerts_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../common') describe "Alerts" do include_context "in-process server selenium tests" - before (:each) do + before(:each) do @context = Account.default @context.settings[:enable_alerts] = true @context.save! diff --git a/spec/selenium/rcs/rce_next_autosave_spec.rb b/spec/selenium/rcs/rce_next_autosave_spec.rb index 464571105f5..f1754b8d5be 100644 --- a/spec/selenium/rcs/rce_next_autosave_spec.rb +++ b/spec/selenium/rcs/rce_next_autosave_spec.rb @@ -134,7 +134,7 @@ describe 'RCE Next autosave feature', ignore_js_errors: true do # remove ignore_js_errors in LS-1163 get '/' driver.local_storage.clear - driver.local_storage['xyzzy'] = 'x' * 5_119 * 1_024 + 'x' * 1_000 + driver.local_storage['xyzzy'] = ('x' * 5_119 * 1_024) + ('x' * 1_000) create_and_edit_announcement saved_content = driver.local_storage[autosave_key] expect(saved_content).to be_nil # though it didn't throw an exception @@ -149,7 +149,7 @@ describe 'RCE Next autosave feature', ignore_js_errors: true do get '/' driver.local_storage.clear driver.local_storage[autosave_key(@teacher.id, 'http://some/url', 'id')] = - make_autosave_entry('x' * 5_119 * 1_024 + 'x' * 921) + make_autosave_entry(('x' * 5_119 * 1_024) + ('x' * 921)) create_and_edit_announcement saved_content = driver.local_storage[autosave_key] saved_content = JSON.parse(saved_content) diff --git a/spec/selenium/test_setup/common_helper_methods/custom_wait_methods.rb b/spec/selenium/test_setup/common_helper_methods/custom_wait_methods.rb index 4dccea8afb5..d6939f51ee3 100644 --- a/spec/selenium/test_setup/common_helper_methods/custom_wait_methods.rb +++ b/spec/selenium/test_setup/common_helper_methods/custom_wait_methods.rb @@ -105,7 +105,7 @@ module CustomWaitMethods } else { var fallbackCallback = window.setTimeout(function() { callback(-2); - }, #{SeleniumDriverSetup.timeouts[:script] * 1000 - 500}) + }, #{(SeleniumDriverSetup.timeouts[:script] * 1000) - 500}) function onXHRCompleted () { // while there are no outstanding requests, a new one could be diff --git a/spec/selenium/user_content_student_spec.rb b/spec/selenium/user_content_student_spec.rb index 27ed5e903aa..8f342e8caba 100644 --- a/spec/selenium/user_content_student_spec.rb +++ b/spec/selenium/user_content_student_spec.rb @@ -32,7 +32,7 @@ describe "user_content" do MESSAGE end - before (:each) do + before(:each) do course_with_student_logged_in(:active_all => true) allow(HostUrl).to receive(:is_file_host?).and_return(true) end diff --git a/spec/selenium/users_spec.rb b/spec/selenium/users_spec.rb index 42134200f9a..45870005c14 100644 --- a/spec/selenium/users_spec.rb +++ b/spec/selenium/users_spec.rb @@ -51,7 +51,7 @@ describe "users" do end context "page views" do - before (:each) do + before(:each) do course_with_admin_logged_in @student = student_in_course.user Setting.set('enable_page_views', 'db') @@ -136,7 +136,7 @@ describe "users" do expect(f('#login_information')).to include_text(user_id) end - before (:each) do + before(:each) do @student_1_id = 'student1@example.com' @student_2_id = 'student2@example.com' diff --git a/spec/selenium/wiki_pages_spec.rb b/spec/selenium/wiki_pages_spec.rb index 149e2562f06..4e288303569 100644 --- a/spec/selenium/wiki_pages_spec.rb +++ b/spec/selenium/wiki_pages_spec.rb @@ -215,7 +215,7 @@ describe "Wiki Pages" do # validation lock_explanation = f('.lock_explanation').text expect(lock_explanation).to include "This page is part of the module the_mod and hasn't been unlocked yet" - expect(lock_explanation).to match /foo\s+must view the page/ + expect(lock_explanation).to match(/foo\s+must view the page/) end it "does not show the show all pages link if the pages tab is disabled" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4ad07b271f0..df099750cc9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -50,7 +50,7 @@ module WebMock::API end end -Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f } require_relative 'sharding_spec_helper' # nuke the db (say, if `rake db:migrate RAILS_ENV=test` created records), @@ -233,7 +233,7 @@ require File.expand_path(File.dirname(__FILE__) + '/ams_spec_helper') require 'i18n_tasks' require_relative 'factories' -Dir[File.dirname(__FILE__) + "/shared_examples/**/*.rb"].each { |f| require f } +Dir[File.dirname(__FILE__) + "/shared_examples/**/*.rb"].sort.each { |f| require f } # rspec aliases :describe to :context in a way that it's pretty much defined # globally on every object. :context is already heavily used in our application, @@ -249,7 +249,7 @@ end RSpec::Mocks.configuration.allow_message_expectations_on_nil = false # Require all custom matchers -Dir[Rails.root.join('spec', 'support', 'custom_matchers', '*.rb')].each { |f| require f } +Dir[Rails.root.join('spec', 'support', 'custom_matchers', '*.rb')].sort.each { |f| require f } module RSpec::Matchers::Helpers # allows for matchers to use symbols and literals even though URIs are always strings. @@ -617,7 +617,7 @@ RSpec.configure do |config| BACKENDS = %w{FileSystem S3}.map { |backend| AttachmentFu::Backends.const_get(:"#{backend}Backend") }.freeze class As # :nodoc: - private *instance_methods.select { |m| m !~ /(^__|^\W|^binding$|^untaint$)/ } + private(*instance_methods.select { |m| m !~ /(^__|^\W|^binding$|^untaint$)/ }) def initialize(subject, ancestor) @subject = subject @@ -861,7 +861,7 @@ module I18nStubs end LazyPresumptuousI18nBackend.prepend(I18nStubs) -Dir[Rails.root + '{gems,vendor}/plugins/*/spec_canvas/spec_helper.rb'].each { |file| require file } +Dir[Rails.root + '{gems,vendor}/plugins/*/spec_canvas/spec_helper.rb'].sort.each { |file| require file } Shoulda::Matchers.configure do |config| config.integrate do |with| diff --git a/spec/support/spec_time_limit.rb b/spec/support/spec_time_limit.rb index 428df85924a..8b615502581 100644 --- a/spec/support/spec_time_limit.rb +++ b/spec/support/spec_time_limit.rb @@ -59,7 +59,7 @@ module SpecTimeLimit [:target, example.metadata[:custom_timeout].to_i] elsif ENV.fetch("SELENIUM_REMOTE_URL", "undefined remote url").include? "saucelabs" [:status_quo, SAUCELABS_ABSOLUTE_TIMEOUT] - elsif example.file_path.match? /\.\/spec\/selenium\/.*rcs/ # files in ./spec/selenium/**/rcs + elsif example.file_path.match?(/\.\/spec\/selenium\/.*rcs/) # files in ./spec/selenium/**/rcs [:target, SIDEBAR_LOADING_TIMEOUT] elsif example.file_path.include? "./spec/selenium/performance/" [:status_quo, PERFORMANCE_TIMEOUT] diff --git a/spec/views/communication_channels/confirm.html.erb_spec.rb b/spec/views/communication_channels/confirm.html.erb_spec.rb index 527c75a73d1..cf4f4b05808 100644 --- a/spec/views/communication_channels/confirm.html.erb_spec.rb +++ b/spec/views/communication_channels/confirm.html.erb_spec.rb @@ -40,7 +40,7 @@ describe "communication_channels/confirm.html.erb" do registration_form = page.css('#registration_confirmation_form').first expect(registration_form).not_to be_nil if @enrollment - expect(registration_form['style']).to match /display:\s*none/ + expect(registration_form['style']).to match(/display:\s*none/) expect(page.css('#register.btn').first).not_to be_nil expect(page.css('#back.btn').first).to be_nil else @@ -57,7 +57,7 @@ describe "communication_channels/confirm.html.erb" do page = Nokogiri::HTML5('' + response.body + '') registration_form = page.css('#registration_confirmation_form').first expect(registration_form).not_to be_nil - expect(registration_form['style']).to match /display:\s*none/ + expect(registration_form['style']).to match(/display:\s*none/) expect(page.css('input[type="radio"][name="pseudonym_select"]')).to be_empty expect(page.css('#register.btn').first).not_to be_nil merge_button = page.css('#merge.btn').first @@ -75,7 +75,7 @@ describe "communication_channels/confirm.html.erb" do page = Nokogiri::HTML5('' + response.body + '') registration_form = page.css('#registration_confirmation_form').first expect(registration_form).not_to be_nil - expect(registration_form['style']).to match /display:\s*none/ + expect(registration_form['style']).to match(/display:\s*none/) expect(page.css('input[type="radio"][name="pseudonym_select"]')).to be_empty expect(page.css('#register.btn').first).not_to be_nil merge_button = page.css('#merge.btn').first @@ -93,7 +93,7 @@ describe "communication_channels/confirm.html.erb" do page = Nokogiri::HTML5('' + response.body + '') registration_form = page.css('#registration_confirmation_form').first expect(registration_form).not_to be_nil - expect(registration_form['style']).to match /display:\s*none/ + expect(registration_form['style']).to match(/display:\s*none/) expect(page.css('input[type="radio"][name="pseudonym_select"]')).to be_empty expect(page.css('#register.btn').first).not_to be_nil merge_button = page.css('#merge.btn').first @@ -111,7 +111,7 @@ describe "communication_channels/confirm.html.erb" do page = Nokogiri::HTML5('' + response.body + '') registration_form = page.css('#registration_confirmation_form').first expect(registration_form).not_to be_nil - expect(registration_form['style']).to match /display:\s*none/ + expect(registration_form['style']).to match(/display:\s*none/) expect(page.css('input[type="radio"][name="pseudonym_select"]').length).to eq 2 expect(page.css('#register.btn').first).not_to be_nil merge_button = page.css('#merge.btn').first @@ -138,7 +138,7 @@ describe "communication_channels/confirm.html.erb" do page = Nokogiri::HTML5('' + response.body + '') registration_form = page.css('#registration_confirmation_form').first expect(registration_form).not_to be_nil - expect(registration_form['style']).to match /display:\s*none/ + expect(registration_form['style']).to match(/display:\s*none/) expect(page.css('input[type="radio"][name="pseudonym_select"]').length).to eq 6 expect(page.css('#register.btn')).to be_empty merge_button = page.css('#merge.btn').first diff --git a/spec/views/context/undelete_index.html.erb_spec.rb b/spec/views/context/undelete_index.html.erb_spec.rb index 64283c85729..6971391e17d 100644 --- a/spec/views/context/undelete_index.html.erb_spec.rb +++ b/spec/views/context/undelete_index.html.erb_spec.rb @@ -31,7 +31,7 @@ describe "context/undelete_index.html.erb" do quiz = @course.quizzes.create! assign(:deleted_items, [quiz]) render - expect(response.body).not_to match /quizzes:quiz/ - expect(response.body).to match /quiz_#{quiz.id}/ + expect(response.body).not_to match(/quizzes:quiz/) + expect(response.body).to match(/quiz_#{quiz.id}/) end end diff --git a/spec/views/courses/settings.html.erb_spec.rb b/spec/views/courses/settings.html.erb_spec.rb index 89cba1c830d..d910a1559be 100644 --- a/spec/views/courses/settings.html.erb_spec.rb +++ b/spec/views/courses/settings.html.erb_spec.rb @@ -96,8 +96,8 @@ describe "courses/settings.html.erb" do assign(:current_user, admin) assign(:publishing_enabled, true) render - expect(response.body).to match // - expect(response.body).to match /
/ + expect(response.body).to match(//) + expect(response.body).to match(/
/) end it "does not show grade export when disabled" do @@ -106,8 +106,8 @@ describe "courses/settings.html.erb" do assign(:current_user, admin) assign(:publishing_enabled, false) render - expect(response.body).not_to match // - expect(response.body).not_to match /
/ + expect(response.body).not_to match(//) + expect(response.body).not_to match(/
/) end end diff --git a/spec/views/files/show.html.erb_spec.rb b/spec/views/files/show.html.erb_spec.rb index aa0ed6c3351..7384ddfdd06 100644 --- a/spec/views/files/show.html.erb_spec.rb +++ b/spec/views/files/show.html.erb_spec.rb @@ -38,6 +38,6 @@ describe "/files/index" do attachment.save! assign(:attachment, attachment) render "files/show" - expect(rendered).to match /This file is currently locked/ + expect(rendered).to match(/This file is currently locked/) end end diff --git a/spec/views/gradebooks/grade_summary.html.erb_spec.rb b/spec/views/gradebooks/grade_summary.html.erb_spec.rb index 83d7a849b07..766d90bb858 100644 --- a/spec/views/gradebooks/grade_summary.html.erb_spec.rb +++ b/spec/views/gradebooks/grade_summary.html.erb_spec.rb @@ -532,7 +532,7 @@ describe "/gradebooks/grade_summary" do end context "when comments exist" do - before (:each) do + before(:each) do submission = assignment.submission_for_student(student) submission.add_comment(author: teacher, comment: "hello") end diff --git a/spec/views/profile/_ways_to_contact.html.erb_spec.rb b/spec/views/profile/_ways_to_contact.html.erb_spec.rb index 1b15a14e326..695e4fd529e 100644 --- a/spec/views/profile/_ways_to_contact.html.erb_spec.rb +++ b/spec/views/profile/_ways_to_contact.html.erb_spec.rb @@ -45,7 +45,7 @@ describe "/profile/_ways_to_contact" do assign(:user, @user) render :partial => "profile/ways_to_contact" - expect(response.body).not_to match /confirm_channel_link/ + expect(response.body).not_to match(/confirm_channel_link/) end it "shows an admin the confirm link" do @@ -59,7 +59,7 @@ describe "/profile/_ways_to_contact" do assign(:user, @user) render :partial => "profile/ways_to_contact" - expect(response.body).to match /confirm_channel_link/ + expect(response.body).to match(/confirm_channel_link/) end it "does not show confirm link for confirmed channels" do @@ -73,7 +73,7 @@ describe "/profile/_ways_to_contact" do assign(:user, @user) render :partial => "profile/ways_to_contact" - expect(response.body).not_to match /confirm_channel_link/ + expect(response.body).not_to match(/confirm_channel_link/) end it "does not show confirm link for push channels" do @@ -104,7 +104,7 @@ describe "/profile/_ways_to_contact" do assign(:user, @user) render :partial => "profile/ways_to_contact" - expect(response.body).to match /channel default.*channel_#{email.id}/ + expect(response.body).to match(/channel default.*channel_#{email.id}/) end it "shows an admin masquerading as a user the confirm link" do @@ -119,7 +119,7 @@ describe "/profile/_ways_to_contact" do assign(:user, @student) render :partial => "profile/ways_to_contact" - expect(response.body).to match /confirm_channel_link/ + expect(response.body).to match(/confirm_channel_link/) end it 'does not show the "I want to log in" for non-default accounts' do @@ -132,6 +132,6 @@ describe "/profile/_ways_to_contact" do assign(:domain_root_account, Account.create!) render :partial => "profile/ways_to_contact" - expect(response.body).not_to match /I want to log in to Canvas using this email address/ + expect(response.body).not_to match(/I want to log in to Canvas using this email address/) end end diff --git a/spec/views/quizzes/quizzes/_quiz_edit.html.erb_spec.rb b/spec/views/quizzes/quizzes/_quiz_edit.html.erb_spec.rb index f7625c2e8bb..c53bf451238 100644 --- a/spec/views/quizzes/quizzes/_quiz_edit.html.erb_spec.rb +++ b/spec/views/quizzes/quizzes/_quiz_edit.html.erb_spec.rb @@ -37,34 +37,34 @@ describe "/quizzes/quizzes/_quiz_edit" do it 'includes conditional content if configured' do allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(true) render :partial => "quizzes/quizzes/quiz_edit" - expect(response.body).to match /conditional_release/ + expect(response.body).to match(/conditional_release/) end it 'does not include conditional content if not configured' do allow(ConditionalRelease::Service).to receive(:enabled_in_context?).and_return(false) render :partial => "quizzes/quizzes/quiz_edit" - expect(response.body).not_to match /conditional_release/ + expect(response.body).not_to match(/conditional_release/) end it 'includes quiz details' do render :partial => "quizzes/quizzes/quiz_edit" - expect(response.body).to match /options_tab/ + expect(response.body).to match(/options_tab/) end it 'includes quiz questions' do render :partial => "quizzes/quizzes/quiz_edit" - expect(response.body).to match /questions_tab/ + expect(response.body).to match(/questions_tab/) end it 'warns about existing submission data' do assign(:has_student_submissions, true) render :partial => "quizzes/quizzes/quiz_edit" - expect(response.body).to match /student_submissions_warning/ + expect(response.body).to match(/student_submissions_warning/) end it 'does not warn if no existing data' do assign(:has_student_submissions, false) render :partial => "quizzes/quizzes/quiz_edit" - expect(response.body).not_to match /student_submissions_warning/ + expect(response.body).not_to match(/student_submissions_warning/) end end diff --git a/spec/views/quizzes/quizzes/history.html.erb_spec.rb b/spec/views/quizzes/quizzes/history.html.erb_spec.rb index 76c8ee772cf..17fe26e1d5d 100644 --- a/spec/views/quizzes/quizzes/history.html.erb_spec.rb +++ b/spec/views/quizzes/quizzes/history.html.erb_spec.rb @@ -40,14 +40,14 @@ describe "/quizzes/quizzes/history" do @student.preferences[:enable_speedgrader_grade_by_question] = true @student.save! render "quizzes/quizzes/history" - expect(response.body).to match /quiz-nav/ + expect(response.body).to match(/quiz-nav/) end it "doesn't display when not enabled" do @student.preferences[:enable_speedgrader_grade_by_question] = nil @student.save! render "quizzes/quizzes/history" - expect(response.body).not_to match /quiz-nav/ + expect(response.body).not_to match(/quiz-nav/) end end @@ -66,7 +66,7 @@ describe "/quizzes/quizzes/history" do assign(:version_instances, sub.submitted_attempts) render "quizzes/quizzes/history" - expect(response.body).to match /grade-by-question-warning/ + expect(response.body).to match(/grade-by-question-warning/) end it 'does not display when quiz has only questions' do @@ -76,7 +76,7 @@ describe "/quizzes/quizzes/history" do assign(:version_instances, sub.submitted_attempts) render "quizzes/quizzes/history" - expect(response.body).not_to match /grade-by-question-warning/ + expect(response.body).not_to match(/grade-by-question-warning/) end end diff --git a/spec/views/users/_name.html.erb_spec.rb b/spec/views/users/_name.html.erb_spec.rb index 43360045e88..f4e669b69f9 100644 --- a/spec/views/users/_name.html.erb_spec.rb +++ b/spec/views/users/_name.html.erb_spec.rb @@ -29,7 +29,7 @@ describe "/users/name" do assign(:user, @student) assign(:enrollments, []) render :partial => "users/name" - expect(response.body).to match /Delete from #{Account.default.name}/ + expect(response.body).to match(/Delete from #{Account.default.name}/) end it "allows deletes for managaged pseudonyms with correct privileges" do @@ -40,7 +40,7 @@ describe "/users/name" do assign(:user, @student) assign(:enrollments, []) render :partial => "users/name" - expect(response.body).to match /Delete from #{Account.default.name}/ + expect(response.body).to match(/Delete from #{Account.default.name}/) end it "does not allow deletes for managed pseudonyms without correct privileges" do @@ -51,7 +51,7 @@ describe "/users/name" do assign(:user, @student) assign(:enrollments, []) render :partial => "users/name" - expect(response.body).not_to match /Delete from #{Account.default.name}/ + expect(response.body).not_to match(/Delete from #{Account.default.name}/) end it "does not allow deletes for unmanaged pseudonyms without correct privileges" do @@ -61,7 +61,7 @@ describe "/users/name" do assign(:user, @student) assign(:enrollments, []) render :partial => "users/name" - expect(response.body).not_to match /Delete from #{Account.default.name}/ + expect(response.body).not_to match(/Delete from #{Account.default.name}/) end describe "default email address" do diff --git a/spec/views/users/admin_merge.html.erb_spec.rb b/spec/views/users/admin_merge.html.erb_spec.rb index 56a98148182..4496409696a 100644 --- a/spec/views/users/admin_merge.html.erb_spec.rb +++ b/spec/views/users/admin_merge.html.erb_spec.rb @@ -40,8 +40,8 @@ describe "/users/admin_merge" do render "users/admin_merge" expect(response).not_to be_nil - expect(response.body).to match /My Root Account/ - expect(response.body).to match /Sub-Account/ - expect(response.body).not_to match /Default Account/ + expect(response.body).to match(/My Root Account/) + expect(response.body).to match(/Sub-Account/) + expect(response.body).not_to match(/Default Account/) end end