From 4d43809cae55a8c6cd4c01f90336468bb835dcb7 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Wed, 17 Nov 2021 15:07:40 -0700 Subject: [PATCH] RuboCop: Style/PercentLiteralDelimiters [skip-stages=Flakey] auto-corrected, with a post-review looking for multiline strings to convert to heredocs Change-Id: I7f7afb11edd63415cde10866822dd2ac5ba0d8be Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278669 Tested-by: Service Cloud Jenkins Reviewed-by: Jacob Burroughs QA-Review: Cody Cutrer Product-Review: Cody Cutrer Migration-Review: Cody Cutrer --- .rubocop.common.yml | 4 +- app/controllers/accounts_controller.rb | 14 +- app/controllers/application_controller.rb | 4 +- .../assignment_groups_controller.rb | 2 +- app/controllers/assignments_api_controller.rb | 2 +- .../calendar_events_api_controller.rb | 4 +- .../content_exports_api_controller.rb | 4 +- app/controllers/content_imports_controller.rb | 4 +- .../content_migrations_controller.rb | 2 +- app/controllers/content_shares_controller.rb | 4 +- .../context_module_items_api_controller.rb | 2 +- .../context_modules_api_controller.rb | 2 +- app/controllers/context_modules_controller.rb | 6 +- app/controllers/conversations_controller.rb | 4 +- app/controllers/courses_controller.rb | 14 +- ...om_gradebook_column_data_api_controller.rb | 2 +- .../discussion_topics_controller.rb | 12 +- app/controllers/enrollments_api_controller.rb | 10 +- .../external_content_controller.rb | 2 +- app/controllers/files_controller.rb | 4 +- app/controllers/folders_controller.rb | 2 +- .../group_categories_controller.rb | 2 +- .../group_memberships_controller.rb | 4 +- app/controllers/groups_controller.rb | 4 +- .../lti/ims/concerns/deep_linking_modules.rb | 4 +- .../lti/ims/line_items_controller.rb | 4 +- .../lti/ims/tool_setting_controller.rb | 20 +- .../lti/membership_service_controller.rb | 2 +- app/controllers/lti/message_controller.rb | 2 +- .../lti/originality_reports_api_controller.rb | 2 +- .../lti/submissions_api_controller.rb | 4 +- app/controllers/lti/users_api_controller.rb | 2 +- .../master_templates_controller.rb | 2 +- .../outcome_imports_api_controller.rb | 2 +- app/controllers/outcome_results_controller.rb | 8 +- app/controllers/outcomes_controller.rb | 2 +- app/controllers/planner_controller.rb | 2 +- .../provisional_grades_base_controller.rb | 2 +- .../provisional_grades_controller.rb | 4 +- app/controllers/question_banks_controller.rb | 4 +- app/controllers/role_overrides_controller.rb | 6 +- .../rubric_associations_controller.rb | 2 +- app/controllers/rubrics_api_controller.rb | 4 +- app/controllers/sections_controller.rb | 2 +- .../sis_import_errors_api_controller.rb | 2 +- app/controllers/submissions_api_controller.rb | 2 +- .../submissions_base_controller.rb | 2 +- app/controllers/submissions_controller.rb | 2 +- app/controllers/tabs_controller.rb | 2 +- app/controllers/terms_api_controller.rb | 2 +- app/controllers/terms_controller.rb | 2 +- app/controllers/user_observees_controller.rb | 2 +- app/controllers/users_controller.rb | 18 +- app/controllers/wiki_pages_api_controller.rb | 6 +- app/helpers/assignments_helper.rb | 2 +- app/helpers/attachment_helper.rb | 2 +- app/helpers/content_imports_helper.rb | 2 +- app/helpers/courses_helper.rb | 2 +- app/helpers/gradebooks_helper.rb | 4 +- app/helpers/stream_items_helper.rb | 4 +- app/models/account.rb | 2 +- app/models/account_report_runner.rb | 6 +- app/models/account_user.rb | 2 +- app/models/asset_user_access.rb | 4 +- app/models/assignment.rb | 30 +- app/models/assignment/bulk_update.rb | 4 +- app/models/assignment_override.rb | 2 +- app/models/assignment_override_student.rb | 2 +- app/models/attachment.rb | 10 +- app/models/authentication_provider.rb | 4 +- app/models/bounce_notification_processor.rb | 2 +- .../assignment_set_action.rb | 4 +- app/models/conditional_release/service.rb | 4 +- app/models/content_migration.rb | 10 +- app/models/content_share.rb | 2 +- app/models/context.rb | 2 +- app/models/context_external_tool.rb | 4 +- app/models/context_module.rb | 6 +- app/models/context_module_progression.rb | 4 +- app/models/conversation.rb | 2 +- app/models/course.rb | 22 +- app/models/course_section.rb | 2 +- app/models/crocodoc_document.rb | 6 +- app/models/discussion_entry.rb | 2 +- app/models/discussion_entry_draft.rb | 6 +- app/models/discussion_entry_participant.rb | 6 +- app/models/enrollment.rb | 10 +- app/models/enrollment/batch_state_updater.rb | 2 +- app/models/enrollment_state.rb | 10 +- app/models/exporters/zip_exporter.rb | 4 +- app/models/external_feed.rb | 2 +- app/models/group_categories/params.rb | 4 +- app/models/importers/assignment_importer.rb | 2 +- .../learning_outcome_group_importer.rb | 2 +- .../importers/learning_outcome_importer.rb | 4 +- app/models/importers/link_parser.rb | 2 +- app/models/late_policy.rb | 4 +- app/models/lti/tool_consumer_profile.rb | 26 +- app/models/master_courses.rb | 6 +- app/models/master_courses/master_migration.rb | 4 +- app/models/media_object.rb | 2 +- app/models/media_track.rb | 2 +- app/models/microsoft_sync/group.rb | 8 +- app/models/microsoft_sync/user_mapping.rb | 8 +- app/models/migration_issue.rb | 2 +- app/models/notification.rb | 2 +- app/models/notification_failure_processor.rb | 2 +- app/models/observer_alert.rb | 4 +- app/models/observer_alert_threshold.rb | 8 +- app/models/outcome_import.rb | 2 +- app/models/page_view.rb | 4 +- app/models/parallel_importer.rb | 2 +- app/models/profile.rb | 2 +- app/models/pseudonym.rb | 2 +- app/models/quizzes/quiz.rb | 4 +- .../quizzes/quiz_question/question_data.rb | 4 +- .../quizzes/quiz_regrader/submission.rb | 2 +- .../quiz_statistics/student_analysis.rb | 2 +- app/models/quizzes/quiz_submission.rb | 4 +- app/models/role_override.rb | 132 +++--- app/models/sis_batch.rb | 6 +- app/models/sis_batch_roll_back_data.rb | 8 +- app/models/sis_post_grades_status.rb | 2 +- app/models/speed_grader/assignment.rb | 16 +- app/models/submission.rb | 10 +- app/models/usage_rights.rb | 2 +- app/models/user.rb | 20 +- app/models/user_preference_value.rb | 2 +- app/models/web_conference.rb | 2 +- app/models/wiki_page.rb | 2 +- app/presenters/grade_summary_presenter.rb | 2 +- .../lti/ims/names_and_roles_serializer.rb | 4 +- build/gergich/compile_assets.rb | 4 +- config/initializers/active_record.rb | 2 +- config/initializers/errors.rb | 4 +- config/initializers/i18n.rb | 2 +- config/initializers/postgresql_adapter.rb | 2 +- config/initializers/sentry.rb | 4 +- config/routes.rb | 44 +- db/migrate/20101210192618_init_canvas_db.rb | 2 +- .../20101216224513_create_delayed_jobs.rb | 2 +- ...10191027_add_cassandra_page_view_tables.rb | 26 +- ...40642_add_authentication_auditor_tables.rb | 12 +- ...de_change_indexes_for_gradebook_history.rb | 6 +- ...11443_add_assignment_group_id_to_scores.rb | 4 +- ...00_create_new_grade_history_batch_table.rb | 4 +- ...1160908_create_sis_batch_roll_back_data.rb | 2 +- .../20180207045041_create_lti_results.rb | 2 +- ...9_create_developer_key_account_bindings.rb | 2 +- .../20190325205830_create_user_past_lti_id.rb | 2 +- ...45_create_notification_policy_overrides.rb | 6 +- ...cassandra_add_account_index_for_courses.rb | 27 +- ..._add_grading_period_id_to_grade_changes.rb | 8 +- ...10604144553_add_flag_auditors_cassandra.rb | 8 +- ...0210817214256_make_timestamps_not_null6.rb | 4 +- ...920100330_create_discussion_entry_draft.rb | 6 +- doc/api/fulldoc/html/setup.rb | 2 +- doc/api/fulldoc/html/swagger/argument_view.rb | 2 +- doc/api/fulldoc/html/swagger/object_view.rb | 2 +- doc/api/topic/html/setup.rb | 6 +- .../activesupport-suspend_callbacks.gemspec | 2 +- .../adheres_to_policy.gemspec | 2 +- .../adheres_to_policy/configuration_spec.rb | 8 +- .../instance_methods_spec.rb | 2 +- gems/attachment_fu/lib/attachment_fu.rb | 2 +- .../bookmarked_collection.gemspec | 2 +- .../canvas_breach_mitigation.gemspec | 2 +- gems/canvas_cache/canvas_cache.gemspec | 2 +- gems/canvas_cache/lib/canvas_cache/redis.rb | 2 +- .../canvas_cassandra/canvas_cassandra.gemspec | 2 +- gems/canvas_crummy/canvas_crummy.gemspec | 2 +- gems/canvas_dynamodb/canvas_dynamodb.gemspec | 2 +- .../lib/canvas_dynamodb/database.rb | 4 +- gems/canvas_errors/canvas_errors.gemspec | 2 +- gems/canvas_ext/canvas_ext.gemspec | 2 +- gems/canvas_http/canvas_http.gemspec | 2 +- gems/canvas_http/lib/canvas_http.rb | 2 +- gems/canvas_kaltura/canvas_kaltura.gemspec | 2 +- .../canvas_kaltura/kaltura_client_v3_spec.rb | 2 +- .../canvas_mimetype_fu.gemspec | 2 +- .../canvas_panda_pub/canvas_panda_pub.gemspec | 2 +- .../canvas_partman/partition_manager_spec.rb | 8 +- gems/canvas_sanitize/canvas_sanitize.gemspec | 2 +- .../lib/canvas_sanitize/canvas_sanitize.rb | 24 +- .../canvas_sanitize/canvas_sanitize_spec.rb | 12 +- gems/canvas_security/canvas_security.gemspec | 2 +- .../lib/canvas_security/key_storage.rb | 2 +- .../spec/canvas_security/key_storage_spec.rb | 2 +- gems/canvas_slug/canvas_slug.gemspec | 2 +- gems/canvas_sort/canvas_sort.gemspec | 2 +- gems/canvas_stringex/canvas_stringex.gemspec | 2 +- .../lib/lucky_sneaks/string_extensions.rb | 4 +- .../unicode_point_suite/basic_latin_spec.rb | 56 +-- .../canvas_text_helper.gemspec | 2 +- gems/canvas_time/canvas_time.gemspec | 2 +- gems/canvas_time/spec/canvas_time_spec.rb | 2 +- gems/canvas_unzip/canvas_unzip.gemspec | 2 +- gems/config_file/config_file.gemspec | 2 +- gems/csv_diff/csv_diff.gemspec | 2 +- gems/diigo/diigo.gemspec | 2 +- gems/dr_diff/lib/dr_diff/manager.rb | 2 +- gems/dr_diff/spec/manager_spec.rb | 4 +- .../dynamic_settings/dynamic_settings.gemspec | 2 +- gems/dynamic_settings/lib/dynamic_settings.rb | 2 +- gems/event_stream/event_stream.gemspec | 2 +- gems/google_drive/google_drive.gemspec | 2 +- gems/google_drive/lib/google_drive/client.rb | 2 +- gems/google_drive/lib/google_drive/entry.rb | 4 +- .../html_text_helper/html_text_helper.gemspec | 2 +- gems/i18n_extraction/i18n_extraction.gemspec | 2 +- gems/i18n_tasks/i18n_tasks.gemspec | 2 +- gems/i18n_tasks/lib/tasks/i18n.rake | 6 +- .../incoming_mail_processor.gemspec | 2 +- .../incoming_message_processor.rb | 2 +- .../incoming_mail_processor/sqs_mailbox.rb | 2 +- .../directory_mailbox_spec.rb | 4 +- gems/json_token/json_token.gemspec | 2 +- gems/linked_in/linked_in.gemspec | 2 +- gems/live_events/live_events.gemspec | 2 +- .../serializers/jwt_message_serializer.rb | 8 +- gems/lti-advantage/lti-advantage.gemspec | 2 +- gems/lti_outbound/lti_outbound.gemspec | 2 +- gems/multipart/multipart.gemspec | 2 +- .../paginated_collection.gemspec | 2 +- .../paginated_collection_spec.rb | 2 +- .../lib/academic_benchmark/engine.rb | 2 +- .../lib/account_reports/outcome_export.rb | 4 +- .../lib/account_reports/outcome_reports.rb | 126 +++--- .../lib/account_reports/report_helper.rb | 2 +- .../sis_provisioning_reports_spec.rb | 8 +- .../lib/moodle_importer/engine.rb | 2 +- .../lib/qti/assessment_item_converter.rb | 2 +- .../qti_exporter/lib/qti_exporter/engine.rb | 2 +- .../lib/qti/assessment_test_converter_spec.rb | 2 +- .../spec_canvas/qti_exporter_spec.rb | 2 +- .../urn_RespondusAPIServant.rb | 10 +- .../integration/respondus_endpoint_spec.rb | 4 +- gems/request_context/request_context.gemspec | 2 +- gems/rubocop-canvas/rubocop-canvas.gemspec | 2 +- .../cop/lint/no_file_utils_rm_rf_spec.rb | 4 +- .../spec/rubocop/cop/lint/no_sleep_spec.rb | 12 +- .../cop/migration/non_transactional_spec.rb | 40 +- .../cop/migration/remove_column_spec.rb | 20 +- .../specs/no_no_such_element_error_spec.rb | 12 +- .../cop/specs/scope_helper_modules_spec.rb | 28 +- .../rubocop/cop/specs/scope_includes_spec.rb | 12 +- .../outcomes_response_transformer.rb | 2 +- gems/twitter/twitter.gemspec | 2 +- gems/utf8_cleaner/utf8_cleaner.gemspec | 2 +- lib/api.rb | 2 +- lib/api/html/content.rb | 2 +- lib/api/v1/account.rb | 4 +- lib/api/v1/account_notifications.rb | 2 +- lib/api/v1/account_report.rb | 2 +- lib/api/v1/assessment_request.rb | 2 +- lib/api/v1/assignment.rb | 20 +- lib/api/v1/assignment_group.rb | 6 +- lib/api/v1/assignment_override.rb | 2 +- lib/api/v1/attachment.rb | 2 +- lib/api/v1/calendar_event.rb | 6 +- lib/api/v1/collaboration.rb | 2 +- lib/api/v1/collaborator.rb | 2 +- lib/api/v1/communication_channel.rb | 4 +- lib/api/v1/conferences.rb | 4 +- lib/api/v1/content_export.rb | 2 +- lib/api/v1/content_migration.rb | 4 +- lib/api/v1/content_share.rb | 4 +- lib/api/v1/context_module.rb | 6 +- lib/api/v1/conversation.rb | 4 +- lib/api/v1/course.rb | 8 +- lib/api/v1/course_json.rb | 6 +- lib/api/v1/custom_gradebook_column.rb | 6 +- lib/api/v1/developer_key.rb | 4 +- lib/api/v1/discussion_topics.rb | 6 +- lib/api/v1/enrollment_term.rb | 2 +- lib/api/v1/eportfolio.rb | 4 +- lib/api/v1/external_feeds.rb | 4 +- lib/api/v1/external_tools.rb | 2 +- lib/api/v1/favorite.rb | 2 +- lib/api/v1/feature_flag.rb | 2 +- lib/api/v1/folders.rb | 2 +- lib/api/v1/grading_standard.rb | 2 +- lib/api/v1/group.rb | 6 +- lib/api/v1/group_category.rb | 2 +- lib/api/v1/history_entry.rb | 2 +- lib/api/v1/master_courses.rb | 6 +- lib/api/v1/media_object.rb | 4 +- lib/api/v1/moderation_grader.rb | 4 +- lib/api/v1/notification_policy.rb | 2 +- lib/api/v1/observer_alert.rb | 4 +- lib/api/v1/observer_alert_threshold.rb | 4 +- lib/api/v1/outcome.rb | 6 +- lib/api/v1/outcome_results.rb | 2 +- lib/api/v1/planner_note.rb | 2 +- lib/api/v1/post_grades_status.rb | 2 +- lib/api/v1/progress.rb | 2 +- lib/api/v1/quiz.rb | 4 +- lib/api/v1/quiz_group.rb | 8 +- lib/api/v1/quiz_question.rb | 18 +- lib/api/v1/rubric.rb | 4 +- lib/api/v1/rubric_assessment.rb | 4 +- lib/api/v1/rubric_association.rb | 4 +- lib/api/v1/section.rb | 2 +- lib/api/v1/section_enrollments.rb | 2 +- lib/api/v1/sis_assignment.rb | 14 +- lib/api/v1/stream_item.rb | 2 +- lib/api/v1/submission.rb | 8 +- lib/api/v1/submission_comment.rb | 2 +- lib/api/v1/usage_rights.rb | 2 +- lib/api/v1/user.rb | 6 +- lib/api/v1/user_profile.rb | 4 +- lib/api/v1/wiki_page.rb | 2 +- lib/authentication_methods.rb | 6 +- lib/basic_lti/basic_outcomes.rb | 20 +- lib/canvas/cache_register.rb | 14 +- lib/canvas/cassandra/migration.rb | 8 +- lib/canvas/migration/package_identifier.rb | 4 +- lib/canvas/password_policy.rb | 4 +- lib/canvas/plugins/default_plugins.rb | 8 +- lib/canvas/security/jwt_validator.rb | 2 +- lib/cc/cc_helper.rb | 4 +- .../epub/converters/topic_epub_converter.rb | 2 +- .../canvas/quiz_metadata_converter.rb | 4 +- lib/cc/importer/canvas/topic_converter.rb | 4 +- lib/cc/lti_resource_links.rb | 4 +- lib/cc/qti/qti_manifest.rb | 2 +- lib/course_link_validator.rb | 2 +- lib/custom_validations.rb | 2 +- .../add_role_overrides_for_new_permission.rb | 2 +- ...init_account_index_for_course_audit_log.rb | 14 +- ..._custom_claim_columns_for_resource_link.rb | 8 +- ..._root_account_id_on_asset_user_accesses.rb | 2 +- lib/feature.rb | 8 +- lib/google_docs_preview.rb | 4 +- lib/gradebook_importer.rb | 6 +- lib/has_content_tags.rb | 2 +- lib/lti/app_launch_collator.rb | 4 +- lib/lti/content_item_response.rb | 2 +- lib/lti/content_item_selection_request.rb | 16 +- lib/lti/messages/deep_linking_request.rb | 62 +-- lib/lti/oauth2/access_token.rb | 2 +- lib/lti/plagiarism_subscriptions_helper.rb | 4 +- lib/lti/privacy_level_expander.rb | 8 +- lib/lti/tool_proxy_validator.rb | 2 +- lib/microsoft_sync/settings_validator.rb | 8 +- lib/notification_message_creator.rb | 2 +- lib/sis/admin_importer.rb | 2 +- lib/sis/course_importer.rb | 2 +- lib/sis/csv/diff_generator.rb | 2 +- lib/sis/csv/import_refactored.rb | 8 +- lib/sis/csv/login_importer.rb | 2 +- lib/sis/csv/user_importer.rb | 2 +- lib/sis/enrollment_importer.rb | 6 +- lib/sis/grade_publishing_results_importer.rb | 2 +- lib/sis/term_importer.rb | 2 +- lib/tasks/canvas.rake | 2 +- lib/tasks/db.rake | 2 +- lib/tasks/parallel_exclude.rb | 2 +- lib/tasks/remove_schema_sig.rake | 6 +- lib/tasks/rspec.rake | 20 +- lib/user_list_v2.rb | 2 +- lib/user_merge.rb | 6 +- script/linter.rb | 2 +- spec/apis/api_spec_helper.rb | 4 +- spec/apis/auth_spec.rb | 12 +- spec/apis/file_uploads_spec_helper.rb | 2 +- spec/apis/general_api_spec.rb | 10 +- spec/apis/locked_spec.rb | 4 +- spec/apis/lti/lti2_api_spec_helper.rb | 2 +- spec/apis/lti/lti_app_api_spec.rb | 16 +- spec/apis/lti/subscriptions_api_spec.rb | 24 +- spec/apis/lti/subscriptions_validator_spec.rb | 22 +- spec/apis/lti/users_api_spec.rb | 4 +- spec/apis/swagger/argument_view_spec.rb | 6 +- spec/apis/user_content_spec.rb | 8 +- .../apis/v1/account_notifications_api_spec.rb | 4 +- spec/apis/v1/account_reports_api_spec.rb | 2 +- spec/apis/v1/accounts_api_spec.rb | 12 +- spec/apis/v1/assignments_api_spec.rb | 32 +- spec/apis/v1/authentication_audit_api_spec.rb | 4 +- spec/apis/v1/collaborations_api_spec.rb | 2 +- spec/apis/v1/content_exports_api_spec.rb | 12 +- spec/apis/v1/context_modules_api_spec.rb | 36 +- spec/apis/v1/conversations_api_spec.rb | 2 +- spec/apis/v1/courses_api_spec.rb | 32 +- .../v1/custom_gradebook_columns_api_spec.rb | 2 +- spec/apis/v1/enrollments_api_spec.rb | 38 +- spec/apis/v1/feature_flags_api_spec.rb | 18 +- spec/apis/v1/files_controller_api_spec.rb | 24 +- spec/apis/v1/folders_controller_api_spec.rb | 12 +- spec/apis/v1/group_categories_api_spec.rb | 6 +- spec/apis/v1/groups_api_spec.rb | 10 +- spec/apis/v1/outcome_results_api_spec.rb | 64 +-- spec/apis/v1/pages_api_spec.rb | 8 +- spec/apis/v1/peer_reviews_api_spec.rb | 16 +- spec/apis/v1/pseudonyms_api_spec.rb | 6 +- spec/apis/v1/quizzes/quiz_reports_api_spec.rb | 4 +- .../v1/quizzes/quiz_statistics_api_spec.rb | 2 +- .../quiz_submission_events_api_spec.rb | 2 +- spec/apis/v1/roles_api_spec.rb | 4 +- spec/apis/v1/sections_api_spec.rb | 2 +- spec/apis/v1/services_api_spec.rb | 4 +- spec/apis/v1/submissions_api_spec.rb | 82 ++-- spec/apis/v1/tabs_api_spec.rb | 6 +- spec/apis/v1/todo_items_api_spec.rb | 14 +- spec/apis/v1/user_profiles_api_spec.rb | 4 +- spec/apis/v1/users_api_spec.rb | 2 +- .../developer_keys_controller_spec.rb | 8 +- spec/controllers/files_controller_spec.rb | 2 +- spec/controllers/info_controller_spec.rb | 2 +- .../advantage_services_shared_context.rb | 4 +- .../concerns/lti_services_shared_examples.rb | 2 +- .../lti/message_controller_spec.rb | 8 +- spec/controllers/lti_api_controllers_spec.rb | 6 +- .../oauth2_provider_controller_spec.rb | 10 +- .../oauth_proxy_controller_spec.rb | 4 +- spec/controllers/planner_controller_spec.rb | 2 +- spec/controllers/profile_controller_spec.rb | 4 +- spec/controllers/security_controller_spec.rb | 2 +- spec/controllers/users_controller_spec.rb | 14 +- spec/factory_bot_spec_helper.rb | 4 +- .../loaders/discussion_entry_loader_spec.rb | 4 +- .../delete_conversation_messages_spec.rb | 4 +- .../mutations/delete_conversations_spec.rb | 6 +- .../update_conversation_participants_spec.rb | 2 +- spec/graphql/types/assignment_type_spec.rb | 2 +- spec/graphql/types/query_type_spec.rb | 2 +- spec/helpers/quizzes_helper_spec.rb | 4 +- spec/initializers/active_record_spec.rb | 4 +- spec/integration/oauth_token_spec.rb | 2 +- .../api/v1/custom_gradebook_column_spec.rb | 4 +- spec/lib/api/v1/planner_item_spec.rb | 8 +- spec/lib/api/v1/submission_spec.rb | 4 +- spec/lib/api_spec.rb | 62 +-- spec/lib/app_center/app_api_spec.rb | 4 +- .../quizzes_next_lti_response_spec.rb | 4 +- .../quizzes_next_versioned_submission_spec.rb | 8 +- .../oauth/client_credentials_provider_spec.rb | 6 +- .../ticketing_system/custom_error_spec.rb | 2 +- spec/lib/cc/cc_exporter_spec.rb | 14 +- spec/lib/cc/cc_helper_spec.rb | 26 +- .../canvas_cartridge_converter_spec.rb | 36 +- .../common_cartridge_converter_spec.rb | 14 +- spec/lib/content_zipper_spec.rb | 2 +- spec/lib/course_link_validator_spec.rb | 40 +- ...ew_grade_history_audit_log_indexes_spec.rb | 8 +- .../lti/update_custom_params_spec.rb | 2 +- spec/lib/enrollments_from_user_list_spec.rb | 4 +- spec/lib/external_feed_aggregator_spec.rb | 94 ++-- spec/lib/feature_spec.rb | 14 +- spec/lib/file_in_context_spec.rb | 2 +- spec/lib/gradebook_importer_spec.rb | 14 +- spec/lib/imported_html_converter_spec.rb | 82 ++-- spec/lib/lti/capabilities_helper_spec.rb | 10 +- .../content_item_selection_request_spec.rb | 2 +- .../plagiarism_subscriptions_helper_spec.rb | 4 +- spec/lib/lti/privacy_level_expander_spec.rb | 14 +- spec/lib/lti/security_spec.rb | 8 +- spec/lib/lti/substitutions_helper_spec.rb | 2 +- spec/lib/lti/variable_expander_spec.rb | 4 +- spec/lib/sis/csv/group_importer_spec.rb | 10 +- .../sis/csv/group_membership_importer_spec.rb | 4 +- spec/lib/text_helper_spec.rb | 4 +- spec/lib/unzip_attachment_spec.rb | 6 +- spec/lib/user_content_spec.rb | 2 +- spec/lib/user_list_spec.rb | 14 +- spec/lib/user_merge_spec.rb | 2 +- spec/models/access_token_spec.rb | 14 +- spec/models/assignment_spec.rb | 4 +- spec/models/attachment_spec.rb | 4 +- spec/models/bookmark_service_spec.rb | 6 +- spec/models/calendar_event_spec.rb | 4 +- spec/models/communication_channel_spec.rb | 8 +- .../course_copy_assignments_spec.rb | 2 +- .../course_copy_attachments_spec.rb | 12 +- .../course_copy_outcomes_spec.rb | 2 +- .../course_copy_quizzes_spec.rb | 4 +- .../content_migration/course_copy_spec.rb | 12 +- .../course_copy_wiki_spec.rb | 10 +- spec/models/context_module_spec.rb | 20 +- spec/models/course_spec.rb | 12 +- spec/models/developer_key_spec.rb | 4 +- .../enrollment/batch_state_updater_spec.rb | 4 +- spec/models/enrollment/query_builder_spec.rb | 184 ++++---- spec/models/external_feed_spec.rb | 146 +++--- spec/models/folder_spec.rb | 4 +- spec/models/grading_period_spec.rb | 2 +- .../group_and_membership_importer_spec.rb | 64 +-- .../importers/calendar_event_importer_spec.rb | 2 +- .../importers/course_content_importer_spec.rb | 6 +- .../incoming_mail/reply_to_address_spec.rb | 10 +- spec/models/lti/app_launch_collator_spec.rb | 8 +- spec/models/lti/tool_proxy_service_spec.rb | 2 +- .../master_courses/master_migration_spec.rb | 4 +- .../partial_sync_change_spec.rb | 2 +- .../item_analysis/item_spec.rb | 4 +- .../item_analysis/summary_spec.rb | 24 +- .../quiz_statistics/item_analysis_spec.rb | 14 +- spec/models/role_override_spec.rb | 16 +- spec/models/role_spec.rb | 2 +- spec/models/sis_batch_spec.rb | 414 +++++++++--------- spec/models/speed_grader/assignment_spec.rb | 8 +- spec/models/submission_comment_spec.rb | 10 +- .../assignments_grading_type_spec.rb | 2 +- spec/selenium/common.rb | 2 +- .../content_exports_spec.rb | 2 +- .../wiki_page_accessibility_spec.rb | 2 +- spec/selenium/courses/course_settings_spec.rb | 18 +- .../gradebook_history_spec.rb | 6 +- .../selenium/grades/pages/speedgrader_page.rb | 2 +- .../speedgrader_teacher_submission_spec.rb | 2 +- spec/selenium/grades/srgb/srgb_spec.rb | 2 +- .../selenium/helpers/collaborations_common.rb | 2 +- .../helpers/collaborations_specs_common.rb | 26 +- spec/selenium/helpers/conversations_common.rb | 2 +- spec/selenium/helpers/files_common.rb | 2 +- .../miscellaneous/enhanceable_content_spec.rb | 4 +- spec/selenium/people/users_spec.rb | 6 +- .../sections/section_teacher_tabs_spec.rb | 2 +- spec/spec_helper.rb | 2 +- spec/support/names_and_roles_matchers.rb | 10 +- spec/support/onceler/noop.rb | 2 +- .../_select_content_dialog.html.erb_spec.rb | 4 +- spec/views/submissions/show.html.erb_spec.rb | 4 +- .../submissions/show_preview.html.erb_spec.rb | 2 +- 525 files changed, 2248 insertions(+), 2217 deletions(-) diff --git a/.rubocop.common.yml b/.rubocop.common.yml index f5634072578..4d2feb00c43 100644 --- a/.rubocop.common.yml +++ b/.rubocop.common.yml @@ -242,6 +242,8 @@ Style/OrAssignment: Severity: error Style/ParenthesesAroundCondition: Severity: error +Style/PercentLiteralDelimiters: + Severity: error Style/PerlBackrefs: Enabled: false # Regexp.last_match(1) is far worse than $1 Style/PreferredHashMethods: @@ -363,8 +365,6 @@ Style/NumericLiterals: # TODO: autocorrect Enabled: false Style/ParallelAssignment: # TODO: autocorrect (with probable exceptions) Enabled: false -Style/PercentLiteralDelimiters: # TODO: autocorrect - Enabled: false Style/PercentQLiterals: # TODO: autocorrect Enabled: false Style/RedundantSelf: # TODO: autocorrect diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 5f29f9b430a..e58d5992a2a 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -491,7 +491,7 @@ class AccountsController < ApplicationController # # @returns TermsOfService def terms_of_service - keys = %w(id terms_type passive account_id) + keys = %w[id terms_type passive account_id] tos = @account.root_account.terms_of_service res = tos.attributes.slice(*keys) res['content'] = tos.terms_of_service_content&.content @@ -614,12 +614,12 @@ class AccountsController < ApplicationController starts_before = CanvasTime.try_parse(params[:starts_before]) ends_after = CanvasTime.try_parse(params[:ends_after]) - params[:state] ||= %w{created claimed available completed} - params[:state] = %w{created claimed available completed deleted} if Array(params[:state]).include?('all') + params[:state] ||= %w[created claimed available completed] + params[:state] = %w[created claimed available completed deleted] if Array(params[:state]).include?('all') if value_to_boolean(params[:published]) - params[:state] -= %w{created claimed completed deleted} + params[:state] -= %w[created claimed completed deleted] elsif !params[:published].nil? && !value_to_boolean(params[:published]) - params[:state] -= %w{available} + params[:state] -= %w[available] end sortable_name_col = User.sortable_name_order_by_clause('users') @@ -1088,7 +1088,7 @@ class AccountsController < ApplicationController # privacy settings unless @account.grants_right?(@current_user, :manage_privacy_settings) - %w{enable_fullstory enable_google_analytics}.each do |setting| + %w[enable_fullstory enable_google_analytics].each do |setting| params[:account][:settings].try(:delete, setting) end end @@ -1565,7 +1565,7 @@ class AccountsController < ApplicationController courses_to_fetch_users_for = courses_to_fetch_users_for.reject { |c| @master_template_index[c.id] } # don't fetch the counts for the master/blueprint courses end - teachers = TeacherEnrollment.for_courses_with_user_name(courses_to_fetch_users_for).where.not(:enrollments => { :workflow_state => %w{rejected deleted} }) + teachers = TeacherEnrollment.for_courses_with_user_name(courses_to_fetch_users_for).where.not(:enrollments => { :workflow_state => %w[rejected deleted] }) course_to_student_counts = StudentEnrollment.student_in_claimed_or_available.where(:course_id => courses_to_fetch_users_for).group(:course_id).distinct.count(:user_id) courses_to_teachers = teachers.each_with_object({}) do |teacher, result| result[teacher.course_id] ||= [] diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4fc12f360de..4ba50bdb60c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1534,12 +1534,12 @@ class ApplicationController < ActionController::Base @access = AssetUserAccess.log(user, @context, @accessed_asset) if @context - if @page_view.nil? && %w{participate submit}.include?(@accessed_asset[:level]) && page_views_enabled? + if @page_view.nil? && %w[participate submit].include?(@accessed_asset[:level]) && page_views_enabled? generate_page_view(user) end if @page_view - @page_view.participated = %w{participate submit}.include?(@accessed_asset[:level]) + @page_view.participated = %w[participate submit].include?(@accessed_asset[:level]) @page_view.asset_user_access = @access end diff --git a/app/controllers/assignment_groups_controller.rb b/app/controllers/assignment_groups_controller.rb index b788009be38..927149487db 100644 --- a/app/controllers/assignment_groups_controller.rb +++ b/app/controllers/assignment_groups_controller.rb @@ -425,7 +425,7 @@ class AssignmentGroupsController < ApplicationController if params[:exclude_assignment_submission_types].present? exclude_types = params[:exclude_assignment_submission_types] exclude_types = Array.wrap(exclude_types) & - %w(online_quiz discussion_topic wiki_page external_tool) + %w[online_quiz discussion_topic wiki_page external_tool] assignments = assignments.where.not(submission_types: exclude_types) end diff --git a/app/controllers/assignments_api_controller.rb b/app/controllers/assignments_api_controller.rb index 170443ef9cd..d9e762f465b 100644 --- a/app/controllers/assignments_api_controller.rb +++ b/app/controllers/assignments_api_controller.rb @@ -1448,7 +1448,7 @@ class AssignmentsApiController < ApplicationController return if @context.students_visible_to(@current_user).include?(@user) end # self, observer - authorized_action(@user, @current_user, %i(read_as_parent read)) + authorized_action(@user, @current_user, %i[read_as_parent read]) end def needs_grading_permission? diff --git a/app/controllers/calendar_events_api_controller.rb b/app/controllers/calendar_events_api_controller.rb index 72317c18367..d5dd0f61d1a 100644 --- a/app/controllers/calendar_events_api_controller.rb +++ b/app/controllers/calendar_events_api_controller.rb @@ -284,10 +284,10 @@ class CalendarEventsApiController < ApplicationController include Api::V1::CalendarEvent include CalendarConferencesHelper - before_action :require_user, :except => %w(public_feed index) + before_action :require_user, :except => %w[public_feed index] before_action :get_calendar_context, :only => :create before_action :require_user_or_observer, :only => [:user_index] - before_action :require_authorization, :only => %w(index user_index) + before_action :require_authorization, :only => %w[index user_index] RECURRING_EVENT_LIMIT = 200 diff --git a/app/controllers/content_exports_api_controller.rb b/app/controllers/content_exports_api_controller.rb index 8e8097e9686..cb40f4e94d6 100644 --- a/app/controllers/content_exports_api_controller.rb +++ b/app/controllers/content_exports_api_controller.rb @@ -147,8 +147,8 @@ class ContentExportsApiController < ApplicationController # @returns ContentExport def create if authorized_action(@context, @current_user, :read) - valid_types = %w(zip) - valid_types += %w(qti common_cartridge quizzes2) if @context.is_a?(Course) + valid_types = %w[zip] + valid_types += %w[qti common_cartridge quizzes2] if @context.is_a?(Course) return render json: { message: 'invalid export_type' }, status: :bad_request unless valid_types.include?(params[:export_type]) export = create_content_export_from_api(params, @context, @current_user) diff --git a/app/controllers/content_imports_controller.rb b/app/controllers/content_imports_controller.rb index 316595518e6..64346fe06d0 100644 --- a/app/controllers/content_imports_controller.rb +++ b/app/controllers/content_imports_controller.rb @@ -26,10 +26,10 @@ class ContentImportsController < ApplicationController include Api::V1::Course include ContentImportsHelper - COPY_TYPES = %w{assignment_groups assignments context_modules + COPY_TYPES = %w[assignment_groups assignments context_modules learning_outcomes quizzes assessment_question_banks folders attachments wiki_pages discussion_topics calendar_events - context_external_tools learning_outcome_groups rubrics}.freeze + context_external_tools learning_outcome_groups rubrics].freeze # these are deprecated, but leaving them for a while so existing links get redirected def index diff --git a/app/controllers/content_migrations_controller.rb b/app/controllers/content_migrations_controller.rb index b39dbb1e8ef..da18e082459 100644 --- a/app/controllers/content_migrations_controller.rb +++ b/app/controllers/content_migrations_controller.rb @@ -517,7 +517,7 @@ class ContentMigrationsController < ApplicationController def find_migration_plugin(name) if name.include?('context_external_tool') plugin = Canvas::Plugin.new(name) - plugin.meta[:settings] = { requires_file_upload: true, worker: 'CCWorker', valid_contexts: %w{Course} }.with_indifferent_access + plugin.meta[:settings] = { requires_file_upload: true, worker: 'CCWorker', valid_contexts: %w[Course] }.with_indifferent_access plugin else Canvas::Plugin.find(name) diff --git a/app/controllers/content_shares_controller.rb b/app/controllers/content_shares_controller.rb index f12ca8ae4f6..c91158b21fb 100644 --- a/app/controllers/content_shares_controller.rb +++ b/app/controllers/content_shares_controller.rb @@ -93,8 +93,8 @@ class ContentSharesController < ApplicationController before_action :require_user before_action :get_user_param - before_action :require_current_user, :except => %w(show index unread_count) - before_action :get_receivers, :only => %w(create add_users) + before_action :require_current_user, :except => %w[show index unread_count] + before_action :get_receivers, :only => %w[create add_users] def get_user_param @user = api_find(User, params[:user_id]) diff --git a/app/controllers/context_module_items_api_controller.rb b/app/controllers/context_module_items_api_controller.rb index 2f0f1bffd42..208b8beaaad 100644 --- a/app/controllers/context_module_items_api_controller.rb +++ b/app/controllers/context_module_items_api_controller.rb @@ -472,7 +472,7 @@ class ContextModuleItemsApiController < ApplicationController return render :json => { :message => "missing module item parameter" }, :status => :bad_request unless params[:module_item] @tag.title = params[:module_item][:title] if params[:module_item][:title] - @tag.url = params[:module_item][:external_url] if %w(ExternalUrl ContextExternalTool).include?(@tag.content_type) && params[:module_item][:external_url] + @tag.url = params[:module_item][:external_url] if %w[ExternalUrl ContextExternalTool].include?(@tag.content_type) && params[:module_item][:external_url] @tag.indent = params[:module_item][:indent] if params[:module_item][:indent] @tag.new_tab = value_to_boolean(params[:module_item][:new_tab]) if params[:module_item][:new_tab] if (target_module_id = params[:module_item][:module_id]) && target_module_id.to_i != @tag.context_module_id diff --git a/app/controllers/context_modules_api_controller.rb b/app/controllers/context_modules_api_controller.rb index f69e429c735..03aca6b2ac9 100644 --- a/app/controllers/context_modules_api_controller.rb +++ b/app/controllers/context_modules_api_controller.rb @@ -274,7 +274,7 @@ class ContextModulesApiController < ApplicationController if authorized_action(@context, @current_user, :manage_content) event = params[:event] return render(:json => { :message => 'need to specify event' }, :status => :bad_request) unless event.present? - return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w(publish unpublish delete).include? event + return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w[publish unpublish delete].include? event return render(:json => { :message => 'must specify module_ids[]' }, :status => :bad_request) unless params[:module_ids].present? module_ids = Api.map_non_sis_ids(Array(params[:module_ids])) diff --git a/app/controllers/context_modules_controller.rb b/app/controllers/context_modules_controller.rb index 07914b9116f..7a0391dd57e 100644 --- a/app/controllers/context_modules_controller.rb +++ b/app/controllers/context_modules_controller.rb @@ -272,7 +272,7 @@ class ContextModulesController < ApplicationController end @tag = params[:last] ? @tags.last : @tags.first unless @tag - flash[:notice] = t 'module_empty', %{There are no items in the module "%{module}"}, :module => @module.name + flash[:notice] = t 'module_empty', %(There are no items in the module "%{module}"), :module => @module.name redirect_to named_context_url(@context, :context_context_modules_url, :anchor => "module_#{@module.id}") return end @@ -400,7 +400,7 @@ class ContextModulesController < ApplicationController if is_child_course || is_master_course tag_ids = GuardRail.activate(:secondary) do - tag_scope = @context.module_items_visible_to(@current_user).where(:content_type => %w{Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage}) + tag_scope = @context.module_items_visible_to(@current_user).where(:content_type => %w[Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage]) tag_scope = tag_scope.where(:id => params[:tag_id]) if params[:tag_id] tag_scope.pluck(:id) end @@ -647,7 +647,7 @@ class ContextModulesController < ApplicationController @tag = @context.context_module_tags.not_deleted.find(params[:id]) if authorized_action(@tag.context_module, @current_user, :update) @tag.title = params[:content_tag][:title] if params[:content_tag] && params[:content_tag][:title] - @tag.url = params[:content_tag][:url] if %w(ExternalUrl ContextExternalTool).include?(@tag.content_type) && params[:content_tag] && params[:content_tag][:url] + @tag.url = params[:content_tag][:url] if %w[ExternalUrl ContextExternalTool].include?(@tag.content_type) && params[:content_tag] && params[:content_tag][:url] @tag.indent = params[:content_tag][:indent] if params[:content_tag] && params[:content_tag][:indent] @tag.new_tab = params[:content_tag][:new_tab] if params[:content_tag] && params[:content_tag][:new_tab] diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index 2df227922d3..7b9e7fe6ff7 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -165,7 +165,7 @@ class ConversationsController < ApplicationController # batch up all delayed jobs to make this more responsive to the user batch_jobs_in_actions :only => :create - API_ALLOWED_FIELDS = %w{workflow_state subscribed starred}.freeze + API_ALLOWED_FIELDS = %w[workflow_state subscribed starred].freeze # @API List conversations # Returns the paginated list of conversations for the current user, most @@ -975,7 +975,7 @@ class ConversationsController < ApplicationController conversation_ids = params[:conversation_ids] update_params = params.permit(:event).to_unsafe_h - allowed_events = %w(mark_as_read mark_as_unread star unstar archive destroy) + allowed_events = %w[mark_as_read mark_as_unread star unstar archive destroy] return render(:json => { :message => 'conversation_ids not specified' }, :status => :bad_request) unless params[:conversation_ids].is_a?(Array) return render(:json => { :message => 'conversation batch size limit (500) exceeded' }, :status => :bad_request) unless params[:conversation_ids].size <= 500 return render(:json => { :message => 'event not specified' }, :status => :bad_request) unless update_params[:event] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8650a91e851..af421e4f4fd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1123,18 +1123,18 @@ class CoursesController < ApplicationController end enrollments_by_user = enrollment_scope.group_by(&:user_id) else - confirmed_user_ids = @context.enrollments.where.not(:workflow_state => %w{invited creation_pending rejected}) + confirmed_user_ids = @context.enrollments.where.not(:workflow_state => %w[invited creation_pending rejected]) .where(:user_id => users).distinct.pluck(:user_id) end render :json => users.map { |u| enrollments = enrollments_by_user[u.id] || [] if includes.include?('enrollments') user_unconfirmed = if enrollments - enrollments.all? { |e| %w{invited creation_pending rejected}.include?(e.workflow_state) } + enrollments.all? { |e| %w[invited creation_pending rejected].include?(e.workflow_state) } else !confirmed_user_ids.include?(u.id) end - excludes = user_unconfirmed ? %w{pseudonym personal_info} : [] + excludes = user_unconfirmed ? %w[pseudonym personal_info] : [] if @context.sections_hidden_on_roster_page?(current_user: @current_user) excludes.append('course_section_id') end @@ -3264,7 +3264,7 @@ class CoursesController < ApplicationController update_params = params.permit(:event).to_unsafe_h return render(:json => { :message => 'need to specify event' }, :status => :bad_request) unless update_params[:event] - return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w(offer conclude delete undelete).include? update_params[:event] + return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w[offer conclude delete undelete].include? update_params[:event] progress = Course.batch_update(@account, @current_user, @course_ids, update_params, :api) render :json => progress_json(progress, @current_user, session) @@ -3462,7 +3462,7 @@ class CoursesController < ApplicationController end # NOTE: Similar to #user_progress, this endpoint should remain on the primary db - users = Api.paginate(UserSearch.scope_for(@context, @current_user, :enrollment_type => %w(Student)), self, api_v1_course_bulk_user_progress_url) + users = Api.paginate(UserSearch.scope_for(@context, @current_user, :enrollment_type => %w[Student]), self, api_v1_course_bulk_user_progress_url) cmps = ContextModuleProgression.where(user_id: users.map(&:id)) .joins(:context_module) .where(context_modules: { context: @context, context_type: 'Course' }) @@ -3629,7 +3629,7 @@ class CoursesController < ApplicationController if params[:state] states = Array(params[:state]) - states += %w(created claimed) if states.include?('unpublished') + states += %w[created claimed] if states.include?('unpublished') conditions = states.filter_map do |state| Enrollment::QueryBuilder.new(nil, course_workflow_state: state, enforce_course_workflow_state: true).conditions end.join(" OR ") @@ -3732,7 +3732,7 @@ class CoursesController < ApplicationController end enrollments_by_course = Api.paginate(enrollments_by_course, self, paginate_url) if api_request? courses = enrollments_by_course.map(&:first).map(&:course) - preloads = %i/account root_account/ + preloads = %i[account root_account] preload_teachers(courses) if includes.include?('teachers') preloads << :grading_standard if includes.include?('total_scores') preloads << :account if includes.include?('subaccount') || includes.include?('account') diff --git a/app/controllers/custom_gradebook_column_data_api_controller.rb b/app/controllers/custom_gradebook_column_data_api_controller.rb index 6f665c94a60..7bdc0ea75d0 100644 --- a/app/controllers/custom_gradebook_column_data_api_controller.rb +++ b/app/controllers/custom_gradebook_column_data_api_controller.rb @@ -148,7 +148,7 @@ class CustomGradebookColumnDataApiController < ApplicationController end def allowed_users - @context.students_visible_to(@current_user, include: %i{inactive completed}) + @context.students_visible_to(@current_user, include: %i[inactive completed]) end private :allowed_users diff --git a/app/controllers/discussion_topics_controller.rb b/app/controllers/discussion_topics_controller.rb index 6e72e6dbe2c..d291a7e2461 100644 --- a/app/controllers/discussion_topics_controller.rb +++ b/app/controllers/discussion_topics_controller.rb @@ -748,7 +748,7 @@ class DiscussionTopicsController < ApplicationController course_id: @context).not_fake.active_or_pending_by_date_ignoring_access .group(:course_section_id).count section_data = @topic.course_sections.map do |cs| - cs.attributes.slice(*%w{id name}).merge(:user_count => user_counts[cs.id] || 0) + cs.attributes.slice(*%w[id name]).merge(:user_count => user_counts[cs.id] || 0) end end api_url = lambda do |endpoint, *params| @@ -1144,12 +1144,12 @@ class DiscussionTopicsController < ApplicationController @user_can_moderate end - API_ALLOWED_TOPIC_FIELDS = %w(title message discussion_type delayed_post_at lock_at podcast_enabled + API_ALLOWED_TOPIC_FIELDS = %w[title message discussion_type delayed_post_at lock_at podcast_enabled podcast_has_student_posts require_initial_post pinned todo_date - group_category_id allow_rating only_graders_can_rate sort_by_rating).freeze + group_category_id allow_rating only_graders_can_rate sort_by_rating].freeze - API_ALLOWED_TOPIC_FIELDS_FOR_GROUP = %w(title message discussion_type podcast_enabled pinned todo_date - allow_rating only_graders_can_rate sort_by_rating).freeze + API_ALLOWED_TOPIC_FIELDS_FOR_GROUP = %w[title message discussion_type podcast_enabled pinned todo_date + allow_rating only_graders_can_rate sort_by_rating].freeze def set_sections if params[:specific_sections] != "all" @@ -1228,7 +1228,7 @@ class DiscussionTopicsController < ApplicationController allowed_fields = @context.is_a?(Group) ? API_ALLOWED_TOPIC_FIELDS_FOR_GROUP : API_ALLOWED_TOPIC_FIELDS discussion_topic_hash = params.permit(*allowed_fields) - only_pinning = discussion_topic_hash.except(*%w{pinned}).blank? + only_pinning = discussion_topic_hash.except(*%w[pinned]).blank? # allow pinning/unpinning if a subtopic and we can update the root topic_to_check = only_pinning && @topic.root_topic ? @topic.root_topic : @topic diff --git a/app/controllers/enrollments_api_controller.rb b/app/controllers/enrollments_api_controller.rb index e7f3d7af7c8..522cef45f4d 100644 --- a/app/controllers/enrollments_api_controller.rb +++ b/app/controllers/enrollments_api_controller.rb @@ -931,7 +931,7 @@ class EnrollmentsApiController < ApplicationController # by default, return active and invited courses. don't use the existing # current_and_invited_enrollments scope because it won't return enrollments # on unpublished courses. - enrollments = enrollments.where(workflow_state: %w{active invited}) if params[:state].blank? + enrollments = enrollments.where(workflow_state: %w[active invited]) if params[:state].blank? end terms = @domain_root_account.enrollment_terms.active @@ -989,14 +989,14 @@ class EnrollmentsApiController < ApplicationController def enrollment_states_for_state_param states = Array(params[:state]).uniq - states.concat(%w(active invited)) if states.delete 'current_and_invited' - states.concat(%w(active invited creation_pending pending_active pending_invited)) if states.delete 'current_and_future' - states.concat(%w(active completed)) if states.delete 'current_and_concluded' + states.concat(%w[active invited]) if states.delete 'current_and_invited' + states.concat(%w[active invited creation_pending pending_active pending_invited]) if states.delete 'current_and_future' + states.concat(%w[active completed]) if states.delete 'current_and_concluded' states.uniq end def check_sis_permissions(sis_context) - sis_filters = %w(sis_account_id sis_course_id sis_section_id sis_user_id) + sis_filters = %w[sis_account_id sis_course_id sis_section_id sis_user_id] if (params.keys & sis_filters).present? unless sis_context.grants_any_right?(@current_user, :read_sis, :manage_sis) return false diff --git a/app/controllers/external_content_controller.rb b/app/controllers/external_content_controller.rb index 02f2299eeeb..50bd4247bd3 100644 --- a/app/controllers/external_content_controller.rb +++ b/app/controllers/external_content_controller.rb @@ -151,7 +151,7 @@ class ExternalContentController < ApplicationController message = IMS::LTI::Models::Messages::Message.generate(request.GET && request.POST) message.content_items else - filtered_params = params.permit(*%w(url text title return_type content_type height width)) + filtered_params = params.permit(*%w[url text title return_type content_type height width]) [Lti::ContentItemConverter.convert_resource_selection(filtered_params)] end end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 130288747ea..30baf871bad 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -632,7 +632,7 @@ class FilesController < ApplicationController end json_include = if @attachment.context.is_a?(User) || @attachment.context.is_a?(Course) - { include: %w(enhanced_preview_url) } + { include: %w[enhanced_preview_url] } else {} end @@ -1159,7 +1159,7 @@ class FilesController < ApplicationController end if (@attachment.folder_id_changed? || @attachment.display_name_changed?) && @attachment.folder.active_file_attachments.where(display_name: @attachment.display_name).where("id<>?", @attachment.id).exists? - return render json: { message: "file already exists; use on_duplicate='overwrite' or 'rename'" }, status: :conflict unless %w(overwrite rename).include?(params[:on_duplicate]) + return render json: { message: "file already exists; use on_duplicate='overwrite' or 'rename'" }, status: :conflict unless %w[overwrite rename].include?(params[:on_duplicate]) on_duplicate = params[:on_duplicate].to_sym end diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index 3142bf11c64..7e4717ffd59 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -570,7 +570,7 @@ class FoldersController < ApplicationController if authorized_action(@attachment, @current_user, :create) on_duplicate, name = params[:on_duplicate].presence, params[:name].presence duplicate_options = (on_duplicate == 'rename' && name) ? { name: name } : {} - return render :json => { :message => "on_duplicate must be 'overwrite' or 'rename'" }, :status => :bad_request if on_duplicate && %w(overwrite rename).exclude?(on_duplicate) + return render :json => { :message => "on_duplicate must be 'overwrite' or 'rename'" }, :status => :bad_request if on_duplicate && %w[overwrite rename].exclude?(on_duplicate) if on_duplicate.nil? && @dest_folder.active_file_attachments.where(display_name: @source_file.display_name).exists? return render :json => { :message => "file already exists; set on_duplicate to 'rename' or 'overwrite'" }, :status => :conflict end diff --git a/app/controllers/group_categories_controller.rb b/app/controllers/group_categories_controller.rb index eaaaba23b4a..332c8e693d3 100644 --- a/app/controllers/group_categories_controller.rb +++ b/app/controllers/group_categories_controller.rb @@ -103,7 +103,7 @@ class GroupCategoriesController < ApplicationController include Api::V1::Group include Api::V1::Progress - SETTABLE_GROUP_ATTRIBUTES = %w(name description join_level is_public group_category avatar_attachment).freeze + SETTABLE_GROUP_ATTRIBUTES = %w[name description join_level is_public group_category avatar_attachment].freeze include TextHelper diff --git a/app/controllers/group_memberships_controller.rb b/app/controllers/group_memberships_controller.rb index c253ef49bdd..356d4295a15 100644 --- a/app/controllers/group_memberships_controller.rb +++ b/app/controllers/group_memberships_controller.rb @@ -77,7 +77,7 @@ class GroupMembershipsController < ApplicationController include Api::V1::Group - ALLOWED_MEMBERSHIP_FILTER = %w(accepted invited requested).freeze + ALLOWED_MEMBERSHIP_FILTER = %w[accepted invited requested].freeze # @API List group memberships # @@ -162,7 +162,7 @@ class GroupMembershipsController < ApplicationController end end - UPDATABLE_MEMBERSHIP_ATTRIBUTES = %w(workflow_state moderator).freeze + UPDATABLE_MEMBERSHIP_ATTRIBUTES = %w[workflow_state moderator].freeze # @API Update a membership # diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index e5263893e56..db582c9904b 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -150,10 +150,10 @@ class GroupsController < ApplicationController include Context include K5Mode - SETTABLE_GROUP_ATTRIBUTES = %w( + SETTABLE_GROUP_ATTRIBUTES = %w[ name description join_level is_public group_category avatar_attachment storage_quota_mb max_membership leader - ).freeze + ].freeze include TextHelper diff --git a/app/controllers/lti/ims/concerns/deep_linking_modules.rb b/app/controllers/lti/ims/concerns/deep_linking_modules.rb index 858ea6f6330..bc5ffdb2e35 100644 --- a/app/controllers/lti/ims/concerns/deep_linking_modules.rb +++ b/app/controllers/lti/ims/concerns/deep_linking_modules.rb @@ -30,8 +30,8 @@ module Lti::IMS::Concerns end end - CREATE_NEW_MODULE_PLACEMENTS = %w(course_assignments_menu module_index_menu_modal).freeze - ALLOW_LINE_ITEM_PLACEMENTS = %w(course_assignments_menu module_index_menu_modal).freeze + CREATE_NEW_MODULE_PLACEMENTS = %w[course_assignments_menu module_index_menu_modal].freeze + ALLOW_LINE_ITEM_PLACEMENTS = %w[course_assignments_menu module_index_menu_modal].freeze def content_items_for_modules @content_items_for_modules ||= lti_resource_links.reject { |item| item.key? :lineItem } diff --git a/app/controllers/lti/ims/line_items_controller.rb b/app/controllers/lti/ims/line_items_controller.rb index 5bbd189f2d7..59751fb52a7 100644 --- a/app/controllers/lti/ims/line_items_controller.rb +++ b/app/controllers/lti/ims/line_items_controller.rb @@ -69,7 +69,7 @@ module Lti include Concerns::GradebookServices before_action :prepare_line_item_for_ags!, only: :create - before_action :verify_line_item_in_context, only: %i(show update destroy) + before_action :verify_line_item_in_context, only: %i[show update destroy] before_action :verify_valid_resource_link, only: :create ACTION_SCOPE_MATCHERS = { @@ -221,7 +221,7 @@ module Lti private def line_item_params - @_line_item_params ||= params.permit(%i(resourceId resourceLinkId scoreMaximum label tag), + @_line_item_params ||= params.permit(%i[resourceId resourceLinkId scoreMaximum label tag], Lti::LineItem::AGS_EXT_SUBMISSION_TYPE => [:type, :external_tool_url]).transform_keys do |k| k.to_s.underscore end.except(:resource_link_id) diff --git a/app/controllers/lti/ims/tool_setting_controller.rb b/app/controllers/lti/ims/tool_setting_controller.rb index 8fb71f2c513..8efc6595736 100644 --- a/app/controllers/lti/ims/tool_setting_controller.rb +++ b/app/controllers/lti/ims/tool_setting_controller.rb @@ -45,29 +45,29 @@ module Lti { id: TOOL_SETTINGS_SERVICE, endpoint: 'api/lti/tool_settings/tool_proxy/{tool_proxy_id}', - format: %w( + format: %w[ application/vnd.ims.lti.v2.toolsettings+json application/vnd.ims.lti.v2.toolsettings.simple+json - ).freeze, - action: %w(GET PUT).freeze + ].freeze, + action: %w[GET PUT].freeze }.freeze, { id: TOOL_PROXY_BINDING_SERVICE, endpoint: 'api/lti/tool_settings/bindings/{binding_id}', - format: %w( + format: %w[ application/vnd.ims.lti.v2.toolsettings+json' application/vnd.ims.lti.v2.toolsettings.simple+json - ).freeze, - action: %w(GET PUT).freeze + ].freeze, + action: %w[GET PUT].freeze }.freeze, { id: LTI_LINK_SETTINGS, endpoint: 'api/lti/tool_proxy/{tool_proxy_guid}/courses/{course_id}/resource_link_id/{resource_link_id}/tool_setting', - format: %w( + format: %w[ application/vnd.ims.lti.v2.toolsettings+json application/vnd.ims.lti.v2.toolsettings.simple+json - ).freeze, - action: %w(GET PUT).freeze + ].freeze, + action: %w[GET PUT].freeze }.freeze ].freeze @@ -92,7 +92,7 @@ module Lti private def tool_setting_json(tool_setting, bubble) - if %w(all distinct).include?(bubble) + if %w[all distinct].include?(bubble) graph = [] distinct = bubble == 'distinct' ? [] : nil while tool_setting diff --git a/app/controllers/lti/membership_service_controller.rb b/app/controllers/lti/membership_service_controller.rb index 22ac5c42a81..5c7e818f987 100644 --- a/app/controllers/lti/membership_service_controller.rb +++ b/app/controllers/lti/membership_service_controller.rb @@ -60,7 +60,7 @@ module Lti end def membership_service_params - keys = %w(role page per_page) + keys = %w[role page per_page] params.select { |k, _| keys.include?(k) } end diff --git a/app/controllers/lti/message_controller.rb b/app/controllers/lti/message_controller.rb index ca98c9e2860..242ec350feb 100644 --- a/app/controllers/lti/message_controller.rb +++ b/app/controllers/lti/message_controller.rb @@ -260,7 +260,7 @@ module Lti end def prep_tool_settings(parameters, tool_proxy, resource_link_id) - params = %w(LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url) + params = %w[LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url] if parameters && (parameters.filter_map { |p| p['variable'] } & params).any? link = ToolSetting.where( tool_proxy_id: tool_proxy.id, diff --git a/app/controllers/lti/originality_reports_api_controller.rb b/app/controllers/lti/originality_reports_api_controller.rb index 9881085bee1..bf2ffc28145 100644 --- a/app/controllers/lti/originality_reports_api_controller.rb +++ b/app/controllers/lti/originality_reports_api_controller.rb @@ -293,7 +293,7 @@ module Lti end def lti_link_attributes - [tool_setting: %i(resource_url resource_type_code)].freeze + [tool_setting: %i[resource_url resource_type_code]].freeze end def assignment diff --git a/app/controllers/lti/submissions_api_controller.rb b/app/controllers/lti/submissions_api_controller.rb index ef2b75e902d..adba8510cc7 100644 --- a/app/controllers/lti/submissions_api_controller.rb +++ b/app/controllers/lti/submissions_api_controller.rb @@ -233,7 +233,7 @@ module Lti end def api_json(submission) - submission_attributes = %w(id body url submitted_at assignment_id user_id submission_type workflow_state attempt attachments) + submission_attributes = %w[id body url submitted_at assignment_id user_id submission_type workflow_state attempt attachments] sub_hash = filtered_json(model: submission, allow_list: submission_attributes) sub_hash[:user_id] = Lti::Asset.opaque_identifier_for(User.find(sub_hash[:user_id]), context: submission.assignment.context) if submission.turnitin_data[:eula_agreement_timestamp].present? @@ -247,7 +247,7 @@ module Lti end def attachment_json(attachment) - attachment_attributes = %w(id display_name filename content-type size created_at updated_at) + attachment_attributes = %w[id display_name filename content-type size created_at updated_at] attach = filtered_json(model: attachment, allow_list: attachment_attributes) attach[:upload_status] = AttachmentUploadStatus.upload_status(attachment) attach[:url] = attachment_url(attachment) diff --git a/app/controllers/lti/users_api_controller.rb b/app/controllers/lti/users_api_controller.rb index 59ba9a0ff3a..34b7869b03e 100644 --- a/app/controllers/lti/users_api_controller.rb +++ b/app/controllers/lti/users_api_controller.rb @@ -46,7 +46,7 @@ module Lti }.freeze ].freeze - USER_INCLUDES = %w(email lti_id).freeze + USER_INCLUDES = %w[email lti_id].freeze def lti2_service_name USER_SERVICE diff --git a/app/controllers/master_courses/master_templates_controller.rb b/app/controllers/master_courses/master_templates_controller.rb index e8c2110ed09..5e60d0fb5ae 100644 --- a/app/controllers/master_courses/master_templates_controller.rb +++ b/app/controllers/master_courses/master_templates_controller.rb @@ -417,7 +417,7 @@ class MasterCourses::MasterTemplatesController < ApplicationController # def restrict_item content_type = params[:content_type] - unless %w{assignment attachment discussion_topic external_tool lti-quiz quiz wiki_page}.include?(content_type) + unless %w[assignment attachment discussion_topic external_tool lti-quiz quiz wiki_page].include?(content_type) return render :json => { :message => "Must be a valid content type (assignment,attachment,discussion_topic,external_tool,lti-quiz,quiz,wiki_page)" }, :status => :bad_request end unless params.key?(:restricted) diff --git a/app/controllers/outcome_imports_api_controller.rb b/app/controllers/outcome_imports_api_controller.rb index abc47e312ba..9d6f2ed278b 100644 --- a/app/controllers/outcome_imports_api_controller.rb +++ b/app/controllers/outcome_imports_api_controller.rb @@ -195,7 +195,7 @@ class OutcomeImportsApiController < ApplicationController # # @returns OutcomeImport def show - if authorized_action(@context, @current_user, %i(import_outcomes manage_outcomes)) + if authorized_action(@context, @current_user, %i[import_outcomes manage_outcomes]) begin @import = if params[:id] == 'latest' @context.latest_outcome_import or raise ActiveRecord::RecordNotFound diff --git a/app/controllers/outcome_results_controller.rb b/app/controllers/outcome_results_controller.rb index 07497f2f604..19dc55dab1f 100644 --- a/app/controllers/outcome_results_controller.rb +++ b/app/controllers/outcome_results_controller.rb @@ -487,13 +487,13 @@ class OutcomeResultsController < ApplicationController def verify_aggregate_parameter aggregate = params[:aggregate] - reject! "invalid aggregate parameter value" if aggregate && !%w(course).include?(aggregate) + reject! "invalid aggregate parameter value" if aggregate && !%w[course].include?(aggregate) true end def verify_aggregate_stat_parameter aggregate_stat = params[:aggregate_stat] - reject! "invalid aggregate_stat parameter value" if aggregate_stat && !%w(mean median).include?(aggregate_stat) + reject! "invalid aggregate_stat parameter value" if aggregate_stat && !%w[mean median].include?(aggregate_stat) true end @@ -501,14 +501,14 @@ class OutcomeResultsController < ApplicationController return true unless params[:sort_by] sort_by = params[:sort_by] - reject! "invalid sort_by parameter value" if sort_by && !%w(student outcome).include?(sort_by) + reject! "invalid sort_by parameter value" if sort_by && !%w[student outcome].include?(sort_by) if sort_by == 'outcome' sort_outcome_id = params[:sort_outcome_id] reject! "missing required sort_outcome_id parameter value" unless sort_outcome_id reject! "invalid sort_outcome_id parameter value" unless /\A\d+\z/.match?(sort_outcome_id) end sort_order = params[:sort_order] - reject! "invalid sort_order parameter value" if sort_by && sort_order && !%w(asc desc).include?(sort_order) + reject! "invalid sort_order parameter value" if sort_by && sort_order && !%w[asc desc].include?(sort_order) true end diff --git a/app/controllers/outcomes_controller.rb b/app/controllers/outcomes_controller.rb index 7811ceb5bc7..3bc69e54c83 100644 --- a/app/controllers/outcomes_controller.rb +++ b/app/controllers/outcomes_controller.rb @@ -103,7 +103,7 @@ class OutcomesController < ApplicationController @outcome.tie_to(@context) render :json => @outcome.as_json( :methods => :artifacts_count_for_tied_context, - :user_content => %w(description) + :user_content => %w[description] ) end diff --git a/app/controllers/planner_controller.rb b/app/controllers/planner_controller.rb index ec0f6b1f4a1..ab1a1bf2b2d 100644 --- a/app/controllers/planner_controller.rb +++ b/app/controllers/planner_controller.rb @@ -335,7 +335,7 @@ class PlannerController < ApplicationController end def set_params - includes = Array.wrap(params[:include]) & %w{concluded} + includes = Array.wrap(params[:include]) & %w[concluded] @per_page = params[:per_page] || 50 @page = params[:page] || 'first' @include_concluded = includes.include? 'concluded' diff --git a/app/controllers/provisional_grades_base_controller.rb b/app/controllers/provisional_grades_base_controller.rb index 9798c7c4669..f30efac0636 100644 --- a/app/controllers/provisional_grades_base_controller.rb +++ b/app/controllers/provisional_grades_base_controller.rb @@ -62,7 +62,7 @@ class ProvisionalGradesBaseController < ApplicationController provisional_grade: pg, current_user: @current_user, avatars: service_enabled?(:avatars) && !@assignment.grade_as_group?, - includes: %w(submission_comments rubric_assessment) + includes: %w[submission_comments rubric_assessment] ) pg_json[:selected] = !!(selection && selection.selected_provisional_grade_id == pg.id) pg_json[:readonly] = !pg.final && (pg.scorer_id != @current_user.id) diff --git a/app/controllers/provisional_grades_controller.rb b/app/controllers/provisional_grades_controller.rb index 1b7eb2e438c..23c2dcee167 100644 --- a/app/controllers/provisional_grades_controller.rb +++ b/app/controllers/provisional_grades_controller.rb @@ -127,7 +127,7 @@ class ProvisionalGradesController < ProvisionalGradesBaseController selection.save! selection.create_moderation_event(@current_user) changed_submission_ids.push(map[:submission].id) - selection_json = selection.as_json(include_root: false, only: %w(assignment_id student_id selected_provisional_grade_id)) + selection_json = selection.as_json(include_root: false, only: %w[assignment_id student_id selected_provisional_grade_id]) unless @assignment.can_view_student_names?(@current_user) selection_json.delete(:student_id) @@ -197,7 +197,7 @@ class ProvisionalGradesController < ProvisionalGradesBaseController # related student is selected. submission.touch - json = selection.as_json(include_root: false, only: %w(assignment_id student_id selected_provisional_grade_id)) + json = selection.as_json(include_root: false, only: %w[assignment_id student_id selected_provisional_grade_id]) unless @assignment.can_view_student_names?(@current_user) json.delete(:student_id) json[:anonymous_id] = submission.anonymous_id diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 8a1f4738a1c..d462b443380 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -100,12 +100,12 @@ class QuestionBanksController < ApplicationController end @questions = @bank.assessment_questions.where(:id => ids) if params[:move] != '1' - attributes = @questions.columns.map(&:name) - %w{id created_at updated_at assessment_question_bank_id} + attributes = @questions.columns.map(&:name) - %w[id created_at updated_at assessment_question_bank_id] connection = @questions.connection attributes = attributes.map { |attr| connection.quote_column_name(attr) } now = connection.quote(Time.now.utc) connection.insert( - "INSERT INTO #{AssessmentQuestion.quoted_table_name} (#{(%w{assessment_question_bank_id created_at updated_at} + attributes).join(', ')})" + + "INSERT INTO #{AssessmentQuestion.quoted_table_name} (#{(%w[assessment_question_bank_id created_at updated_at] + attributes).join(', ')})" + @questions.select(([@new_bank.id, now, now] + attributes).join(', ')).to_sql ) else diff --git a/app/controllers/role_overrides_controller.rb b/app/controllers/role_overrides_controller.rb index ab8d9d7f015..4a5a8222d77 100644 --- a/app/controllers/role_overrides_controller.rb +++ b/app/controllers/role_overrides_controller.rb @@ -133,8 +133,8 @@ class RoleOverridesController < ApplicationController def api_index if authorized_action(@context, @current_user, :manage_role_overrides) route = polymorphic_url([:api, :v1, @context, :roles]) - states = params[:state].to_a.reject { |s| %w(active inactive).exclude?(s) } - states = %w(active) if states.empty? + states = params[:state].to_a.reject { |s| %w[active inactive].exclude?(s) } + states = %w[active] if states.empty? roles = [] roles += Role.visible_built_in_roles(root_account_id: @context.resolved_root_account_id) if states.include?('active') @@ -576,7 +576,7 @@ class RoleOverridesController < ApplicationController # Could be generalized for other use cases by adding to the whitelist def check_account_permission - whitelist = %w(manage_catalog) + whitelist = %w[manage_catalog] permission = params[:permission] if whitelist.include?(permission) diff --git a/app/controllers/rubric_associations_controller.rb b/app/controllers/rubric_associations_controller.rb index e972f90684b..1c424a7718c 100644 --- a/app/controllers/rubric_associations_controller.rb +++ b/app/controllers/rubric_associations_controller.rb @@ -113,7 +113,7 @@ class RubricAssociationsController < ApplicationController :rubric => @rubric.as_json(:methods => :criteria, :include_root => false, :permissions => { :user => @current_user, :session => session }), :rubric_association => @association.as_json(:include_root => false, - :include => %i{rubric_assessments assessment_requests}, + :include => %i[rubric_assessments assessment_requests], :permissions => { :user => @current_user, :session => session }) } render :json => json_res diff --git a/app/controllers/rubrics_api_controller.rb b/app/controllers/rubrics_api_controller.rb index cb005f9d137..1ea0729fd0c 100644 --- a/app/controllers/rubrics_api_controller.rb +++ b/app/controllers/rubrics_api_controller.rb @@ -266,8 +266,8 @@ class RubricsApiController < ApplicationController before_action :require_context before_action :validate_args - VALID_ASSESSMENT_SCOPES = %w(assessments graded_assessments peer_assessments).freeze - VALID_ASSOCIATION_SCOPES = %w(associations assignment_associations course_associations account_associations).freeze + VALID_ASSESSMENT_SCOPES = %w[assessments graded_assessments peer_assessments].freeze + VALID_ASSOCIATION_SCOPES = %w[associations assignment_associations course_associations account_associations].freeze VALID_INCLUDE_PARAMS = (VALID_ASSESSMENT_SCOPES + VALID_ASSOCIATION_SCOPES).freeze diff --git a/app/controllers/sections_controller.rb b/app/controllers/sections_controller.rb index 958694ea788..ef718d86940 100644 --- a/app/controllers/sections_controller.rb +++ b/app/controllers/sections_controller.rb @@ -318,7 +318,7 @@ class SectionsController < ApplicationController add_crumb(@section.name, named_context_url(@context, :context_section_url, @section)) @enrollments_count = @section.enrollments.not_fake.where(:workflow_state => 'active').count @completed_enrollments_count = @section.enrollments.not_fake.where(:workflow_state => 'completed').count - @pending_enrollments_count = @section.enrollments.not_fake.where(:workflow_state => %w{invited pending}).count + @pending_enrollments_count = @section.enrollments.not_fake.where(:workflow_state => %w[invited pending]).count @student_enrollments_count = @section.enrollments.not_fake.where(:type => 'StudentEnrollment').count js_env if @context.grants_right?(@current_user, session, :manage) diff --git a/app/controllers/sis_import_errors_api_controller.rb b/app/controllers/sis_import_errors_api_controller.rb index 8d3b93b504a..8486a2dbe22 100644 --- a/app/controllers/sis_import_errors_api_controller.rb +++ b/app/controllers/sis_import_errors_api_controller.rb @@ -82,7 +82,7 @@ class SisImportErrorsApiController < ApplicationController # # @returns [SisImportError] def index - if authorized_action(@account, @current_user, %i(import_sis manage_sis)) + if authorized_action(@account, @current_user, %i[import_sis manage_sis]) scope = @account.sis_batch_errors.order('created_at DESC') if params[:id] batch = @account.sis_batches.find(params[:id]) diff --git a/app/controllers/submissions_api_controller.rb b/app/controllers/submissions_api_controller.rb index 978ae651d76..7fd3be6a3ba 100644 --- a/app/controllers/submissions_api_controller.rb +++ b/app/controllers/submissions_api_controller.rb @@ -929,7 +929,7 @@ class SubmissionsApiController < ApplicationController @submission.reload bulk_load_attachments_and_previews([@submission]) - includes = %w(submission_comments) + includes = %w[submission_comments] includes.concat(Array.wrap(params[:include]) & ['visibility']) includes << 'provisional_grades' if submission[:provisional] diff --git a/app/controllers/submissions_base_controller.rb b/app/controllers/submissions_base_controller.rb index 687d9ffb402..4ab55395f9d 100644 --- a/app/controllers/submissions_base_controller.rb +++ b/app/controllers/submissions_base_controller.rb @@ -74,7 +74,7 @@ class SubmissionsBaseController < ApplicationController render :json => @submission.as_json( Submission.json_serialization_full_parameters( - except: %i(quiz_submission submission_history) + except: %i[quiz_submission submission_history] ).merge({ except: submission_json_exclusions, permissions: { diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index b887bedeb4e..71f97f817ef 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -321,7 +321,7 @@ class SubmissionsController < SubmissionsBaseController end format.json do if api_request? - includes = %|submission_comments attachments| + includes = %(submission_comments attachments) json = submission_json(@submission, @assignment, @current_user, session, @context, includes, params) render json: json, status: :created, diff --git a/app/controllers/tabs_controller.rb b/app/controllers/tabs_controller.rb index 0eafbe228b2..7d9aea23fbf 100644 --- a/app/controllers/tabs_controller.rb +++ b/app/controllers/tabs_controller.rb @@ -152,7 +152,7 @@ class TabsController < ApplicationController pos = tab_config.index { |t| t['id'] == tab['id'] } if pos.nil? pos = (tab['position'] || tab_config.size) - 1 - tab_config.insert(pos, tab.with_indifferent_access.slice(*%w{id hidden position})) + tab_config.insert(pos, tab.with_indifferent_access.slice(*%w[id hidden position])) end if value_to_boolean(params['hidden']) diff --git a/app/controllers/terms_api_controller.rb b/app/controllers/terms_api_controller.rb index 70a90287cf9..a40b9320f77 100644 --- a/app/controllers/terms_api_controller.rb +++ b/app/controllers/terms_api_controller.rb @@ -159,7 +159,7 @@ class TermsApiController < ApplicationController # @returns EnrollmentTerm def show term = api_find(@context.enrollment_terms, params[:id]) - render json: enrollment_term_json(term, @current_user, session, nil, %w{overrides}) + render json: enrollment_term_json(term, @current_user, session, nil, %w[overrides]) end protected diff --git a/app/controllers/terms_controller.rb b/app/controllers/terms_controller.rb index 850f8731af5..54d5d090715 100644 --- a/app/controllers/terms_controller.rb +++ b/app/controllers/terms_controller.rb @@ -125,7 +125,7 @@ class TermsController < ApplicationController params.require(:enrollment_term) overrides = params[:enrollment_term][:overrides]&.to_unsafe_h if overrides.present? - unless (overrides.keys.map(&:classify) - %w(StudentEnrollment TeacherEnrollment TaEnrollment DesignerEnrollment)).empty? + unless (overrides.keys.map(&:classify) - %w[StudentEnrollment TeacherEnrollment TaEnrollment DesignerEnrollment]).empty? return render :json => { :message => 'Invalid enrollment type in overrides' }, :status => :bad_request end end diff --git a/app/controllers/user_observees_controller.rb b/app/controllers/user_observees_controller.rb index f5cc025bea4..2acf26ad5a1 100644 --- a/app/controllers/user_observees_controller.rb +++ b/app/controllers/user_observees_controller.rb @@ -346,7 +346,7 @@ class UserObserveesController < ApplicationController end def root_account_for_new_link - if %w{create update}.include?(action_name) + if %w[create update].include?(action_name) case params[:root_account_id] when "all" nil diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4d42cdbe078..751fa3e1d3f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -421,7 +421,7 @@ class UsersController < ApplicationController end page_opts[:total_entries] = nil unless @context.root_account.allow_last_page_on_users? - includes = (params[:include] || []) & %w{avatar_url email last_login time_zone uuid} + includes = (params[:include] || []) & %w[avatar_url email last_login time_zone uuid] includes << 'last_login' if params[:sort] == 'last_login' && !includes.include?('last_login') GuardRail.activate(:secondary) do users = Api.paginate(users, self, api_v1_account_users_url, page_opts) @@ -1310,7 +1310,7 @@ class UsersController < ApplicationController render status: status end format.json do - render json: user_json(@user, @current_user, session, %w{locale avatar_url}, + render json: user_json(@user, @current_user, session, %w[locale avatar_url], @current_user.pseudonym.account), status: status end @@ -1606,7 +1606,7 @@ class UsersController < ApplicationController create_user end - BOOLEAN_PREFS = %i(manual_mark_as_read collapse_global_nav hide_dashcard_color_overlays release_notes_badge_disabled comment_library_suggestions_enabled elementary_dashboard_disabled).freeze + BOOLEAN_PREFS = %i[manual_mark_as_read collapse_global_nav hide_dashcard_color_overlays release_notes_badge_disabled comment_library_suggestions_enabled elementary_dashboard_disabled].freeze # @API Update user settings. # Update an existing user's settings. @@ -1681,8 +1681,8 @@ class UsersController < ApplicationController return render(json: { :message => "This endpoint only works against the current user" }, status: :unauthorized) end - valid_names = %w{home modules pages assignments quizzes settings files people announcements - grades discussions syllabus collaborations import conferences} + valid_names = %w[home modules pages assignments quizzes settings files people announcements + grades discussions syllabus collaborations import conferences] # Check if the page_name is valid unless valid_names.include?(params[:page_name]) @@ -2030,7 +2030,7 @@ class UsersController < ApplicationController @user.grants_right?(@current_user, :update_avatar) && @user.grants_right?(@current_user, :manage_user_details) - includes = %w{locale avatar_url email time_zone} + includes = %w[locale avatar_url email time_zone] if (title = user_params.delete(:title)) @user.profile.title = title includes << "title" @@ -2408,7 +2408,7 @@ class UsersController < ApplicationController render(:json => user_json(into_user, @current_user, session, - %w{locale}, + %w[locale], destination_account)) end end @@ -2869,7 +2869,7 @@ class UsersController < ApplicationController end def api_show_includes - includes = %w{locale avatar_url permissions email effective_locale} + includes = %w[locale avatar_url permissions email effective_locale] includes += Array.wrap(params[:include]) & ['uuid', 'last_login'] includes end @@ -2928,7 +2928,7 @@ class UsersController < ApplicationController notify_policy = Users::CreationNotifyPolicy.new(manage_user_logins, params[:pseudonym]) - includes = %w{locale} + includes = %w[locale] cc_params = params[:communication_channel] diff --git a/app/controllers/wiki_pages_api_controller.rb b/app/controllers/wiki_pages_api_controller.rb index e9ad108da7a..14b900cacf3 100644 --- a/app/controllers/wiki_pages_api_controller.rb +++ b/app/controllers/wiki_pages_api_controller.rb @@ -548,7 +548,7 @@ class WikiPagesApiController < ApplicationController end def get_wiki_page - GuardRail.activate(%w{update update_front_page}.include?(params[:action]) ? :primary : :secondary) do + GuardRail.activate(%w[update update_front_page].include?(params[:action]) ? :primary : :secondary) do @wiki = @context.wiki # attempt to find an existing page @@ -588,7 +588,7 @@ class WikiPagesApiController < ApplicationController def get_update_params(allowed_fields = Set[]) # normalize parameters - page_params = params[:wiki_page] ? params[:wiki_page].permit(*%w(title body notify_of_update published front_page editing_roles)) : {} + page_params = params[:wiki_page] ? params[:wiki_page].permit(*%w[title body notify_of_update published front_page editing_roles]) : {} if page_params.key?(:published) published_value = page_params.delete(:published) @@ -599,7 +599,7 @@ class WikiPagesApiController < ApplicationController if page_params.key?(:editing_roles) editing_roles = page_params[:editing_roles].split(',').map(&:strip) - invalid_roles = editing_roles.reject { |role| %w(teachers students members public).include?(role) } + invalid_roles = editing_roles.reject { |role| %w[teachers students members public].include?(role) } unless invalid_roles.empty? @page.errors.add(:editing_roles, t(:invalid_editing_roles, 'The provided editing roles are invalid')) return :bad_request diff --git a/app/helpers/assignments_helper.rb b/app/helpers/assignments_helper.rb index 6ce1578d15e..82c563cb5d9 100644 --- a/app/helpers/assignments_helper.rb +++ b/app/helpers/assignments_helper.rb @@ -101,7 +101,7 @@ module AssignmentsHelper end def i18n_grade(grade, grading_type = nil) - if grading_type == "pass_fail" && %w{complete incomplete}.include?(grade) + if grading_type == "pass_fail" && %w[complete incomplete].include?(grade) return grade == "complete" ? I18n.t("Complete") : I18n.t("Incomplete") end diff --git a/app/helpers/attachment_helper.rb b/app/helpers/attachment_helper.rb index 169bfe551f8..ca268d7768a 100644 --- a/app/helpers/attachment_helper.rb +++ b/app/helpers/attachment_helper.rb @@ -49,7 +49,7 @@ module AttachmentHelper attrs[:attachment_preview_processing] = true end attrs.map { |attr, val| - %|data-#{attr}="#{ERB::Util.html_escape(val)}"| + %(data-#{attr}="#{ERB::Util.html_escape(val)}") }.join(" ").html_safe end diff --git a/app/helpers/content_imports_helper.rb b/app/helpers/content_imports_helper.rb index 8117d140946..ca77e762eae 100644 --- a/app/helpers/content_imports_helper.rb +++ b/app/helpers/content_imports_helper.rb @@ -29,7 +29,7 @@ module ContentImportsHelper def error_link_or_message(string) if string =~ /ErrorReport(?: id)?: ?(\d+)\z/ - %{Error Report #{$1}}.html_safe + %(Error Report #{$1}).html_safe else user_content(string) end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index e8ed58608a4..eefed186b2f 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -130,7 +130,7 @@ module CoursesHelper end type = enrollment.type.remove(/Enrollment/).downcase - type = "student" if %w/studentview observer/.include?(type) + type = "student" if %w[studentview observer].include?(type) type end diff --git a/app/helpers/gradebooks_helper.rb b/app/helpers/gradebooks_helper.rb index 241807c1594..2b14b33a593 100644 --- a/app/helpers/gradebooks_helper.rb +++ b/app/helpers/gradebooks_helper.rb @@ -147,7 +147,7 @@ module GradebooksHelper def ungraded_submission_display(submission_type) sub_score = ungraded_submission_icon_attributes_for(submission_type) if sub_score - screenreadable_icon(sub_score, %w{submission_icon}) + screenreadable_icon(sub_score, %w[submission_icon]) else '-' end @@ -159,7 +159,7 @@ module GradebooksHelper else fail_icon_attributes end - screenreadable_icon(icon_attrs, %w{graded_icon}) + screenreadable_icon(icon_attrs, %w[graded_icon]) end def screenreadable_icon(icon_attrs, html_classes = []) diff --git a/app/helpers/stream_items_helper.rb b/app/helpers/stream_items_helper.rb index 161f6efcd90..bd4c35de91b 100644 --- a/app/helpers/stream_items_helper.rb +++ b/app/helpers/stream_items_helper.rb @@ -33,10 +33,10 @@ module StreamItemsHelper categorized_items = {} return categorized_items unless stream_items.present? # if we have no items (possibly because we have no user), don't try to activate the user's shard - supported_categories = %w(Announcement Conversation Assignment DiscussionTopic DiscussionEntry AssessmentRequest) + supported_categories = %w[Announcement Conversation Assignment DiscussionTopic DiscussionEntry AssessmentRequest] supported_categories.each { |category| categorized_items[category] = [] } - topic_types = %w{DiscussionTopic Announcement} + topic_types = %w[DiscussionTopic Announcement] ActiveRecord::Associations::Preloader.new.preload( stream_items.select { |i| topic_types.include?(i.asset_type) }.map(&:data), :context ) diff --git a/app/models/account.rb b/app/models/account.rb index 124159ebb93..54f493fd601 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -27,7 +27,7 @@ class Account < ActiveRecord::Base INSTANCE_GUID_SUFFIX = 'canvas-lms' # a list of columns necessary for validation and save callbacks to work on a slim object - BASIC_COLUMNS_FOR_CALLBACKS = %i{id parent_account_id root_account_id name workflow_state}.freeze + BASIC_COLUMNS_FOR_CALLBACKS = %i[id parent_account_id root_account_id name workflow_state].freeze include Workflow include BrandConfigHelpers diff --git a/app/models/account_report_runner.rb b/app/models/account_report_runner.rb index 3f6831a6249..acec07bb3d5 100644 --- a/app/models/account_report_runner.rb +++ b/app/models/account_report_runner.rb @@ -67,9 +67,9 @@ class AccountReportRunner < ActiveRecord::Base self.update!(workflow_state: 'error', ended_at: Time.now.utc) end - scope :in_progress, -> { where(workflow_state: %w(running)) } - scope :completed, -> { where(workflow_state: %w(completed)) } - scope :incomplete, -> { where(workflow_state: %w(created running)) } + scope :in_progress, -> { where(workflow_state: %w[running]) } + scope :completed, -> { where(workflow_state: %w[completed]) } + scope :incomplete, -> { where(workflow_state: %w[created running]) } def delete_account_report_rows cleanup = self.account_report_rows.limit(10_000) diff --git a/app/models/account_user.rb b/app/models/account_user.rb index 372acdb07dc..329e07b7f74 100644 --- a/app/models/account_user.rb +++ b/app/models/account_user.rb @@ -71,7 +71,7 @@ class AccountUser < ActiveRecord::Base being_deleted = self.workflow_state == 'deleted' && self.workflow_state_before_last_save != 'deleted' if (self.saved_change_to_account_id? || self.saved_change_to_user_id?) || being_deleted if self.new_record? - return if %w{creation_pending deleted}.include?(self.user.workflow_state) + return if %w[creation_pending deleted].include?(self.user.workflow_state) account_chain = self.account.account_chain associations = {} diff --git a/app/models/asset_user_access.rb b/app/models/asset_user_access.rb index f2c5308bdeb..e2f9cc05e12 100644 --- a/app/models/asset_user_access.rb +++ b/app/models/asset_user_access.rb @@ -265,8 +265,8 @@ class AssetUserAccess < ActiveRecord::Base end def log_action(level) - increment(:view_score) if %w{view participate}.include?(level) - increment(:participate_score) if %w{participate submit}.include?(level) + increment(:view_score) if %w[view participate].include?(level) + increment(:participate_score) if %w[participate submit].include?(level) if self.action_level != 'participate' self.action_level = (level == 'submit') ? 'participate' : level diff --git a/app/models/assignment.rb b/app/models/assignment.rb index fb0cf8dd5f5..eb966f0b9b8 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -42,9 +42,9 @@ class Assignment < ActiveRecord::Base self.ignored_columns = %i[context_code] - ALLOWED_GRADING_TYPES = %w(points percent letter_grade gpa_scale pass_fail not_graded).freeze - OFFLINE_SUBMISSION_TYPES = %i(on_paper external_tool none not_graded wiki_page).freeze - SUBMITTABLE_TYPES = %w(online_quiz discussion_topic wiki_page).freeze + ALLOWED_GRADING_TYPES = %w[points percent letter_grade gpa_scale pass_fail not_graded].freeze + OFFLINE_SUBMISSION_TYPES = %i[on_paper external_tool none not_graded wiki_page].freeze + SUBMITTABLE_TYPES = %w[online_quiz discussion_topic wiki_page].freeze LTI_EULA_SERVICE = 'vnd.Canvas.Eula' AUDITABLE_ATTRIBUTES = %w[ muted @@ -456,7 +456,7 @@ class Assignment < ActiveRecord::Base end end - API_NEEDED_FIELDS = %w( + API_NEEDED_FIELDS = %w[ id title context_id @@ -504,7 +504,7 @@ class Assignment < ActiveRecord::Base grader_comments_visible_to_graders grader_names_visible_to_final_grader grader_count - ).freeze + ].freeze def external_tool? self.submission_types == 'external_tool' @@ -1387,7 +1387,7 @@ class Assignment < ActiveRecord::Base def process_if_quiz if self.submission_types == "online_quiz" self.points_possible = quiz.points_possible if quiz&.available? - copy_attrs = %w(due_at lock_at unlock_at) + copy_attrs = %w[due_at lock_at unlock_at] if quiz && @saved_by != :quiz && copy_attrs.any? { |attr| changes[attr] } copy_attrs.each { |attr| quiz.send "#{attr}=", send(attr) } @@ -1674,7 +1674,7 @@ class Assignment < ActiveRecord::Base end def self.assignment_type?(type) - %w(quiz attendance discussion_topic wiki_page external_tool).include? type.to_s + %w[quiz attendance discussion_topic wiki_page external_tool].include? type.to_s end def self.get_submission_type(assignment_type) @@ -1715,7 +1715,7 @@ class Assignment < ActiveRecord::Base def each_submission_type if block_given? - submittable_types = %i(discussion_topic quiz) + submittable_types = %i[discussion_topic quiz] submittable_types << :wiki_page if self.context.try(:feature_enabled?, :conditional_release) submittable_types.each do |asg_type| submittable = self.send(asg_type) @@ -1761,7 +1761,7 @@ class Assignment < ActiveRecord::Base can :submit given do |user, session| - (submittable_type? || %w(discussion_topic online_quiz).include?(submission_types)) && + (submittable_type? || %w[discussion_topic online_quiz].include?(submission_types)) && context.grants_right?(user, session, :participate_as_student) && visible_to_user?(user) end @@ -2968,10 +2968,10 @@ class Assignment < ActiveRecord::Base } scope :expecting_submission, -> do - where.not(submission_types: [nil, ''] + %w(none not_graded on_paper wiki_page)) + where.not(submission_types: [nil, ''] + %w[none not_graded on_paper wiki_page]) end - scope :gradeable, -> { where.not(submission_types: %w(not_graded wiki_page)) } + scope :gradeable, -> { where.not(submission_types: %w[not_graded wiki_page]) } scope :active, -> { where.not(workflow_state: 'deleted') } scope :before, lambda { |date| where("assignments.created_at).freeze + DYNAMIC_THUMBNAIL_SIZES = %w[640x>].freeze # the list of allowed thumbnail sizes to be generated dynamically def self.dynamic_thumbnail_sizes diff --git a/app/models/authentication_provider.rb b/app/models/authentication_provider.rb index 03d58f5588a..28b5f4089ef 100644 --- a/app/models/authentication_provider.rb +++ b/app/models/authentication_provider.rb @@ -235,7 +235,7 @@ class AuthenticationProvider < ActiveRecord::Base end end - CANVAS_ALLOWED_FEDERATED_ATTRIBUTES = %w{ + CANVAS_ALLOWED_FEDERATED_ATTRIBUTES = %w[ admin_roles display_name email @@ -247,7 +247,7 @@ class AuthenticationProvider < ActiveRecord::Base sortable_name surname time_zone - }.freeze + ].freeze def provision_user(unique_id, provider_attributes = {}) User.transaction(requires_new: true) do diff --git a/app/models/bounce_notification_processor.rb b/app/models/bounce_notification_processor.rb index 3d5a1c0abd1..ffa84ce6b00 100644 --- a/app/models/bounce_notification_processor.rb +++ b/app/models/bounce_notification_processor.rb @@ -23,7 +23,7 @@ require 'aws-sdk-sqs' class BounceNotificationProcessor attr_reader :config - POLL_PARAMS = %i{idle_timeout wait_time_seconds visibility_timeout}.freeze + POLL_PARAMS = %i[idle_timeout wait_time_seconds visibility_timeout].freeze DEFAULT_CONFIG = { bounce_queue_name: 'canvas_notifications_bounces', idle_timeout: 10 diff --git a/app/models/conditional_release/assignment_set_action.rb b/app/models/conditional_release/assignment_set_action.rb index a497da641af..722062ea752 100644 --- a/app/models/conditional_release/assignment_set_action.rb +++ b/app/models/conditional_release/assignment_set_action.rb @@ -21,8 +21,8 @@ module ConditionalRelease class AssignmentSetAction < ActiveRecord::Base include Deletion - validates :action, inclusion: { in: %w(assign unassign) } - validates :source, inclusion: { in: %w(grade_change select_assignment_set) } + validates :action, inclusion: { in: %w[assign unassign] } + validates :source, inclusion: { in: %w[grade_change select_assignment_set] } validates :student_id, presence: true validates :actor_id, presence: true validates :assignment_set_id, presence: true diff --git a/app/models/conditional_release/service.rb b/app/models/conditional_release/service.rb index e01d4259160..8c5c5c594b5 100644 --- a/app/models/conditional_release/service.rb +++ b/app/models/conditional_release/service.rb @@ -229,10 +229,10 @@ module ConditionalRelease end def assignment_keys - %i(id title name description due_at unlock_at lock_at + %i[id title name description due_at unlock_at lock_at points_possible min_score max_score grading_type submission_types workflow_state context_id - context_type updated_at context_code) + context_type updated_at context_code] end end end diff --git a/app/models/content_migration.rb b/app/models/content_migration.rb index dbacaba7a9a..6bb0ea77b0c 100644 --- a/app/models/content_migration.rb +++ b/app/models/content_migration.rb @@ -425,7 +425,7 @@ class ContentMigration < ActiveRecord::Base running_cutoff = Setting.get('content_migration_job_block_hours', '4').to_i.hours.ago # at some point just let the jobs keep going if self.context && self.context.content_migrations - .where(:workflow_state => %w{created queued pre_processing pre_processed exporting importing}).where("id < ?", self.id) + .where(:workflow_state => %w[created queued pre_processing pre_processed exporting importing]).where("id < ?", self.id) .where("started_at > ?", running_cutoff).exists? # there's another job already going so punt @@ -1041,16 +1041,16 @@ class ContentMigration < ActiveRecord::Base def handle_import_in_progress_notice return unless context.is_a?(Course) && is_set?(migration_settings[:import_in_progress_notice]) - if (just_created || (saved_change_to_workflow_state? && %w{created queued}.include?(workflow_state_before_last_save))) && - %w(pre_processing pre_processed exporting importing).include?(workflow_state) + if (just_created || (saved_change_to_workflow_state? && %w[created queued].include?(workflow_state_before_last_save))) && + %w[pre_processing pre_processed exporting importing].include?(workflow_state) context.add_content_notice(:import_in_progress, 4.hours) - elsif saved_change_to_workflow_state? && %w(pre_process_error exported imported failed).include?(workflow_state) + elsif saved_change_to_workflow_state? && %w[pre_process_error exported imported failed].include?(workflow_state) context.remove_content_notice(:import_in_progress) end end def check_for_blocked_migration - if self.saved_change_to_workflow_state? && %w(pre_process_error exported imported failed).include?(workflow_state) + if self.saved_change_to_workflow_state? && %w[pre_process_error exported imported failed].include?(workflow_state) if self.context && (next_cm = self.context.content_migrations.where(:workflow_state => 'queued').order(:id).first) job_id = next_cm.job_progress.try(:delayed_job_id) if job_id && (job = Delayed::Job.where(:id => job_id, :locked_at => nil).first) diff --git a/app/models/content_share.rb b/app/models/content_share.rb index bd241a4e91f..dd7922f8a82 100644 --- a/app/models/content_share.rb +++ b/app/models/content_share.rb @@ -40,7 +40,7 @@ class ContentShare < ActiveRecord::Base belongs_to :sender, class_name: "User" belongs_to :root_account, class_name: "Account" - validates :read_state, inclusion: { in: %w(read unread) } + validates :read_state, inclusion: { in: %w[read unread] } before_create :set_root_account_id diff --git a/app/models/context.rb b/app/models/context.rb index 2f5b2f0c84a..2e8e66ce7c8 100644 --- a/app/models/context.rb +++ b/app/models/context.rb @@ -278,7 +278,7 @@ module Context object = ContextExternalTool.find_external_tool_by_id(params[:id], context) end when 'context_modules' - object = if %w(item_redirect item_redirect_mastery_paths choose_mastery_path).include?(params[:action]) + object = if %w[item_redirect item_redirect_mastery_paths choose_mastery_path].include?(params[:action]) context.context_module_tags.find_by(id: params[:id]) else context.context_modules.find_by(id: params[:id]) diff --git a/app/models/context_external_tool.rb b/app/models/context_external_tool.rb index 58d9f20ae21..2bbeb2e20d0 100644 --- a/app/models/context_external_tool.rb +++ b/app/models/context_external_tool.rb @@ -146,7 +146,7 @@ class ContextExternalTool < ActiveRecord::Base def visible?(visibility, user, context, session = nil) visibility = visibility.to_s - return true unless %w(public members admins).include?(visibility) + return true unless %w[public members admins].include?(visibility) return true if visibility == 'public' return true if visibility == 'members' && context.grants_any_right?(user, session, :participate_as_student, :read_as_admin) @@ -295,7 +295,7 @@ class ContextExternalTool < ActiveRecord::Base extension_keys += custom_keys end extension_keys += { - :visibility => lambda { |v| %w{members admins public}.include?(v) || v.nil? } + :visibility => lambda { |v| %w[members admins public].include?(v) || v.nil? } }.to_a # merge with existing settings so that no caller can complain diff --git a/app/models/context_module.rb b/app/models/context_module.rb index e4b4a3874d0..998fdc3177b 100644 --- a/app/models/context_module.rb +++ b/app/models/context_module.rb @@ -513,9 +513,9 @@ class ContextModule < ActiveRecord::Base tags = self.content_tags.not_deleted.index_by(&:id) validated_reqs = requirements.select do |req| if req[:id] && (tag = tags[req[:id]]) - if %w(must_view must_mark_done must_contribute).include?(req[:type]) + if %w[must_view must_mark_done must_contribute].include?(req[:type]) true - elsif %w(must_submit min_score).include?(req[:type]) + elsif %w[must_submit min_score].include?(req[:type]) true if tag.scoreable? end end @@ -756,7 +756,7 @@ class ContextModule < ActiveRecord::Base new_tags = [] items.each do |item| next unless item.is_a?(ActiveRecord::Base) - next unless %w(Attachment Assignment WikiPage Quizzes::Quiz DiscussionTopic ContextExternalTool).include?(item.class_name) + next unless %w[Attachment Assignment WikiPage Quizzes::Quiz DiscussionTopic ContextExternalTool].include?(item.class_name) item = item.submittable_object if item.is_a?(Assignment) && item.submittable_object next if tags.any? { |tag| tag.content_type == item.class_name && tag.content_id == item.id } diff --git a/app/models/context_module_progression.rb b/app/models/context_module_progression.rb index 0bca4fea90f..53e7006f026 100644 --- a/app/models/context_module_progression.rb +++ b/app/models/context_module_progression.rb @@ -196,7 +196,7 @@ class ContextModuleProgression < ActiveRecord::Base if req[:type] == 'must_view' calc.add_view_requirement(req) - elsif %w(must_contribute must_mark_done).include? req[:type] + elsif %w[must_contribute must_mark_done].include? req[:type] # must_contribute is handled by ContextModule#update_for calc.check_action!(req, false) elsif req[:type] == 'must_submit' @@ -204,7 +204,7 @@ class ContextModuleProgression < ActiveRecord::Base if sub.workflow_state == 'graded' && sub.attempt.nil? # is a manual grade - doesn't count for submission false - elsif %w(submitted graded complete pending_review).include?(sub.workflow_state) + elsif %w[submitted graded complete pending_review].include?(sub.workflow_state) true end }) diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 80573a0f7bb..9aeb940304c 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -759,7 +759,7 @@ class Conversation < ActiveRecord::Base end def replies_locked_for?(user) - return false unless %w{Course Group}.include?(self.context_type) + return false unless %w[Course Group].include?(self.context_type) course = self.context.is_a?(Course) ? self.context : self.context.context diff --git a/app/models/course.rb b/app/models/course.rb index d0140242641..6d0bcdd8c2a 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -367,8 +367,8 @@ class Course < ActiveRecord::Base def update_enrollment_states_if_necessary return if saved_change_to_id # new object, nothing to possibly invalidate - if (saved_changes.keys & %w{restrict_enrollments_to_course_dates account_id enrollment_term_id}).any? || - (self.restrict_enrollments_to_course_dates? && (saved_changes.keys & %w{start_at conclude_at}).any?) || + if (saved_changes.keys & %w[restrict_enrollments_to_course_dates account_id enrollment_term_id]).any? || + (self.restrict_enrollments_to_course_dates? && (saved_changes.keys & %w[start_at conclude_at]).any?) || (self.saved_change_to_workflow_state? && (completed? || self.workflow_state_before_last_save == 'completed')) # a lot of things can change the date logic here :/ @@ -519,7 +519,7 @@ class Course < ActiveRecord::Base def validate_default_view if self.default_view_changed? - if !%w{assignments feed modules syllabus wiki}.include?(self.default_view) + if !%w[assignments feed modules syllabus wiki].include?(self.default_view) self.errors.add(:default_view, t("Home page is not valid")) return false elsif self.default_view == 'wiki' && !(self.wiki_id && self.wiki.has_front_page?) @@ -868,8 +868,8 @@ class Course < ActiveRecord::Base none : where("EXISTS (?)", CourseAccountAssociation.where("course_account_associations.course_id=courses.id AND course_account_associations.account_id IN (?)", account_ids)) } - scope :published, -> { where(workflow_state: %w(available completed)) } - scope :unpublished, -> { where(workflow_state: %w(created claimed)) } + scope :published, -> { where(workflow_state: %w[available completed]) } + scope :unpublished, -> { where(workflow_state: %w[created claimed]) } scope :deleted, -> { where(:workflow_state => 'deleted') } @@ -1027,7 +1027,7 @@ class Course < ActiveRecord::Base def user_has_been_instructor?(user) return unless user if @user_ids_by_enroll_type - return preloaded_user_has_been?(user, %w{TaEnrollment TeacherEnrollment}) + return preloaded_user_has_been?(user, %w[TaEnrollment TeacherEnrollment]) end # enrollments should be on the course's shard @@ -1039,7 +1039,7 @@ class Course < ActiveRecord::Base def user_has_been_admin?(user) return unless user if @user_ids_by_enroll_type - return preloaded_user_has_been?(user, %w{TaEnrollment TeacherEnrollment DesignerEnrollment}) + return preloaded_user_has_been?(user, %w[TaEnrollment TeacherEnrollment DesignerEnrollment]) end fetch_on_enrollments('user_has_been_admin', user) do @@ -1061,7 +1061,7 @@ class Course < ActiveRecord::Base def user_has_been_student?(user) return unless user if @user_ids_by_enroll_type - return preloaded_user_has_been?(user, %w{StudentEnrollment StudentViewEnrollment}) + return preloaded_user_has_been?(user, %w[StudentEnrollment StudentViewEnrollment]) end fetch_on_enrollments('user_has_been_student', user) do @@ -1974,7 +1974,7 @@ class Course < ActiveRecord::Base end overall_status = "error" overall_status = "unpublished" unless found_statuses.size > 0 - overall_status = %w{error unpublished pending publishing published unpublishable}.detect { |s| found_statuses.include?(s) } || overall_status + overall_status = %w[error unpublished pending publishing published unpublishable].detect { |s| found_statuses.include?(s) } || overall_status [enrollments, overall_status] end @@ -2656,7 +2656,7 @@ class Course < ActiveRecord::Base end end - ADMIN_TYPES = %w{TeacherEnrollment TaEnrollment DesignerEnrollment}.freeze + ADMIN_TYPES = %w[TeacherEnrollment TaEnrollment DesignerEnrollment].freeze def section_visibilities_for(user, opts = {}) fetch_on_enrollments('section_visibilities_for', user, opts) do workflow_not = opts[:excluded_workflows] || 'deleted' @@ -3706,7 +3706,7 @@ class Course < ActiveRecord::Base end end - %w{student_count teacher_count primary_enrollment_type primary_enrollment_role_id primary_enrollment_rank primary_enrollment_state primary_enrollment_date invitation}.each do |method| + %w[student_count teacher_count primary_enrollment_type primary_enrollment_role_id primary_enrollment_rank primary_enrollment_state primary_enrollment_date invitation].each do |method| class_eval <<~RUBY def #{method} read_attribute(:#{method}) || @#{method} diff --git a/app/models/course_section.rb b/app/models/course_section.rb index 2cf9fe2edfb..61600d01ef5 100644 --- a/app/models/course_section.rb +++ b/app/models/course_section.rb @@ -406,7 +406,7 @@ class CourseSection < ActiveRecord::Base end def update_enrollment_states_if_necessary - if self.saved_change_to_restrict_enrollments_to_section_dates? || (self.restrict_enrollments_to_section_dates? && (saved_changes.keys & %w{start_at end_at}).any?) + if self.saved_change_to_restrict_enrollments_to_section_dates? || (self.restrict_enrollments_to_section_dates? && (saved_changes.keys & %w[start_at end_at]).any?) EnrollmentState.delay_if_production(n_strand: ["invalidate_enrollment_states", self.global_root_account_id]) .invalidate_states_for_course_or_section(self) end diff --git a/app/models/crocodoc_document.rb b/app/models/crocodoc_document.rb index 51198787ed9..1f37b50e8a1 100644 --- a/app/models/crocodoc_document.rb +++ b/app/models/crocodoc_document.rb @@ -27,7 +27,7 @@ class CrocodocDocument < ActiveRecord::Base has_many :canvadocs_submissions - MIME_TYPES = %w( + MIME_TYPES = %w[ application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document @@ -36,7 +36,7 @@ class CrocodocDocument < ActiveRecord::Base application/excel application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - ).freeze + ].freeze def upload return if uuid.present? @@ -194,7 +194,7 @@ class CrocodocDocument < ActiveRecord::Base def self.update_process_states bs = Setting.get('crocodoc_status_check_batch_size', '45').to_i GuardRail.activate(:secondary) do - CrocodocDocument.where(:process_state => %w(QUEUED PROCESSING)).find_in_batches do |docs| + CrocodocDocument.where(:process_state => %w[QUEUED PROCESSING]).find_in_batches do |docs| GuardRail.activate(:primary) do statuses = [] docs.each_slice(bs) do |sub_docs| diff --git a/app/models/discussion_entry.rb b/app/models/discussion_entry.rb index 008e11deed0..c3b3a7c6178 100644 --- a/app/models/discussion_entry.rb +++ b/app/models/discussion_entry.rb @@ -219,7 +219,7 @@ class DiscussionEntry < ActiveRecord::Base end def update_discussion - if %w(workflow_state message attachment_id editor_id).any? { |a| self.saved_change_to_attribute?(a) } + if %w[workflow_state message attachment_id editor_id].any? { |a| self.saved_change_to_attribute?(a) } dt = self.discussion_topic loop do dt.touch diff --git a/app/models/discussion_entry_draft.rb b/app/models/discussion_entry_draft.rb index b733410252e..8cf685f659d 100644 --- a/app/models/discussion_entry_draft.rb +++ b/app/models/discussion_entry_draft.rb @@ -25,8 +25,8 @@ class DiscussionEntryDraft < ActiveRecord::Base belongs_to :user, inverse_of: :discussion_entry_drafts def self.upsert_draft(user:, topic:, message:, entry: nil, parent: nil, attachment: nil, reply_preview: false) - insert_columns = %w(user_id discussion_topic_id discussion_entry_id root_entry_id parent_id - attachment_id message include_reply_preview updated_at created_at) + insert_columns = %w[user_id discussion_topic_id discussion_entry_id root_entry_id parent_id + attachment_id message include_reply_preview updated_at created_at] topic.shard.activate do insert_values = [] @@ -44,7 +44,7 @@ class DiscussionEntryDraft < ActiveRecord::Base conflict_condition = '(root_entry_id, user_id) WHERE discussion_entry_id IS NULL' if parent conflict_condition = '(discussion_entry_id, user_id)' if entry - update_columns = %w(message include_reply_preview) + update_columns = %w[message include_reply_preview] update_columns << 'parent_id' if parent update_columns << 'attachment' if attachment diff --git a/app/models/discussion_entry_participant.rb b/app/models/discussion_entry_participant.rb index bd03d339eff..ce3b8d463ad 100644 --- a/app/models/discussion_entry_participant.rb +++ b/app/models/discussion_entry_participant.rb @@ -29,7 +29,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base validates :discussion_entry_id, :user_id, :workflow_state, presence: true validate :prevent_creates - validates :report_type, inclusion: { in: %w(inappropriate offensive other), + validates :report_type, inclusion: { in: %w[inappropriate offensive other], message: "%{value} is not valid" } def prevent_creates @@ -81,7 +81,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base return not_null_column_object(column: :entry, entry: entry_or_topic, user: user) unless entry_or_topic return not_null_column_object(column: :user, entry: entry_or_topic, user: user) unless user - insert_columns = %w(discussion_entry_id user_id root_account_id workflow_state) + insert_columns = %w[discussion_entry_id user_id root_account_id workflow_state] update_columns = [] update_values = [] @@ -98,7 +98,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base end unless report_type.nil? - unless %w(inappropriate offensive other).include? report_type + unless %w[inappropriate offensive other].include? report_type raise(ArgumentError) end diff --git a/app/models/enrollment.rb b/app/models/enrollment.rb index b9ff6d8cdb7..8da5c26cd2f 100644 --- a/app/models/enrollment.rb +++ b/app/models/enrollment.rb @@ -349,7 +349,7 @@ class Enrollment < ActiveRecord::Base return if self.fake_student? if id_before_last_save.nil? || being_restored? - return if %w{creation_pending deleted}.include?(self.user.workflow_state) + return if %w[creation_pending deleted].include?(self.user.workflow_state) associations = User.calculate_account_associations_from_accounts([self.course.account_id, self.course_section.course.account_id, self.course_section.nonxlist_course.try(:account_id)].compact.uniq) self.user.update_account_associations(:incremental => true, :precalculated_associations => associations) @@ -510,7 +510,7 @@ class Enrollment < ActiveRecord::Base end def cancel_future_appointments - if saved_change_to_workflow_state? && %w{completed deleted}.include?(workflow_state) + if saved_change_to_workflow_state? && %w[completed deleted].include?(workflow_state) unless self.course.current_enrollments.where(:user_id => self.user_id).exists? # ignore if they have another still valid enrollment course.appointment_participants.active.current.for_context_codes(user.asset_string).update_all(:workflow_state => 'deleted') end @@ -752,7 +752,7 @@ class Enrollment < ActiveRecord::Base end def recalculate_enrollment_state - if (self.saved_changes.keys & %w{workflow_state start_at end_at}).any? + if (self.saved_changes.keys & %w[workflow_state start_at end_at]).any? @enrollment_dates = nil self.enrollment_state.state_is_current = false self.enrollment_state.is_direct_recalculation = true @@ -763,7 +763,7 @@ class Enrollment < ActiveRecord::Base def state_based_on_date RequestCache.cache('enrollment_state_based_on_date', self, self.workflow_state, self.saved_changes?) do - if %w{invited active completed}.include?(self.workflow_state) + if %w[invited active completed].include?(self.workflow_state) self.enrollment_state.get_effective_state else self.workflow_state.to_sym @@ -1148,7 +1148,7 @@ class Enrollment < ActiveRecord::Base def find_score(id_opts = nil) id_opts ||= Score.params_for_course - valid_keys = %i(course_score grading_period grading_period_id assignment_group assignment_group_id) + valid_keys = %i[course_score grading_period grading_period_id assignment_group assignment_group_id] return nil if id_opts.except(*valid_keys).any? result = if scores.loaded? diff --git a/app/models/enrollment/batch_state_updater.rb b/app/models/enrollment/batch_state_updater.rb index e14aac3d396..0c7e359572e 100644 --- a/app/models/enrollment/batch_state_updater.rb +++ b/app/models/enrollment/batch_state_updater.rb @@ -56,7 +56,7 @@ class Enrollment::BatchStateUpdater e.workflow_state = 'deleted' e.readonly! } - @user_course_tuples = Enrollment.where(id: batch).active.select(%i(user_id course_id)).distinct.to_a + @user_course_tuples = Enrollment.where(id: batch).active.select(%i[user_id course_id]).distinct.to_a @user_ids = Enrollment.where(id: batch).order(:user_id).distinct.pluck(:user_id) @courses = Course.where(id: Enrollment.where(id: batch).select(:course_id).distinct).to_a @root_account = @courses.first.root_account diff --git a/app/models/enrollment_state.rb b/app/models/enrollment_state.rb index f0eb57e33be..3de2f02a530 100644 --- a/app/models/enrollment_state.rb +++ b/app/models/enrollment_state.rb @@ -105,7 +105,7 @@ class EnrollmentState < ActiveRecord::Base end def pending? - %w{pending_active pending_invited creation_pending}.include?(self.state) + %w[pending_active pending_invited creation_pending].include?(self.state) end def recalculate_state @@ -113,7 +113,7 @@ class EnrollmentState < ActiveRecord::Base self.state_started_at = nil wf_state = self.enrollment.workflow_state - invited_or_active = %w{invited active}.include?(wf_state) + invited_or_active = %w[invited active].include?(wf_state) if invited_or_active if self.enrollment.course.completed? @@ -254,7 +254,7 @@ class EnrollmentState < ActiveRecord::Base enrollment.enrollment_state.ensure_current_state end - INVALIDATEABLE_STATES = %w{pending_invited pending_active invited active completed inactive}.freeze # don't worry about creation_pending or rejected, etc + INVALIDATEABLE_STATES = %w[pending_invited pending_active invited active completed inactive].freeze # don't worry about creation_pending or rejected, etc def self.invalidate_states(enrollment_scope) EnrollmentState.where(:enrollment_id => enrollment_scope, :state => INVALIDATEABLE_STATES) .update_all(["lock_version = COALESCE(lock_version, 0) + 1, state_is_current = ?", false]) @@ -280,7 +280,7 @@ class EnrollmentState < ActiveRecord::Base end def self.enrollments_for_account_ids(account_ids) - Enrollment.joins(:course).where(:courses => { :account_id => account_ids }).where(:type => %w{StudentEnrollment ObserverEnrollment}) + Enrollment.joins(:course).where(:courses => { :account_id => account_ids }).where(:type => %w[StudentEnrollment ObserverEnrollment]) end ENROLLMENT_BATCH_SIZE = 1_000 @@ -327,7 +327,7 @@ class EnrollmentState < ActiveRecord::Base def self.invalidate_access_for_course(course, changed_keys) states_to_update = access_states_to_update(changed_keys) - scope = course.enrollments.where(:type => %w{StudentEnrollment ObserverEnrollment}) + scope = course.enrollments.where(:type => %w[StudentEnrollment ObserverEnrollment]) if invalidate_access(scope, states_to_update) > 0 process_states_for(enrollments_needing_calculation(scope)) end diff --git a/app/models/exporters/zip_exporter.rb b/app/models/exporters/zip_exporter.rb index 321250f2172..59e0bae17bd 100644 --- a/app/models/exporters/zip_exporter.rb +++ b/app/models/exporters/zip_exporter.rb @@ -35,11 +35,11 @@ module Exporters folders = (content_export.selected_content['folders'] || {}) .select { |_tag, included| Canvas::Plugin.value_to_boolean(included) } .keys - .filter_map { |folder_tag| context.folders.active.find_by_asset_string(folder_tag, %w(Folder)) } + .filter_map { |folder_tag| context.folders.active.find_by_asset_string(folder_tag, %w[Folder]) } files = (content_export.selected_content['attachments'] || {}) .select { |_tag, included| Canvas::Plugin.value_to_boolean(included) } .keys - .filter_map { |att_tag| context.attachments.not_deleted.find_by_asset_string(att_tag, %w(Attachment)) } + .filter_map { |att_tag| context.attachments.not_deleted.find_by_asset_string(att_tag, %w[Attachment]) } end [folders, files] end diff --git a/app/models/external_feed.rb b/app/models/external_feed.rb index 2acfa97b992..41ba87f6bc0 100644 --- a/app/models/external_feed.rb +++ b/app/models/external_feed.rb @@ -35,7 +35,7 @@ class ExternalFeed < ActiveRecord::Base uniqueness: { scope: [:context_id, :context_type, :verbosity, :header_match] }, length: { maximum: maximum_string_length } - VERBOSITIES = %w(full link_only truncate).freeze + VERBOSITIES = %w[full link_only truncate].freeze validates :verbosity, inclusion: { :in => VERBOSITIES, :allow_nil => true } def infer_defaults diff --git a/app/models/group_categories/params.rb b/app/models/group_categories/params.rb index 1e762b98bc3..65fd429e784 100644 --- a/app/models/group_categories/params.rb +++ b/app/models/group_categories/params.rb @@ -114,7 +114,7 @@ module GroupCategories return nil unless raw_value raw_value = raw_value.to_s.downcase - %w(enabled restricted).include?(raw_value) ? raw_value : nil + %w[enabled restricted].include?(raw_value) ? raw_value : nil end def _auto_leader @@ -122,7 +122,7 @@ module GroupCategories return nil unless raw_value raw_value = raw_value.to_s.downcase - %w(random first).include?(raw_value) ? raw_value : nil + %w[random first].include?(raw_value) ? raw_value : nil end def auto_leader_type diff --git a/app/models/importers/assignment_importer.rb b/app/models/importers/assignment_importer.rb index 910738bc08f..39813fa9e1d 100644 --- a/app/models/importers/assignment_importer.rb +++ b/app/models/importers/assignment_importer.rb @@ -272,7 +272,7 @@ module Importers if gs item.grading_standard = gs if gs else - migration.add_warning(t('errors.import.grading_standard_not_found', %{The assignment "%{title}" referenced a grading scheme that was not found in the target course's account chain.}, :title => hash[:title])) + migration.add_warning(t('errors.import.grading_standard_not_found', %(The assignment "%{title}" referenced a grading scheme that was not found in the target course's account chain.), :title => hash[:title])) end end if quiz diff --git a/app/models/importers/learning_outcome_group_importer.rb b/app/models/importers/learning_outcome_group_importer.rb index 06e2af9884d..7441f35385d 100644 --- a/app/models/importers/learning_outcome_group_importer.rb +++ b/app/models/importers/learning_outcome_group_importer.rb @@ -36,7 +36,7 @@ module Importers item ||= LearningOutcomeGroup.global.where(vendor_guid: hash[:vendor_guid]).first if hash[:vendor_guid] item ||= LearningOutcomeGroup.new else - migration.add_warning(t(:no_global_permission, %{You're not allowed to manage global outcomes, can't add "%{title}"}, :title => hash[:title])) + migration.add_warning(t(:no_global_permission, %(You're not allowed to manage global outcomes, can't add "%{title}"), :title => hash[:title])) return end else diff --git a/app/models/importers/learning_outcome_importer.rb b/app/models/importers/learning_outcome_importer.rb index dd5cc8941d8..f8163bfcc64 100644 --- a/app/models/importers/learning_outcome_importer.rb +++ b/app/models/importers/learning_outcome_importer.rb @@ -68,7 +68,7 @@ module Importers end unless outcome - migration.add_warning(t(:no_context_found, %{The external Learning Outcome couldn't be found for "%{title}", creating a copy.}, :title => hash[:title])) + migration.add_warning(t(:no_context_found, %(The external Learning Outcome couldn't be found for "%{title}", creating a copy.), :title => hash[:title])) migration.copied_external_outcome_map[hash[:external_identifier]] = hash[:migration_id] end end @@ -91,7 +91,7 @@ module Importers item ||= LearningOutcome.global.where(vendor_guid: hash[:vendor_guid]).first if hash[:vendor_guid] item ||= LearningOutcome.new else - migration.add_warning(t(:no_global_permission, %{You're not allowed to manage global outcomes, can't add "%{title}"}, :title => hash[:title])) + migration.add_warning(t(:no_global_permission, %(You're not allowed to manage global outcomes, can't add "%{title}"), :title => hash[:title])) return end else diff --git a/app/models/importers/link_parser.rb b/app/models/importers/link_parser.rb index a60cc5e9393..9d30ac9a18f 100644 --- a/app/models/importers/link_parser.rb +++ b/app/models/importers/link_parser.rb @@ -35,7 +35,7 @@ module Importers include Helpers - REFERENCE_KEYWORDS = %w{CANVAS_COURSE_REFERENCE CANVAS_OBJECT_REFERENCE WIKI_REFERENCE IMS_CC_FILEBASE IMS-CC-FILEBASE}.freeze + REFERENCE_KEYWORDS = %w[CANVAS_COURSE_REFERENCE CANVAS_OBJECT_REFERENCE WIKI_REFERENCE IMS_CC_FILEBASE IMS-CC-FILEBASE].freeze LINK_PLACEHOLDER = "LINK.PLACEHOLDER" attr_reader :unresolved_link_map diff --git a/app/models/late_policy.rb b/app/models/late_policy.rb index df7449099ad..9d26ee4d08f 100644 --- a/app/models/late_policy.rb +++ b/app/models/late_policy.rb @@ -19,7 +19,7 @@ # class LatePolicy < ActiveRecord::Base - POINT_DEDUCTIBLE_GRADING_TYPES = %w(points percent letter_grade gpa_scale).freeze + POINT_DEDUCTIBLE_GRADING_TYPES = %w[points percent letter_grade gpa_scale].freeze belongs_to :course, inverse_of: :late_policy @@ -31,7 +31,7 @@ class LatePolicy < ActiveRecord::Base numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 } validates :late_submission_interval, presence: true, - inclusion: { in: %w(day hour) } + inclusion: { in: %w[day hour] } before_save :set_root_account_id after_save :update_late_submissions, if: :late_policy_attributes_changed? diff --git a/app/models/lti/tool_consumer_profile.rb b/app/models/lti/tool_consumer_profile.rb index 680bff2a9bf..0df6ca34210 100644 --- a/app/models/lti/tool_consumer_profile.rb +++ b/app/models/lti/tool_consumer_profile.rb @@ -32,20 +32,20 @@ module Lti WEBHOOK_GRANT_ALL_CAPABILITY = 'vnd.instructure.webhooks.root_account.all' WEBHOOK_SUBSCRIPTION_CAPABILITIES = { all: [WEBHOOK_GRANT_ALL_CAPABILITY].freeze, - quiz_submitted: %w(vnd.instructure.webhooks.root_account.quiz_submitted - vnd.instructure.webhooks.assignment.quiz_submitted).freeze, - grade_change: %w(vnd.instructure.webhooks.root_account.grade_change).freeze, - attachment_created: %w(vnd.instructure.webhooks.root_account.attachment_created - vnd.instructure.webhooks.assignment.attachment_created).freeze, - submission_created: %w(vnd.instructure.webhooks.root_account.submission_created - vnd.instructure.webhooks.assignment.submission_created).freeze, - plagiarism_resubmit: %w(vnd.instructure.webhooks.root_account.plagiarism_resubmit - vnd.instructure.webhooks.assignment.plagiarism_resubmit).freeze, - submission_updated: %w(vnd.instructure.webhooks.root_account.submission_updated - vnd.instructure.webhooks.assignment.submission_updated).freeze, + quiz_submitted: %w[vnd.instructure.webhooks.root_account.quiz_submitted + vnd.instructure.webhooks.assignment.quiz_submitted].freeze, + grade_change: %w[vnd.instructure.webhooks.root_account.grade_change].freeze, + attachment_created: %w[vnd.instructure.webhooks.root_account.attachment_created + vnd.instructure.webhooks.assignment.attachment_created].freeze, + submission_created: %w[vnd.instructure.webhooks.root_account.submission_created + vnd.instructure.webhooks.assignment.submission_created].freeze, + plagiarism_resubmit: %w[vnd.instructure.webhooks.root_account.plagiarism_resubmit + vnd.instructure.webhooks.assignment.plagiarism_resubmit].freeze, + submission_updated: %w[vnd.instructure.webhooks.root_account.submission_updated + vnd.instructure.webhooks.assignment.submission_updated].freeze, }.freeze - DEFAULT_CAPABILITIES = %w( + DEFAULT_CAPABILITIES = %w[ basic-lti-launch-request ToolProxyRegistrationRequest Canvas.placements.accountNavigation @@ -57,7 +57,7 @@ module Lti Canvas.placements.postGrades Security.splitSecret Context.sourcedId - ).concat( + ].concat( Lti::VariableExpander.expansion_keys ).freeze diff --git a/app/models/master_courses.rb b/app/models/master_courses.rb index 401f256ba48..79dc59c8b4c 100644 --- a/app/models/master_courses.rb +++ b/app/models/master_courses.rb @@ -23,10 +23,10 @@ module MasterCourses end # probably not be a comprehensive list but oh well - ALLOWED_CONTENT_TYPES = %w{ + ALLOWED_CONTENT_TYPES = %w[ Announcement AssessmentQuestionBank Assignment AssignmentGroup Attachment CalendarEvent DiscussionTopic ContextExternalTool ContextModule ContentTag LearningOutcome LearningOutcomeGroup Quizzes::Quiz Rubric Wiki WikiPage - }.freeze + ].freeze CONTENT_TYPES_FOR_DELETIONS = (ALLOWED_CONTENT_TYPES - ['Wiki']).freeze CONTENT_TYPES_FOR_UNSYNCED_CHANGES = (ALLOWED_CONTENT_TYPES - ['ContentTag', 'Wiki'] + ['Folder']).freeze @@ -35,5 +35,5 @@ module MasterCourses LOCK_TYPES = [:content, :settings, :points, :due_dates, :availability_dates, :state].freeze - RESTRICTED_OBJECT_TYPES = %w{Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage}.freeze + RESTRICTED_OBJECT_TYPES = %w[Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage].freeze end diff --git a/app/models/master_courses/master_migration.rb b/app/models/master_courses/master_migration.rb index f86ec68a10f..c3632df335f 100644 --- a/app/models/master_courses/master_migration.rb +++ b/app/models/master_courses/master_migration.rb @@ -97,7 +97,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base end def in_running_state? - %w{created queued exporting imports_queued}.include?(self.workflow_state) + %w[created queued exporting imports_queued].include?(self.workflow_state) end def still_running? @@ -322,7 +322,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base end end - unless self.migration_results.where.not(:state => %w{completed failed}).exists? + unless self.migration_results.where.not(:state => %w[completed failed]).exists? self.class.transaction do self.lock! if self.workflow_state == 'imports_queued' diff --git a/app/models/media_object.rb b/app/models/media_object.rb index 5668fd045be..217e13985f2 100644 --- a/app/models/media_object.rb +++ b/app/models/media_object.rb @@ -303,7 +303,7 @@ class MediaObject < ActiveRecord::Base def ensure_attachment return if self.attachment_id - return unless %w{Account Course Group User}.include?(self.context_type) + return unless %w[Account Course Group User].include?(self.context_type) sources = self.media_sources return unless sources.present? diff --git a/app/models/media_track.rb b/app/models/media_track.rb index 099e13c11f1..49b3b5b7b25 100644 --- a/app/models/media_track.rb +++ b/app/models/media_track.rb @@ -22,7 +22,7 @@ class MediaTrack < ActiveRecord::Base belongs_to :media_object, :touch => true before_save :convert_srt_to_wvtt validates :media_object_id, presence: true - validates :kind, inclusion: { in: %w(subtitles captions descriptions chapters metadata) } + validates :kind, inclusion: { in: %w[subtitles captions descriptions chapters metadata] } validates :locale, format: { with: /\A[A-Za-z\-]+\z/ } validates :content, presence: true diff --git a/app/models/microsoft_sync/group.rb b/app/models/microsoft_sync/group.rb index f3cf5aaee06..4787022472d 100644 --- a/app/models/microsoft_sync/group.rb +++ b/app/models/microsoft_sync/group.rb @@ -42,15 +42,15 @@ class MicrosoftSync::Group < ActiveRecord::Base include Workflow # States at which a manual sync is allowed - COOLDOWN_NOT_REQUIRED_STATES = %i( + COOLDOWN_NOT_REQUIRED_STATES = %i[ pending errored - ).freeze + ].freeze - RUNNING_STATES = %i( + RUNNING_STATES = %i[ running retrying - ).freeze + ].freeze belongs_to :course belongs_to :last_error_report, class_name: 'ErrorReport' diff --git a/app/models/microsoft_sync/user_mapping.rb b/app/models/microsoft_sync/user_mapping.rb index 60925ff36fa..65a8159e7b8 100644 --- a/app/models/microsoft_sync/user_mapping.rb +++ b/app/models/microsoft_sync/user_mapping.rb @@ -65,11 +65,11 @@ class MicrosoftSync::UserMapping < ActiveRecord::Base Enrollment .microsoft_sync_relevant .where(course_id: course.id) - .joins(%{ + .joins(<<~SQL.squish) LEFT JOIN #{quoted_table_name} AS mappings ON mappings.user_id=enrollments.user_id AND mappings.root_account_id=#{course.root_account_id.to_i} - }) + SQL .where(mappings: { id: nil }) .select(:user_id).distinct.limit(MAX_ENROLLMENT_MEMBERS) .pluck(:user_id) @@ -131,11 +131,11 @@ class MicrosoftSync::UserMapping < ActiveRecord::Base Enrollment .microsoft_sync_relevant .where(course_id: course.id) - .joins(%{ + .joins(<<~SQL.squish) JOIN #{quoted_table_name} AS mappings ON mappings.user_id=enrollments.user_id AND mappings.root_account_id=#{course.root_account_id.to_i} - }) + SQL .select(:id, :type, 'mappings.aad_id as aad_id') end diff --git a/app/models/migration_issue.rb b/app/models/migration_issue.rb index 4b623a7ba79..31d3bd72448 100644 --- a/app/models/migration_issue.rb +++ b/app/models/migration_issue.rb @@ -24,7 +24,7 @@ class MigrationIssue < ActiveRecord::Base belongs_to :error_report validates :issue_type, :content_migration_id, :workflow_state, presence: true - validates :issue_type, inclusion: { :in => %w(todo warning error) } + validates :issue_type, inclusion: { :in => %w[todo warning error] } workflow do state :active do diff --git a/app/models/notification.rb b/app/models/notification.rb index 74cf51c62d2..4f33e137a52 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -93,7 +93,7 @@ class Notification < Switchman::UnshardedRecord "Web Conference Invitation" ].freeze - NON_CONFIGURABLE_TYPES = %w(Migration Registration Summaries Alert).freeze + NON_CONFIGURABLE_TYPES = %w[Migration Registration Summaries Alert].freeze COURSE_TYPES = [ # Course Activities diff --git a/app/models/notification_failure_processor.rb b/app/models/notification_failure_processor.rb index dc1f1991b51..427ac8b6adb 100644 --- a/app/models/notification_failure_processor.rb +++ b/app/models/notification_failure_processor.rb @@ -25,7 +25,7 @@ class ConfigurationMissingError < StandardError; end class NotificationFailureProcessor attr_reader :config - POLL_PARAMS = %i(idle_timeout wait_time_seconds visibility_timeout).freeze + POLL_PARAMS = %i[idle_timeout wait_time_seconds visibility_timeout].freeze DEFAULT_CONFIG = { notification_failure_queue_name: 'notification-service-failures', # stop the loop if no message received for 10s diff --git a/app/models/observer_alert.rb b/app/models/observer_alert.rb index 00297b9179c..b7bcd70f580 100644 --- a/app/models/observer_alert.rb +++ b/app/models/observer_alert.rb @@ -23,7 +23,7 @@ class ObserverAlert < ActiveRecord::Base belongs_to :observer_alert_threshold, :inverse_of => :observer_alerts belongs_to :context, polymorphic: [:discussion_topic, :assignment, :course, :account_notification, :submission] - ALERT_TYPES = %w( + ALERT_TYPES = %w[ assignment_missing assignment_grade_high assignment_grade_low @@ -31,7 +31,7 @@ class ObserverAlert < ActiveRecord::Base course_grade_low course_announcement institution_announcement - ).freeze + ].freeze validates :alert_type, inclusion: { in: ALERT_TYPES } validates :user_id, :observer_id, :observer_alert_threshold_id, :alert_type, :action_date, :title, presence: true validate :validate_users_link diff --git a/app/models/observer_alert_threshold.rb b/app/models/observer_alert_threshold.rb index e245f595a87..3c61a8dc3ae 100644 --- a/app/models/observer_alert_threshold.rb +++ b/app/models/observer_alert_threshold.rb @@ -22,18 +22,18 @@ class ObserverAlertThreshold < ActiveRecord::Base belongs_to :observer, :class_name => 'User', inverse_of: :as_observer_observer_alert_thresholds has_many :observer_alerts, :inverse_of => :observer_alert_threshold - ALERT_TYPES_WITH_THRESHOLD = %w( + ALERT_TYPES_WITH_THRESHOLD = %w[ assignment_grade_high assignment_grade_low course_grade_high course_grade_low - ).freeze + ].freeze - ALERT_TYPES_WITHOUT_THRESHOLD = %w( + ALERT_TYPES_WITHOUT_THRESHOLD = %w[ assignment_missing course_announcement institution_announcement - ).freeze + ].freeze ALERT_TYPES = (ALERT_TYPES_WITH_THRESHOLD | ALERT_TYPES_WITHOUT_THRESHOLD).freeze diff --git a/app/models/outcome_import.rb b/app/models/outcome_import.rb index 5f329bc0591..3a737ad86f6 100644 --- a/app/models/outcome_import.rb +++ b/app/models/outcome_import.rb @@ -42,7 +42,7 @@ class OutcomeImport < ApplicationRecord state :failed end - IMPORT_TYPES = %w(instructure_csv).freeze + IMPORT_TYPES = %w[instructure_csv].freeze def self.valid_import_type?(type) IMPORT_TYPES.include? type diff --git a/app/models/page_view.rb b/app/models/page_view.rb index e8934706e8d..e7dde0a471e 100644 --- a/app/models/page_view.rb +++ b/app/models/page_view.rb @@ -31,7 +31,7 @@ class PageView < ActiveRecord::Base before_save :cap_interaction_seconds belongs_to :context, polymorphic: [:course, :account, :group, :user, :user_profile], polymorphic_prefix: true - CONTEXT_TYPES = %w{Course Account Group User UserProfile}.freeze + CONTEXT_TYPES = %w[Course Account Group User UserProfile].freeze attr_accessor :is_update @@ -101,7 +101,7 @@ class PageView < ActiveRecord::Base end # the list of columns we display to users, export to csv, etc - EXPORTED_COLUMNS = %w(request_id user_id url context_id context_type asset_id asset_type controller action interaction_seconds created_at user_request render_time user_agent participated account_id real_user_id http_method remote_ip).freeze + EXPORTED_COLUMNS = %w[request_id user_id url context_id context_type asset_id asset_type controller action interaction_seconds created_at user_request render_time user_agent participated account_id real_user_id http_method remote_ip].freeze def self.page_views_enabled? !!page_view_method diff --git a/app/models/parallel_importer.rb b/app/models/parallel_importer.rb index 75ceccc8c38..d1cae56eb0a 100644 --- a/app/models/parallel_importer.rb +++ b/app/models/parallel_importer.rb @@ -25,7 +25,7 @@ class ParallelImporter < ActiveRecord::Base scope :running, -> { where(workflow_state: 'running') } scope :completed, -> { where(workflow_state: 'completed') } - scope :not_completed, -> { where(workflow_state: %w{pending queued running retry}) } + scope :not_completed, -> { where(workflow_state: %w[pending queued running retry]) } include Workflow workflow do diff --git a/app/models/profile.rb b/app/models/profile.rb index 8f0a7636098..52f2bc4bfe5 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -30,7 +30,7 @@ class Profile < ActiveRecord::Base validates :path, format: { :with => /\A[a-z0-9-]+\z/ } validates :path, uniqueness: { :scope => :root_account_id } validates :context_id, uniqueness: { :scope => :context_type } - validates :visibility, inclusion: { :in => %w{public unlisted private} } + validates :visibility, inclusion: { :in => %w[public unlisted private] } def title=(title) write_attribute(:title, title) diff --git a/app/models/pseudonym.rb b/app/models/pseudonym.rb index 8a712a92d83..e863e5157ad 100644 --- a/app/models/pseudonym.rb +++ b/app/models/pseudonym.rb @@ -124,7 +124,7 @@ class Pseudonym < ActiveRecord::Base return unless self.user && !User.skip_updating_account_associations? if self.id_before_last_save.nil? - return if %w{creation_pending deleted}.include?(self.user.workflow_state) + return if %w[creation_pending deleted].include?(self.user.workflow_state) self.user.update_account_associations(:incremental => true, :precalculated_associations => { self.account_id => 0 }) elsif self.saved_change_to_account_id? diff --git a/app/models/quizzes/quiz.rb b/app/models/quizzes/quiz.rb index d324395cafd..74907d3d23f 100644 --- a/app/models/quizzes/quiz.rb +++ b/app/models/quizzes/quiz.rb @@ -964,7 +964,7 @@ class Quizzes::Quiz < ActiveRecord::Base end def strip_html_answers(question) - return if !question || !question[:answers] || !(%w(multiple_choice_question multiple_answers_question).include? question[:question_type]) + return if !question || !question[:answers] || !(%w[multiple_choice_question multiple_answers_question].include? question[:question_type]) for answer in question[:answers] do answer[:text] = strip_tags(answer[:html]) if !answer[:html].blank? && answer[:text].blank? @@ -1490,7 +1490,7 @@ class Quizzes::Quiz < ActiveRecord::Base end def self.class_names - %w(Quiz Quizzes::Quiz) + %w[Quiz Quizzes::Quiz] end def self.reflection_type_name diff --git a/app/models/quizzes/quiz_question/question_data.rb b/app/models/quizzes/quiz_question/question_data.rb index db0c85799bb..fe86cf4b8b0 100644 --- a/app/models/quizzes/quiz_question/question_data.rb +++ b/app/models/quizzes/quiz_question/question_data.rb @@ -103,9 +103,9 @@ class Quizzes::QuizQuestion::QuestionData private def question_types - @question_types ||= %w(calculated essay file_upload fill_in_multiple_blanks matching + @question_types ||= %w[calculated essay file_upload fill_in_multiple_blanks matching multiple_answers multiple_choice multiple_dropdowns numerical - short_answer text_only unknown ).map(&:to_sym) + short_answer text_only unknown ].map(&:to_sym) end def set_defaults diff --git a/app/models/quizzes/quiz_regrader/submission.rb b/app/models/quizzes/quiz_regrader/submission.rb index 056e38489d8..a1b1ceb1529 100644 --- a/app/models/quizzes/quiz_regrader/submission.rb +++ b/app/models/quizzes/quiz_regrader/submission.rb @@ -74,7 +74,7 @@ class Quizzes::QuizRegrader::Submission @submitted_answer_ids ||= submitted_answers.pluck(:question_id).to_set end - REGRADE_KEEP_FIELDS = %w{id position name question_name published_at}.freeze + REGRADE_KEEP_FIELDS = %w[id position name question_name published_at].freeze def regraded_question_data pos = 0 diff --git a/app/models/quizzes/quiz_statistics/student_analysis.rb b/app/models/quizzes/quiz_statistics/student_analysis.rb index 7b113ebaa9b..80d88d2533c 100644 --- a/app/models/quizzes/quiz_statistics/student_analysis.rb +++ b/app/models/quizzes/quiz_statistics/student_analysis.rb @@ -349,7 +349,7 @@ class Quizzes::QuizStatistics::StudentAnalysis < Quizzes::QuizStatistics::Report end def strip_html_answers(question) - return if !question || !question[:answers] || !(%w(multiple_choice_question multiple_answers_question).include? question[:question_type]) + return if !question || !question[:answers] || !(%w[multiple_choice_question multiple_answers_question].include? question[:question_type]) for answer in question[:answers] do answer[:text] = strip_tags(answer[:html]) if !answer[:html].blank? && answer[:text].blank? diff --git a/app/models/quizzes/quiz_submission.rb b/app/models/quizzes/quiz_submission.rb index 22fe8faef09..b5efa47ff62 100644 --- a/app/models/quizzes/quiz_submission.rb +++ b/app/models/quizzes/quiz_submission.rb @@ -801,7 +801,7 @@ class Quizzes::QuizSubmission < ActiveRecord::Base scope :for_user_ids, lambda { |user_ids| where(:user_id => user_ids) } scope :logged_out, -> { where("temporary_user_code is not null AND NOT was_preview") } scope :not_settings_only, -> { where("quiz_submissions.workflow_state<>'settings_only'") } - scope :completed, -> { where(:workflow_state => %w(complete pending_review)) } + scope :completed, -> { where(:workflow_state => %w[complete pending_review]) } # Excludes teacher preview submissions. # @@ -964,7 +964,7 @@ class Quizzes::QuizSubmission < ActiveRecord::Base def filter_attributes_for_user(hash, user, session) if submission.present? && !submission.user_can_read_grade?(user, session) - secret_keys = %w(score kept_score) + secret_keys = %w[score kept_score] hash.except!(*secret_keys) end end diff --git a/app/models/role_override.rb b/app/models/role_override.rb index 7d8b17ef4cd..30db9b6612c 100644 --- a/app/models/role_override.rb +++ b/app/models/role_override.rb @@ -112,15 +112,15 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('Act as users') }, :label_v2 => lambda { t("Users - act as") }, :account_only => :root, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :import_sis => { :label => lambda { t('Import SIS data') }, :label_v2 => lambda { t("SIS Data - import") }, :account_only => :root, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_account_memberships => { :label => lambda { t('permissions.manage_account_memberships', "Add/remove other admins for the account") }, @@ -148,15 +148,15 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('permissions.manage_announcements', "Manage global announcements") }, :label_v2 => lambda { t("Global Announcements - add / edit / delete") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_catalog => { :label => lambda { t('permissions.manage_catalog', "Manage catalog") }, :label_v2 => lambda { t("Catalog - manage") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], :account_allows => lambda { |a| a.settings[:catalog_enabled] } }, # deprecated; legacy role override @@ -250,8 +250,8 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('permissions.manage_data_services', "Manage data services") }, :label_v2 => lambda { t("Data Services - manage ") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_course_visibility => { :label => lambda { t("Change course visibility") }, @@ -274,51 +274,51 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('permissions.manage_developer_keys', "Manage developer keys") }, :label_v2 => lambda { t("Developer Keys - manage ") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :moderate_user_content => { :label => lambda { t('permissions.moderate_user_content', "Moderate user content") }, :label_v2 => lambda { t("Users - moderate content") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :view_feature_flags => { :label => lambda { t("View feature options at an account level") }, :label_v2 => lambda { t("Feature Options - view") }, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership] }, :manage_feature_flags => { :label => lambda { t('permissions.manage_feature_flags', "Enable or disable features at an account level") }, :label_v2 => lambda { t("Feature Options - enable / disable") }, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership] }, :manage_frozen_assignments => { :label => lambda { t('permissions.manage_frozen_assignment', "Manage (edit / delete) frozen assignments") }, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], :enabled_for_plugin => :assignment_freezer }, :manage_global_outcomes => { :label => lambda { t('permissions.manage_global_outcomes', "Manage global learning outcomes") }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_jobs => { :label => lambda { t('permissions.managed_jobs', "Manage background jobs") }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_release_notes => { :label => lambda { t('Manage release notes') }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_master_courses => { :label => lambda { t('Blueprint Courses (create / edit / associate / delete)') }, @@ -336,28 +336,28 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('permissions.manage_role_overrides', "Manage permissions") }, :label_v2 => lambda { t("Permissions - manage") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountMembership] }, :manage_storage_quotas => { :label => lambda { t('permissions.manage_storage_quotas', "Manage storage quotas") }, :label_v2 => lambda { t("Storage Quotas - manage") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership] }, :manage_sis => { :label => lambda { t('permissions.manage_sis', "Manage SIS data") }, :label_v2 => lambda { t("SIS Data - manage") }, :account_only => :root, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_site_settings => { :label => lambda { t('permissions.manage_site_settings', "Manage site-wide and plugin settings") }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :manage_user_logins => { :label => lambda { t('permissions.manage_user_logins', "Modify login details for users") }, @@ -375,33 +375,33 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('permissions.manage_user_observers', "Manage observers for users") }, :label_v2 => lambda { t("Users - manage observers") }, :account_only => :root, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :read_course_content => { :label => lambda { t('permissions.read_course_content', "View course content") }, :label_v2 => lambda { t("Course Content - view") }, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership] }, :read_course_list => { :label => lambda { t('permissions.read_course_list', "View the list of courses") }, :label_v2 => lambda { t("Courses - view list") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership] }, :read_messages => { :label => lambda { t('permissions.read_messages', "View notifications sent to users") }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :reset_any_mfa => { :label => -> { t('Reset Multi-Factor Authentication') }, :account_only => :root, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], :account_allows => lambda { |a| a.mfa_settings != :disabled } }, :view_course_changes => { @@ -418,8 +418,8 @@ class RoleOverride < ActiveRecord::Base :view_error_reports => { :label => lambda { t('permissions.view_error_reports', "View error reports") }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :view_grade_changes => { :label => lambda { t('permissions.view_grade_changes', "View Grade Change Logs") }, @@ -435,8 +435,8 @@ class RoleOverride < ActiveRecord::Base :view_jobs => { :label => lambda { t('permissions.view_jobs', "View background jobs") }, :account_only => :site_admin, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], }, :view_notifications => { :label => lambda { t('permissions.view_notifications', "View notifications") }, @@ -454,8 +454,8 @@ class RoleOverride < ActiveRecord::Base :label => lambda { t('permissions.view_statistics', "View statistics") }, :label_v2 => lambda { t("Statistics - view") }, :account_only => true, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership] }, :undelete_courses => { :label => lambda { t('permissions.undelete_courses', "Undelete courses") }, @@ -545,8 +545,8 @@ class RoleOverride < ActiveRecord::Base }, :generate_observer_pairing_code => { :label => -> { t('Users - generate observer pairing codes for students') }, - :true_for => %w(AccountAdmin), - :available_to => %w(TeacherEnrollment ObserverEnrollment TaEnrollment AccountAdmin AccountMembership DesignerEnrollment) + :true_for => %w[AccountAdmin], + :available_to => %w[TeacherEnrollment ObserverEnrollment TaEnrollment AccountAdmin AccountMembership DesignerEnrollment] }, :import_outcomes => { :label => lambda { t("Import learning outcomes") }, @@ -568,8 +568,8 @@ class RoleOverride < ActiveRecord::Base :lti_add_edit => { :label => -> { t('LTI add and edit') }, :label_v2 => -> { t('LTI - add / edit / delete') }, - :true_for => %w(TeacherEnrollment TaEnrollment DesignerEnrollment AccountAdmin), - :available_to => %w(TeacherEnrollment TaEnrollment DesignerEnrollment AccountAdmin AccountMembership) + :true_for => %w[TeacherEnrollment TaEnrollment DesignerEnrollment AccountAdmin], + :available_to => %w[TeacherEnrollment TaEnrollment DesignerEnrollment AccountAdmin AccountMembership] }, manage_admin_users: { label: lambda { t("permissions.manage_admin_users", "Add/remove other teachers, course designers or TAs to the course") }, @@ -1062,8 +1062,8 @@ class RoleOverride < ActiveRecord::Base :manage_interaction_alerts => { :label => lambda { t('permissions.manage_interaction_alerts', "Manage alerts") }, :label_v2 => lambda { t("Alerts - add / edit / delete") }, - :true_for => %w(AccountAdmin TeacherEnrollment), - :available_to => %w(AccountAdmin AccountMembership TeacherEnrollment TaEnrollment), + :true_for => %w[AccountAdmin TeacherEnrollment], + :available_to => %w[AccountAdmin AccountMembership TeacherEnrollment TaEnrollment], }, :manage_outcomes => { :label => lambda { t('permissions.manage_outcomes', "Manage learning outcomes") }, @@ -1477,13 +1477,13 @@ class RoleOverride < ActiveRecord::Base :read_sis => { :label => lambda { t('permission.read_sis', "Read SIS data") }, :label_v2 => lambda { t("SIS Data - read") }, - :true_for => %w(AccountAdmin TeacherEnrollment), - :available_to => %w(AccountAdmin AccountMembership TeacherEnrollment TaEnrollment StudentEnrollment) + :true_for => %w[AccountAdmin TeacherEnrollment], + :available_to => %w[AccountAdmin AccountMembership TeacherEnrollment TaEnrollment StudentEnrollment] }, :select_final_grade => { :label => -> { t('Grades - select final grade for moderation') }, - :true_for => %w(AccountAdmin TeacherEnrollment TaEnrollment), - :available_to => %w(AccountAdmin AccountMembership TeacherEnrollment TaEnrollment) + :true_for => %w[AccountAdmin TeacherEnrollment TaEnrollment], + :available_to => %w[AccountAdmin AccountMembership TeacherEnrollment TaEnrollment] }, :send_messages => { :label => lambda { t('permissions.send_messages', "Send messages to individual course members") }, @@ -1526,8 +1526,8 @@ class RoleOverride < ActiveRecord::Base }, :view_audit_trail => { :label => -> { t('Grades - view audit trail') }, - :true_for => %w(AccountAdmin), - :available_to => %w(TeacherEnrollment AccountAdmin AccountMembership) + :true_for => %w[AccountAdmin], + :available_to => %w[TeacherEnrollment AccountAdmin AccountMembership] }, :view_all_grades => { :label => lambda { t('permissions.view_all_grades', "View all grades") }, @@ -1569,15 +1569,15 @@ class RoleOverride < ActiveRecord::Base :view_quiz_answer_audits => { :label => lambda { t('permissions.view_quiz_answer_audits', 'View the answer matrix in Quiz Submission Logs') }, :label_v2 => lambda { t('Quizzes - view submission log') }, - :true_for => %w(AccountAdmin), - :available_to => %w(AccountAdmin AccountMembership), + :true_for => %w[AccountAdmin], + :available_to => %w[AccountAdmin AccountMembership], :account_allows => lambda { |a| a.feature_allowed?(:quiz_log_auditing) } }, :view_user_logins => { :label => lambda { t("View login ids for users") }, :label_v2 => lambda { t("Users - view login IDs") }, - :available_to => %w(AccountAdmin AccountMembership TeacherEnrollment TaEnrollment), - :true_for => %w(AccountAdmin TeacherEnrollment TaEnrollment) + :available_to => %w[AccountAdmin AccountMembership TeacherEnrollment TaEnrollment], + :true_for => %w[AccountAdmin TeacherEnrollment TaEnrollment] } } ) diff --git a/app/models/sis_batch.rb b/app/models/sis_batch.rb index 260dad0a60c..34f4eb58cf2 100644 --- a/app/models/sis_batch.rb +++ b/app/models/sis_batch.rb @@ -742,7 +742,7 @@ class SisBatch < ActiveRecord::Base def write_errors_to_file file = temp_error_file_path CSV.open(file, "w") do |csv| - csv << %w(sis_import_id file message row) + csv << %w[sis_import_id file message row] self.sis_batch_errors.find_each do |error| row = [] row << error.sis_batch_id @@ -879,8 +879,8 @@ class SisBatch < ActiveRecord::Base restore_progress&.start self.update_attribute(:workflow_state, 'restoring') roll_back = self.roll_back_data - roll_back = roll_back.where(updated_workflow_state: %w(retired deleted)) if undelete_only - roll_back = roll_back.where(updated_workflow_state: %w(completed)) if unconclude_only + roll_back = roll_back.where(updated_workflow_state: %w[retired deleted]) if undelete_only + roll_back = roll_back.where(updated_workflow_state: %w[completed]) if unconclude_only roll_back = roll_back.where(batch_mode_delete: batch_mode) if batch_mode types = roll_back.active.distinct.order(:context_type).pluck(:context_type) total = roll_back.active.count if restore_progress diff --git a/app/models/sis_batch_roll_back_data.rb b/app/models/sis_batch_roll_back_data.rb index 65de0514b1a..2535fc4ede5 100644 --- a/app/models/sis_batch_roll_back_data.rb +++ b/app/models/sis_batch_roll_back_data.rb @@ -19,19 +19,19 @@ # class SisBatchRollBackData < ActiveRecord::Base belongs_to :sis_batch, inverse_of: :roll_back_data - belongs_to :context, polymorphic: %i{abstract_course account account_user + belongs_to :context, polymorphic: %i[abstract_course account account_user communication_channel course course_section enrollment enrollment_term group group_category group_membership - pseudonym user_observer} + pseudonym user_observer] scope :expired_data, -> { where('created_at < ?', 30.days.ago) } scope :active, -> { where(workflow_state: 'active') } scope :restored, -> { where(workflow_state: 'restored') } - RESTORE_ORDER = %w{Account EnrollmentTerm AbstractCourse Course CourseSection + RESTORE_ORDER = %w[Account EnrollmentTerm AbstractCourse Course CourseSection GroupCategory Group Pseudonym CommunicationChannel - Enrollment GroupMembership UserObserver AccountUser}.freeze + Enrollment GroupMembership UserObserver AccountUser].freeze def self.cleanup_expired_data return unless expired_data.exists? diff --git a/app/models/sis_post_grades_status.rb b/app/models/sis_post_grades_status.rb index 47cfe26a28e..2b229658976 100644 --- a/app/models/sis_post_grades_status.rb +++ b/app/models/sis_post_grades_status.rb @@ -19,7 +19,7 @@ # class SisPostGradesStatus < ActiveRecord::Base - ALLOWED_STATUSES = %w{success warning failed}.freeze + ALLOWED_STATUSES = %w[success warning failed].freeze belongs_to :course belongs_to :course_section belongs_to :user diff --git a/app/models/speed_grader/assignment.rb b/app/models/speed_grader/assignment.rb index 39e2319e3bf..0096945de67 100644 --- a/app/models/speed_grader/assignment.rb +++ b/app/models/speed_grader/assignment.rb @@ -35,22 +35,22 @@ module SpeedGrader def json Attachment.skip_thumbnails = true - submission_json_fields = %i(id submitted_at workflow_state grade + submission_json_fields = %i[id submitted_at workflow_state grade grade_matches_current_submission graded_at turnitin_data submission_type score points_deducted assignment_id submission_comments grading_period_id excused updated_at attempt posted_at resource_link_lookup_uuid - redo_request cached_due_date) + redo_request cached_due_date] submission_json_fields << (anonymous_students?(current_user: current_user, assignment: assignment) ? :anonymous_id : :user_id) - attachment_json_fields = %i(id comment_id content_type context_id context_type display_name - filename mime_class size submitter_id workflow_state) + attachment_json_fields = %i[id comment_id content_type context_id context_type display_name + filename mime_class size submitter_id workflow_state] if !assignment.anonymize_students? || course.account_membership_allows(current_user) attachment_json_fields << :viewed_at end - enrollment_json_fields = %i(course_section_id workflow_state user_id) + enrollment_json_fields = %i[course_section_id workflow_state user_id] res = assignment.as_json( :include => [ @@ -103,7 +103,7 @@ module SpeedGrader includes << { all_submission_comments: { submission: { assignment: { context: :root_account } } } } submissions = assignment.submissions.where(user_id: students).preload(*includes) - student_json_fields = anonymous_students?(current_user: current_user, assignment: assignment) ? [] : %i(name id sortable_name) + student_json_fields = anonymous_students?(current_user: current_user, assignment: assignment) ? [] : %i[name id sortable_name] res[:context][:students] = students.map do |student| json = student.as_json(include_root: false, methods: submission_comment_methods, only: student_json_fields) @@ -140,7 +140,7 @@ module SpeedGrader end res[:context][:quiz] = assignment.quiz.as_json(:include_root => false, :only => [:anonymous_submissions]) - attachment_includes = %i(crocodoc_document canvadoc root_attachment) + attachment_includes = %i[crocodoc_document canvadoc root_attachment] # Preload attachments for later looping attachments_for_submission = ::Submission.bulk_load_attachments_for_submissions(submissions, preloads: attachment_includes) @@ -171,7 +171,7 @@ module SpeedGrader end res[:submissions] = submissions.map do |sub| - submission_methods = %i(submission_history late external_tool_url entered_score entered_grade seconds_late missing) + submission_methods = %i[submission_history late external_tool_url entered_score entered_grade seconds_late missing] submission_methods << :word_count if assignment.root_account.feature_enabled?(:word_count_in_speed_grader) json = sub.as_json( include_root: false, diff --git a/app/models/submission.rb b/app/models/submission.rb index 475581a5377..9389222ad20 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -22,7 +22,7 @@ require 'atom' require 'anonymity' class Submission < ActiveRecord::Base - self.ignored_columns = %w{has_admin_comment has_rubric_assessment process_attempts context_code} + self.ignored_columns = %w[has_admin_comment has_rubric_assessment process_attempts context_code] include Canvas::GradeValidations include CustomValidations @@ -906,7 +906,7 @@ class Submission < ActiveRecord::Base end def turnitinable? - %w(online_upload online_text_entry).include?(submission_type) && + %w[online_upload online_text_entry].include?(submission_type) && assignment.turnitin_enabled? end @@ -1193,7 +1193,7 @@ class Submission < ActiveRecord::Base end def vericiteable? - %w(online_upload online_text_entry).include?(submission_type) && + %w[online_upload online_text_entry].include?(submission_type) && assignment.vericite_enabled? end @@ -1956,7 +1956,7 @@ class Submission < ActiveRecord::Base def grade_change_audit(force_audit: self.assignment_changed_not_sub, skip_insert: false) newly_graded = self.saved_change_to_workflow_state? && self.workflow_state == 'graded' - grade_changed = (self.saved_changes.keys & %w(grade score excused)).present? + grade_changed = (self.saved_changes.keys & %w[grade score excused]).present? return true unless newly_graded || grade_changed || force_audit if grade_change_event_author_id.present? @@ -2486,7 +2486,7 @@ class Submission < ActiveRecord::Base def filter_attributes_for_user(hash, user, session) unless user_can_read_grade?(user, session) - %w(score grade published_score published_grade entered_score entered_grade).each do |secret_attr| + %w[score grade published_score published_grade entered_score entered_grade].each do |secret_attr| hash.delete secret_attr end end diff --git a/app/models/usage_rights.rb b/app/models/usage_rights.rb index 1d6ed90cc0e..485b1ebdbfc 100644 --- a/app/models/usage_rights.rb +++ b/app/models/usage_rights.rb @@ -21,7 +21,7 @@ class UsageRights < ActiveRecord::Base include ContentLicenses - USE_JUSTIFICATIONS = %w(own_copyright public_domain used_by_permission fair_use creative_commons).freeze + USE_JUSTIFICATIONS = %w[own_copyright public_domain used_by_permission fair_use creative_commons].freeze belongs_to :context, polymorphic: [:course, :group, :user] diff --git a/app/models/user.rb b/app/models/user.rb index 7f6d8478c7c..ce975031c7a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -566,7 +566,7 @@ class User < ActiveRecord::Base # Through account_users # User -> AccountUser -> Account def self.calculate_account_associations(user, data, account_chain_cache) - return [] if %w{creation_pending deleted}.include?(user.workflow_state) || user.fake_student? + return [] if %w[creation_pending deleted].include?(user.workflow_state) || user.fake_student? enrollments = data[:enrollments][user.id] || [] sections = enrollments.map { |e| data[:sections][e.course_section_id] } @@ -2043,8 +2043,8 @@ class User < ActiveRecord::Base return @_has_student_enrollment if defined?(@_has_student_enrollment) @_has_student_enrollment = Rails.cache.fetch_with_batched_keys(['has_student_enrollment', ApplicationController.region].cache_key, batch_object: self, batched_keys: :enrollments) do - self.enrollments.shard(in_region_associated_shards).where(:type => %w{StudentEnrollment StudentViewEnrollment}) - .where.not(:workflow_state => %w{rejected inactive deleted}).exists? + self.enrollments.shard(in_region_associated_shards).where(:type => %w[StudentEnrollment StudentViewEnrollment]) + .where.not(:workflow_state => %w[rejected inactive deleted]).exists? end end @@ -2053,8 +2053,8 @@ class User < ActiveRecord::Base return @_non_student_enrollment if defined?(@_non_student_enrollment) @_non_student_enrollment = Rails.cache.fetch_with_batched_keys(['has_non_student_enrollment', ApplicationController.region].cache_key, batch_object: self, batched_keys: :enrollments) do - self.enrollments.shard(in_region_associated_shards).where.not(type: %w{StudentEnrollment StudentViewEnrollment ObserverEnrollment}) - .where.not(workflow_state: %w{rejected inactive deleted}).exists? + self.enrollments.shard(in_region_associated_shards).where.not(type: %w[StudentEnrollment StudentViewEnrollment ObserverEnrollment]) + .where.not(workflow_state: %w[rejected inactive deleted]).exists? end end @@ -2078,13 +2078,13 @@ class User < ActiveRecord::Base def participating_student_current_and_concluded_course_ids cached_course_ids('student_current_and_concluded') do |enrollments| - enrollments.current_and_concluded.not_inactive_by_date_ignoring_access.where(type: %w{StudentEnrollment StudentViewEnrollment}) + enrollments.current_and_concluded.not_inactive_by_date_ignoring_access.where(type: %w[StudentEnrollment StudentViewEnrollment]) end end def participating_student_course_ids cached_course_ids('participating_student') do |enrollments| - enrollments.current.active_by_date.where(type: %w{StudentEnrollment StudentViewEnrollment}) + enrollments.current.active_by_date.where(type: %w[StudentEnrollment StudentViewEnrollment]) end end @@ -2418,7 +2418,7 @@ class User < ActiveRecord::Base Rails.cache.fetch([self, include_concluded_codes, 'conversation_context_codes4'].cache_key, :expires_in => 1.day) do Shard.birth.activate do - associations = %w{courses concluded_courses current_groups} + associations = %w[courses concluded_courses current_groups] associations.slice!(1) unless include_concluded_codes associations.inject([]) do |result, association| @@ -2769,7 +2769,7 @@ class User < ActiveRecord::Base if type != 'StudentEnrollment' && course.grants_right?(self, session, :manage_admin_users) return true end - if %w{StudentEnrollment ObserverEnrollment}.include?(type) && course.grants_right?(self, session, :manage_students) + if %w[StudentEnrollment ObserverEnrollment].include?(type) && course.grants_right?(self, session, :manage_students) return true end end @@ -2993,7 +2993,7 @@ class User < ActiveRecord::Base # Convert the string "StudentEnrollment" to "student". # Return only valid matching types. Otherwise, nil. type = type.to_s.downcase.sub(/(view)?enrollment/, '') - %w{student teacher ta observer}.include?(type) ? type : nil + %w[student teacher ta observer].include?(type) ? type : nil end def self.preload_shard_associations(users) diff --git a/app/models/user_preference_value.rb b/app/models/user_preference_value.rb index c7905f6227c..375417c21d3 100644 --- a/app/models/user_preference_value.rb +++ b/app/models/user_preference_value.rb @@ -177,7 +177,7 @@ class UserPreferenceValue < ActiveRecord::Base end # --- here are some hacks so we can split up the gradebook column size setting better --- - SHARED_GRADEBOOK_COLUMNS = %w{student secondary_identifier total_grade}.freeze + SHARED_GRADEBOOK_COLUMNS = %w[student secondary_identifier total_grade].freeze # whether we can split the column size setting into a per-course hash or in a shared one def shared_gradebook_column?(column) SHARED_GRADEBOOK_COLUMNS.include?(column) diff --git a/app/models/web_conference.rb b/app/models/web_conference.rb index e660fa51a37..a441e8c341c 100644 --- a/app/models/web_conference.rb +++ b/app/models/web_conference.rb @@ -499,7 +499,7 @@ class WebConference < ActiveRecord::Base def as_json(options = {}) url = options.delete(:url) join_url = options.delete(:join_url) - options.reverse_merge!(:only => %w(id title description conference_type duration started_at ended_at user_ids context_id context_type context_code)) + options.reverse_merge!(:only => %w[id title description conference_type duration started_at ended_at user_ids context_id context_type context_code]) result = super(options.merge(:include_root => false, :methods => [:has_advanced_settings, :long_running, :user_settings, :recordings])) result['url'] = url result['join_url'] = join_url diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 9ac6728a258..56096f38fce 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -340,7 +340,7 @@ class WikiPage < ActiveRecord::Base def effective_roles context_roles = context.default_wiki_editing_roles rescue nil roles = (editing_roles || context_roles || default_roles).split(',') - roles == %w(teachers) ? [] : roles # "Only teachers" option doesn't grant rights excluded by RoleOverrides + roles == %w[teachers] ? [] : roles # "Only teachers" option doesn't grant rights excluded by RoleOverrides end def available_for?(user, session = nil) diff --git a/app/presenters/grade_summary_presenter.rb b/app/presenters/grade_summary_presenter.rb index 1232d3f6467..e588c002ec9 100644 --- a/app/presenters/grade_summary_presenter.rb +++ b/app/presenters/grade_summary_presenter.rb @@ -152,7 +152,7 @@ class GradeSummaryPresenter includes << :assignment_group if @assignment_order == :assignment_group AssignmentGroup .visible_assignments(student, @context, all_groups, includes: includes) - .where.not(submission_types: %w(not_graded wiki_page)) + .where.not(submission_types: %w[not_graded wiki_page]) .except(:order) end diff --git a/app/serializers/lti/ims/names_and_roles_serializer.rb b/app/serializers/lti/ims/names_and_roles_serializer.rb index 6cee00d178b..c7d147ecc2a 100644 --- a/app/serializers/lti/ims/names_and_roles_serializer.rb +++ b/app/serializers/lti/ims/names_and_roles_serializer.rb @@ -61,7 +61,7 @@ module Lti::IMS current_user: Lti::IMS::Providers::MembershipsProvider.unwrap(enrollment.user), tool: page[:tool], enrollment: enrollment, - variable_whitelist: %w( + variable_whitelist: %w[ Person.name.full Person.name.display Person.name.family @@ -82,7 +82,7 @@ module Lti::IMS Canvas.user.sisIntegrationId Canvas.xapi.url Caliper.url - ) + ] } ) end diff --git a/build/gergich/compile_assets.rb b/build/gergich/compile_assets.rb index 6c754bf00e4..833752c149a 100644 --- a/build/gergich/compile_assets.rb +++ b/build/gergich/compile_assets.rb @@ -40,11 +40,11 @@ class Gergich::CompileAssets cwd = Dir.pwd puts cwd - pattern = %r| # Example: + pattern = %r{ # Example: ^#{cwd}/([^\n]+?):(\d+):\d+:\serror:\s([^\n]+)\n # /absolute/path/to/file.coffee:7:1: error: unexpected INDENT ([^\n]+)\n # falseList = [] ([^\n]+)\n # ^^^^^ - |mx + }mx result.concat(output.scan(pattern).map do |file, line, error, context1, context2| error = "#{error}\n\n #{context1}\n #{context2}" diff --git a/config/initializers/active_record.rb b/config/initializers/active_record.rb index 73c8e0f81fb..bb619a3df0e 100644 --- a/config/initializers/active_record.rb +++ b/config/initializers/active_record.rb @@ -1656,7 +1656,7 @@ end # but _none_ of them (as of writing) will invert them on reversion. Some will # purposely strip the option, but most don't do anything. module ExistenceInversions - %w{index foreign_key column}.each do |type| + %w[index foreign_key column].each do |type| # these methods purposely pull the flag from the incoming args, # and assign to the outgoing args, not relying on it getting # passed through. and sometimes they even modify args. diff --git a/config/initializers/errors.rb b/config/initializers/errors.rb index 176b6a95c61..0e77c082b62 100644 --- a/config/initializers/errors.rb +++ b/config/initializers/errors.rb @@ -27,13 +27,13 @@ # disabled individually with a setting. # Rails.configuration.to_prepare do - ErrorReport.configure_to_ignore(%w{ + ErrorReport.configure_to_ignore(%w[ AuthenticationMethods::AccessTokenError ActionController::InvalidAuthenticityToken Turnitin::Errors::SubmissionNotScoredError ActionController::ParameterMissing SearchTermHelper::SearchTermTooShortError - }) + ]) # write a database record to our application DB capturing useful info for looking # at this error later diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 3db4cbd8380..32efc03aa3c 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -242,7 +242,7 @@ module NumberLocalizer end def form_proper_noun_singular_genitive(noun) - if I18n.locale.to_s.start_with?('de') && %{s ß x z}.include?(noun.last) + if I18n.locale.to_s.start_with?('de') && %(s ß x z).include?(noun.last) "#{noun}'" else I18n.t("#proper_noun_singular_genitive", "%{noun}'s", noun: noun) diff --git a/config/initializers/postgresql_adapter.rb b/config/initializers/postgresql_adapter.rb index 9b238618532..feddf9d18f9 100644 --- a/config/initializers/postgresql_adapter.rb +++ b/config/initializers/postgresql_adapter.rb @@ -29,7 +29,7 @@ module PostgreSQLAdapterExtensions Timeout.timeout(@config[:receive_timeout], PG::ConnectionBad, "receive timeout", &block) end - %I{begin_db_transaction create_savepoint active?}.each do |method| + %I[begin_db_transaction create_savepoint active?].each do |method| class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{method}(*) receive_timeout_wrapper { super } diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 9e2ae68afe0..80b0fc81417 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -41,7 +41,7 @@ if settings.present? # thrown to drive client facing behavior. A good example # are login/auth exceptions. Exceptions that are simply noisy/inconvenient # should probably be caught and solved... - config.excluded_exceptions += %w{ + config.excluded_exceptions += %w[ AuthenticationMethods::AccessTokenError AuthenticationMethods::AccessTokenScopeError AuthenticationMethods::LoggedOutError @@ -50,7 +50,7 @@ if settings.present? Turnitin::Errors::SubmissionNotScoredError Rack::QueryParser::InvalidParameterError PG::UnableToSend - } + ] end Rails.configuration.to_prepare do diff --git a/config/routes.rb b/config/routes.rb index 09438d4cc12..64a7f1a5324 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -508,12 +508,12 @@ CanvasRails::Application.routes.draw do get 'external_content/retrieve/oembed' => 'external_content#oembed_retrieve', as: :external_content_oembed_retrieve get 'external_content/cancel/:service' => 'external_content#cancel', as: :external_content_cancel - %w(account course group).each do |context| + %w[account course group].each do |context| prefix = "#{context}s/:#{context}_id" post "#{prefix}/deep_linking_response", controller: 'lti/ims/deep_linking', action: :deep_linking_response, as: "#{context}_deep_linking_response" end - %w(account course group user).each do |context| + %w[account course group user].each do |context| match "#{context.pluralize}/:#{context}_id/external_content/success/:service" => 'external_content#success', as: "#{context}_external_content_success", via: [:get, :post] match "#{context.pluralize}/:#{context}_id/external_content/success/:service/:id" => 'external_content#success', as: "#{context}_external_content_update", via: [:get, :post] end @@ -1200,7 +1200,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :submissions_api) do - [%w(course course), %w(section course_section)].each do |(context, path_prefix)| + [%w[course course], %w[section course_section]].each do |(context, path_prefix)| post "#{context.pluralize}/:#{context}_id/submissions/update_grades", action: :bulk_update put "#{context.pluralize}/:#{context}_id/assignments/:assignment_id/submissions/:user_id/read", action: :mark_submission_read, as: "#{context}_submission_mark_read" delete "#{context.pluralize}/:#{context}_id/assignments/:assignment_id/submissions/:user_id/read", action: :mark_submission_unread, as: "#{context}_submission_mark_unread" @@ -1264,7 +1264,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :content_migrations) do - %w(account course group user).each do |context| + %w[account course group user].each do |context| get "#{context.pluralize}/:#{context}_id/content_migrations/migrators", action: :available_migrators, as: "#{context}_content_migration_migrators_list" get "#{context.pluralize}/:#{context}_id/content_migrations/:id", action: :show, as: "#{context}_content_migration" get "#{context.pluralize}/:#{context}_id/content_migrations", action: :index, as: "#{context}_content_migration_list" @@ -1275,7 +1275,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :migration_issues) do - %w(account course group user).each do |context| + %w[account course group user].each do |context| get "#{context.pluralize}/:#{context}_id/content_migrations/:content_migration_id/migration_issues/:id", action: :show, as: "#{context}_content_migration_migration_issue" get "#{context.pluralize}/:#{context}_id/content_migrations/:content_migration_id/migration_issues", action: :index, as: "#{context}_content_migration_migration_issue_list" post "#{context.pluralize}/:#{context}_id/content_migrations/:content_migration_id/migration_issues", action: :create, as: "#{context}_content_migration_migration_issue_create" @@ -1284,7 +1284,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :discussion_topics_api) do - %w(course group).each do |context| + %w[course group].each do |context| get "#{context.pluralize}/:#{context}_id/discussion_topics/:topic_id", action: :show, as: "#{context}_discussion_topic" post "#{context.pluralize}/:#{context}_id/discussion_topics", controller: :discussion_topics, action: :create put "#{context.pluralize}/:#{context}_id/discussion_topics/:topic_id", controller: :discussion_topics, action: :update @@ -1339,7 +1339,7 @@ CanvasRails::Application.routes.draw do get "/courses/:course_id/external_tools/visible_course_nav_tools", action: :visible_course_nav_tools, as: :visible_course_nav_tools get "/external_tools/visible_course_nav_tools", action: :all_visible_nav_tools, as: :all_visible_nav_tools - %w(course account).each do |context| + %w[course account].each do |context| get "#{context}s/:#{context}_id/external_tools/sessionless_launch", action: :generate_sessionless_launch, as: "#{context}_external_tool_sessionless_launch" get "#{context}s/:#{context}_id/external_tools/:external_tool_id", action: :show, as: "#{context}_external_tool_show" get "#{context}s/:#{context}_id/external_tools", action: :index, as: "#{context}_external_tools" @@ -1353,14 +1353,14 @@ CanvasRails::Application.routes.draw do end scope(controller: 'lti/lti_apps') do - %w(course account).each do |context| + %w[course account].each do |context| get "#{context}s/:#{context}_id/lti_apps/launch_definitions", action: :launch_definitions, as: "#{context}_launch_definitions" get "#{context}s/:#{context}_id/lti_apps", action: :index, as: "#{context}_app_definitions" end end scope(controller: 'lti/tool_proxy') do - %w(course account).each do |context| + %w[course account].each do |context| delete "#{context}s/:#{context}_id/tool_proxies/:tool_proxy_id", action: :destroy, as: "#{context}_delete_tool_proxy" put "#{context}s/:#{context}_id/tool_proxies/:tool_proxy_id", action: :update, @@ -1377,7 +1377,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :external_feeds) do - %w(course group).each do |context| + %w[course group].each do |context| get "#{context}s/:#{context}_id/external_feeds", action: :index, as: "#{context}_external_feeds" post "#{context}s/:#{context}_id/external_feeds", action: :create, as: "#{context}_external_feeds_create" delete "#{context}s/:#{context}_id/external_feeds/:external_feed_id", action: :destroy, as: "#{context}_external_feeds_delete" @@ -1400,7 +1400,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :outcome_imports_api) do - %w(account course).each do |context| + %w[account course].each do |context| post "#{context}s/:#{context}_id/outcome_imports(/group/:learning_outcome_group_id)", action: :create get "#{context}s/:#{context}_id/outcome_imports/:id", action: :show end @@ -1757,7 +1757,7 @@ CanvasRails::Application.routes.draw do get 'files/:id/:uuid/status', action: :api_file_status, as: 'file_status' get 'files/:id/public_url', action: :public_url - %w(course group user).each do |context| + %w[course group user].each do |context| get "#{context}s/:#{context}_id/files/quota", action: :api_quota get "#{context}s/:#{context}_id/files/:id", action: :api_show, as: "#{context}_attachment" end @@ -2004,7 +2004,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :outcome_groups_api) do - %w(global account course).each do |context| + %w[global account course].each do |context| prefix = (context == "global" ? context : "#{context}s/:#{context}_id") unless context == "global" get "#{prefix}/outcome_groups", action: :index, as: "#{context}_outcome_groups" @@ -2068,7 +2068,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :app_center) do - %w(course account).each do |context| + %w[course account].each do |context| prefix = "#{context}s/:#{context}_id/app_center" get "#{prefix}/apps", action: :index, as: "#{context}_app_center_apps" get "#{prefix}/apps/:app_id/reviews", action: :reviews, as: "#{context}_app_center_app_reviews" @@ -2078,7 +2078,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :feature_flags) do - %w(course account user).each do |context| + %w[course account user].each do |context| prefix = "#{context}s/:#{context}_id/features" get prefix.to_s, action: :index, as: "#{context}_features" get "#{prefix}/enabled", action: :enabled_features, as: "#{context}_enabled_features" @@ -2090,7 +2090,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :conferences) do - %w(course group).each do |context| + %w[course group].each do |context| prefix = "#{context}s/:#{context}_id/conferences" get prefix, action: :index, as: "#{context}_conferences" post prefix.to_s, action: :create @@ -2117,7 +2117,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :content_exports_api) do - %w(course group user).each do |context| + %w[course group user].each do |context| context_prefix = "#{context.pluralize}/:#{context}_id" prefix = "#{context_prefix}/content_exports" get prefix, action: :index, as: "#{context}_content_exports" @@ -2182,7 +2182,7 @@ CanvasRails::Application.routes.draw do end scope(controller: :usage_rights) do - %w(course group user).each do |context| + %w[course group user].each do |context| content_prefix = "#{context.pluralize}/:#{context}_id" put "#{content_prefix}/usage_rights", action: :set_usage_rights delete "#{content_prefix}/usage_rights", action: :remove_usage_rights @@ -2324,7 +2324,7 @@ CanvasRails::Application.routes.draw do end scope(:controller => :csp_settings) do - %w(course account).each do |context| + %w[course account].each do |context| get "#{context.pluralize}/:#{context}_id/csp_settings", :action => :get_csp_settings put "#{context.pluralize}/:#{context}_id/csp_settings", :action => :set_csp_setting end @@ -2431,7 +2431,7 @@ CanvasRails::Application.routes.draw do post 'accounts/:account_id/developer_keys/tool_configuration', action: :create delete 'developer_keys/:developer_key_id/tool_configuration', action: :destroy - %w(account course).each do |context| + %w[account course].each do |context| get "#{context}s/:#{context}_id/developer_keys/:developer_key_id/tool_configuration", action: :show, as: "#{context}_show_tool_configuration" end end @@ -2459,7 +2459,7 @@ CanvasRails::Application.routes.draw do get 'authorize', action: :authorize, as: :lti_1_3_authorization end - %w(course account).each do |context| + %w[course account].each do |context| prefix = "#{context}s/:#{context}_id" post "#{prefix}/authorize", controller: 'lti/ims/authorization', action: :authorize, as: "#{context}_lti_oauth2_authorize" @@ -2570,7 +2570,7 @@ CanvasRails::Application.routes.draw do # Feature Flags scope(controller: 'lti/feature_flags') do - %w(course account).each do |context| + %w[course account].each do |context| prefix = "#{context}s/:#{context}_id" get "/#{prefix}/feature_flags/:feature", action: :show end diff --git a/db/migrate/20101210192618_init_canvas_db.rb b/db/migrate/20101210192618_init_canvas_db.rb index 19926a134c6..f8cf65a9244 100644 --- a/db/migrate/20101210192618_init_canvas_db.rb +++ b/db/migrate/20101210192618_init_canvas_db.rb @@ -2804,7 +2804,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2] end add_index "stream_item_instances", ["stream_item_id"] - add_index :stream_item_instances, %w(user_id hidden id stream_item_id), :name => "index_stream_item_instances_global" + add_index :stream_item_instances, %w[user_id hidden id stream_item_id], :name => "index_stream_item_instances_global" add_index :stream_item_instances, [:context_type, :context_id] add_index :stream_item_instances, [:stream_item_id, :user_id], :unique => true diff --git a/db/migrate/20101216224513_create_delayed_jobs.rb b/db/migrate/20101216224513_create_delayed_jobs.rb index f44ee01ad67..d2001ae7a4d 100644 --- a/db/migrate/20101216224513_create_delayed_jobs.rb +++ b/db/migrate/20101216224513_create_delayed_jobs.rb @@ -61,7 +61,7 @@ class CreateDelayedJobs < ActiveRecord::Migration[4.2] connection.execute("CREATE INDEX get_delayed_jobs_index ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} (priority, run_at) WHERE locked_at IS NULL AND queue = 'canvas_queue' AND next_in_strand = 't'") add_index :delayed_jobs, [:tag] - add_index :delayed_jobs, %w(strand id), :name => 'index_delayed_jobs_on_strand' + add_index :delayed_jobs, %w[strand id], :name => 'index_delayed_jobs_on_strand' add_index :delayed_jobs, :locked_by, :where => "locked_by IS NOT NULL" add_index :delayed_jobs, %w[run_at tag] add_index :delayed_jobs, :shard_id diff --git a/db/migrate/20121010191027_add_cassandra_page_view_tables.rb b/db/migrate/20121010191027_add_cassandra_page_view_tables.rb index 9bfcdb032d7..758db891b5c 100644 --- a/db/migrate/20121010191027_add_cassandra_page_view_tables.rb +++ b/db/migrate/20121010191027_add_cassandra_page_view_tables.rb @@ -31,7 +31,7 @@ class AddCassandraPageViewTables < ActiveRecord::Migration[4.2] "WITH compression = { 'sstable_compression' : 'DeflateCompressor' }" : "WITH compression_parameters:sstable_compression='DeflateCompressor'" - cassandra.execute %{ + cassandra.execute <<~SQL.squish CREATE TABLE page_views ( request_id text PRIMARY KEY, session_id text, @@ -57,17 +57,19 @@ class AddCassandraPageViewTables < ActiveRecord::Migration[4.2] real_user_id bigint, http_method text, remote_ip text - ) #{compression_params}} + ) #{compression_params} + SQL - cassandra.execute %{ + cassandra.execute <<~SQL.squish CREATE TABLE page_views_history_by_context ( context_and_time_bucket text, ordered_id text, request_id text, PRIMARY KEY (context_and_time_bucket, ordered_id) - ) #{compression_params}} + ) #{compression_params} + SQL - cassandra.execute %{ + cassandra.execute <<~SQL.squish CREATE TABLE page_views_migration_metadata_per_account ( shard_id text, account_id bigint, @@ -75,18 +77,18 @@ class AddCassandraPageViewTables < ActiveRecord::Migration[4.2] last_request_id text, PRIMARY KEY (shard_id, account_id) ) - } + SQL end def self.down - cassandra.execute %{ + cassandra.execute <<~SQL.squish DROP TABLE page_views_history_by_context; - } - cassandra.execute %{ + SQL + cassandra.execute <<~SQL.squish DROP TABLE page_views; - } - cassandra.execute %{ + SQL + cassandra.execute <<~SQL.squish DROP TABLE page_views_migration_metadata_per_account; - } + SQL end end diff --git a/db/migrate/20130627140642_add_authentication_auditor_tables.rb b/db/migrate/20130627140642_add_authentication_auditor_tables.rb index 1f5ae5df14b..15bf1310fac 100644 --- a/db/migrate/20130627140642_add_authentication_auditor_tables.rb +++ b/db/migrate/20130627140642_add_authentication_auditor_tables.rb @@ -27,7 +27,7 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2] end def self.indexes - %w( + %w[ authentications_by_pseudonym authentications_by_account authentications_by_user @@ -36,7 +36,7 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2] grade_changes_by_course grade_changes_by_root_account_student grade_changes_by_root_account_grader - ) + ] end def self.up @@ -106,11 +106,11 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2] def self.down indexes.each do |index_name| - cassandra.execute %{DROP TABLE #{index_name};} + cassandra.execute %(DROP TABLE #{index_name};) end - cassandra.execute %{DROP TABLE authentications;} - cassandra.execute %{DROP TABLE courses;} - cassandra.execute %{DROP TABLE grade_changes;} + cassandra.execute %(DROP TABLE authentications;) + cassandra.execute %(DROP TABLE courses;) + cassandra.execute %(DROP TABLE grade_changes;) end end diff --git a/db/migrate/20170605134354_cassandra_add_additional_grade_change_indexes_for_gradebook_history.rb b/db/migrate/20170605134354_cassandra_add_additional_grade_change_indexes_for_gradebook_history.rb index 8c55007343c..c1aa9fd7535 100644 --- a/db/migrate/20170605134354_cassandra_add_additional_grade_change_indexes_for_gradebook_history.rb +++ b/db/migrate/20170605134354_cassandra_add_additional_grade_change_indexes_for_gradebook_history.rb @@ -28,7 +28,7 @@ class CassandraAddAdditionalGradeChangeIndexesForGradebookHistory < ActiveRecord end def self.indexes - %w( + %w[ grade_changes_by_course_assignment grade_changes_by_course_assignment_grader grade_change_by_course_assignment_grader_student @@ -36,7 +36,7 @@ class CassandraAddAdditionalGradeChangeIndexesForGradebookHistory < ActiveRecord grade_changes_by_course_grader grade_changes_by_course_grader_student grade_changes_by_course_student - ) + ] end def self.up @@ -59,7 +59,7 @@ class CassandraAddAdditionalGradeChangeIndexesForGradebookHistory < ActiveRecord def self.down indexes.each do |index_name| - cassandra.execute %{DROP TABLE #{index_name};} + cassandra.execute %(DROP TABLE #{index_name};) end end end diff --git a/db/migrate/20170815211443_add_assignment_group_id_to_scores.rb b/db/migrate/20170815211443_add_assignment_group_id_to_scores.rb index 7b68b01deb7..bec6ab3c1e5 100644 --- a/db/migrate/20170815211443_add_assignment_group_id_to_scores.rb +++ b/db/migrate/20170815211443_add_assignment_group_id_to_scores.rb @@ -32,12 +32,12 @@ class AddAssignmentGroupIdToScores < ActiveRecord::Migration[5.0] algorithm: :concurrently, name: :index_enrollment_scores - add_index :scores, %i(enrollment_id grading_period_id), unique: true, + add_index :scores, %i[enrollment_id grading_period_id], unique: true, where: "grading_period_id IS NOT NULL", algorithm: :concurrently, name: :index_grading_period_scores - add_index :scores, %i(enrollment_id assignment_group_id), unique: true, + add_index :scores, %i[enrollment_id assignment_group_id], unique: true, where: "assignment_group_id IS NOT NULL", algorithm: :concurrently, name: :index_assignment_group_scores diff --git a/db/migrate/20170902211600_create_new_grade_history_batch_table.rb b/db/migrate/20170902211600_create_new_grade_history_batch_table.rb index a3e261e480e..31c578daea6 100644 --- a/db/migrate/20170902211600_create_new_grade_history_batch_table.rb +++ b/db/migrate/20170902211600_create_new_grade_history_batch_table.rb @@ -55,11 +55,11 @@ class CreateNewGradeHistoryBatchTable < ActiveRecord::Migration[4.2] end def self.table_exists?(cassandra, table) - cql = %{ + cql = <<~SQL.squish SELECT * FROM #{table} LIMIT 1 - } + SQL cassandra.execute(cql) true rescue CassandraCQL::Error::InvalidRequestException diff --git a/db/migrate/20180201160908_create_sis_batch_roll_back_data.rb b/db/migrate/20180201160908_create_sis_batch_roll_back_data.rb index d928cd10ba1..963328090b8 100644 --- a/db/migrate/20180201160908_create_sis_batch_roll_back_data.rb +++ b/db/migrate/20180201160908_create_sis_batch_roll_back_data.rb @@ -36,7 +36,7 @@ class CreateSisBatchRollBackData < ActiveRecord::Migration[5.0] add_foreign_key :sis_batch_roll_back_data, :sis_batches add_index :sis_batch_roll_back_data, :sis_batch_id add_index :sis_batch_roll_back_data, :workflow_state - add_index :sis_batch_roll_back_data, %i(updated_workflow_state previous_workflow_state), + add_index :sis_batch_roll_back_data, %i[updated_workflow_state previous_workflow_state], name: 'index_sis_batch_roll_back_context_workflow_states' end end diff --git a/db/migrate/20180207045041_create_lti_results.rb b/db/migrate/20180207045041_create_lti_results.rb index 6449d42ecd2..07090915844 100644 --- a/db/migrate/20180207045041_create_lti_results.rb +++ b/db/migrate/20180207045041_create_lti_results.rb @@ -36,6 +36,6 @@ class CreateLtiResults < ActiveRecord::Migration[5.0] t.timestamps end - add_index :lti_results, %i(lti_line_item_id user_id), unique: true + add_index :lti_results, %i[lti_line_item_id user_id], unique: true end end diff --git a/db/migrate/20180312105009_create_developer_key_account_bindings.rb b/db/migrate/20180312105009_create_developer_key_account_bindings.rb index 1dd568e86f5..48707a30ad4 100644 --- a/db/migrate/20180312105009_create_developer_key_account_bindings.rb +++ b/db/migrate/20180312105009_create_developer_key_account_bindings.rb @@ -35,7 +35,7 @@ class CreateDeveloperKeyAccountBindings < ActiveRecord::Migration[5.0] add_foreign_key :developer_key_account_bindings, :developer_keys add_index :developer_key_account_bindings, :developer_key_id - add_index :developer_key_account_bindings, %i(account_id developer_key_id), name: :index_dev_key_bindings_on_account_id_and_developer_key_id, unique: true + add_index :developer_key_account_bindings, %i[account_id developer_key_id], name: :index_dev_key_bindings_on_account_id_and_developer_key_id, unique: true end def down diff --git a/db/migrate/20190325205830_create_user_past_lti_id.rb b/db/migrate/20190325205830_create_user_past_lti_id.rb index 17b8f496625..5227d8a8c70 100644 --- a/db/migrate/20190325205830_create_user_past_lti_id.rb +++ b/db/migrate/20190325205830_create_user_past_lti_id.rb @@ -29,6 +29,6 @@ class CreateUserPastLtiId < ActiveRecord::Migration[5.1] t.text :user_lti_id, null: false t.string :user_lti_context_id, limit: 255, index: true end - add_index :user_past_lti_ids, %w(user_id context_id context_type), name: 'user_past_lti_ids_index', unique: true + add_index :user_past_lti_ids, %w[user_id context_id context_type], name: 'user_past_lti_ids_index', unique: true end end diff --git a/db/migrate/20200120224245_create_notification_policy_overrides.rb b/db/migrate/20200120224245_create_notification_policy_overrides.rb index e9930ea1d5b..87e9c92d2e0 100644 --- a/db/migrate/20200120224245_create_notification_policy_overrides.rb +++ b/db/migrate/20200120224245_create_notification_policy_overrides.rb @@ -32,12 +32,12 @@ class CreateNotificationPolicyOverrides < ActiveRecord::Migration[5.2] t.timestamps end - add_index :notification_policy_overrides, %i(communication_channel_id notification_id), + add_index :notification_policy_overrides, %i[communication_channel_id notification_id], name: 'index_notification_policies_overrides_on_cc_id_and_notification' - add_index :notification_policy_overrides, %i(context_id context_type communication_channel_id notification_id), + add_index :notification_policy_overrides, %i[context_id context_type communication_channel_id notification_id], where: 'notification_id IS NOT NULL', unique: true, name: 'index_notification_policies_overrides_uniq_context_notification' - add_index :notification_policy_overrides, %i(context_id context_type communication_channel_id), + add_index :notification_policy_overrides, %i[context_id context_type communication_channel_id], where: 'notification_id IS NULL', unique: true, name: 'index_notification_policies_overrides_uniq_context_and_cc' end diff --git a/db/migrate/20200320143033_cassandra_add_account_index_for_courses.rb b/db/migrate/20200320143033_cassandra_add_account_index_for_courses.rb index 67540258c62..04ada871491 100644 --- a/db/migrate/20200320143033_cassandra_add_account_index_for_courses.rb +++ b/db/migrate/20200320143033_cassandra_add_account_index_for_courses.rb @@ -26,10 +26,12 @@ class CassandraAddAccountIndexForCourses < ActiveRecord::Migration[5.2] end def self.up - cassandra.execute %{ - ALTER TABLE courses - ADD account_id bigint; - } unless cassandra_column_exists?('courses', 'account_id') + unless cassandra_column_exists?('courses', 'account_id') + cassandra.execute <<~SQL.squish + ALTER TABLE courses + ADD account_id bigint; + SQL + end return if cassandra_table_exists?('courses_by_account') @@ -39,21 +41,24 @@ class CassandraAddAccountIndexForCourses < ActiveRecord::Migration[5.2] "WITH compression_parameters:sstable_compression='DeflateCompressor'" end - cassandra.execute %{ + cassandra.execute <<~SQL.squish CREATE TABLE courses_by_account ( key text, ordered_id text, id text, PRIMARY KEY (key, ordered_id) - ) #{compression_params}} + ) #{compression_params} + SQL end def self.down - cassandra.execute %{ - ALTER TABLE courses - DROP account_id; - } if cassandra_column_exists?('courses', 'account_id') + if cassandra_column_exists?('courses', 'account_id') + cassandra.execute <<~SQL.squish + ALTER TABLE courses + DROP account_id; + SQL + end - cassandra.execute %{DROP TABLE courses_by_account} if cassandra_table_exists?('courses_by_account') + cassandra.execute %(DROP TABLE courses_by_account) if cassandra_table_exists?('courses_by_account') end end diff --git a/db/migrate/20200821203605_cassandra_add_grading_period_id_to_grade_changes.rb b/db/migrate/20200821203605_cassandra_add_grading_period_id_to_grade_changes.rb index 87730b5fbe8..54fe30ba829 100644 --- a/db/migrate/20200821203605_cassandra_add_grading_period_id_to_grade_changes.rb +++ b/db/migrate/20200821203605_cassandra_add_grading_period_id_to_grade_changes.rb @@ -27,19 +27,19 @@ class CassandraAddGradingPeriodIdToGradeChanges < ActiveRecord::Migration[5.2] def self.up unless cassandra_column_exists?('grade_changes', 'grading_period_id') - cassandra.execute %{ + cassandra.execute <<~SQL.squish ALTER TABLE grade_changes ADD grading_period_id bigint; - } + SQL end end def self.down if cassandra_column_exists?('grade_changes', 'grading_period_id') - cassandra.execute %{ + cassandra.execute <<~SQL.squish ALTER TABLE grade_changes DROP grading_period_id; - } + SQL end end end diff --git a/db/migrate/20210604144553_add_flag_auditors_cassandra.rb b/db/migrate/20210604144553_add_flag_auditors_cassandra.rb index 39c71ac6888..7c3f02779ea 100644 --- a/db/migrate/20210604144553_add_flag_auditors_cassandra.rb +++ b/db/migrate/20210604144553_add_flag_auditors_cassandra.rb @@ -33,9 +33,9 @@ class AddFlagAuditorsCassandra < ActiveRecord::Migration[6.0] end def self.indexes - %w( + %w[ feature_flag_changes_by_feature_flag - ) + ] end def self.up @@ -72,8 +72,8 @@ class AddFlagAuditorsCassandra < ActiveRecord::Migration[6.0] def self.down indexes.each do |index_name| - cassandra.execute %{DROP TABLE #{index_name};} + cassandra.execute %(DROP TABLE #{index_name};) end - cassandra.execute %{DROP TABLE feature_flags;} + cassandra.execute %(DROP TABLE feature_flags;) end end diff --git a/db/migrate/20210817214256_make_timestamps_not_null6.rb b/db/migrate/20210817214256_make_timestamps_not_null6.rb index 0996bd30cb7..b2cacda9e82 100644 --- a/db/migrate/20210817214256_make_timestamps_not_null6.rb +++ b/db/migrate/20210817214256_make_timestamps_not_null6.rb @@ -21,7 +21,7 @@ class MakeTimestampsNotNull6 < ActiveRecord::Migration[6.0] tag :postdeploy disable_ddl_transaction! - TABLES = %w{ + TABLES = %w[ abstract_courses account_reports account_users @@ -99,7 +99,7 @@ class MakeTimestampsNotNull6 < ActiveRecord::Migration[6.0] web_conferences wiki_pages wikis - }.freeze + ].freeze def change tries = 0 diff --git a/db/migrate/20210920100330_create_discussion_entry_draft.rb b/db/migrate/20210920100330_create_discussion_entry_draft.rb index 70d90f7171c..5fb9430ee96 100644 --- a/db/migrate/20210920100330_create_discussion_entry_draft.rb +++ b/db/migrate/20210920100330_create_discussion_entry_draft.rb @@ -30,15 +30,15 @@ class CreateDiscussionEntryDraft < ActiveRecord::Migration[6.0] t.text :message t.boolean :include_reply_preview, null: false, default: false t.timestamps - t.index %i(discussion_topic_id user_id), + t.index %i[discussion_topic_id user_id], name: 'unique_index_on_topic_and_user', where: 'discussion_entry_id IS NULL AND root_entry_id IS NULL', unique: true - t.index %i(root_entry_id user_id), + t.index %i[root_entry_id user_id], name: 'unique_index_on_root_entry_and_user', where: 'discussion_entry_id IS NULL', unique: true - t.index %i(discussion_entry_id user_id), + t.index %i[discussion_entry_id user_id], name: 'unique_index_on_entry_and_user', unique: true end diff --git a/doc/api/fulldoc/html/setup.rb b/doc/api/fulldoc/html/setup.rb index a0ce9b9a3e2..1325a0c9914 100644 --- a/doc/api/fulldoc/html/setup.rb +++ b/doc/api/fulldoc/html/setup.rb @@ -191,7 +191,7 @@ def init end def generate_swagger(filename, json) - output_dir = File.join(%w(public doc api)) + output_dir = File.join(%w[public doc api]) FileUtils.mkdir_p output_dir path = File.join(output_dir, filename) diff --git a/doc/api/fulldoc/html/swagger/argument_view.rb b/doc/api/fulldoc/html/swagger/argument_view.rb index 3dfe5408dc3..6012d95e7f5 100644 --- a/doc/api/fulldoc/html/swagger/argument_view.rb +++ b/doc/api/fulldoc/html/swagger/argument_view.rb @@ -93,7 +93,7 @@ class ArgumentView < HashView def types enum_and_types.last.reject do |t| - %w(optional required).include?(t.downcase) + %w[optional required].include?(t.downcase) end end diff --git a/doc/api/fulldoc/html/swagger/object_view.rb b/doc/api/fulldoc/html/swagger/object_view.rb index daaa9ae63f0..a6f72b625e4 100644 --- a/doc/api/fulldoc/html/swagger/object_view.rb +++ b/doc/api/fulldoc/html/swagger/object_view.rb @@ -77,6 +77,6 @@ class ObjectView < HashView end def self.strip_comments(str) - str.gsub(%r(//[^\n"]+$), '') + str.gsub(%r{//[^\n"]+$}, '') end end diff --git a/doc/api/topic/html/setup.rb b/doc/api/topic/html/setup.rb index 69b6c2f2457..4cc50a450fc 100644 --- a/doc/api/topic/html/setup.rb +++ b/doc/api/topic/html/setup.rb @@ -88,9 +88,9 @@ def render_value(prop) when 'object' JSON.generate(value) when 'integer', 'number', 'boolean' then value.to_s - when 'string', 'datetime' then %{"#{value}"} + when 'string', 'datetime' then %("#{value}") else - raise ArgumentError, %{invalid or missing "type" in API property: #{prop.inspect}} + raise ArgumentError, %(invalid or missing "type" in API property: #{prop.inspect}) end end @@ -103,7 +103,7 @@ def render_properties(json) result << ("{\n" + indent( properties.map do |name, prop| render_comment(prop) + - %{"#{name}": } + render_value(prop) + %("#{name}": ) + render_value(prop) end.join(",\n") ) + "\n}") end diff --git a/gems/activesupport-suspend_callbacks/activesupport-suspend_callbacks.gemspec b/gems/activesupport-suspend_callbacks/activesupport-suspend_callbacks.gemspec index 50e5f3d9bec..8d46f728ef4 100644 --- a/gems/activesupport-suspend_callbacks/activesupport-suspend_callbacks.gemspec +++ b/gems/activesupport-suspend_callbacks/activesupport-suspend_callbacks.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["jacob@instructure.com"] spec.summary = 'Temporarily suspend specific ActiveSupport::Callbacks callbacks' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(LICENSE.txt Rakefile README.md test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE.txt Rakefile README.md test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/adheres_to_policy/adheres_to_policy.gemspec b/gems/adheres_to_policy/adheres_to_policy.gemspec index 61b775eac0a..38fd32879f3 100644 --- a/gems/adheres_to_policy/adheres_to_policy.gemspec +++ b/gems/adheres_to_policy/adheres_to_policy.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "stephan@pivotallabs.com"] spec.summary = 'The canvas adheres to policy gem' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile README.md test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile README.md test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/adheres_to_policy/spec/adheres_to_policy/configuration_spec.rb b/gems/adheres_to_policy/spec/adheres_to_policy/configuration_spec.rb index 8990b225e68..28e371189b4 100644 --- a/gems/adheres_to_policy/spec/adheres_to_policy/configuration_spec.rb +++ b/gems/adheres_to_policy/spec/adheres_to_policy/configuration_spec.rb @@ -28,16 +28,16 @@ describe AdheresToPolicy::Configuration do end it 'must return the literal value set' do - config.blacklist = %w{foo bar} - expect(config.blacklist).to eq %w{foo bar} + config.blacklist = %w[foo bar] + expect(config.blacklist).to eq %w[foo bar] end it 'must evaluate the supplied block and return the result' do config.blacklist = -> { - %w{baz qux} + %w[baz qux] } - expect(config.blacklist).to eq %w{baz qux} + expect(config.blacklist).to eq %w[baz qux] end end diff --git a/gems/adheres_to_policy/spec/adheres_to_policy/instance_methods_spec.rb b/gems/adheres_to_policy/spec/adheres_to_policy/instance_methods_spec.rb index 0e53b6d43cb..001b015ddf2 100644 --- a/gems/adheres_to_policy/spec/adheres_to_policy/instance_methods_spec.rb +++ b/gems/adheres_to_policy/spec/adheres_to_policy/instance_methods_spec.rb @@ -36,7 +36,7 @@ describe AdheresToPolicy::InstanceMethods do let(:user_class) { Class.new } it "has setup a series of methods on the instance" do - %w(rights_status granted_rights grants_right? grants_any_right? grants_all_rights?).each do |method| + %w[rights_status granted_rights grants_right? grants_any_right? grants_all_rights?].each do |method| expect(some_class.new).to respond_to(method) end end diff --git a/gems/attachment_fu/lib/attachment_fu.rb b/gems/attachment_fu/lib/attachment_fu.rb index eefd0a36be9..538333e69f3 100644 --- a/gems/attachment_fu/lib/attachment_fu.rb +++ b/gems/attachment_fu/lib/attachment_fu.rb @@ -23,7 +23,7 @@ require 'attachment_fu/backends/file_system_backend' require 'attachment_fu/backends/s3_backend' module AttachmentFu # :nodoc: - @@default_processors = %w(MiniMagick) + @@default_processors = %w[MiniMagick] # Instructure: I (ryan shaw) just copied and pasted this from http://github.com/technoweenie/attachment_fu/blob/master/lib/technoweenie/attachment_fu.rb @@content_types = [ 'image/jpeg', diff --git a/gems/bookmarked_collection/bookmarked_collection.gemspec b/gems/bookmarked_collection/bookmarked_collection.gemspec index e7c15eb3ef5..c620f667386 100644 --- a/gems/bookmarked_collection/bookmarked_collection.gemspec +++ b/gems/bookmarked_collection/bookmarked_collection.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "nickc@instructure.com"] spec.summary = 'Bookmarked collections for Canvas' - spec.files = Dir.glob("{lib}/**/*") + %w(Rakefile) + spec.files = Dir.glob("{lib}/**/*") + %w[Rakefile] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_breach_mitigation/canvas_breach_mitigation.gemspec b/gems/canvas_breach_mitigation/canvas_breach_mitigation.gemspec index d66ea5f4735..716b6e2b8ad 100644 --- a/gems/canvas_breach_mitigation/canvas_breach_mitigation.gemspec +++ b/gems/canvas_breach_mitigation/canvas_breach_mitigation.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "djulia@pivotallabs.com"] spec.summary = 'Subset of breach-mitigation-rails gem' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(LICENSE.txt README.md test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE.txt README.md test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_cache/canvas_cache.gemspec b/gems/canvas_cache/canvas_cache.gemspec index bf125d55bc2..88cdc44df9b 100644 --- a/gems/canvas_cache/canvas_cache.gemspec +++ b/gems/canvas_cache/canvas_cache.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["evizitei@instructure.com", "cody@instructure.com", "jburroughs@instructure.com"] spec.summary = "Instructure's caching capabilities, all in one place" - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_cache/lib/canvas_cache/redis.rb b/gems/canvas_cache/lib/canvas_cache/redis.rb index 31e690ae6f6..6560d5dc54d 100644 --- a/gems/canvas_cache/lib/canvas_cache/redis.rb +++ b/gems/canvas_cache/lib/canvas_cache/redis.rb @@ -249,7 +249,7 @@ module CanvasCache response end - SET_COMMANDS = %i{set setex}.freeze + SET_COMMANDS = %i[set setex].freeze def log_request_response(request, response, start_time) return if request.nil? # redis client does internal keepalives and connection commands return if CanvasCache::Redis.log_style == 'off' diff --git a/gems/canvas_cassandra/canvas_cassandra.gemspec b/gems/canvas_cassandra/canvas_cassandra.gemspec index 45270708faf..043e7b4aa00 100644 --- a/gems/canvas_cassandra/canvas_cassandra.gemspec +++ b/gems/canvas_cassandra/canvas_cassandra.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/instructure/canvas-lms" spec.license = "AGPL" - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_crummy/canvas_crummy.gemspec b/gems/canvas_crummy/canvas_crummy.gemspec index 847f1cb0a7b..910f79856e0 100644 --- a/gems/canvas_crummy/canvas_crummy.gemspec +++ b/gems/canvas_crummy/canvas_crummy.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "djulia@pivotallabs.com"] spec.summary = 'Instructure fork of crummy gem' - spec.files = Dir.glob("{lib}/**/*") + %w(LICENSE.txt README.md Rakefile) + spec.files = Dir.glob("{lib}/**/*") + %w[LICENSE.txt README.md Rakefile] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_dynamodb/canvas_dynamodb.gemspec b/gems/canvas_dynamodb/canvas_dynamodb.gemspec index a654c4c2e60..629662fbfdc 100644 --- a/gems/canvas_dynamodb/canvas_dynamodb.gemspec +++ b/gems/canvas_dynamodb/canvas_dynamodb.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/instructure/canvas-lms" spec.license = "AGPL" - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_dynamodb/lib/canvas_dynamodb/database.rb b/gems/canvas_dynamodb/lib/canvas_dynamodb/database.rb index e7d18ff3929..4dab12cd1df 100644 --- a/gems/canvas_dynamodb/lib/canvas_dynamodb/database.rb +++ b/gems/canvas_dynamodb/lib/canvas_dynamodb/database.rb @@ -38,7 +38,7 @@ module CanvasDynamoDB @logger = logger || Logger.new(STDOUT) end - %i(delete_item get_item put_item query scan update_item).each do |method| + %i[delete_item get_item put_item query scan update_item].each do |method| define_method(method) do |params| params = params.merge( table_name: prefixed_table_name(params[:table_name]) @@ -47,7 +47,7 @@ module CanvasDynamoDB end end - %i(batch_get_item batch_write_item).each do |method| + %i[batch_get_item batch_write_item].each do |method| define_method(method) do |params| request_items = {} params[:request_items].each_key do |table_name| diff --git a/gems/canvas_errors/canvas_errors.gemspec b/gems/canvas_errors/canvas_errors.gemspec index 8a747cd0f47..9f402268d5c 100644 --- a/gems/canvas_errors/canvas_errors.gemspec +++ b/gems/canvas_errors/canvas_errors.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["evizitei@instructure.com"] spec.summary = 'Instructure gem for capturing errors to arbitrary reporting destinations' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_ext/canvas_ext.gemspec b/gems/canvas_ext/canvas_ext.gemspec index e6c1a225477..6f90e2950a0 100644 --- a/gems/canvas_ext/canvas_ext.gemspec +++ b/gems/canvas_ext/canvas_ext.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["ncloward@instructure.com"] spec.summary = 'Monkey Patches for core classes' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_http/canvas_http.gemspec b/gems/canvas_http/canvas_http.gemspec index 534b903890b..b42a7728b44 100644 --- a/gems/canvas_http/canvas_http.gemspec +++ b/gems/canvas_http/canvas_http.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["brianp@instructure.com"] spec.summary = 'Canvas HTTP' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_http/lib/canvas_http.rb b/gems/canvas_http/lib/canvas_http.rb index 2d9cff5cefe..98f1e8e02ed 100644 --- a/gems/canvas_http/lib/canvas_http.rb +++ b/gems/canvas_http/lib/canvas_http.rb @@ -172,7 +172,7 @@ module CanvasHttp end # returns [normalized_url_string, URI] if valid, raises otherwise - def self.validate_url(value, host: nil, scheme: nil, allowed_schemes: %w{http https}, check_host: false) + def self.validate_url(value, host: nil, scheme: nil, allowed_schemes: %w[http https], check_host: false) value = value.strip raise ArgumentError if value.empty? diff --git a/gems/canvas_kaltura/canvas_kaltura.gemspec b/gems/canvas_kaltura/canvas_kaltura.gemspec index 34c30650e18..b7d8a475d37 100644 --- a/gems/canvas_kaltura/canvas_kaltura.gemspec +++ b/gems/canvas_kaltura/canvas_kaltura.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["ncloward@instructure.com"] spec.summary = 'Canvas Kaltura' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_kaltura/spec/canvas_kaltura/kaltura_client_v3_spec.rb b/gems/canvas_kaltura/spec/canvas_kaltura/kaltura_client_v3_spec.rb index f1c40d2601c..12e283f4e89 100644 --- a/gems/canvas_kaltura/spec/canvas_kaltura/kaltura_client_v3_spec.rb +++ b/gems/canvas_kaltura/spec/canvas_kaltura/kaltura_client_v3_spec.rb @@ -409,7 +409,7 @@ describe CanvasKaltura::ClientV3 do }] expect(@kaltura).to receive(:bulkUploadCsv).with( - %Q[the_name,the_desc,the_tags,the_url,the_media_type,"","","","","","",the_partner_data\n] + %Q(the_name,the_desc,the_tags,the_url,the_media_type,"","","","","","",the_partner_data\n) ) @kaltura.bulkUploadAdd(files) diff --git a/gems/canvas_mimetype_fu/canvas_mimetype_fu.gemspec b/gems/canvas_mimetype_fu/canvas_mimetype_fu.gemspec index 7acbd593fa1..fe4a499f0da 100644 --- a/gems/canvas_mimetype_fu/canvas_mimetype_fu.gemspec +++ b/gems/canvas_mimetype_fu/canvas_mimetype_fu.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com"] spec.summary = 'Instructure fork of mimetype_fu gem' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(LICENSE.txt Rakefile README.md test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE.txt Rakefile README.md test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_panda_pub/canvas_panda_pub.gemspec b/gems/canvas_panda_pub/canvas_panda_pub.gemspec index f10aad14263..2d8f2a9d18b 100644 --- a/gems/canvas_panda_pub/canvas_panda_pub.gemspec +++ b/gems/canvas_panda_pub/canvas_panda_pub.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["zach@instructure.com"] spec.summary = 'Canvas PandaPub' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_partman/spec/canvas_partman/partition_manager_spec.rb b/gems/canvas_partman/spec/canvas_partman/partition_manager_spec.rb index 2dfe8b15619..6e51c03072b 100644 --- a/gems/canvas_partman/spec/canvas_partman/partition_manager_spec.rb +++ b/gems/canvas_partman/spec/canvas_partman/partition_manager_spec.rb @@ -71,7 +71,7 @@ describe CanvasPartman::PartitionManager do describe "#prune_partitions" do it "prunes the proper number of partitions" do expect(Time).to receive(:now).and_return(Time.utc(2015, 05, 02)) - expect(subject).to receive(:partition_tables).and_return(%w{ + expect(subject).to receive(:partition_tables).and_return(%w[ partman_animals_2014_9 partman_animals_2014_10 partman_animals_2014_11 @@ -82,7 +82,7 @@ describe CanvasPartman::PartitionManager do partman_animals_2015_4 partman_animals_2015_5 partman_animals_2015_6 - }) + ]) expect(subject.base_class.connection).to receive(:drop_table).with('partman_animals_2014_9') expect(subject.base_class.connection).to receive(:drop_table).with('partman_animals_2014_10') @@ -92,14 +92,14 @@ describe CanvasPartman::PartitionManager do it "prunes weekly partitions too" do expect(Time).to receive(:now).and_return(Time.utc(2015, 02, 05)) allow(Animal).to receive(:partitioning_interval).and_return(:weeks) - expect(subject).to receive(:partition_tables).and_return(%w{ + expect(subject).to receive(:partition_tables).and_return(%w[ partman_animals_2015_01 partman_animals_2015_02 partman_animals_2015_03 partman_animals_2015_04 partman_animals_2015_05 partman_animals_2015_06 - }) + ]) expect(subject.base_class.connection).to receive(:drop_table).with('partman_animals_2015_01') expect(subject.base_class.connection).to receive(:drop_table).with('partman_animals_2015_02') diff --git a/gems/canvas_sanitize/canvas_sanitize.gemspec b/gems/canvas_sanitize/canvas_sanitize.gemspec index 55c9bf25c66..4b85ef83612 100644 --- a/gems/canvas_sanitize/canvas_sanitize.gemspec +++ b/gems/canvas_sanitize/canvas_sanitize.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "stephan@pivotallabs.com"] spec.summary = 'The canvas sanitizer gem' - spec.files = Dir.glob("{lib}/**/*") + %w(Rakefile README.md) + spec.files = Dir.glob("{lib}/**/*") + %w[Rakefile README.md] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_sanitize/lib/canvas_sanitize/canvas_sanitize.rb b/gems/canvas_sanitize/lib/canvas_sanitize/canvas_sanitize.rb index 06338642b56..e63c193d7a3 100644 --- a/gems/canvas_sanitize/lib/canvas_sanitize/canvas_sanitize.rb +++ b/gems/canvas_sanitize/lib/canvas_sanitize/canvas_sanitize.rb @@ -317,18 +317,18 @@ module CanvasSanitize # :nodoc: 'visibility', 'white-space', 'width', 'z-index', 'zoom' ] + - %w{area auto-columns auto-flow auto-rows column gap row template}.map { |i| "grid-#{i}" } + - %w{areas columns rows}.map { |i| "grid-template-#{i}" } + - %w{end gap start}.map { |i| "grid-column-#{i}" } + - %w{end gap start}.map { |i| "grid-row-#{i}" } + - %w{attachment color image position repeat}.map { |i| "background-#{i}" } + - %w{x y}.map { |i| "background-position-#{i}" } + - %w{bottom collapse color left right spacing style top width}.map { |i| "border-#{i}" } + - %w{bottom left right top}.map { |i| %w{color style width}.map { |j| "border-#{i}-#{j}" } }.flatten + - %w{family size stretch style variant width}.map { |i| "font-#{i}" } + - %w{image position type}.map { |i| "list-style-#{i}" } + - %w{bottom left right top offset}.map { |i| "margin-#{i}" } + - %w{bottom left right top}.map { |i| "padding-#{i}" } + %w[area auto-columns auto-flow auto-rows column gap row template].map { |i| "grid-#{i}" } + + %w[areas columns rows].map { |i| "grid-template-#{i}" } + + %w[end gap start].map { |i| "grid-column-#{i}" } + + %w[end gap start].map { |i| "grid-row-#{i}" } + + %w[attachment color image position repeat].map { |i| "background-#{i}" } + + %w[x y].map { |i| "background-position-#{i}" } + + %w[bottom collapse color left right spacing style top width].map { |i| "border-#{i}" } + + %w[bottom left right top].map { |i| %w[color style width].map { |j| "border-#{i}-#{j}" } }.flatten + + %w[family size stretch style variant width].map { |i| "font-#{i}" } + + %w[image position type].map { |i| "list-style-#{i}" } + + %w[bottom left right top offset].map { |i| "margin-#{i}" } + + %w[bottom left right top].map { |i| "padding-#{i}" } ).to_set.freeze, protocols: DEFAULT_PROTOCOLS } diff --git a/gems/canvas_sanitize/spec/canvas_sanitize/canvas_sanitize_spec.rb b/gems/canvas_sanitize/spec/canvas_sanitize/canvas_sanitize_spec.rb index 1560a5d9aef..14a3cff7f85 100644 --- a/gems/canvas_sanitize/spec/canvas_sanitize/canvas_sanitize_spec.rb +++ b/gems/canvas_sanitize/spec/canvas_sanitize/canvas_sanitize_spec.rb @@ -142,31 +142,31 @@ describe CanvasSanitize do end it "allows font tags with valid attributes" do - str = %{hello} + str = %(hello) res = Sanitize.clean(str, CanvasSanitize::SANITIZE) - expect(res).to eq %{hello} + expect(res).to eq %(hello) end it "allows valid MathML" do - str = %{a+b} + str = %(a+b) res = Sanitize.clean(str, CanvasSanitize::SANITIZE) expect(res).to eq str end it "strips invalid attributes from MathML" do - str = %{a+b} + str = %(a+b) res = Sanitize.clean(str, CanvasSanitize::SANITIZE) expect(res).not_to match(/foo/) end it "removes and not escape contents of style tags" do - str = %{

but not me

} + str = %(

but not me

) res = Sanitize.clean(str, CanvasSanitize::SANITIZE) expect(res).to eq "

but not me

" end it "is not extremely slow with long, weird microsoft styles" do - str = %{

} + str = %(

) # the above string took over a minute to sanitize as of 8ae4ba8e Timeout.timeout(1) { Sanitize.clean(str, CanvasSanitize::SANITIZE) } end diff --git a/gems/canvas_security/canvas_security.gemspec b/gems/canvas_security/canvas_security.gemspec index f93aca5351b..9996a4944eb 100644 --- a/gems/canvas_security/canvas_security.gemspec +++ b/gems/canvas_security/canvas_security.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["evizitei@instructure.com"] spec.summary = 'Instructure gem for checking sigs and such' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_security/lib/canvas_security/key_storage.rb b/gems/canvas_security/lib/canvas_security/key_storage.rb index e5c14d2bb38..277de3f34f1 100644 --- a/gems/canvas_security/lib/canvas_security/key_storage.rb +++ b/gems/canvas_security/lib/canvas_security/key_storage.rb @@ -80,7 +80,7 @@ module CanvasSecurity def public_keyset JSON::JWK::Set.new(retrieve_keys.values.compact.map do |private_jwk| public_jwk = private_jwk.to_key.public_key.to_jwk - public_jwk.merge(private_jwk.select { |k, _| %w(alg use kid).include?(k) }) + public_jwk.merge(private_jwk.select { |k, _| %w[alg use kid].include?(k) }) end) end diff --git a/gems/canvas_security/spec/canvas_security/key_storage_spec.rb b/gems/canvas_security/spec/canvas_security/key_storage_spec.rb index 6e2cbdf8a42..7b644e4c423 100644 --- a/gems/canvas_security/spec/canvas_security/key_storage_spec.rb +++ b/gems/canvas_security/spec/canvas_security/key_storage_spec.rb @@ -114,6 +114,6 @@ describe CanvasSecurity::KeyStorage do end def select_public_claims(key) - key.select { |k, _| %w(kty e n kid alg use).include?(k) } + key.select { |k, _| %w[kty e n kid alg use].include?(k) } end end diff --git a/gems/canvas_slug/canvas_slug.gemspec b/gems/canvas_slug/canvas_slug.gemspec index be975c46f0f..e821ce3a7a7 100644 --- a/gems/canvas_slug/canvas_slug.gemspec +++ b/gems/canvas_slug/canvas_slug.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com"] spec.summary = 'Canvas Slug generation' - spec.files = Dir.glob("{lib,test}/**/*") + %w(Rakefile) + spec.files = Dir.glob("{lib,test}/**/*") + %w[Rakefile] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_sort/canvas_sort.gemspec b/gems/canvas_sort/canvas_sort.gemspec index 19920f8eb11..b8327656757 100644 --- a/gems/canvas_sort/canvas_sort.gemspec +++ b/gems/canvas_sort/canvas_sort.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["ncloward@instructure.com"] spec.summary = 'Canvas Sort' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_stringex/canvas_stringex.gemspec b/gems/canvas_stringex/canvas_stringex.gemspec index bda58bb9acc..55afd62e5a8 100644 --- a/gems/canvas_stringex/canvas_stringex.gemspec +++ b/gems/canvas_stringex/canvas_stringex.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "stephan@pivotallabs.com"] spec.summary = 'Instructure fork of the stringex gem' - spec.files = Dir.glob("{lib,test}/**/*") + %w(LICENSE.txt Rakefile README.rdoc test.sh) + spec.files = Dir.glob("{lib,test}/**/*") + %w[LICENSE.txt Rakefile README.rdoc test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_stringex/lib/lucky_sneaks/string_extensions.rb b/gems/canvas_stringex/lib/lucky_sneaks/string_extensions.rb index a0ab1889d80..c7d40cef041 100644 --- a/gems/canvas_stringex/lib/lucky_sneaks/string_extensions.rb +++ b/gems/canvas_stringex/lib/lucky_sneaks/string_extensions.rb @@ -188,11 +188,11 @@ module LuckySneaks # Returns string of random characters with a length matching the specified limit. Excludes 0 # to avoid confusion between 0 and O. def random(limit) - strong_alphanumerics = %w{ + strong_alphanumerics = %w[ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 - } + ] Array.new(limit, "").collect { strong_alphanumerics[rand(61)] }.join end end diff --git a/gems/canvas_stringex/spec/lucky_sneaks/unicode_point_suite/basic_latin_spec.rb b/gems/canvas_stringex/spec/lucky_sneaks/unicode_point_suite/basic_latin_spec.rb index dc30e1677b4..26be20eb8d0 100644 --- a/gems/canvas_stringex/spec/lucky_sneaks/unicode_point_suite/basic_latin_spec.rb +++ b/gems/canvas_stringex/spec/lucky_sneaks/unicode_point_suite/basic_latin_spec.rb @@ -33,56 +33,56 @@ describe "BasicLatin" do # Get weird results trying to pack them to unicode. it "spaces" do - assert_equal_encoded " ", %w{0020 00a0} - assert_equal_encoded "", %w{200b 2060} + assert_equal_encoded " ", %w[0020 00a0] + assert_equal_encoded "", %w[200b 2060] end it "exclamation_marks" do - assert_equal_encoded "!", %w{0021 2762} + assert_equal_encoded "!", %w[0021 2762] assert_equal_encoded "!!", "203c" assert_equal_encoded "", "00a1" assert_equal_encoded "?!", "203d" end it "quotation_marks" do - assert_equal_encoded "\"", %w{0022 02ba 2033 3003} + assert_equal_encoded "\"", %w[0022 02ba 2033 3003] end it "apostrophes" do - assert_equal_encoded "'", %w{0027 02b9 02bc 02c8 2032} + assert_equal_encoded "'", %w[0027 02b9 02bc 02c8 2032] end it "asterisks" do - assert_equal_encoded "*", %w{002a 066d 204e 2217 26b9 2731} + assert_equal_encoded "*", %w[002a 066d 204e 2217 26b9 2731] end it "commas" do - assert_equal_encoded ",", %w{002c 060c} + assert_equal_encoded ",", %w[002c 060c] end it "periods" do - assert_equal_encoded ".", %w{002e 06d4} + assert_equal_encoded ".", %w[002e 06d4] end it "hyphens" do - assert_equal_encoded "-", %w{002d 2010 2011 2012 2013 2212} + assert_equal_encoded "-", %w[002d 2010 2011 2012 2013 2212] end it "slashes" do - assert_equal_encoded "/", %w{002f 2044 2215} - assert_equal_encoded "\\", %w{005c 2216} + assert_equal_encoded "/", %w[002f 2044 2215] + assert_equal_encoded "\\", %w[005c 2216] end it "colons" do - assert_equal_encoded ":", %w{003a 2236} + assert_equal_encoded ":", %w[003a 2236] end it "semicolons" do - assert_equal_encoded ";", %w{003b 061b} + assert_equal_encoded ";", %w[003b 061b] end it "less_thans" do - assert_equal_encoded "<", %w{003c 2039 2329 27e8 3008} + assert_equal_encoded "<", %w[003c 2039 2329 27e8 3008] end it "equals" do @@ -90,52 +90,52 @@ describe "BasicLatin" do end it "greater_thans" do - assert_equal_encoded ">", %w{003e 203a 232a 27e9 3009} + assert_equal_encoded ">", %w[003e 203a 232a 27e9 3009] end it "question_marks" do - assert_equal_encoded "?", %w{003f 061f} + assert_equal_encoded "?", %w[003f 061f] assert_equal_encoded "", "00bf" - assert_equal_encoded "?!", %w{203d 2048} + assert_equal_encoded "?!", %w[203d 2048] assert_equal_encoded "!?", "2049" end it "circumflexes" do - assert_equal_encoded "^", %w{005e 2038 2303} + assert_equal_encoded "^", %w[005e 2038 2303] end it "underscores" do - assert_equal_encoded "_", %w{005f 02cd 2017} + assert_equal_encoded "_", %w[005f 02cd 2017] end it "grave_accents" do - assert_equal_encoded "`", %w{0060 02cb 2035} + assert_equal_encoded "`", %w[0060 02cb 2035] end it "bars" do - assert_equal_encoded "|", %w{007c 2223 2758} + assert_equal_encoded "|", %w[007c 2223 2758] end it "tildes" do - assert_equal_encoded "~", %w{007e 02dc 2053 223c ff5e} + assert_equal_encoded "~", %w[007e 02dc 2053 223c ff5e] end it "related_letters" do { "B" => "212c", - "C" => %w{2102 212d}, - "E" => %w{2107 2130}, + "C" => %w[2102 212d], + "E" => %w[2107 2130], "F" => "2131", - "H" => %w{210b 210c 210d}, - "I" => %w{0130 0406 04c0 2110 2111 2160}, + "H" => %w[210b 210c 210d], + "I" => %w[0130 0406 04c0 2110 2111 2160], "K" => "212a", "L" => "2112", "M" => "2133", "N" => "2115", "P" => "2119", "Q" => "211a", - "R" => %w{211b 211c 211d}, - "Z" => %w{2124 2128} + "R" => %w[211b 211c 211d], + "Z" => %w[2124 2128] }.each do |expected, encode_mes| assert_equal_encoded expected, encode_mes end diff --git a/gems/canvas_text_helper/canvas_text_helper.gemspec b/gems/canvas_text_helper/canvas_text_helper.gemspec index faf99a8bfd1..3739bf306bc 100644 --- a/gems/canvas_text_helper/canvas_text_helper.gemspec +++ b/gems/canvas_text_helper/canvas_text_helper.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["kromney@instructure.com", "nathanm@instructure.com"] spec.summary = 'Canvas text helpers' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_time/canvas_time.gemspec b/gems/canvas_time/canvas_time.gemspec index a6abf44a578..da7ddd3746a 100644 --- a/gems/canvas_time/canvas_time.gemspec +++ b/gems/canvas_time/canvas_time.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com"] spec.summary = 'Canvas Time' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/canvas_time/spec/canvas_time_spec.rb b/gems/canvas_time/spec/canvas_time_spec.rb index 7ad8766b38f..e03f1f4ea36 100644 --- a/gems/canvas_time/spec/canvas_time_spec.rb +++ b/gems/canvas_time/spec/canvas_time_spec.rb @@ -34,7 +34,7 @@ describe 'Time Marshal override' do dumped = Marshal.dump(raw_time) # the last character differs between ruby 1.9 and ruby 2.1 expect(dumped[0..-2]).to eq("\x04\bIu:\tTime!pre1900:0010-05-13T04:12:51Z\x06:\x06E") - expect(%w{F T}).to be_include(dumped[-1]) + expect(%w[F T]).to be_include(dumped[-1]) dumped[-1] = 'F' reloaded = Marshal.load(dumped) expect(reloaded).to eq(raw_time) diff --git a/gems/canvas_unzip/canvas_unzip.gemspec b/gems/canvas_unzip/canvas_unzip.gemspec index 31f9e3a8f38..213bd7b22bd 100644 --- a/gems/canvas_unzip/canvas_unzip.gemspec +++ b/gems/canvas_unzip/canvas_unzip.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["jeremy@instructure.com"] spec.summary = 'Safe archive extraction' - spec.files = Dir.glob("{lib,test}/**/*") + %w(Rakefile) + spec.files = Dir.glob("{lib,test}/**/*") + %w[Rakefile] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/config_file/config_file.gemspec b/gems/config_file/config_file.gemspec index 61db7e772e8..ae42010a7a4 100644 --- a/gems/config_file/config_file.gemspec +++ b/gems/config_file/config_file.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["evizitei@instructure.com"] spec.summary = 'Instructure gem for loading config info from yaml on disk' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/csv_diff/csv_diff.gemspec b/gems/csv_diff/csv_diff.gemspec index ac8335e6090..eb216cd9b2d 100644 --- a/gems/csv_diff/csv_diff.gemspec +++ b/gems/csv_diff/csv_diff.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.email = ["brianp@instructure.com"] spec.summary = 'Generate CSV diffs' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/diigo/diigo.gemspec b/gems/diigo/diigo.gemspec index 13db4932813..c97d61c3a06 100644 --- a/gems/diigo/diigo.gemspec +++ b/gems/diigo/diigo.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["brian@instructure.com"] spec.summary = 'Diigo' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/dr_diff/lib/dr_diff/manager.rb b/gems/dr_diff/lib/dr_diff/manager.rb index 14c6d29403d..154ec7e37dc 100644 --- a/gems/dr_diff/lib/dr_diff/manager.rb +++ b/gems/dr_diff/lib/dr_diff/manager.rb @@ -31,7 +31,7 @@ module DrDiff private :severe_anywhere # all levels: %w(error warn info) - SEVERE_LEVELS = %w(error warn).freeze + SEVERE_LEVELS = %w[error warn].freeze def initialize(git: nil, git_dir: nil, sha: nil, campsite: true, heavy: false, base_dir: nil, severe_anywhere: true) @git_dir = git_dir diff --git a/gems/dr_diff/spec/manager_spec.rb b/gems/dr_diff/spec/manager_spec.rb index 1711132c811..eeeb5ba9be9 100644 --- a/gems/dr_diff/spec/manager_spec.rb +++ b/gems/dr_diff/spec/manager_spec.rb @@ -23,8 +23,8 @@ module DrDiff describe Manager do describe ".files" do let(:git_files_output) do - %{lib/dr_diff.rb -spec/dr_diff_spec.rb} + %(lib/dr_diff.rb +spec/dr_diff_spec.rb) end let(:file_list) { git_files_output.split("\n") } diff --git a/gems/dynamic_settings/dynamic_settings.gemspec b/gems/dynamic_settings/dynamic_settings.gemspec index dcfc2c09164..fe3ba869fcc 100644 --- a/gems/dynamic_settings/dynamic_settings.gemspec +++ b/gems/dynamic_settings/dynamic_settings.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["jburroughs@instructure.com", "evizitei@instructure.com"] spec.summary = 'Instructure gem for loading config and settings from consul' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/dynamic_settings/lib/dynamic_settings.rb b/gems/dynamic_settings/lib/dynamic_settings.rb index 8aee2cb71e9..d8f81e5140a 100644 --- a/gems/dynamic_settings/lib/dynamic_settings.rb +++ b/gems/dynamic_settings/lib/dynamic_settings.rb @@ -28,7 +28,7 @@ require 'dynamic_settings/fallback_proxy' require 'dynamic_settings/prefix_proxy' module DynamicSettings - CONSUL_READ_OPTIONS = %i{recurse stale}.freeze + CONSUL_READ_OPTIONS = %i[recurse stale].freeze KV_NAMESPACE = "config/canvas" CACHE_KEY_PREFIX = "dynamic_settings/" diff --git a/gems/event_stream/event_stream.gemspec b/gems/event_stream/event_stream.gemspec index e43803dd919..001b54dc339 100644 --- a/gems/event_stream/event_stream.gemspec +++ b/gems/event_stream/event_stream.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["evizitei@instructure.com"] spec.summary = 'Instructure event stream gem' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/google_drive/google_drive.gemspec b/gems/google_drive/google_drive.gemspec index 7b052ddfa9b..a9c0fae14e0 100644 --- a/gems/google_drive/google_drive.gemspec +++ b/gems/google_drive/google_drive.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["brad@instructure.com"] spec.summary = 'Google Drive' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/google_drive/lib/google_drive/client.rb b/gems/google_drive/lib/google_drive/client.rb index 3f6d6e5d3d2..3222c2a3b8e 100644 --- a/gems/google_drive/lib/google_drive/client.rb +++ b/gems/google_drive/lib/google_drive/client.rb @@ -39,7 +39,7 @@ module GoogleDrive client.authorization.redirect_uri = client_secrets['redirect_uri'] client.authorization.refresh_token = refresh_token if refresh_token client.authorization.access_token = access_token if access_token - client.authorization.scope = %w{https://www.googleapis.com/auth/drive} + client.authorization.scope = %w[https://www.googleapis.com/auth/drive] client end diff --git a/gems/google_drive/lib/google_drive/entry.rb b/gems/google_drive/lib/google_drive/entry.rb index cc039375ad0..1f3489e9586 100644 --- a/gems/google_drive/lib/google_drive/entry.rb +++ b/gems/google_drive/lib/google_drive/entry.rb @@ -103,7 +103,7 @@ module GoogleDrive def preferred_mime_types # Order is important # we return the first matching mime type - %w{ + %w[ application/vnd.openxmlformats-officedocument.wordprocessingml.document application/vnd.oasis.opendocument.text application/vnd.openxmlformats-officedocument.presentationml.presentation @@ -111,7 +111,7 @@ module GoogleDrive application/x-vnd.oasis.opendocument.spreadsheet application/pdf application/zip - } + ] end end end diff --git a/gems/html_text_helper/html_text_helper.gemspec b/gems/html_text_helper/html_text_helper.gemspec index ba4f73fdd73..e60a992f478 100644 --- a/gems/html_text_helper/html_text_helper.gemspec +++ b/gems/html_text_helper/html_text_helper.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["zachp@instructure.com", "stephan@pivotallabs.com"] spec.summary = 'Html text helpers' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/i18n_extraction/i18n_extraction.gemspec b/gems/i18n_extraction/i18n_extraction.gemspec index 70f6c99c1ec..bdfb21febc4 100644 --- a/gems/i18n_extraction/i18n_extraction.gemspec +++ b/gems/i18n_extraction/i18n_extraction.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com"] spec.summary = 'i18n extraction for Instructure' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/i18n_tasks/i18n_tasks.gemspec b/gems/i18n_tasks/i18n_tasks.gemspec index fb02c92edb7..355304292f0 100644 --- a/gems/i18n_tasks/i18n_tasks.gemspec +++ b/gems/i18n_tasks/i18n_tasks.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com", "stephan@pivotallabs.com"] spec.summary = 'Instructure i18n tasks gem' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/i18n_tasks/lib/tasks/i18n.rake b/gems/i18n_tasks/lib/tasks/i18n.rake index 2eba3ba1e4c..94759b0fb9a 100755 --- a/gems/i18n_tasks/lib/tasks/i18n.rake +++ b/gems/i18n_tasks/lib/tasks/i18n.rake @@ -58,14 +58,14 @@ namespace :i18n do yaml_dir = './config/locales/generated' FileUtils.mkdir_p(File.join(yaml_dir)) yaml_file = File.join(yaml_dir, "en.yml") - special_keys = %w{ + special_keys = %w[ locales crowdsourced custom bigeasy_locale fullcalendar_locale moment_locale - }.freeze + ].freeze Rails.root.join(yaml_file).open("w") do |file| file.write( @@ -445,7 +445,7 @@ namespace :i18n do languages.split(',') end else - %w(ar zh fr ja pt es ru) + %w[ar zh fr ja pt es ru] end end diff --git a/gems/incoming_mail_processor/incoming_mail_processor.gemspec b/gems/incoming_mail_processor/incoming_mail_processor.gemspec index bc71f9a6e64..40affa40c72 100644 --- a/gems/incoming_mail_processor/incoming_mail_processor.gemspec +++ b/gems/incoming_mail_processor/incoming_mail_processor.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["jonw@instructure.com"] spec.summary = 'Read mail from IMAP inbox and process it.' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/incoming_mail_processor/lib/incoming_mail_processor/incoming_message_processor.rb b/gems/incoming_mail_processor/lib/incoming_mail_processor/incoming_message_processor.rb index 70cf23714cb..70d209a64f6 100644 --- a/gems/incoming_mail_processor/lib/incoming_mail_processor/incoming_message_processor.rb +++ b/gems/incoming_mail_processor/lib/incoming_mail_processor/incoming_message_processor.rb @@ -31,7 +31,7 @@ module IncomingMailProcessor :sqs => IncomingMailProcessor::SqsMailbox, }.freeze - ImportantHeaders = %w(To From Subject Content-Type).freeze + ImportantHeaders = %w[To From Subject Content-Type].freeze BULK_PRECEDENCE_VALUES = %w[bulk list junk].freeze private_constant :BULK_PRECEDENCE_VALUES diff --git a/gems/incoming_mail_processor/lib/incoming_mail_processor/sqs_mailbox.rb b/gems/incoming_mail_processor/lib/incoming_mail_processor/sqs_mailbox.rb index f17cceedb53..73c798e141d 100644 --- a/gems/incoming_mail_processor/lib/incoming_mail_processor/sqs_mailbox.rb +++ b/gems/incoming_mail_processor/lib/incoming_mail_processor/sqs_mailbox.rb @@ -28,7 +28,7 @@ module IncomingMailProcessor attr_reader :config - POLL_PARAMS = %i{idle_timeout wait_time_seconds visibility_timeout}.freeze + POLL_PARAMS = %i[idle_timeout wait_time_seconds visibility_timeout].freeze def initialize(opts = {}) @config = opts diff --git a/gems/incoming_mail_processor/spec/incoming_mail_processor/directory_mailbox_spec.rb b/gems/incoming_mail_processor/spec/incoming_mail_processor/directory_mailbox_spec.rb index 194da3eb2bc..46f4e414d5e 100644 --- a/gems/incoming_mail_processor/spec/incoming_mail_processor/directory_mailbox_spec.rb +++ b/gems/incoming_mail_processor/spec/incoming_mail_processor/directory_mailbox_spec.rb @@ -46,7 +46,7 @@ describe IncomingMailProcessor::DirectoryMailbox do describe ".each_message" do it "iterates through and yield files in a directory" do folder = default_config[:folder] - folder_entries = %w(. .. foo bar baz) + folder_entries = %w[. .. foo bar baz] expect(@mailbox).to receive(:files_in_folder).with(folder).and_return(folder_entries) folder_entries.each do |entry| expect(@mailbox).to receive(:file?).with(folder, entry).and_return(!entry.include?('.')) @@ -65,7 +65,7 @@ describe IncomingMailProcessor::DirectoryMailbox do it "iterates with stride and offset" do folder = default_config[:folder] - folder_entries = %w(. .. foo bar baz) + folder_entries = %w[. .. foo bar baz] expect(@mailbox).to receive(:files_in_folder).with(folder).twice.and_return(folder_entries) folder_entries.each do |entry| expect(@mailbox).to receive(:file?).with(folder, entry).and_return(!entry.include?('.')) diff --git a/gems/json_token/json_token.gemspec b/gems/json_token/json_token.gemspec index 2bdf684eb1a..3583f7bd495 100644 --- a/gems/json_token/json_token.gemspec +++ b/gems/json_token/json_token.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["nickc@instructure.com", "jrodriguez@pivotallabs.com"] spec.summary = 'Convenience methods for encoding and decoding a slug of data into base64 encoded JSON' - spec.files = Dir.glob("{lib}/**/*") + %w(Rakefile) + spec.files = Dir.glob("{lib}/**/*") + %w[Rakefile] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/linked_in/linked_in.gemspec b/gems/linked_in/linked_in.gemspec index 17ad8a405e4..b5f86a64551 100644 --- a/gems/linked_in/linked_in.gemspec +++ b/gems/linked_in/linked_in.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["brian@instructure.com"] spec.summary = 'LinkedIn' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/live_events/live_events.gemspec b/gems/live_events/live_events.gemspec index e7c24d101a1..b345efe95cb 100644 --- a/gems/live_events/live_events.gemspec +++ b/gems/live_events/live_events.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["zach@instructure.com"] spec.summary = 'LiveEvents' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/lti-advantage/lib/lti_advantage/serializers/jwt_message_serializer.rb b/gems/lti-advantage/lib/lti_advantage/serializers/jwt_message_serializer.rb index 4bad40c51d0..251507c34d3 100644 --- a/gems/lti-advantage/lib/lti_advantage/serializers/jwt_message_serializer.rb +++ b/gems/lti-advantage/lib/lti_advantage/serializers/jwt_message_serializer.rb @@ -24,7 +24,7 @@ module LtiAdvantage::Serializers NRPS_CLAIM_URL = 'https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice' AGS_CLAIM_URL = 'https://purl.imsglobal.org/spec/lti-ags/claim/endpoint' - STANDARD_IMS_CLAIMS = %w( + STANDARD_IMS_CLAIMS = %w[ context custom deployment_id @@ -39,12 +39,12 @@ module LtiAdvantage::Serializers target_link_uri lti11_legacy_user_id lti1p1 - ).freeze + ].freeze - DEEP_LINKING_CLAIMS = %w( + DEEP_LINKING_CLAIMS = %w[ deep_linking_settings content_items - ).freeze + ].freeze NAMES_AND_ROLES_SERVICE_CLAIM = 'names_and_roles_service' ASSIGNMENT_AND_GRADE_SERVICE_CLAIM = 'assignment_and_grade_service' diff --git a/gems/lti-advantage/lti-advantage.gemspec b/gems/lti-advantage/lti-advantage.gemspec index f0f18211d5c..8339c543f56 100644 --- a/gems/lti-advantage/lti-advantage.gemspec +++ b/gems/lti-advantage/lti-advantage.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| "public gem pushes." end - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] diff --git a/gems/lti_outbound/lti_outbound.gemspec b/gems/lti_outbound/lti_outbound.gemspec index b0b367dfc82..5245f35561a 100644 --- a/gems/lti_outbound/lti_outbound.gemspec +++ b/gems/lti_outbound/lti_outbound.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.homepage = 'https://github.com/instructure/canvas-lms' spec.license = 'AGPL' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(LICENSE.txt Rakefile README.md test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE.txt Rakefile README.md test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] diff --git a/gems/multipart/multipart.gemspec b/gems/multipart/multipart.gemspec index c533af862e3..8872164a2f7 100644 --- a/gems/multipart/multipart.gemspec +++ b/gems/multipart/multipart.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com"] spec.summary = 'Multipart helper to prepare an HTTP POST request with file upload' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/paginated_collection/paginated_collection.gemspec b/gems/paginated_collection/paginated_collection.gemspec index 4af98e6b90f..148fddd1937 100644 --- a/gems/paginated_collection/paginated_collection.gemspec +++ b/gems/paginated_collection/paginated_collection.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["brianp@instructure.com"] spec.summary = 'Paginated Collection gem' - spec.files = Dir.glob("{lib}/**/*") + %w(Rakefile) + spec.files = Dir.glob("{lib}/**/*") + %w[Rakefile] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/paginated_collection/spec/paginated_collection/paginated_collection_spec.rb b/gems/paginated_collection/spec/paginated_collection/paginated_collection_spec.rb index 70dee28b7d8..d70ad21fc72 100644 --- a/gems/paginated_collection/spec/paginated_collection/paginated_collection_spec.rb +++ b/gems/paginated_collection/spec/paginated_collection/paginated_collection_spec.rb @@ -40,7 +40,7 @@ describe PaginatedCollection do expect(items.current_page).to eq 1 expect(items.per_page).to eq 5 expect(items.last_page).to eq 1 - %w(first_page next_page previous_page total_entries).each do |a| + %w[first_page next_page previous_page total_entries].each do |a| expect(items.send(a)).to be_nil end end diff --git a/gems/plugins/academic_benchmark/lib/academic_benchmark/engine.rb b/gems/plugins/academic_benchmark/lib/academic_benchmark/engine.rb index 11ceee3406f..257a6465701 100644 --- a/gems/plugins/academic_benchmark/lib/academic_benchmark/engine.rb +++ b/gems/plugins/academic_benchmark/lib/academic_benchmark/engine.rb @@ -35,7 +35,7 @@ module AcademicBenchmark :worker => 'CCWorker', :converter_class => AcademicBenchmark::Converter, :provides => { :academic_benchmark => AcademicBenchmark::Converter }, - :valid_contexts => %w{Account} + :valid_contexts => %w[Account] } } end diff --git a/gems/plugins/account_reports/lib/account_reports/outcome_export.rb b/gems/plugins/account_reports/lib/account_reports/outcome_export.rb index b033a683015..c81b7617064 100644 --- a/gems/plugins/account_reports/lib/account_reports/outcome_export.rb +++ b/gems/plugins/account_reports/lib/account_reports/outcome_export.rb @@ -29,8 +29,8 @@ module AccountReports include_deleted_objects end - NO_SCORE_HEADERS = %w(vendor_guid object_type title description display_name parent_guids workflow_state).freeze - OUTCOME_EXPORT_SCALAR_HEADERS = %w(vendor_guid object_type title description display_name calculation_method calculation_int parent_guids workflow_state mastery_points).freeze + NO_SCORE_HEADERS = %w[vendor_guid object_type title description display_name parent_guids workflow_state].freeze + OUTCOME_EXPORT_SCALAR_HEADERS = %w[vendor_guid object_type title description display_name calculation_method calculation_int parent_guids workflow_state mastery_points].freeze OUTCOME_EXPORT_HEADERS = (OUTCOME_EXPORT_SCALAR_HEADERS + ['ratings']).freeze def outcome_export diff --git a/gems/plugins/account_reports/lib/account_reports/outcome_reports.rb b/gems/plugins/account_reports/lib/account_reports/outcome_reports.rb index 526f1075c1a..b378d350059 100644 --- a/gems/plugins/account_reports/lib/account_reports/outcome_reports.rb +++ b/gems/plugins/account_reports/lib/account_reports/outcome_reports.rb @@ -116,66 +116,70 @@ module AccountReports :root_account_id => root_account.id } students = root_account.pseudonyms.except(:preload) - .select(%{ - pseudonyms.id, - u.sortable_name AS "student name", - pseudonyms.user_id AS "student id", - pseudonyms.sis_user_id AS "student sis id", - a.title AS "assignment title", - a.id AS "assignment id", - sub.submitted_at AS "submission date", - sub.score AS "submission score", - lo.short_description AS "learning outcome name", - lo.id AS "learning outcome id", - lo.display_name AS "learning outcome friendly name", - lo.data AS "learning outcome data", - r.attempt AS "attempt", - r.hide_points AS "learning outcome points hidden", - r.score AS "outcome score", - r.possible AS "learning outcome points possible", - r.mastery AS "learning outcome mastered", - c.name AS "course name", - c.id AS "course id", - c.sis_source_id AS "course sis id", - s.name AS "section name", - s.id AS "section id", - s.sis_source_id AS "section sis id", - e.workflow_state AS "enrollment state", - lo.context_id AS "outcome context id", - lo.context_type AS "outcome context type", - acct.id AS "account id", - acct.name AS "account name"}) - .joins(Pseudonym.send(:sanitize_sql, [" - INNER JOIN #{User.quoted_table_name} u ON pseudonyms.user_id = u.id - INNER JOIN ( - SELECT user_id, course_id, course_section_id, workflow_state - FROM #{Enrollment.quoted_table_name} - WHERE type = 'StudentEnrollment' - AND root_account_id = :root_account_id - " + (@include_deleted ? "" : "AND workflow_state <> 'deleted'") + " - GROUP BY user_id, course_id, course_section_id, workflow_state - ) e ON pseudonyms.user_id = e.user_id - INNER JOIN #{Course.quoted_table_name} c ON c.id = e.course_id - AND c.root_account_id = :root_account_id - INNER JOIN #{Account.quoted_table_name} acct ON acct.id = c.account_id - INNER JOIN #{CourseSection.quoted_table_name} s ON s.id = e.course_section_id - INNER JOIN #{Assignment.quoted_table_name} a ON (a.context_id = c.id - AND a.context_type = 'Course') - INNER JOIN #{ContentTag.quoted_table_name} ct ON (ct.content_id = a.id - AND ct.content_type = 'Assignment') - INNER JOIN #{LearningOutcome.quoted_table_name} lo ON lo.id = ct.learning_outcome_id - INNER JOIN #{ContentTag.quoted_table_name} lol ON lol.content_id = lo.id - AND lol.context_id = :account_id - AND lol.context_type = 'Account' - AND lol.tag_type = 'learning_outcome_association' - AND lol.workflow_state != 'deleted' - LEFT JOIN #{LearningOutcomeResult.quoted_table_name} r ON (r.user_id=pseudonyms.user_id - AND r.content_tag_id = ct.id) - LEFT JOIN #{Submission.quoted_table_name} sub ON sub.assignment_id = a.id - AND sub.user_id = pseudonyms.user_id AND sub.workflow_state <> 'deleted' - AND sub.workflow_state <> 'unsubmitted'", parameters])) - .where("ct.tag_type = 'learning_outcome' AND ct.workflow_state <> 'deleted' - AND (r.id IS NULL OR (r.workflow_state <> 'deleted' AND r.artifact_type IS NOT NULL AND r.artifact_type <> 'Submission'))") + .select(<<~SQL.squish) + pseudonyms.id, + u.sortable_name AS "student name", + pseudonyms.user_id AS "student id", + pseudonyms.sis_user_id AS "student sis id", + a.title AS "assignment title", + a.id AS "assignment id", + sub.submitted_at AS "submission date", + sub.score AS "submission score", + lo.short_description AS "learning outcome name", + lo.id AS "learning outcome id", + lo.display_name AS "learning outcome friendly name", + lo.data AS "learning outcome data", + r.attempt AS "attempt", + r.hide_points AS "learning outcome points hidden", + r.score AS "outcome score", + r.possible AS "learning outcome points possible", + r.mastery AS "learning outcome mastered", + c.name AS "course name", + c.id AS "course id", + c.sis_source_id AS "course sis id", + s.name AS "section name", + s.id AS "section id", + s.sis_source_id AS "section sis id", + e.workflow_state AS "enrollment state", + lo.context_id AS "outcome context id", + lo.context_type AS "outcome context type", + acct.id AS "account id", + acct.name AS "account name" + SQL + .joins(Pseudonym.send(:sanitize_sql, [<<~SQL.squish, parameters])) + INNER JOIN #{User.quoted_table_name} u ON pseudonyms.user_id = u.id + INNER JOIN ( + SELECT user_id, course_id, course_section_id, workflow_state + FROM #{Enrollment.quoted_table_name} + WHERE type = 'StudentEnrollment' + AND root_account_id = :root_account_id + #{"AND workflow_state <> 'deleted'" unless @include_deleted} + GROUP BY user_id, course_id, course_section_id, workflow_state + ) e ON pseudonyms.user_id = e.user_id + INNER JOIN #{Course.quoted_table_name} c ON c.id = e.course_id + AND c.root_account_id = :root_account_id + INNER JOIN #{Account.quoted_table_name} acct ON acct.id = c.account_id + INNER JOIN #{CourseSection.quoted_table_name} s ON s.id = e.course_section_id + INNER JOIN #{Assignment.quoted_table_name} a ON (a.context_id = c.id + AND a.context_type = 'Course') + INNER JOIN #{ContentTag.quoted_table_name} ct ON (ct.content_id = a.id + AND ct.content_type = 'Assignment') + INNER JOIN #{LearningOutcome.quoted_table_name} lo ON lo.id = ct.learning_outcome_id + INNER JOIN #{ContentTag.quoted_table_name} lol ON lol.content_id = lo.id + AND lol.context_id = :account_id + AND lol.context_type = 'Account' + AND lol.tag_type = 'learning_outcome_association' + AND lol.workflow_state != 'deleted' + LEFT JOIN #{LearningOutcomeResult.quoted_table_name} r ON (r.user_id=pseudonyms.user_id + AND r.content_tag_id = ct.id) + LEFT JOIN #{Submission.quoted_table_name} sub ON sub.assignment_id = a.id + AND sub.user_id = pseudonyms.user_id AND sub.workflow_state <> 'deleted' + AND sub.workflow_state <> 'unsubmitted' + SQL + .where(<<~SQL.squish) + ct.tag_type = 'learning_outcome' AND ct.workflow_state <> 'deleted' + AND (r.id IS NULL OR (r.workflow_state <> 'deleted' AND r.artifact_type IS NOT NULL AND r.artifact_type <> 'Submission')) + SQL unless @include_deleted students = students.where("pseudonyms.workflow_state<>'deleted' AND c.workflow_state IN ('available', 'completed')") @@ -261,7 +265,7 @@ module AccountReports def outcome_order param = @account_report.value_for_param('order') param = param.downcase if param - order_options = %w(users courses outcomes) + order_options = %w[users courses outcomes] select = order_options & [param] order_sql = { 'users' => 'u.id, learning_outcomes.id, c.id', diff --git a/gems/plugins/account_reports/lib/account_reports/report_helper.rb b/gems/plugins/account_reports/lib/account_reports/report_helper.rb index 43bf727fe1d..0480333071b 100644 --- a/gems/plugins/account_reports/lib/account_reports/report_helper.rb +++ b/gems/plugins/account_reports/lib/account_reports/report_helper.rb @@ -274,7 +274,7 @@ module AccountReports::ReportHelper end def valid_enrollment_workflow_states - %w(invited creation_pending active completed inactive deleted rejected).freeze & + %w[invited creation_pending active completed inactive deleted rejected].freeze & Api.value_to_array(@account_report.parameters["enrollment_states"]) end diff --git a/gems/plugins/account_reports/spec_canvas/sis_provisioning_reports_spec.rb b/gems/plugins/account_reports/spec_canvas/sis_provisioning_reports_spec.rb index 067bbd988e9..c600fb077d4 100644 --- a/gems/plugins/account_reports/spec_canvas/sis_provisioning_reports_spec.rb +++ b/gems/plugins/account_reports/spec_canvas/sis_provisioning_reports_spec.rb @@ -320,11 +320,11 @@ describe "Default Account Reports" do header = case format when 'sis' - %w(user_id integration_id authentication_provider_id login_id password first_name last_name - full_name sortable_name short_name email status) + %w[user_id integration_id authentication_provider_id login_id password first_name last_name + full_name sortable_name short_name email status] when 'provisioning' - %w(canvas_user_id user_id integration_id authentication_provider_id login_id first_name last_name - full_name sortable_name short_name email status created_by_sis) + %w[canvas_user_id user_id integration_id authentication_provider_id login_id first_name last_name + full_name sortable_name short_name email status created_by_sis] end header << 'pronouns' if @report.should_add_pronouns? header diff --git a/gems/plugins/moodle_importer/lib/moodle_importer/engine.rb b/gems/plugins/moodle_importer/lib/moodle_importer/engine.rb index eafdc0f23c4..d8bab860314 100644 --- a/gems/plugins/moodle_importer/lib/moodle_importer/engine.rb +++ b/gems/plugins/moodle_importer/lib/moodle_importer/engine.rb @@ -36,7 +36,7 @@ module Moodle :migration_partial => 'moodle_config', :worker => 'CCWorker', :provides => { :moodle_1_9 => Moodle::Converter, :moodle_2 => Moodle::Converter }, - :valid_contexts => %w{Account Course} + :valid_contexts => %w[Account Course] } } end diff --git a/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb b/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb index 3fbbf2fc815..3722a69560a 100644 --- a/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb +++ b/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb @@ -148,7 +148,7 @@ module Qti if @migration_type and UNSUPPORTED_TYPES.member?(@migration_type) @question[:question_type] = @migration_type @question[:unsupported] = true - elsif !%w(text_only_question file_upload_question).include?(@migration_type) + elsif !%w[text_only_question file_upload_question].include?(@migration_type) self.parse_question_data else self.get_feedback if @migration_type == 'file_upload_question' diff --git a/gems/plugins/qti_exporter/lib/qti_exporter/engine.rb b/gems/plugins/qti_exporter/lib/qti_exporter/engine.rb index 9f365e90225..2a93392122d 100644 --- a/gems/plugins/qti_exporter/lib/qti_exporter/engine.rb +++ b/gems/plugins/qti_exporter/lib/qti_exporter/engine.rb @@ -39,7 +39,7 @@ module QtiExporter :requires_file_upload => true, :provides => { :qti => Qti::Converter, :webct => Qti::Converter, }, # It can import WebCT Quizzes - :valid_contexts => %w{Account Course} + :valid_contexts => %w[Account Course] }, :validator => 'QtiPluginValidator' } diff --git a/gems/plugins/qti_exporter/spec_canvas/lib/qti/assessment_test_converter_spec.rb b/gems/plugins/qti_exporter/spec_canvas/lib/qti/assessment_test_converter_spec.rb index a59e7b7589d..190de4c3476 100644 --- a/gems/plugins/qti_exporter/spec_canvas/lib/qti/assessment_test_converter_spec.rb +++ b/gems/plugins/qti_exporter/spec_canvas/lib/qti/assessment_test_converter_spec.rb @@ -41,7 +41,7 @@ describe Qti::AssessmentTestConverter do def test_section(select) Nokogiri::XML(<<~XML).at_css('testPart') - #{select && %Q{}} + #{select && %Q()} XML end diff --git a/gems/plugins/qti_exporter/spec_canvas/qti_exporter_spec.rb b/gems/plugins/qti_exporter/spec_canvas/qti_exporter_spec.rb index 03a691dab9a..f6966760456 100644 --- a/gems/plugins/qti_exporter/spec_canvas/qti_exporter_spec.rb +++ b/gems/plugins/qti_exporter/spec_canvas/qti_exporter_spec.rb @@ -337,7 +337,7 @@ if Qti.migration_executable expect(d['answers'].map { |a| a['weight'] }).to eq [0, 100, 0] expect(d['answers'].map { |a| a['comments'] }).to eq ['nope', 'yes!', nil] attachment = @course.attachments.detect { |a| a.filename == 'smiley.jpg' } - expect(d['answers'].map { |a| a['comments_html'] }).to eq [nil, %{yes! }, nil] + expect(d['answers'].map { |a| a['comments_html'] }).to eq [nil, %(yes! ), nil] end it "imports respondus question types" do diff --git a/gems/plugins/respondus_soap_endpoint/lib/respondus_soap_endpoint/urn_RespondusAPIServant.rb b/gems/plugins/respondus_soap_endpoint/lib/respondus_soap_endpoint/urn_RespondusAPIServant.rb index f07d33ec606..f525dd9acba 100644 --- a/gems/plugins/respondus_soap_endpoint/lib/respondus_soap_endpoint/urn_RespondusAPIServant.rb +++ b/gems/plugins/respondus_soap_endpoint/lib/respondus_soap_endpoint/urn_RespondusAPIServant.rb @@ -107,7 +107,7 @@ module RespondusSoapEndpoint end def load_user(method, userName, password) - return nil if %w(identifyServer).include?(method.to_s) + return nil if %w[identifyServer].include?(method.to_s) domain_root_account = rack_env['canvas.domain_root_account'] || Account.default if userName == OAUTH_TOKEN_USERNAME @@ -142,7 +142,7 @@ module RespondusSoapEndpoint userName, password, context, *args = args Rails.logger.debug "\nProcessing RespondusSoapApi##{method} (for #{rack_env['REMOTE_ADDR']} at #{Time.now}) [SOAP]" log_args = args.dup - log_args.pop if %w(publishServerItem replaceServerItem appendServerItem).include?(method.to_s) + log_args.pop if %w[publishServerItem replaceServerItem appendServerItem].include?(method.to_s) Rails.logger.debug "Parameters: #{([userName, "[FILTERED]", context] + log_args).inspect}" load_user(method, userName, password) load_session(context) @@ -203,10 +203,10 @@ module RespondusSoapEndpoint # identification C_String - {http://www.w3.org/2001/XMLSchema}string # def identifyServer(_userName, _password, _context) - [%{ + [%( Respondus Generic Server API Contract version: 1 -Implemented for: Canvas LMS}] +Implemented for: Canvas LMS)] end # SYNOPSIS @@ -535,7 +535,7 @@ Implemented for: Canvas LMS}] return poll_for_completion() end - unless %w(quiz qdb).include?(itemType) + unless %w[quiz qdb].include?(itemType) raise OtherError, "Invalid item type" end if uploadType != 'zipPackage' diff --git a/gems/plugins/respondus_soap_endpoint/spec_canvas/integration/respondus_endpoint_spec.rb b/gems/plugins/respondus_soap_endpoint/spec_canvas/integration/respondus_endpoint_spec.rb index 55a075f07a5..a580aa95309 100644 --- a/gems/plugins/respondus_soap_endpoint/spec_canvas/integration/respondus_endpoint_spec.rb +++ b/gems/plugins/respondus_soap_endpoint/spec_canvas/integration/respondus_endpoint_spec.rb @@ -72,10 +72,10 @@ describe "Respondus SOAP API", type: :request do it "identifies the server without user credentials" do soap_response = soap_request('IdentifyServer', '', '', '') expect(soap_response.first).to eq "Success" - expect(soap_response.last).to eq %{ + expect(soap_response.last).to eq %( Respondus Generic Server API Contract version: 1 -Implemented for: Canvas LMS} +Implemented for: Canvas LMS) end it "authenticates an existing user" do diff --git a/gems/request_context/request_context.gemspec b/gems/request_context/request_context.gemspec index 625d083b506..9332d76fff2 100644 --- a/gems/request_context/request_context.gemspec +++ b/gems/request_context/request_context.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["evizitei@instructure.com"] spec.summary = 'Instructure gem for managing http request metadata' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/rubocop-canvas/rubocop-canvas.gemspec b/gems/rubocop-canvas/rubocop-canvas.gemspec index ec236d304dd..b1fe5754dc4 100644 --- a/gems/rubocop-canvas/rubocop-canvas.gemspec +++ b/gems/rubocop-canvas/rubocop-canvas.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.email = ["brianp@instructure.com"] spec.summary = 'custom cops for canvas' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/rubocop-canvas/spec/rubocop/cop/lint/no_file_utils_rm_rf_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/lint/no_file_utils_rm_rf_spec.rb index e55b413a4c2..664ade8b676 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/lint/no_file_utils_rm_rf_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/lint/no_file_utils_rm_rf_spec.rb @@ -21,11 +21,11 @@ describe RuboCop::Cop::Lint::NoFileUtilsRmRf do subject(:cop) { described_class.new } it 'disallows FileUtils.rm_rf' do - inspect_source(%{ + inspect_source(<<~RUBY) def rm_sekrets FileUtils.rm_rf end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/avoid FileUtils.rm_rf/) expect(cop.offenses.first.severity.name).to eq(:warning) diff --git a/gems/rubocop-canvas/spec/rubocop/cop/lint/no_sleep_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/lint/no_sleep_spec.rb index 1933a812e83..34c776f9785 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/lint/no_sleep_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/lint/no_sleep_spec.rb @@ -26,13 +26,13 @@ describe RuboCop::Cop::Lint::NoSleep do end it 'disallows sleep' do - inspect_source(%{ + inspect_source(<<~RUBY) class KnightsController < ApplicationController def find_sword sleep 999 end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/tie up this process/) expect(cop.offenses.first.severity.name).to eq(:error) @@ -45,13 +45,13 @@ describe RuboCop::Cop::Lint::NoSleep do end it 'disallows sleep' do - inspect_source(%{ + inspect_source(<<~RUBY) describe "Alerts" do it "should validate the form" do sleep 2 end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/consider: Timecop/) expect(cop.offenses.first.severity.name).to eq(:warning) @@ -64,13 +64,13 @@ describe RuboCop::Cop::Lint::NoSleep do end it 'disallows sleep' do - inspect_source(%{ + inspect_source(<<~RUBY) class BookmarkService < UserService def find_bookmarks(query) sleep Time.now - last_get end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to eq("Avoid using sleep.") expect(cop.offenses.first.severity.name).to eq(:warning) diff --git a/gems/rubocop-canvas/spec/rubocop/cop/migration/non_transactional_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/migration/non_transactional_spec.rb index 217d558e2f1..c74f9e4e5df 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/migration/non_transactional_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/migration/non_transactional_spec.rb @@ -21,33 +21,33 @@ describe RuboCop::Cop::Migration::NonTransactional do subject(:cop) { described_class.new } it 'complains about concurrent indexes in ddl transaction' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration def up add_index :my_index, algorithm: :concurrently end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/disable_ddl/) expect(cop.offenses.first.severity.name).to eq(:warning) end it 'ignores non-concurrent indexes' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration def up add_index :my_index end end - }) + RUBY expect(cop.offenses.size).to eq(0) end it 'is ok with concurrent indexes added non-transactionally' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration disable_ddl_transaction! @@ -55,12 +55,12 @@ describe RuboCop::Cop::Migration::NonTransactional do add_index :my_index, algorithm: :concurrently, if_not_exists: true end end - }) + RUBY expect(cop.offenses.size).to eq(0) end it 'complains about missing if_not_exists for add_index' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration disable_ddl_transaction! @@ -68,14 +68,14 @@ describe RuboCop::Cop::Migration::NonTransactional do add_index :my_index end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/if_not_exists/) expect(cop.offenses.first.severity.name).to eq(:warning) end it 'complains about missing if_not_exists for add_column' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration disable_ddl_transaction! @@ -83,36 +83,36 @@ describe RuboCop::Cop::Migration::NonTransactional do add_column :table, :column, :type end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/if_not_exists/) expect(cop.offenses.first.severity.name).to eq(:warning) end it 'is ok about missing if_not_exists for add_index when transactional' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration def up add_index :my_index end end - }) + RUBY expect(cop.offenses.size).to eq(0) end it 'is ok about missing if_not_exists for add_column when transactional' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration def up add_column :table, :column, :type end end - }) + RUBY expect(cop.offenses.size).to eq(0) end it 'is ok about if_not_exists for add_index' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration disable_ddl_transaction! @@ -120,12 +120,12 @@ describe RuboCop::Cop::Migration::NonTransactional do add_index :my_index, if_not_exists: true end end - }) + RUBY expect(cop.offenses.size).to eq(0) end it 'is ok about if_not_exists for add_column' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration disable_ddl_transaction! @@ -133,12 +133,12 @@ describe RuboCop::Cop::Migration::NonTransactional do add_column :table, :column, :type, if_not_exists: true end end - }) + RUBY expect(cop.offenses.size).to eq(0) end it 'complains about missing if_exists on remove_foreign_key' do - inspect_source(%{ + inspect_source(<<~RUBY) class TestMigration < ActiveRecord::Migration disable_ddl_transaction! @@ -146,7 +146,7 @@ describe RuboCop::Cop::Migration::NonTransactional do remove_foreign_key :table, :column end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/if_exists/) expect(cop.offenses.first.severity.name).to eq(:warning) diff --git a/gems/rubocop-canvas/spec/rubocop/cop/migration/remove_column_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/migration/remove_column_spec.rb index 1b190ce4330..dfd69efbc98 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/migration/remove_column_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/migration/remove_column_spec.rb @@ -22,7 +22,7 @@ describe RuboCop::Cop::Migration::RemoveColumn do context 'predeploy' do it 'disallows remove_column in `up`' do - inspect_source(%{ + inspect_source(<<~RUBY) class MyMigration < ActiveRecord::Migration tag :predeploy @@ -30,14 +30,14 @@ describe RuboCop::Cop::Migration::RemoveColumn do remove_column :x, :y end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/column removal/) expect(cop.offenses.first.severity.name).to eq(:error) end it 'disallows remove_column in `self.up`' do - inspect_source(%{ + inspect_source(<<~RUBY) class MyMigration < ActiveRecord::Migration tag :predeploy @@ -45,14 +45,14 @@ describe RuboCop::Cop::Migration::RemoveColumn do remove_column :x, :y end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/column removal/) expect(cop.offenses.first.severity.name).to eq(:error) end it 'disallows remove_column in `change`' do - inspect_source(%{ + inspect_source(<<~RUBY) class MyMigration < ActiveRecord::Migration tag :predeploy @@ -60,14 +60,14 @@ describe RuboCop::Cop::Migration::RemoveColumn do remove_column :x, :y end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/column removal/) expect(cop.offenses.first.severity.name).to eq(:error) end it 'disallows a bunch of other column removal methods' do - inspect_source(%{ + inspect_source(<<~RUBY) class MyMigration < ActiveRecord::Migration tag :predeploy @@ -82,12 +82,12 @@ describe RuboCop::Cop::Migration::RemoveColumn do remove_columns :y, :z end end - }) + RUBY expect(cop.offenses.size).to eq(6) end it 'allows remove_column in `down`' do - inspect_source(%{ + inspect_source(<<~RUBY) class MyMigration < ActiveRecord::Migration tag :predeploy @@ -95,7 +95,7 @@ describe RuboCop::Cop::Migration::RemoveColumn do remove_column :x, :y end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end diff --git a/gems/rubocop-canvas/spec/rubocop/cop/specs/no_no_such_element_error_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/specs/no_no_such_element_error_spec.rb index 8ff081ce111..1e48e578c82 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/specs/no_no_such_element_error_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/specs/no_no_such_element_error_spec.rb @@ -23,40 +23,40 @@ describe RuboCop::Cop::Specs::NoNoSuchElementError do let(:msg_regex) { /Avoid using Selenium::WebDriver::Error::NoSuchElementError/ } it 'disallows Selenium::WebDriver::Error::NoSuchElementError' do - inspect_source(%{ + inspect_source(<<~RUBY) describe "breaks all the things" do it 'is a bad spec' do Selenium::WebDriver::Error::NoSuchElementError end end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(msg_regex) expect(cop.offenses.first.severity.name).to eq(:warning) end it 'disallows rescuing Selenium::WebDriver::Error::NoSuchElementError' do - inspect_source(%{ + inspect_source(<<~RUBY) def not_found? find("#yar") false rescue Selenium::WebDriver::Error::NoSuchElementError true end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(msg_regex) expect(cop.offenses.first.severity.name).to eq(:warning) end it 'disallows raising Selenium::WebDriver::Error::NoSuchElementError' do - inspect_source(%{ + inspect_source(<<~RUBY) def not_found? a = find("#yar") return true if a raise Selenium::WebDriver::Error::NoSuchElementError end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(msg_regex) expect(cop.offenses.first.severity.name).to eq(:warning) diff --git a/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_helper_modules_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_helper_modules_spec.rb index d21c71c93dc..0e43ceff2e2 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_helper_modules_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_helper_modules_spec.rb @@ -22,89 +22,89 @@ describe RuboCop::Cop::Specs::ScopeHelperModules do context "within class" do it 'allows defs' do - inspect_source(%{ + inspect_source(<<~RUBY) class CombatArmband def laserbeams "PEWPEWPEPWEPWPEW" end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end context "within context" do it 'allows defs' do - inspect_source(%{ + inspect_source(<<~RUBY) context "Jumpity JumpStick" do def jump_and_jab puts "heeeeeya!" end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end context "within describe" do it 'allows defs' do - inspect_source(%{ + inspect_source(<<~RUBY) describe JumpStick do def zappy_zap puts "yarrwafeiowhf" end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end context "within module" do it 'allows defs' do - inspect_source(%{ + inspect_source(<<~RUBY) module JumpStick def jumpy puts "vroom" puts "vroom" end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end context "within shared_context" do it 'allows defs' do - inspect_source(%{ + inspect_source(<<~RUBY) shared_context "in-process server selenium tests" do def bat_poo "splat!" end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end context "within shared_examples" do it 'allows defs' do - inspect_source(%{ + inspect_source(<<~RUBY) shared_examples '[:correct]' do def pirates "attaaaaaaaack!" end end - }) + RUBY expect(cop.offenses.size).to eq(0) end end it "disallows defs on Object" do - inspect_source(%{ + inspect_source(<<~RUBY) def crow_tornado_so_op puts "yoo" end - }) + RUBY expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/Define all helper/) expect(cop.offenses.first.severity.name).to eq(:warning) diff --git a/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_includes_spec.rb b/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_includes_spec.rb index 4c3c80ebe82..a38898a5d2c 100644 --- a/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_includes_spec.rb +++ b/gems/rubocop-canvas/spec/rubocop/cop/specs/scope_includes_spec.rb @@ -22,30 +22,30 @@ describe RuboCop::Cop::Specs::ScopeIncludes do context "within describe" do it 'allows includes' do - inspect_source(%{ + inspect_source(%( describe JumpStick do include Foo end - }) + )) expect(cop.offenses.size).to eq(0) end end context "within module" do it 'allows includes' do - inspect_source(%{ + inspect_source(%( module JumpStick include Foo end - }) + )) expect(cop.offenses.size).to eq(0) end end it "disallows defs on Object" do - inspect_source(%{ + inspect_source(%( include Foo - }) + )) expect(cop.offenses.size).to eq(1) expect(cop.messages.first).to match(/Never `include`/) expect(cop.offenses.first.severity.name).to eq(:error) diff --git a/gems/turnitin_api/lib/turnitin_api/outcomes_response_transformer.rb b/gems/turnitin_api/lib/turnitin_api/outcomes_response_transformer.rb index 554dce7d1b1..c817a8e0829 100644 --- a/gems/turnitin_api/lib/turnitin_api/outcomes_response_transformer.rb +++ b/gems/turnitin_api/lib/turnitin_api/outcomes_response_transformer.rb @@ -49,7 +49,7 @@ module TurnitinApi end def originality_data - response.body['outcome_originalityreport'].select { |k, _| %w(breakdown numeric).include?(k) } + response.body['outcome_originalityreport'].select { |k, _| %w[breakdown numeric].include?(k) } end def uploaded_at diff --git a/gems/twitter/twitter.gemspec b/gems/twitter/twitter.gemspec index deb5a785dc0..adb2fc427dd 100644 --- a/gems/twitter/twitter.gemspec +++ b/gems/twitter/twitter.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["rweiner@pivotallabs.com"] spec.summary = 'Gem for posting to Twitter' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/gems/utf8_cleaner/utf8_cleaner.gemspec b/gems/utf8_cleaner/utf8_cleaner.gemspec index f426b76c8c3..1d8b78a6a6a 100644 --- a/gems/utf8_cleaner/utf8_cleaner.gemspec +++ b/gems/utf8_cleaner/utf8_cleaner.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.email = ["zachp@instructure.com", "stephan@pivotallabs.com"] spec.summary = 'Strip invalid UTF8 characters' - spec.files = Dir.glob("{lib,spec}/**/*") + %w(Rakefile test.sh) + spec.files = Dir.glob("{lib,spec}/**/*") + %w[Rakefile test.sh] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] diff --git a/lib/api.rb b/lib/api.rb index 63409a71772..83cbc90c53b 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -420,7 +420,7 @@ module Api PAGINATION_PARAMS = [:current, :next, :prev, :first, :last].freeze LINK_PRIORITY = [:next, :last, :prev, :current, :first].freeze - EXCLUDE_IN_PAGINATION_LINKS = %w(page per_page access_token api_key).freeze + EXCLUDE_IN_PAGINATION_LINKS = %w[page per_page access_token api_key].freeze def self.build_links(base_url, opts = {}) links = build_links_hash(base_url, opts) build_links_from_hash(links) diff --git a/lib/api/html/content.rb b/lib/api/html/content.rb index e63ebe366f1..ab931fb234e 100644 --- a/lib/api/html/content.rb +++ b/lib/api/html/content.rb @@ -158,7 +158,7 @@ module Api private - APPLICABLE_ATTRS = %w{href src}.freeze + APPLICABLE_ATTRS = %w[href src].freeze def scrub_links!(node) APPLICABLE_ATTRS.each do |attr| diff --git a/lib/api/v1/account.rb b/lib/api/v1/account.rb index 81f69967f0f..ea8572c0f7f 100644 --- a/lib/api/v1/account.rb +++ b/lib/api/v1/account.rb @@ -36,7 +36,7 @@ module Api::V1::Account end def account_json(account, user, session, includes, read_only = false) - attributes = %w(id name parent_account_id root_account_id workflow_state uuid) + attributes = %w[id name parent_account_id root_account_id workflow_state uuid] if read_only return api_json(account, user, session, :only => attributes).tap do |hash| hash['root_account_id'] = nil if account.root_account? @@ -44,7 +44,7 @@ module Api::V1::Account end end - methods = %w(default_storage_quota_mb default_user_storage_quota_mb default_group_storage_quota_mb) + methods = %w[default_storage_quota_mb default_user_storage_quota_mb default_group_storage_quota_mb] api_json(account, user, session, :only => attributes, :methods => methods).tap do |hash| hash['root_account_id'] = nil if account.root_account? hash['default_time_zone'] = account.default_time_zone.tzinfo.name diff --git a/lib/api/v1/account_notifications.rb b/lib/api/v1/account_notifications.rb index 7d2e94165b9..6b7770b8f6a 100644 --- a/lib/api/v1/account_notifications.rb +++ b/lib/api/v1/account_notifications.rb @@ -26,7 +26,7 @@ module Api::V1::AccountNotifications end def account_notification_json(account_notification, user, session) - json = api_json(account_notification, user, session, :only => %w(id subject start_at end_at icon message)) + json = api_json(account_notification, user, session, :only => %w[id subject start_at end_at icon message]) json['role_ids'] = account_notification.account_notification_roles.map(&:role_id) json['roles'] = account_notification.account_notification_roles.map(&:role_name) json diff --git a/lib/api/v1/account_report.rb b/lib/api/v1/account_report.rb index d352571a9b4..4623d7760d0 100644 --- a/lib/api/v1/account_report.rb +++ b/lib/api/v1/account_report.rb @@ -29,7 +29,7 @@ module Api::V1::AccountReport end def account_report_json(report, user) - json = api_json(report, user, nil, only: %w(id progress parameters current_line)) + json = api_json(report, user, nil, only: %w[id progress parameters current_line]) json[:status] = report.workflow_state json[:report] = report.report_type json[:created_at] = report.created_at&.iso8601 diff --git a/lib/api/v1/assessment_request.rb b/lib/api/v1/assessment_request.rb index c765a002a97..7bcc982d8e2 100644 --- a/lib/api/v1/assessment_request.rb +++ b/lib/api/v1/assessment_request.rb @@ -25,7 +25,7 @@ module Api::V1::AssessmentRequest def assessment_request_json(assessment_request, user, session, includes = Set.new) assignment = assessment_request.asset.assignment - json_attributes = %w(id user_id assessor_id asset_id asset_type workflow_state) + json_attributes = %w[id user_id assessor_id asset_id asset_type workflow_state] if assignment.anonymous_peer_reviews? && !assignment.grants_any_right?(user, session, :grade) json_attributes.delete('assessor_id') end diff --git a/lib/api/v1/assignment.rb b/lib/api/v1/assignment.rb index 12f8942de35..b4896cf33f6 100644 --- a/lib/api/v1/assignment.rb +++ b/lib/api/v1/assignment.rb @@ -33,7 +33,7 @@ module Api::V1::Assignment :rubric_association].freeze API_ALLOWED_ASSIGNMENT_OUTPUT_FIELDS = { - :only => %w( + :only => %w[ id position description @@ -64,11 +64,11 @@ module Api::V1::Assignment anonymous_grading allowed_attempts annotatable_attachment_id - ) + ] }.freeze API_ASSIGNMENT_NEW_RECORD_FIELDS = { - :only => %w( + :only => %w[ graders_anonymous_to_graders grader_comments_visible_to_graders grader_names_visible_to_final_grader @@ -77,7 +77,7 @@ module Api::V1::Assignment assignment_group_id post_to_sis annotatable_attachment_id - ) + ] }.freeze EDITABLE_ATTRS_IN_CLOSED_GRADING_PERIOD = %w[ @@ -455,7 +455,7 @@ module Api::V1::Assignment settings.slice(*API_ALLOWED_VERICITE_SETTINGS) end - API_ALLOWED_ASSIGNMENT_INPUT_FIELDS = %w( + API_ALLOWED_ASSIGNMENT_INPUT_FIELDS = %w[ name description position @@ -489,9 +489,9 @@ module Api::V1::Assignment anonymous_instructor_annotations allowed_attempts important_dates - ).freeze + ].freeze - API_ALLOWED_TURNITIN_SETTINGS = %w( + API_ALLOWED_TURNITIN_SETTINGS = %w[ originality_report_visibility s_paper_check internet_check @@ -501,14 +501,14 @@ module Api::V1::Assignment exclude_small_matches_type exclude_small_matches_value submit_papers_to - ).freeze + ].freeze - API_ALLOWED_VERICITE_SETTINGS = %w( + API_ALLOWED_VERICITE_SETTINGS = %w[ originality_report_visibility exclude_quoted exclude_self_plag store_in_index - ).freeze + ].freeze def create_api_assignment(assignment, assignment_params, user, context = assignment.context, calculate_grades: nil) return :forbidden unless grading_periods_allow_submittable_create?(assignment, assignment_params) diff --git a/lib/api/v1/assignment_group.rb b/lib/api/v1/assignment_group.rb index 697dd403db2..54fc59d4137 100644 --- a/lib/api/v1/assignment_group.rb +++ b/lib/api/v1/assignment_group.rb @@ -23,20 +23,20 @@ module Api::V1::AssignmentGroup include Api::V1::Assignment include Api::V1::Submission - API_ALLOWED_ASSIGNMENT_GROUP_INPUT_FIELDS = %w( + API_ALLOWED_ASSIGNMENT_GROUP_INPUT_FIELDS = %w[ name position group_weight rules sis_source_id integration_data - ).freeze + ].freeze def assignment_group_json(group, user, session, includes = [], opts = {}) includes ||= [] opts.reverse_merge!(override_assignment_dates: true, exclude_response_fields: []) - hash = api_json(group, user, session, :only => %w(id name position group_weight sis_source_id integration_data)) + hash = api_json(group, user, session, :only => %w[id name position group_weight sis_source_id integration_data]) hash['rules'] = group.rules_hash(stringify_json_ids: opts[:stringify_json_ids]) if includes.include?('assignments') diff --git a/lib/api/v1/assignment_override.rb b/lib/api/v1/assignment_override.rb index 000be1ee224..0942bef215d 100644 --- a/lib/api/v1/assignment_override.rb +++ b/lib/api/v1/assignment_override.rb @@ -192,7 +192,7 @@ module Api::V1::AssignmentOverride errors << "one of student_ids, group_id, or course_section_id is required" if !set_type && errors.empty? - if %w(ADHOC Noop).include?(set_type) && data.key?(:title) + if %w[ADHOC Noop].include?(set_type) && data.key?(:title) override_data[:title] = data[:title] end diff --git a/lib/api/v1/attachment.rb b/lib/api/v1/attachment.rb index 7f8d6205a60..0405265c0f5 100644 --- a/lib/api/v1/attachment.rb +++ b/lib/api/v1/attachment.rb @@ -247,7 +247,7 @@ module Api::V1::Attachment end def validate_on_duplicate(params) - if params[:on_duplicate] && !%w(rename overwrite).include?(params[:on_duplicate]) + if params[:on_duplicate] && !%w[rename overwrite].include?(params[:on_duplicate]) render status: :bad_request, json: { message: 'invalid on_duplicate option' } diff --git a/lib/api/v1/calendar_event.rb b/lib/api/v1/calendar_event.rb index 2d003877d0e..f0831e62d72 100644 --- a/lib/api/v1/calendar_event.rb +++ b/lib/api/v1/calendar_event.rb @@ -49,7 +49,7 @@ module Api::V1::CalendarEvent event, user, session, - :only => %w(id created_at updated_at start_at end_at all_day all_day_date title workflow_state comments) + :only => %w[id created_at updated_at start_at end_at all_day all_day_date title workflow_state comments] ) if user @@ -180,7 +180,7 @@ module Api::V1::CalendarEvent def assignment_event_json(assignment, user, session, options = {}) excludes = options[:excludes] || [] - target_fields = %w(created_at updated_at title all_day all_day_date workflow_state) + target_fields = %w[created_at updated_at title all_day all_day_date workflow_state] target_fields << 'description' unless excludes.include?('description') hash = api_json(assignment, user, session, only: target_fields) hash['description'] = api_user_content(hash['description'], assignment.context) unless excludes.include?('description') @@ -218,7 +218,7 @@ module Api::V1::CalendarEvent group, user, session, - :only => %w{id created_at description end_at max_appointments_per_participant min_appointments_per_participant participants_per_appointment start_at title updated_at workflow_state participant_visibility}, :methods => :sub_context_codes + :only => %w[id created_at description end_at max_appointments_per_participant min_appointments_per_participant participants_per_appointment start_at title updated_at workflow_state participant_visibility], :methods => :sub_context_codes ) if user diff --git a/lib/api/v1/collaboration.rb b/lib/api/v1/collaboration.rb index 59ca7ae6c17..cc6b5823aeb 100644 --- a/lib/api/v1/collaboration.rb +++ b/lib/api/v1/collaboration.rb @@ -22,7 +22,7 @@ module Api::V1::Collaboration include Api::V1::Json def collaboration_json(collaboration, current_user, session) - attribute_whitelist = %w{id collaboration_type document_id user_id context_id context_type url created_at updated_at description title type update_url} + attribute_whitelist = %w[id collaboration_type document_id user_id context_id context_type url created_at updated_at description title type update_url] api_json(collaboration, current_user, session, :only => attribute_whitelist).tap do |hash| hash['user_name'] = collaboration.user[:name] hash['update_url'] = collaboration.update_url diff --git a/lib/api/v1/collaborator.rb b/lib/api/v1/collaborator.rb index 23086ea462a..035d5766d81 100644 --- a/lib/api/v1/collaborator.rb +++ b/lib/api/v1/collaborator.rb @@ -23,7 +23,7 @@ module Api::V1::Collaborator def collaborator_json(collaborator, current_user, session, options = {}, context: nil) includes = options[:include] || [] - api_json(collaborator, current_user, session, :only => %w{id}).tap do |hash| + api_json(collaborator, current_user, session, :only => %w[id]).tap do |hash| hash['type'] = collaborator.group_id.present? ? 'group' : 'user' hash['name'] = collaborator.user.try(:sortable_name) || collaborator.group.try(:name) diff --git a/lib/api/v1/communication_channel.rb b/lib/api/v1/communication_channel.rb index 66a26b891ad..fb1a8ee8ce5 100644 --- a/lib/api/v1/communication_channel.rb +++ b/lib/api/v1/communication_channel.rb @@ -36,11 +36,11 @@ module Api::V1::CommunicationChannel # :workflow_state # :created_at def communication_channel_json(channel, current_user, session) - only = %w{id path_type position workflow_state user_id created_at} + only = %w[id path_type position workflow_state user_id created_at] # Uses the method "path_description" instead of the field "path" because # when path_type is twitter or yo, it goes and fetches tha user's account # name with a fallback display value. - methods = %w{path_description} + methods = %w[path_description] # If the user is super special, show them this channel's bounce details if channel.grants_right?(current_user, :read_bounce_details) diff --git a/lib/api/v1/conferences.rb b/lib/api/v1/conferences.rb index cd8445cec80..ebf5d17d270 100644 --- a/lib/api/v1/conferences.rb +++ b/lib/api/v1/conferences.rb @@ -20,12 +20,12 @@ module Api::V1::Conferences API_CONFERENCE_JSON_OPTS = { - :only => %w( + :only => %w[ id title conference_type description duration ended_at started_at user_ids long_running recordings join_url has_advanced_settings conference_key context_type context_id - ).freeze + ].freeze }.freeze def api_conferences_json(conferences, user, session) diff --git a/lib/api/v1/content_export.rb b/lib/api/v1/content_export.rb index cab6de48aab..fe2f99b7a3b 100644 --- a/lib/api/v1/content_export.rb +++ b/lib/api/v1/content_export.rb @@ -26,7 +26,7 @@ module Api::V1::ContentExport include Api::V1::QuizzesNext::Quiz def content_export_json(export, current_user, session, includes = []) - json = api_json(export, current_user, session, :only => %w(id user_id created_at workflow_state export_type)) + json = api_json(export, current_user, session, :only => %w[id user_id created_at workflow_state export_type]) json['course_id'] = export.context_id if export.context_type == 'Course' if export.attachment && !export.for_course_copy? && !export.expired? json[:attachment] = attachment_json(export.attachment, current_user, {}, { :can_view_hidden_files => true }) diff --git a/lib/api/v1/content_migration.rb b/lib/api/v1/content_migration.rb index a8c7aa46c83..9ffb5f0702d 100644 --- a/lib/api/v1/content_migration.rb +++ b/lib/api/v1/content_migration.rb @@ -29,7 +29,7 @@ module Api::V1::ContentMigration end def content_migration_json(migration, current_user, session, attachment_preflight = nil, includes = []) - json = api_json(migration, current_user, session, :only => %w(id user_id workflow_state started_at finished_at migration_type)) + json = api_json(migration, current_user, session, :only => %w[id user_id workflow_state started_at finished_at migration_type]) json[:created_at] = migration.created_at if json[:workflow_state] == 'created' json[:workflow_state] = 'pre_processing' @@ -97,7 +97,7 @@ module Api::V1::ContentMigration end def migration_issue_json(issue, migration, current_user, session) - json = api_json(issue, current_user, session, :only => %w(id description workflow_state fix_issue_html_url issue_type created_at updated_at)) + json = api_json(issue, current_user, session, :only => %w[id description workflow_state fix_issue_html_url issue_type created_at updated_at]) json[:content_migration_url] = api_v1_course_content_migration_url(migration.context_id, issue.content_migration_id) if issue.grants_right?(current_user, :read_errors) json[:error_message] = issue.error_message diff --git a/lib/api/v1/content_share.rb b/lib/api/v1/content_share.rb index 7bb07830f6c..d9ab2476f2c 100644 --- a/lib/api/v1/content_share.rb +++ b/lib/api/v1/content_share.rb @@ -33,7 +33,7 @@ module Api::V1::ContentShare }.freeze def content_share_json(content_share, user, session, opts = {}) - json = api_json(content_share, user, session, opts.merge(only: %w(id name created_at updated_at user_id read_state))) + json = api_json(content_share, user, session, opts.merge(only: %w[id name created_at updated_at user_id read_state])) json['sender'] = content_share.respond_to?(:sender) && content_share.sender ? user_display_json(content_share.sender) : nil json['receivers'] = content_share.respond_to?(:receivers) ? content_share.receivers.map { |rec| user_display_json(rec) } : [] if content_share.content_export @@ -82,7 +82,7 @@ module Api::V1::ContentShare return nil unless settings.key?('selected_content') selected_types = settings['selected_content'].keys.filter_map { |k| EXPORT_TYPES[k] } - %w(module module_item).each { |k| return k if selected_types.include?(k) } + %w[module module_item].each { |k| return k if selected_types.include?(k) } # otherwise there should be only one selected type... selected_types.first end diff --git a/lib/api/v1/context_module.rb b/lib/api/v1/context_module.rb index 74753d7973f..19a5203de10 100644 --- a/lib/api/v1/context_module.rb +++ b/lib/api/v1/context_module.rb @@ -26,9 +26,9 @@ module Api::V1::ContextModule include Api::V1::Locked include Api::V1::Assignment - MODULE_JSON_ATTRS = %w(id position name unlock_at).freeze + MODULE_JSON_ATTRS = %w[id position name unlock_at].freeze - MODULE_ITEM_JSON_ATTRS = %w(id position title indent).freeze + MODULE_ITEM_JSON_ATTRS = %w[id position title indent].freeze ITEM_TYPE = { Assignment: 'assignment', @@ -97,7 +97,7 @@ module Api::V1::ContextModule # add content_id, if applicable # (note that wiki page ids are not exposed by the api) - unless %w(WikiPage ContextModuleSubHeader ExternalUrl).include? content_tag.content_type + unless %w[WikiPage ContextModuleSubHeader ExternalUrl].include? content_tag.content_type hash['content_id'] = content_tag.content_id end diff --git a/lib/api/v1/conversation.rb b/lib/api/v1/conversation.rb index 2036d85b1c7..129a5f47223 100644 --- a/lib/api/v1/conversation.rb +++ b/lib/api/v1/conversation.rb @@ -146,8 +146,8 @@ module Api::V1::Conversation result = api_json batch, current_user, session, - :only => %w{id workflow_state}, - :methods => %w{completion recipient_count} + :only => %w[id workflow_state], + :methods => %w[completion recipient_count] result[:message] = conversation_message_json(batch.root_conversation_message, current_user, session) result[:tags] = batch.local_tags result diff --git a/lib/api/v1/course.rb b/lib/api/v1/course.rb index 25cb0460ac3..264372503aa 100644 --- a/lib/api/v1/course.rb +++ b/lib/api/v1/course.rb @@ -106,7 +106,7 @@ module Api::V1::Course hash['term'] = enrollment_term_json(course.enrollment_term, user, session, enrollments, []) if includes.include?('term') if includes.include?('grading_periods') hash['grading_periods'] = course.enrollment_term&.grading_period_group&.grading_periods&.map do |gp| - api_json(gp, user, session, :only => %w(id title start_date end_date workflow_state)) + api_json(gp, user, session, :only => %w[id title start_date end_date workflow_state]) end end if includes.include?('course_progress') @@ -119,7 +119,7 @@ module Api::V1::Course hash['sections'] = if enrollments.any? section_enrollments_json(enrollments) else - course.course_sections.map { |section| section.attributes.slice(*%w(id name start_at end_at)) } + course.course_sections.map { |section| section.attributes.slice(*%w[id name start_at end_at]) } end end hash['total_students'] = course.student_count || course.student_enrollments.not_fake.distinct.count(:user_id) if includes.include?('total_students') @@ -165,7 +165,7 @@ module Api::V1::Course end def copy_status_json(import, course, user, session) - hash = api_json(import, user, session, :only => %w(id progress created_at workflow_state integration_id)) + hash = api_json(import, user, session, :only => %w[id progress created_at workflow_state integration_id]) # the type of object for course copy changed but we don't want the api to change # so map the workflow states to the old ones @@ -215,7 +215,7 @@ module Api::V1::Course def preload_teachers(courses) threshold = params[:teacher_limit].presence&.to_i if threshold - scope = TeacherEnrollment.where.not(:workflow_state => %w{deleted rejected}).where(:course_id => courses).distinct.select(:user_id, :course_id) + scope = TeacherEnrollment.where.not(:workflow_state => %w[deleted rejected]).where(:course_id => courses).distinct.select(:user_id, :course_id) teacher_counts = Enrollment.from("(#{scope.to_sql}) AS t").group("t.course_id").count to_preload = [] courses.each do |course| diff --git a/lib/api/v1/course_json.rb b/lib/api/v1/course_json.rb index f88a4f2322b..7c0b7d72af1 100644 --- a/lib/api/v1/course_json.rb +++ b/lib/api/v1/course_json.rb @@ -19,13 +19,13 @@ module Api::V1 class CourseJson - BASE_ATTRIBUTES = %w(id name course_code account_id created_at start_at default_view enrollment_term_id is_public - grading_standard_id root_account_id uuid license grade_passback_setting).freeze + BASE_ATTRIBUTES = %w[id name course_code account_id created_at start_at default_view enrollment_term_id is_public + grading_standard_id root_account_id uuid license grade_passback_setting].freeze INCLUDE_CHECKERS = { grading: 'needs_grading_count', syllabus: 'syllabus_body', url: 'html_url', description: 'public_description', permissions: 'permissions' }.freeze - OPTIONAL_FIELDS = %w(needs_grading_count public_description enrollments).freeze + OPTIONAL_FIELDS = %w[needs_grading_count public_description enrollments].freeze attr_reader :course, :user, :includes, :enrollments, :hash diff --git a/lib/api/v1/custom_gradebook_column.rb b/lib/api/v1/custom_gradebook_column.rb index 3fc886c1d5b..eff596034f4 100644 --- a/lib/api/v1/custom_gradebook_column.rb +++ b/lib/api/v1/custom_gradebook_column.rb @@ -22,13 +22,13 @@ module Api::V1::CustomGradebookColumn include Api::V1::Json def custom_gradebook_column_json(column, user, session) - json = api_json column, user, session, :only => %w(id title position - teacher_notes read_only) + json = api_json column, user, session, :only => %w[id title position + teacher_notes read_only] json[:hidden] = column.hidden? json end def custom_gradebook_column_datum_json(datum, user, session) - api_json datum, user, session, :only => %w(user_id content) + api_json datum, user, session, :only => %w[user_id content] end end diff --git a/lib/api/v1/developer_key.rb b/lib/api/v1/developer_key.rb index 1541813208a..1dc726dc5aa 100644 --- a/lib/api/v1/developer_key.rb +++ b/lib/api/v1/developer_key.rb @@ -21,9 +21,9 @@ module Api::V1::DeveloperKey include Api::V1::Json - DEVELOPER_KEY_JSON_ATTRS = %w( + DEVELOPER_KEY_JSON_ATTRS = %w[ name created_at email user_id user_name icon_url notes workflow_state scopes require_scopes client_credentials_audience - ).freeze + ].freeze INHERITED_DEVELOPER_KEY_JSON_ATTRS = %w[name created_at icon_url workflow_state].freeze def developer_keys_json(keys, user, session, context, inherited: false, include_tool_config: false) diff --git a/lib/api/v1/discussion_topics.rb b/lib/api/v1/discussion_topics.rb index ff4f7beca69..fb38e319a08 100644 --- a/lib/api/v1/discussion_topics.rb +++ b/lib/api/v1/discussion_topics.rb @@ -29,12 +29,12 @@ module Api::V1::DiscussionTopics include HtmlTextHelper # Public: DiscussionTopic fields to serialize. - ALLOWED_TOPIC_FIELDS = %w{ + ALLOWED_TOPIC_FIELDS = %w[ id title assignment_id delayed_post_at lock_at created_at last_reply_at posted_at root_topic_id podcast_has_student_posts discussion_type position allow_rating only_graders_can_rate sort_by_rating is_section_specific - }.freeze + ].freeze # Public: DiscussionTopic methods to serialize. ALLOWED_TOPIC_METHODS = [:user_name, :discussion_subentry_count].freeze @@ -240,7 +240,7 @@ module Api::V1::DiscussionTopics # # Returns a hash. def serialize_entry(entry, user, context, session, includes) - allowed_fields = %w{id created_at updated_at parent_id rating_count rating_sum} + allowed_fields = %w[id created_at updated_at parent_id rating_count rating_sum] allowed_methods = [] allowed_fields << 'editor_id' if entry.deleted? || entry.editor_id allowed_fields << 'user_id' unless entry.deleted? diff --git a/lib/api/v1/enrollment_term.rb b/lib/api/v1/enrollment_term.rb index 6ea2c89c2b8..11582201d2a 100644 --- a/lib/api/v1/enrollment_term.rb +++ b/lib/api/v1/enrollment_term.rb @@ -21,7 +21,7 @@ module Api::V1::EnrollmentTerm include Api::V1::Json def enrollment_term_json(enrollment_term, user, session, enrollments = [], includes = []) - api_json(enrollment_term, user, session, :only => %w(id name start_at end_at workflow_state grading_period_group_id created_at)).tap do |hash| + api_json(enrollment_term, user, session, :only => %w[id name start_at end_at workflow_state grading_period_group_id created_at]).tap do |hash| hash['sis_term_id'] = enrollment_term.sis_source_id if enrollment_term.root_account.grants_any_right?(user, :read_sis, :manage_sis) if enrollment_term.root_account.grants_right?(user, :manage_sis) hash['sis_import_id'] = enrollment_term.sis_batch_id diff --git a/lib/api/v1/eportfolio.rb b/lib/api/v1/eportfolio.rb index 1602c2f96e7..18e026724d1 100644 --- a/lib/api/v1/eportfolio.rb +++ b/lib/api/v1/eportfolio.rb @@ -20,8 +20,8 @@ module Api::V1::Eportfolio include Api::V1::Json - EPORTFOLIO_ATTRIBUTES = %w(id user_id name public created_at updated_at workflow_state deleted_at spam_status).freeze - ENTRY_ATTRIBUTES = %w(id eportfolio_id position name content created_at updated_at).freeze + EPORTFOLIO_ATTRIBUTES = %w[id user_id name public created_at updated_at workflow_state deleted_at spam_status].freeze + ENTRY_ATTRIBUTES = %w[id eportfolio_id position name content created_at updated_at].freeze def eportfolio_json(eportfolio, current_user, session) api_json(eportfolio, current_user, session, only: EPORTFOLIO_ATTRIBUTES).tap do |hash| diff --git a/lib/api/v1/external_feeds.rb b/lib/api/v1/external_feeds.rb index d07eac7d25a..d2395cd00e0 100644 --- a/lib/api/v1/external_feeds.rb +++ b/lib/api/v1/external_feeds.rb @@ -21,8 +21,8 @@ module Api::V1::ExternalFeeds include Api::V1::Json - API_ALLOWED_EXTERNAL_FEED_PARAMS = %w{url header_match verbosity}.freeze - API_EXPOSED_EXTERNAL_FEED_PARAMS = %w(id url header_match created_at verbosity).freeze + API_ALLOWED_EXTERNAL_FEED_PARAMS = %w[url header_match verbosity].freeze + API_EXPOSED_EXTERNAL_FEED_PARAMS = %w[id url header_match created_at verbosity].freeze def external_feeds_api_json(external_feeds, context, user, session) external_feeds.map do |external_feed| diff --git a/lib/api/v1/external_tools.rb b/lib/api/v1/external_tools.rb index a0036da827c..c69bbc0bc56 100644 --- a/lib/api/v1/external_tools.rb +++ b/lib/api/v1/external_tools.rb @@ -30,7 +30,7 @@ module Api::V1::ExternalTools def external_tool_json(tool, context, user, session, extension_types = Lti::ResourcePlacement.valid_placements(@domain_root_account)) methods = %w[privacy_level custom_fields workflow_state vendor_help_link] methods += extension_types - only = %w(id name description url domain consumer_key created_at updated_at description) + only = %w[id name description url domain consumer_key created_at updated_at description] only << 'allow_membership_service_access' if tool.context.root_account.feature_enabled?(:membership_service_for_lti_tools) json = api_json(tool, user, session, :only => only, diff --git a/lib/api/v1/favorite.rb b/lib/api/v1/favorite.rb index ffaec7289b6..2830b36c735 100644 --- a/lib/api/v1/favorite.rb +++ b/lib/api/v1/favorite.rb @@ -23,6 +23,6 @@ module Api::V1::Favorite include Api::V1::User def favorite_json(favorite, current_user, session) - api_json(favorite, current_user, session, :only => %w(context_id context_type)) + api_json(favorite, current_user, session, :only => %w[context_id context_type]) end end diff --git a/lib/api/v1/feature_flag.rb b/lib/api/v1/feature_flag.rb index 519ff0552f1..585f682c190 100644 --- a/lib/api/v1/feature_flag.rb +++ b/lib/api/v1/feature_flag.rb @@ -41,7 +41,7 @@ module Api::V1::FeatureFlag hash = if feature_flag.default? feature_flag.as_json.slice('feature', 'state') else - keys = %w(feature context_id context_type state) + keys = %w[feature context_id context_type state] api_json(feature_flag, current_user, session, only: keys) end hash['locking_account_id'] = nil unless feature_flag.default? diff --git a/lib/api/v1/folders.rb b/lib/api/v1/folders.rb index 14b7dcd6dc5..05baa6659ad 100644 --- a/lib/api/v1/folders.rb +++ b/lib/api/v1/folders.rb @@ -30,7 +30,7 @@ module Api::V1::Folders def folder_json(folder, user, session, opts = {}) can_view_hidden_files = opts.key?(:can_view_hidden_files) ? opts[:can_view_hidden_files] : folder.grants_right?(user, :update) json = api_json(folder, user, session, - :only => %w(id name full_name position parent_folder_id context_type context_id unlock_at lock_at created_at updated_at)) + :only => %w[id name full_name position parent_folder_id context_type context_id unlock_at lock_at created_at updated_at]) if folder if opts[:master_course_restricted_folder_ids]&.include?(folder.id) json['is_master_course_child_content'] = true diff --git a/lib/api/v1/grading_standard.rb b/lib/api/v1/grading_standard.rb index 2fae250be02..6b918b4c12f 100644 --- a/lib/api/v1/grading_standard.rb +++ b/lib/api/v1/grading_standard.rb @@ -21,7 +21,7 @@ module Api::V1::GradingStandard include Api::V1::Json def grading_standard_json(grading_standard, user, session) - api_json(grading_standard, user, session, :only => %w(id title context_type context_id)).tap do |hash| + api_json(grading_standard, user, session, :only => %w[id title context_type context_id]).tap do |hash| hash[:grading_scheme] = grading_standard['data'].map { |a| { name: a[0], value: a[1] } } end end diff --git a/lib/api/v1/group.rb b/lib/api/v1/group.rb index 4dae2044580..ccbce9594b2 100644 --- a/lib/api/v1/group.rb +++ b/lib/api/v1/group.rb @@ -24,12 +24,12 @@ module Api::V1::Group include Api::V1::Tab API_GROUP_JSON_OPTS = { - :only => %w(id name description is_public join_level group_category_id max_membership created_at), - :methods => %w(members_count storage_quota_mb), + :only => %w[id name description is_public join_level group_category_id max_membership created_at], + :methods => %w[members_count storage_quota_mb], }.freeze API_GROUP_MEMBERSHIP_JSON_OPTS = { - :only => %w(id group_id user_id workflow_state moderator created_at).freeze + :only => %w[id group_id user_id workflow_state moderator created_at].freeze }.freeze # permission keys need to be symbols diff --git a/lib/api/v1/group_category.rb b/lib/api/v1/group_category.rb index 01b03e3cdbb..9c92f5c2a5a 100644 --- a/lib/api/v1/group_category.rb +++ b/lib/api/v1/group_category.rb @@ -25,7 +25,7 @@ module Api::V1::GroupCategory include Api::V1::Group API_GROUP_CATEGORY_JSON_OPTS = { - :only => %w(id name role self_signup group_limit auto_leader created_at) + :only => %w[id name role self_signup group_limit auto_leader created_at] }.freeze def group_category_json(group_category, user, session, options = {}) diff --git a/lib/api/v1/history_entry.rb b/lib/api/v1/history_entry.rb index 4bdd14321aa..38126ed4e0f 100644 --- a/lib/api/v1/history_entry.rb +++ b/lib/api/v1/history_entry.rb @@ -22,7 +22,7 @@ module Api::V1::HistoryEntry include Api::V1::Json def history_entry_json(page_view, asset_user_access, user, session) - entry = api_json(asset_user_access, user, session, only: %w(asset_code context_type context_id)) + entry = api_json(asset_user_access, user, session, only: %w[asset_code context_type context_id]) entry['visited_at'] = page_view.created_at if asset_user_access.category == 'files' && page_view.url.include?('verifier') strip_verifier = Addressable::URI.parse(page_view.url) diff --git a/lib/api/v1/master_courses.rb b/lib/api/v1/master_courses.rb index a3e6309e910..5419064198f 100644 --- a/lib/api/v1/master_courses.rb +++ b/lib/api/v1/master_courses.rb @@ -21,7 +21,7 @@ module Api::V1::MasterCourses include Api::V1::User def master_template_json(template, user, session, **) - hash = api_json(template, user, session, :only => %w(id course_id), :methods => %w{last_export_completed_at associated_course_count}) + hash = api_json(template, user, session, :only => %w[id course_id], :methods => %w[last_export_completed_at associated_course_count]) migration = template.active_migration hash[:latest_migration] = master_migration_json(migration, user, session) if migration hash @@ -30,7 +30,7 @@ module Api::V1::MasterCourses def master_migration_json(migration, user, session, opts = {}) migration.expire_if_necessary! hash = api_json(migration, user, session, - :only => %w(id user_id workflow_state created_at exports_started_at imports_queued_at imports_completed_at comment)) + :only => %w[id user_id workflow_state created_at exports_started_at imports_queued_at imports_completed_at comment]) if opts[:subscription] hash['subscription_id'] = opts[:subscription].id else @@ -101,7 +101,7 @@ module Api::V1::MasterCourses def course_summary_json(course, opts = {}) can_read_sis = opts[:can_read_sis] || course.account.grants_any_right?(@current_user, :read_sis, :manage_sis) - hash = api_json(course, @current_user, session, :only => %w{id name course_code}) + hash = api_json(course, @current_user, session, :only => %w[id name course_code]) hash['sis_course_id'] = course.sis_source_id if can_read_sis hash['term_name'] = course.enrollment_term.name if opts[:include_teachers] diff --git a/lib/api/v1/media_object.rb b/lib/api/v1/media_object.rb index 628cc358239..9f792b7df7a 100644 --- a/lib/api/v1/media_object.rb +++ b/lib/api/v1/media_object.rb @@ -19,7 +19,7 @@ # API_MEDIA_OBJECT_JSON_OPTS = { - :only => %w(media_id created_at media_type).freeze, + :only => %w[media_id created_at media_type].freeze, }.freeze module Api::V1::MediaObject @@ -32,7 +32,7 @@ module Api::V1::MediaObject unless exclude.include?('tracks') json['media_tracks'] = media_object.media_tracks.map do |track| - api_json(track, current_user, session, :only => %w(kind created_at updated_at id locale)).tap do |json2| + api_json(track, current_user, session, :only => %w[kind created_at updated_at id locale]).tap do |json2| json2[:url] = show_media_tracks_url(media_object.media_id, track.id) end end diff --git a/lib/api/v1/moderation_grader.rb b/lib/api/v1/moderation_grader.rb index 0bf8258b24b..130413182a9 100644 --- a/lib/api/v1/moderation_grader.rb +++ b/lib/api/v1/moderation_grader.rb @@ -30,7 +30,7 @@ module Api::V1::ModerationGrader graders = provisional_graders.preload(:user) graders_by_id = graders.index_by(&:id) - api_json(graders, user, session, only: %w(id user_id)).tap do |hash| + api_json(graders, user, session, only: %w[id user_id]).tap do |hash| hash.each do |grader_json| grader_json['grader_name'] = graders_by_id[grader_json['id']].user.short_name grader_json['grader_selectable'] = active_user_ids.include?(grader_json['user_id']) @@ -38,7 +38,7 @@ module Api::V1::ModerationGrader end else active_user_ids.map! { |id| assignment.grader_ids_to_anonymous_ids[id.to_s] } - api_json(provisional_graders, user, session, only: %w(id anonymous_id)) + api_json(provisional_graders, user, session, only: %w[id anonymous_id]) .each { |grader_json| grader_json['grader_selectable'] = active_user_ids.include?(grader_json['anonymous_id']) } end end diff --git a/lib/api/v1/notification_policy.rb b/lib/api/v1/notification_policy.rb index f7906cab6d2..e242431bc27 100644 --- a/lib/api/v1/notification_policy.rb +++ b/lib/api/v1/notification_policy.rb @@ -23,7 +23,7 @@ module Api::V1::NotificationPolicy include Api::V1::Json JSON_OPTS = { - :only => %w{frequency} + :only => %w[frequency] }.freeze def notification_policy_json(policy, user, session) diff --git a/lib/api/v1/observer_alert.rb b/lib/api/v1/observer_alert.rb index ffa19b98feb..65877af7b9d 100644 --- a/lib/api/v1/observer_alert.rb +++ b/lib/api/v1/observer_alert.rb @@ -23,7 +23,7 @@ module Api::V1::ObserverAlert include ApplicationHelper API_ALLOWED_OUTPUT_FIELDS = { - :only => %w( + :only => %w[ id title user_id @@ -34,7 +34,7 @@ module Api::V1::ObserverAlert context_id workflow_state action_date - ).freeze + ].freeze }.freeze def observer_alert_json(alert, user, session, _opts = {}) diff --git a/lib/api/v1/observer_alert_threshold.rb b/lib/api/v1/observer_alert_threshold.rb index 6e17fe9bdd0..6394631df5f 100644 --- a/lib/api/v1/observer_alert_threshold.rb +++ b/lib/api/v1/observer_alert_threshold.rb @@ -23,14 +23,14 @@ module Api::V1::ObserverAlertThreshold include ApplicationHelper API_ALLOWED_OUTPUT_FIELDS = { - :only => %w( + :only => %w[ id user_id observer_id alert_type threshold workflow_state - ).freeze + ].freeze }.freeze def observer_alert_threshold_json(threshold, user, session, _opts = {}) diff --git a/lib/api/v1/outcome.rb b/lib/api/v1/outcome.rb index 5173b52c02b..c851d3d2d3e 100644 --- a/lib/api/v1/outcome.rb +++ b/lib/api/v1/outcome.rb @@ -63,7 +63,7 @@ module Api::V1::Outcome Account.site_admin.grants_right?(user, session, :manage_global_outcomes) end - json_attributes = %w(id context_type context_id vendor_guid display_name) + json_attributes = %w[id context_type context_id vendor_guid display_name] api_json(outcome, user, session, :only => json_attributes, :methods => [:title]).tap do |hash| hash['url'] = api_v1_outcome_path :id => outcome.id hash['can_edit'] = can_edit.call @@ -103,7 +103,7 @@ module Api::V1::Outcome # context id and type, and description. def outcome_group_json(outcome_group, user, session, style = :full) path_context = outcome_group.context || :global - api_json(outcome_group, user, session, :only => %w(id title vendor_guid)).tap do |hash| + api_json(outcome_group, user, session, :only => %w[id title vendor_guid]).tap do |hash| hash['url'] = polymorphic_path [:api_v1, path_context, :outcome_group], :id => outcome_group.id hash['subgroups_url'] = polymorphic_path [:api_v1, path_context, :outcome_group_subgroups], :id => outcome_group.id hash['outcomes_url'] = polymorphic_path [:api_v1, path_context, :outcome_group_outcomes], :id => outcome_group.id @@ -141,7 +141,7 @@ module Api::V1::Outcome def outcome_link_json(outcome_link, user, session, opts = {}) opts[:outcome_style] ||= :abbrev opts[:outcome_group_style] ||= :abbrev - api_json(outcome_link, user, session, :only => %w(context_type context_id)).tap do |hash| + api_json(outcome_link, user, session, :only => %w[context_type context_id]).tap do |hash| hash['url'] = polymorphic_path [:api_v1, outcome_link.context || :global, :outcome_link], :id => outcome_link.associated_asset_id, :outcome_id => outcome_link.content_id diff --git a/lib/api/v1/outcome_results.rb b/lib/api/v1/outcome_results.rb index dbea495fbb2..ae6fc477ba5 100644 --- a/lib/api/v1/outcome_results.rb +++ b/lib/api/v1/outcome_results.rb @@ -38,7 +38,7 @@ module Api::V1::OutcomeResults def outcome_result_json(result) hash = api_json(result, @current_user, session, { methods: :submitted_or_assessed_at, - only: %w(id score mastery possible percent hide_points hidden) + only: %w[id score mastery possible percent hide_points hidden] }) hash[:links] = { user: result.user.id.to_s, diff --git a/lib/api/v1/planner_note.rb b/lib/api/v1/planner_note.rb index 0aba0ff0158..fe4824242d5 100644 --- a/lib/api/v1/planner_note.rb +++ b/lib/api/v1/planner_note.rb @@ -29,7 +29,7 @@ module Api::V1::PlannerNote }.freeze API_JSON_OPTS = { - :only => %w(id todo_date title details user_id course_id workflow_state created_at updated_at) + :only => %w[id todo_date title details user_id course_id workflow_state created_at updated_at] }.freeze def planner_note_json(note, user, session, opts = {}) diff --git a/lib/api/v1/post_grades_status.rb b/lib/api/v1/post_grades_status.rb index eaa5a35ff3b..c7a228ff5ef 100644 --- a/lib/api/v1/post_grades_status.rb +++ b/lib/api/v1/post_grades_status.rb @@ -22,6 +22,6 @@ module Api::V1::PostGradesStatus include Api::V1::Json def post_grades_status_json(course_or_section) - course_or_section.sis_post_grades_statuses.last.as_json(:only => %w(id course_id course_section_id status message grades_posted_at)) + course_or_section.sis_post_grades_statuses.last.as_json(:only => %w[id course_id course_section_id status message grades_posted_at]) end end diff --git a/lib/api/v1/progress.rb b/lib/api/v1/progress.rb index 9da9e33fcac..7602425cf2f 100644 --- a/lib/api/v1/progress.rb +++ b/lib/api/v1/progress.rb @@ -22,7 +22,7 @@ module Api::V1::Progress include Api::V1::Json def progress_json(progress, current_user, session, **) - api_json(progress, current_user, session, :only => %w(id context_id context_type user_id tag completion workflow_state created_at updated_at message)).tap do |hash| + api_json(progress, current_user, session, :only => %w[id context_id context_type user_id tag completion workflow_state created_at updated_at message]).tap do |hash| hash['url'] = polymorphic_url([:api_v1, progress]) unless progress.pending? || progress.results.nil? hash['results'] = progress.results diff --git a/lib/api/v1/quiz.rb b/lib/api/v1/quiz.rb index c58ec69f84f..fc165468b10 100644 --- a/lib/api/v1/quiz.rb +++ b/lib/api/v1/quiz.rb @@ -21,7 +21,7 @@ module Api::V1::Quiz include Api::V1::Json API_ALLOWED_QUIZ_INPUT_FIELDS = { - :only => (%w( + :only => (%w[ access_code allowed_attempts anonymous_submissions @@ -52,7 +52,7 @@ module Api::V1::Quiz disable_timer_autosubmission title unlock_at - ) + [{ 'hide_results' => ArbitraryStrongishParams::ANYTHING }] # because sometimes this is a hash :/ + ] + [{ 'hide_results' => ArbitraryStrongishParams::ANYTHING }] # because sometimes this is a hash :/ ).freeze }.freeze diff --git a/lib/api/v1/quiz_group.rb b/lib/api/v1/quiz_group.rb index 40bedffa177..11ddc05c5cf 100644 --- a/lib/api/v1/quiz_group.rb +++ b/lib/api/v1/quiz_group.rb @@ -22,7 +22,7 @@ module Api::V1::QuizGroup include Api::V1::Json API_ALLOWED_QUIZ_GROUP_OUTPUT_FIELDS = { - :only => %w( + :only => %w[ id quiz_id name @@ -30,17 +30,17 @@ module Api::V1::QuizGroup question_points assessment_question_bank_id position - ) + ] }.freeze API_ALLOWED_QUIZ_INPUT_FIELDS = { - :only => %w( + :only => %w[ name pick_count question_points assessment_question_bank_id position - ) + ] }.freeze def quiz_groups_compound_json(quiz_groups, context, user, session) diff --git a/lib/api/v1/quiz_question.rb b/lib/api/v1/quiz_question.rb index 8ba51b0bd49..9c9c8fa0941 100644 --- a/lib/api/v1/quiz_question.rb +++ b/lib/api/v1/quiz_question.rb @@ -22,17 +22,17 @@ module Api::V1::QuizQuestion include Api::V1::Json API_ALLOWED_QUESTION_OUTPUT_FIELDS = { - :only => %w( + :only => %w[ id quiz_id position regrade_option assessment_question_id quiz_group_id - ) + ] }.freeze - API_ALLOWED_QUESTION_DATA_OUTPUT_FIELDS = %w( + API_ALLOWED_QUESTION_DATA_OUTPUT_FIELDS = %w[ question_name question_type question_text @@ -51,7 +51,7 @@ module Api::V1::QuizQuestion formula_decimal_places matches matching_answer_incorrect_matches - ).freeze + ].freeze # @param [Quizzes::Quiz#quiz_data] quiz_data # If you specify a quiz_data construct from a submission (or a quiz), then @@ -122,22 +122,22 @@ module Api::V1::QuizQuestion question_data = question_data.with_indifferent_access # whitelist question details for students - attr_whitelist = %w( + attr_whitelist = %w[ id position quiz_group_id quiz_id assessment_question_id assessment_question question_name question_type question_text answers matches formulas variables answer_tolerance formula_decimal_places - ) + ] question_data.keep_if { |k, _v| attr_whitelist.include?(k.to_s) } # only include answers for types that need it to show choices - allow_answer_whitelist = %w( + allow_answer_whitelist = %w[ multiple_choice_question true_false_question multiple_answers_question matching_question multiple_dropdowns_question calculated_question - ) + ] unless allow_answer_whitelist.include?(question_data[:question_type]) question_data.delete(:answers) @@ -147,7 +147,7 @@ module Api::V1::QuizQuestion # multiple_dropdown needs blank_id # formula questions need variables question_data[:answers]&.each do |record| - record.keep_if { |k, _| %w(id text html blank_id variables).include?(k.to_s) } + record.keep_if { |k, _| %w[id text html blank_id variables].include?(k.to_s) } end question_data diff --git a/lib/api/v1/rubric.rb b/lib/api/v1/rubric.rb index c8ed645e4b2..6efc883781b 100644 --- a/lib/api/v1/rubric.rb +++ b/lib/api/v1/rubric.rb @@ -24,7 +24,7 @@ module Api::V1::Rubric include Api::V1::RubricAssociation API_ALLOWED_RUBRIC_OUTPUT_FIELDS = { - only: %w( + only: %w[ id title context_id @@ -36,7 +36,7 @@ module Api::V1::Rubric free_form_criterion_comments hide_score_total data - ) + ] }.freeze def rubrics_json(rubrics, user, session, opts = {}) diff --git a/lib/api/v1/rubric_assessment.rb b/lib/api/v1/rubric_assessment.rb index ea1b572b8e9..9fe30f94dcc 100644 --- a/lib/api/v1/rubric_assessment.rb +++ b/lib/api/v1/rubric_assessment.rb @@ -22,7 +22,7 @@ module Api::V1::RubricAssessment include Api::V1::Json API_ALLOWED_RUBRIC_ASSESSMENT_OUTPUT_FIELDS = { - only: %w( + only: %w[ id rubric_id rubric_association_id @@ -32,7 +32,7 @@ module Api::V1::RubricAssessment artifact_attempt assessment_type assessor_id - ) + ] }.freeze def rubric_assessments_json(rubric_assessments, user, session, opts = {}) diff --git a/lib/api/v1/rubric_association.rb b/lib/api/v1/rubric_association.rb index 908f72e2f27..d5eb3900f28 100644 --- a/lib/api/v1/rubric_association.rb +++ b/lib/api/v1/rubric_association.rb @@ -22,7 +22,7 @@ module Api::V1::RubricAssociation include Api::V1::Json API_ALLOWED_RUBRIC_ASSOCIATION_OUTPUT_FIELDS = { - only: %w( + only: %w[ id rubric_id association_type @@ -33,7 +33,7 @@ module Api::V1::RubricAssociation hide_score_total hide_points hide_outcome_results - ) + ] }.freeze def rubric_associations_json(rubric_associations, user, session, opts = {}) diff --git a/lib/api/v1/section.rb b/lib/api/v1/section.rb index 8771a6e2a67..89f367ead3d 100644 --- a/lib/api/v1/section.rb +++ b/lib/api/v1/section.rb @@ -24,7 +24,7 @@ module Api::V1::Section def section_json(section, user, session, includes, options = {}) res = section.as_json(:include_root => false, - :only => %w(id name course_id nonxlist_course_id start_at end_at restrict_enrollments_to_section_dates created_at)) + :only => %w[id name course_id nonxlist_course_id start_at end_at restrict_enrollments_to_section_dates created_at]) if options[:allow_sis_ids] || section.course.grants_any_right?(user, :read_sis, :manage_sis) res['sis_section_id'] = section.sis_source_id res['sis_course_id'] = section.course.sis_source_id diff --git a/lib/api/v1/section_enrollments.rb b/lib/api/v1/section_enrollments.rb index 727150e5751..0c912b6d554 100644 --- a/lib/api/v1/section_enrollments.rb +++ b/lib/api/v1/section_enrollments.rb @@ -22,7 +22,7 @@ module Api::V1::SectionEnrollments def section_enrollments_json(enrollments) enrollments.map do |enrollment| section = enrollment.course_section - section_json = section.attributes.slice(*%w(id name start_at end_at)) + section_json = section.attributes.slice(*%w[id name start_at end_at]) section_json[:enrollment_role] = enrollment.type section_json end diff --git a/lib/api/v1/sis_assignment.rb b/lib/api/v1/sis_assignment.rb index d4cab08be01..70034b0e37f 100644 --- a/lib/api/v1/sis_assignment.rb +++ b/lib/api/v1/sis_assignment.rb @@ -25,28 +25,28 @@ module Api::V1::SisAssignment end API_SIS_ASSIGNMENT_JSON_OPTS = { - only: %i(id created_at due_at unlock_at lock_at points_possible sis_assignment_id integration_id integration_data include_in_final_grade).freeze, - methods: %i(name submission_types_array).freeze + only: %i[id created_at due_at unlock_at lock_at points_possible sis_assignment_id integration_id integration_data include_in_final_grade].freeze, + methods: %i[name submission_types_array].freeze }.freeze API_SIS_ASSIGNMENT_GROUP_JSON_OPTS = { - only: %i(id name sis_source_id integration_data group_weight).freeze + only: %i[id name sis_source_id integration_data group_weight].freeze }.freeze API_SIS_ASSIGNMENT_COURSE_SECTION_JSON_OPTS = { - only: %i(id name sis_source_id integration_id).freeze + only: %i[id name sis_source_id integration_id].freeze }.freeze API_SIS_ASSIGNMENT_COURSE_JSON_OPTS = { - only: %i(id name sis_source_id integration_id).freeze + only: %i[id name sis_source_id integration_id].freeze }.freeze API_SIS_ASSIGNMENT_OVERRIDES_JSON_OPTS = { - only: %i(id title due_at unlock_at lock_at).freeze + only: %i[id title due_at unlock_at lock_at].freeze }.freeze API_SIS_ASSIGNMENT_STUDENT_OVERRIDES_JSON_OPTS = { - only: %i(user_id).freeze + only: %i[user_id].freeze }.freeze def sis_assignments_json(assignments, includes = {}) diff --git a/lib/api/v1/stream_item.rb b/lib/api/v1/stream_item.rb index 94ec503f68d..ab18d825938 100644 --- a/lib/api/v1/stream_item.rb +++ b/lib/api/v1/stream_item.rb @@ -87,7 +87,7 @@ module Api::V1::StreamItem when 'Submission' submission = stream_item.asset assignment = submission.assignment - includes = %w|submission_comments assignment course html_url user| + includes = %w[submission_comments assignment course html_url user] json = submission_json(submission, assignment, current_user, session, nil, includes, params) json.delete('id') hash.merge! json diff --git a/lib/api/v1/submission.rb b/lib/api/v1/submission.rb index e219136c31d..cfe3d046620 100644 --- a/lib/api/v1/submission.rb +++ b/lib/api/v1/submission.rb @@ -139,11 +139,11 @@ module Api::V1::Submission hash end - SUBMISSION_JSON_FIELDS = %w(id user_id url score grade excused attempt submission_type submitted_at body + SUBMISSION_JSON_FIELDS = %w[id user_id url score grade excused attempt submission_type submitted_at body assignment_id graded_at grade_matches_current_submission grader_id workflow_state late_policy_status - points_deducted grading_period_id cached_due_date extra_attempts posted_at).freeze - SUBMISSION_JSON_METHODS = %w(late missing seconds_late entered_grade entered_score).freeze - SUBMISSION_OTHER_FIELDS = %w(attachments discussion_entries).freeze + points_deducted grading_period_id cached_due_date extra_attempts posted_at].freeze + SUBMISSION_JSON_METHODS = %w[late missing seconds_late entered_grade entered_score].freeze + SUBMISSION_OTHER_FIELDS = %w[attachments discussion_entries].freeze def submission_attempt_json(attempt, assignment, user, session, context = nil, params = {}, quiz_submission_version = nil) context ||= assignment.context diff --git a/lib/api/v1/submission_comment.rb b/lib/api/v1/submission_comment.rb index a5b5a0883b4..fd6966bd1b1 100644 --- a/lib/api/v1/submission_comment.rb +++ b/lib/api/v1/submission_comment.rb @@ -38,7 +38,7 @@ module Api::V1::SubmissionComment def submission_comment_json(submission_comment, user) sc_hash = submission_comment.as_json( :include_root => false, - :only => %w(id author_id author_name created_at edited_at comment) + :only => %w[id author_id author_name created_at edited_at comment] ) if submission_comment.media_comment? diff --git a/lib/api/v1/usage_rights.rb b/lib/api/v1/usage_rights.rb index 40d3f67d089..b4d91415628 100644 --- a/lib/api/v1/usage_rights.rb +++ b/lib/api/v1/usage_rights.rb @@ -23,6 +23,6 @@ module Api::V1::UsageRights include Api::V1::User def usage_rights_json(usage_rights, current_user) - api_json(usage_rights, current_user, session, :only => %w(legal_copyright use_justification license), :methods => %w(license_name)) + api_json(usage_rights, current_user, session, :only => %w[legal_copyright use_justification license], :methods => %w[license_name]) end end diff --git a/lib/api/v1/user.rb b/lib/api/v1/user.rb index e6fcc972325..0a4a8261fd4 100644 --- a/lib/api/v1/user.rb +++ b/lib/api/v1/user.rb @@ -24,8 +24,8 @@ module Api::V1::User include AvatarHelper API_USER_JSON_OPTS = { - :only => %w(id name created_at).freeze, - :methods => %w(sortable_name short_name).freeze + :only => %w[id name created_at].freeze, + :methods => %w[sortable_name short_name].freeze }.freeze def user_json_preloads(users, preload_email = false, opts = {}) @@ -298,7 +298,7 @@ module Api::V1::User json[:sis_user_id] = pseudonym.try(:sis_user_id) end json[:html_url] = course_user_url(enrollment.course_id, enrollment.user_id) - user_includes = includes & %w{avatar_url group_ids uuid} + user_includes = includes & %w[avatar_url group_ids uuid] json[:user] = user_json(enrollment.user, user, session, user_includes, @context, nil, []) if includes.include?(:user) if includes.include?('locked') diff --git a/lib/api/v1/user_profile.rb b/lib/api/v1/user_profile.rb index 0c963432046..6b551f3e2d3 100644 --- a/lib/api/v1/user_profile.rb +++ b/lib/api/v1/user_profile.rb @@ -72,11 +72,11 @@ module Api::V1::UserProfile def user_service_json(user_service, current_user, session) api_json(user_service, current_user, session, - :only => %w(service visible), + :only => %w[service visible], :methods => %(service_user_link)) end def user_profile_link_json(link, current_user, session) - api_json(link, current_user, session, :only => %w(url title)) + api_json(link, current_user, session, :only => %w[url title]) end end diff --git a/lib/api/v1/wiki_page.rb b/lib/api/v1/wiki_page.rb index f37ecabd789..f402c823f44 100644 --- a/lib/api/v1/wiki_page.rb +++ b/lib/api/v1/wiki_page.rb @@ -24,7 +24,7 @@ module Api::V1::WikiPage include Api::V1::Locked include Api::V1::Assignment - WIKI_PAGE_JSON_ATTRS = %w(url title created_at editing_roles).freeze + WIKI_PAGE_JSON_ATTRS = %w[url title created_at editing_roles].freeze def wiki_page_json(wiki_page, current_user, session, include_body = true, opts = {}) opts = opts.reverse_merge(include_assignment: true, assignment_opts: {}) diff --git a/lib/authentication_methods.rb b/lib/authentication_methods.rb index 38957303c03..407282c7c5d 100644 --- a/lib/authentication_methods.rb +++ b/lib/authentication_methods.rb @@ -90,7 +90,7 @@ module AuthenticationMethods end end - ALLOWED_SCOPE_INCLUDES = %w{uuid}.freeze + ALLOWED_SCOPE_INCLUDES = %w[uuid].freeze def filter_includes(key) # no funny business @@ -237,7 +237,7 @@ module AuthenticationMethods # required by the user throttling middleware session[:user_id] = @current_user.global_id if @current_user - if @current_user && %w(become_user_id me become_teacher become_student).any? { |k| params.key?(k) } + if @current_user && %w[become_user_id me become_teacher become_student].any? { |k| params.key?(k) } request_become_user = nil if params[:become_user_id] request_become_user = User.where(id: params[:become_user_id]).first @@ -394,7 +394,7 @@ module AuthenticationMethods end def add_www_authenticate_header - response['WWW-Authenticate'] = %{Bearer realm="canvas-lms"} + response['WWW-Authenticate'] = %(Bearer realm="canvas-lms") end # Reset the session, and copy the specified keys over to the new session. diff --git a/lib/basic_lti/basic_outcomes.rb b/lib/basic_lti/basic_outcomes.rb index 45debc392c1..84a7e14741b 100644 --- a/lib/basic_lti/basic_outcomes.rb +++ b/lib/basic_lti/basic_outcomes.rb @@ -377,16 +377,16 @@ module BasicLTI def handle_read_result(_, assignment, user) @submission = assignment.submission_for_student(user) - self.body = %{ - - - - en - #{submission_score} - - - - } + self.body = <<~XML + + + + en + #{submission_score} + + + + XML true end diff --git a/lib/canvas/cache_register.rb b/lib/canvas/cache_register.rb index 5138ab95a56..2078721d97a 100644 --- a/lib/canvas/cache_register.rb +++ b/lib/canvas/cache_register.rb @@ -33,16 +33,16 @@ module Canvas # (which is far less often than the many times per day users are currently being touched) ALLOWED_TYPES = { - 'Account' => %w{account_chain role_overrides global_navigation feature_flags brand_config default_locale - resolved_outcome_proficiency resolved_outcome_calculation_method}, - 'Course' => %w{account_associations conditional_release}, - 'User' => %w{enrollments groups account_users todo_list submissions user_services k5_user}, - 'Assignment' => %w{availability conditional_release needs_grading}, - 'Quizzes::Quiz' => %w{availability} + 'Account' => %w[account_chain role_overrides global_navigation feature_flags brand_config default_locale + resolved_outcome_proficiency resolved_outcome_calculation_method], + 'Course' => %w[account_associations conditional_release], + 'User' => %w[enrollments groups account_users todo_list submissions user_services k5_user], + 'Assignment' => %w[availability conditional_release needs_grading], + 'Quizzes::Quiz' => %w[availability] }.freeze PREFER_MULTI_CACHE_TYPES = { - 'Account' => %w{feature_flags} + 'Account' => %w[feature_flags] }.freeze MIGRATED_TYPES = {}.freeze # for someday when we're reasonably sure we've moved all the cache keys for a type over diff --git a/lib/canvas/cassandra/migration.rb b/lib/canvas/cassandra/migration.rb index 76f3a6d44d3..1f812977677 100644 --- a/lib/canvas/cassandra/migration.rb +++ b/lib/canvas/cassandra/migration.rb @@ -36,11 +36,11 @@ module Canvas end def cassandra_table_exists?(table) - cql = %{ + cql = <<~SQL.squish SELECT * FROM #{table} LIMIT 1 - } + SQL cassandra.execute(cql) true rescue CassandraCQL::Error::InvalidRequestException @@ -48,11 +48,11 @@ module Canvas end def cassandra_column_exists?(table, column) - cql = %{ + cql = <<~SQL.squish SELECT #{column} FROM #{table} LIMIT 1 - } + SQL cassandra.execute(cql) true rescue CassandraCQL::Error::InvalidRequestException diff --git a/lib/canvas/migration/package_identifier.rb b/lib/canvas/migration/package_identifier.rb index 9704bf27791..8e56c3b51bb 100644 --- a/lib/canvas/migration/package_identifier.rb +++ b/lib/canvas/migration/package_identifier.rb @@ -53,8 +53,8 @@ module Canvas::Migration doc = create_xml_doc(data) if COMMON_CARTRIDGE_REGEX.match?(get_node_val(doc, 'metadata schema')) - if doc.at_css(%{resources resource[href="#{CC::CCHelper::COURSE_SETTINGS_DIR}/#{CC::CCHelper::SYLLABUS}"] file[href="#{CC::CCHelper::COURSE_SETTINGS_DIR}/#{CC::CCHelper::COURSE_SETTINGS}"]}) || - doc.at_css(%{resources resource[href="#{CC::CCHelper::COURSE_SETTINGS_DIR}/#{CC::CCHelper::CANVAS_EXPORT_FLAG}"]}) + if doc.at_css(%(resources resource[href="#{CC::CCHelper::COURSE_SETTINGS_DIR}/#{CC::CCHelper::SYLLABUS}"] file[href="#{CC::CCHelper::COURSE_SETTINGS_DIR}/#{CC::CCHelper::COURSE_SETTINGS}"])) || + doc.at_css(%(resources resource[href="#{CC::CCHelper::COURSE_SETTINGS_DIR}/#{CC::CCHelper::CANVAS_EXPORT_FLAG}"])) :canvas_cartridge elsif get_node_val(doc, 'metadata schemaversion') == "1.0.0" :common_cartridge_1_0 diff --git a/lib/canvas/password_policy.rb b/lib/canvas/password_policy.rb index 51e60e53680..ab2c94b41ba 100644 --- a/lib/canvas/password_policy.rb +++ b/lib/canvas/password_policy.rb @@ -57,7 +57,7 @@ module Canvas end # per http://www.prweb.com/releases/2012/10/prweb10046001.htm - COMMON_PASSWORDS = %w{ + COMMON_PASSWORDS = %w[ password 123456 12345678 @@ -83,6 +83,6 @@ module Canvas ninja mustang password1 - }.freeze + ].freeze end end diff --git a/lib/canvas/plugins/default_plugins.rb b/lib/canvas/plugins/default_plugins.rb index f3da2f196df..5cd016074c3 100644 --- a/lib/canvas/plugins/default_plugins.rb +++ b/lib/canvas/plugins/default_plugins.rb @@ -187,7 +187,7 @@ module Canvas::Plugins::DefaultPlugins :migration_partial => 'canvas_config', :requires_file_upload => true, :provides => { :canvas_cartridge => CC::Importer::Canvas::Converter }, - :valid_contexts => %w{Account Course} + :valid_contexts => %w[Account Course] }, } require_dependency 'canvas/migration/worker/course_copy_worker' @@ -206,7 +206,7 @@ module Canvas::Plugins::DefaultPlugins :skip_conversion_step => true, :required_options_validator => Canvas::Migration::Validators::CourseCopyValidator, :required_settings => [:source_course_id], - :valid_contexts => %w{Course} + :valid_contexts => %w[Course] }, } require_dependency 'canvas/migration/worker/zip_file_worker' @@ -225,7 +225,7 @@ module Canvas::Plugins::DefaultPlugins :no_selective_import => true, :required_options_validator => Canvas::Migration::Validators::ZipImporterValidator, :required_settings => [:source_folder_id], - :valid_contexts => %w(Course Group User) + :valid_contexts => %w[Course Group User] }, } Canvas::Plugin.register 'common_cartridge_importer', :export_system, { @@ -245,7 +245,7 @@ module Canvas::Plugins::DefaultPlugins :common_cartridge_1_1 => CC::Importer::Standard::Converter, :common_cartridge_1_2 => CC::Importer::Standard::Converter, :common_cartridge_1_3 => CC::Importer::Standard::Converter }, - :valid_contexts => %w{Account Course} + :valid_contexts => %w[Account Course] }, } Canvas::Plugin.register('grade_export', :sis, { diff --git a/lib/canvas/security/jwt_validator.rb b/lib/canvas/security/jwt_validator.rb index e991b71d89d..72d047e86cf 100644 --- a/lib/canvas/security/jwt_validator.rb +++ b/lib/canvas/security/jwt_validator.rb @@ -20,7 +20,7 @@ module Canvas::Security class JwtValidator include ActiveModel::Validations - REQUIRED_ASSERTIONS = Set.new(%w(sub aud exp iat jti)) + REQUIRED_ASSERTIONS = Set.new(%w[sub aud exp iat jti]) validate :assertions, :aud, :exp, :iat, :jti diff --git a/lib/cc/cc_helper.rb b/lib/cc/cc_helper.rb index e5722d10939..c02a4e2564c 100644 --- a/lib/cc/cc_helper.rb +++ b/lib/cc/cc_helper.rb @@ -328,10 +328,10 @@ module CC meta_fields.each_pair do |k, v| next unless v.present? - meta_html += %{\n} + meta_html += %(\n) end - %{\n\n\n#{HtmlTextHelper.escape_html(title)}\n#{meta_html}\n\n#{content}\n\n} + %(\n\n\n#{HtmlTextHelper.escape_html(title)}\n#{meta_html}\n\n#{content}\n\n) end def html_content(html) diff --git a/lib/cc/exporter/epub/converters/topic_epub_converter.rb b/lib/cc/exporter/epub/converters/topic_epub_converter.rb index c14654b2043..08e429e4c06 100644 --- a/lib/cc/exporter/epub/converters/topic_epub_converter.rb +++ b/lib/cc/exporter/epub/converters/topic_epub_converter.rb @@ -29,7 +29,7 @@ module CC::Exporter::Epub::Converters cc_path = @package_root.item_path res.at_css('file')['href'] canvas_id = get_node_att(res, 'dependency', 'identifierref') - if canvas_id && (meta_res = @manifest.at_css(%{resource[identifier="#{canvas_id}"]})) + if canvas_id && (meta_res = @manifest.at_css(%(resource[identifier="#{canvas_id}"]))) canvas_path = @package_root.item_path meta_res.at_css('file')['href'] meta_node = open_file_xml(canvas_path) else diff --git a/lib/cc/importer/canvas/quiz_metadata_converter.rb b/lib/cc/importer/canvas/quiz_metadata_converter.rb index ff761c29738..1260946c49f 100644 --- a/lib/cc/importer/canvas/quiz_metadata_converter.rb +++ b/lib/cc/importer/canvas/quiz_metadata_converter.rb @@ -54,7 +54,7 @@ module CC::Importer::Canvas quiz['hide_correct_answers_at'] = get_time_val(doc, 'hide_correct_answers_at') quiz['time_limit'] = get_int_val(doc, 'time_limit') quiz['allowed_attempts'] = get_int_val(doc, 'allowed_attempts') - %w( + %w[ could_be_locked anonymous_submissions show_correct_answers @@ -69,7 +69,7 @@ module CC::Importer::Canvas one_time_results show_correct_answers_last_attempt only_visible_to_overrides - ).each do |bool_val| + ].each do |bool_val| val = get_bool_val(doc, bool_val) quiz[bool_val] = val unless val.nil? end diff --git a/lib/cc/importer/canvas/topic_converter.rb b/lib/cc/importer/canvas/topic_converter.rb index 53ccf2afbf3..1d34199a13e 100644 --- a/lib/cc/importer/canvas/topic_converter.rb +++ b/lib/cc/importer/canvas/topic_converter.rb @@ -29,7 +29,7 @@ module CC::Importer::Canvas cc_path = @package_root.item_path res.at_css('file')['href'] cc_id = res['identifier'] canvas_id = get_node_att(res, 'dependency', 'identifierref') - if canvas_id && (meta_res = @manifest.at_css(%{resource[identifier="#{canvas_id}"]})) + if canvas_id && (meta_res = @manifest.at_css(%(resource[identifier="#{canvas_id}"]))) canvas_path = @package_root.item_path meta_res.at_css('file')['href'] meta_node = open_file_xml(canvas_path) else @@ -70,7 +70,7 @@ module CC::Importer::Canvas topic['workflow_state'] = wf_state if wf_state.present? topic['group_category'] = get_node_val(meta_doc, 'group_category') topic['todo_date'] = get_time_val(meta_doc, 'todo_date') - %w(has_group_category allow_rating only_graders_can_rate sort_by_rating locked).each do |setting| + %w[has_group_category allow_rating only_graders_can_rate sort_by_rating locked].each do |setting| get_bool_val(meta_doc, setting).tap { |val| topic[setting] = val unless val.nil? } end if (asmnt_node = meta_doc.at_css('assignment')) diff --git a/lib/cc/lti_resource_links.rb b/lib/cc/lti_resource_links.rb index 532d23c711c..712fbf3ae81 100644 --- a/lib/cc/lti_resource_links.rb +++ b/lib/cc/lti_resource_links.rb @@ -87,13 +87,13 @@ module CC 'xmlns:lticm' => 'http://www.imsglobal.org/xsd/imslticm_v1p0', 'xmlns:lticp' => 'http://www.imsglobal.org/xsd/imslticp_v1p0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => %w( + 'xsi:schemaLocation' => %w[ http://www.imsglobal.org/xsd/imslticc_v1p3.xsd http://www.imsglobal.org/xsd/imslticp_v1p0 imslticp_v1p0.xsd http://www.imsglobal.org/xsd/imslticm_v1p0 imslticm_v1p0.xsd http://www.imsglobal.org/xsd/imsbasiclti_v1p0 imsbasiclti_v1p0p1.xsd - ).join(' ') + ].join(' ') ) do |cartridge_basiclti_link| # Basic elements cartridge_basiclti_link.blti :title, tool.name diff --git a/lib/cc/qti/qti_manifest.rb b/lib/cc/qti/qti_manifest.rb index 50a68a636f5..ced193cb819 100644 --- a/lib/cc/qti/qti_manifest.rb +++ b/lib/cc/qti/qti_manifest.rb @@ -119,7 +119,7 @@ module CC md.imsmd :lom do |lom| lom.imsmd :general do |general| general.imsmd :title do |title| - title.imsmd :string, %{QTI Quiz Export for course "#{course.name}"} + title.imsmd :string, %(QTI Quiz Export for course "#{course.name}") end end lom.imsmd :lifeCycle do |general| diff --git a/lib/course_link_validator.rb b/lib/course_link_validator.rb index f04c9893d4a..aedd54b2d91 100644 --- a/lib/course_link_validator.rb +++ b/lib/course_link_validator.rb @@ -307,7 +307,7 @@ class CourseLinkValidator begin response = CanvasHttp.head(url, { "Accept-Encoding" => "gzip" }, redirect_limit: 9, redirect_spy: redirect_proc) - if %w{404 405}.include?(response.code) + if %w[404 405].include?(response.code) response = CanvasHttp.get(url, { "Accept-Encoding" => "gzip" }, redirect_limit: 9, redirect_spy: redirect_proc) do # don't read the response body end diff --git a/lib/custom_validations.rb b/lib/custom_validations.rb index 528dbe0909d..c02a80b079a 100644 --- a/lib/custom_validations.rb +++ b/lib/custom_validations.rb @@ -20,7 +20,7 @@ module CustomValidations module ClassMethods - def validates_as_url(*fields, allowed_schemes: %w{http https}) + def validates_as_url(*fields, allowed_schemes: %w[http https]) validates_each(fields, :allow_nil => true) do |record, attr, value| value, = CanvasHttp.validate_url(value, allowed_schemes: allowed_schemes) diff --git a/lib/data_fixup/add_role_overrides_for_new_permission.rb b/lib/data_fixup/add_role_overrides_for_new_permission.rb index 5baeb4ea2d6..89e53543a66 100644 --- a/lib/data_fixup/add_role_overrides_for_new_permission.rb +++ b/lib/data_fixup/add_role_overrides_for_new_permission.rb @@ -41,7 +41,7 @@ module DataFixup::AddRoleOverridesForNewPermission new_ro = RoleOverride.new new_ro.permission = new_permission - attrs = ro.attributes.slice(*%w{context_type context_id role_id locked enabled applies_to_self applies_to_descendants applies_to_env root_account_id}) + attrs = ro.attributes.slice(*%w[context_type context_id role_id locked enabled applies_to_self applies_to_descendants applies_to_env root_account_id]) new_ro.assign_attributes(attrs) new_ro.save! end diff --git a/lib/data_fixup/init_account_index_for_course_audit_log.rb b/lib/data_fixup/init_account_index_for_course_audit_log.rb index 7a99e973f89..b250723a497 100644 --- a/lib/data_fixup/init_account_index_for_course_audit_log.rb +++ b/lib/data_fixup/init_account_index_for_course_audit_log.rb @@ -49,19 +49,19 @@ module DataFixup end def drop_table - database.execute %{DROP TABLE #{LAST_BATCH_TABLE};} + database.execute %(DROP TABLE #{LAST_BATCH_TABLE};) end - SEARCH_CQL = %{ + SEARCH_CQL = <<~SQL.squish SELECT id, created_at, course_id, account_id FROM courses WHERE token(id) > token(?) LIMIT ? - } + SQL - UPDATE_CQL = %{ + UPDATE_CQL = <<~SQL.squish UPDATE courses SET account_id = ? WHERE id = ? - } + SQL ResultStruct = Struct.new(:index, :record, :key) @@ -172,11 +172,11 @@ module DataFixup end def table_exists?(table) - cql = %{ + cql = <<~SQL.squish SELECT * FROM #{table} LIMIT 1 - } + SQL database.execute(cql) true rescue CassandraCQL::Error::InvalidRequestException diff --git a/lib/data_fixup/lti/fill_custom_claim_columns_for_resource_link.rb b/lib/data_fixup/lti/fill_custom_claim_columns_for_resource_link.rb index fee1b7ef2c7..ed7d5dc1341 100644 --- a/lib/data_fixup/lti/fill_custom_claim_columns_for_resource_link.rb +++ b/lib/data_fixup/lti/fill_custom_claim_columns_for_resource_link.rb @@ -28,18 +28,18 @@ module DataFixup::Lti::FillCustomClaimColumnsForResourceLink end def self.drop_resource_links_without_a_context - Lti::LineItem.connection.execute(%{ + Lti::LineItem.connection.execute(<<~SQL.squish) DELETE FROM #{Lti::LineItem.quoted_table_name} WHERE lti_resource_link_id IN ( SELECT ID FROM #{Lti::ResourceLink.quoted_table_name} WHERE context_type IS NULL OR context_id IS NULL ); - }) + SQL - Lti::ResourceLink.connection.execute(%{ + Lti::ResourceLink.connection.execute(<<~SQL.squish) DELETE FROM #{Lti::ResourceLink.quoted_table_name} WHERE context_type IS NULL OR context_id IS NULL; - }) + SQL end def self.update_context! diff --git a/lib/data_fixup/populate_root_account_id_on_asset_user_accesses.rb b/lib/data_fixup/populate_root_account_id_on_asset_user_accesses.rb index 2541c5908f6..73e99dd10d8 100644 --- a/lib/data_fixup/populate_root_account_id_on_asset_user_accesses.rb +++ b/lib/data_fixup/populate_root_account_id_on_asset_user_accesses.rb @@ -22,7 +22,7 @@ module DataFixup::PopulateRootAccountIdOnAssetUserAccesses # all other context types are handled in PopulateRootAccountIdOnModels to_transform = AssetUserAccess.where(id: min..max, context_type: "User") - asset_types = %w(attachment calendar_event group course) + asset_types = %w[attachment calendar_event group course] # find any other asset types besides these and "user" (which the backfill fills with 0) types_string = [*asset_types, "user"].map { |t| "'%#{t}%'" }.join(',') diff --git a/lib/feature.rb b/lib/feature.rb index 71275dead33..69048360e40 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -29,7 +29,7 @@ class Feature @state = 'allowed' opts.each do |key, val| next unless ATTRS.include?(key) - next if key == :state && !%w(hidden off allowed on allowed_on).include?(val) + next if key == :state && !%w[hidden off allowed on allowed_on].include?(val) instance_variable_set "@#{key}", val end @@ -132,9 +132,9 @@ class Feature STATE_DISABLED = 'disabled' VALID_STATES = [STATE_ON, STATE_DEFAULT_OFF, STATE_DEFAULT_ON, STATE_HIDDEN, STATE_DISABLED].freeze - VALID_APPLIES_TO = %w(Course Account RootAccount User SiteAdmin).freeze - VALID_ENVS = %i(development ci beta test production).freeze - VALID_TYPES = %w(feature_option setting).freeze + VALID_APPLIES_TO = %w[Course Account RootAccount User SiteAdmin].freeze + VALID_ENVS = %i[development ci beta test production].freeze + VALID_TYPES = %w[feature_option setting].freeze DISABLED_FEATURE = Feature.new.freeze diff --git a/lib/google_docs_preview.rb b/lib/google_docs_preview.rb index 4e05371ab59..0ee3bfc588f 100644 --- a/lib/google_docs_preview.rb +++ b/lib/google_docs_preview.rb @@ -19,7 +19,7 @@ # module GoogleDocsPreview - PREVIEWABLE_TYPES = %w{ + PREVIEWABLE_TYPES = %w[ application/vnd.openxmlformats-officedocument.wordprocessingml.template application/vnd.oasis.opendocument.spreadsheet application/vnd.sun.xml.writer @@ -43,7 +43,7 @@ module GoogleDocsPreview application/postscript application/pdf application/vnd.ms-powerpoint - }.freeze + ].freeze def self.previewable?(account, attachment) account&.service_enabled?(:google_docs_previews) && diff --git a/lib/gradebook_importer.rb b/lib/gradebook_importer.rb index 69855a6ce80..0d7105e41a9 100644 --- a/lib/gradebook_importer.rb +++ b/lib/gradebook_importer.rb @@ -21,10 +21,10 @@ require 'csv' class GradebookImporter - ASSIGNMENT_PRELOADED_FIELDS = %i/ + ASSIGNMENT_PRELOADED_FIELDS = %i[ id title points_possible grading_type updated_at context_id context_type group_category_id created_at due_at only_visible_to_overrides moderated_grading grades_published_at final_grader_id - /.freeze + ].freeze class NegativeId class << self @@ -696,7 +696,7 @@ class GradebookImporter csv_file = attachment.open(need_local_file: true) is_semicolon_delimited = semicolon_delimited?(csv_file) csv_parse_options = { - converters: %i(nil decimal_comma_to_period), + converters: %i[nil decimal_comma_to_period], skip_lines: /^[;, ]+$/, col_sep: is_semicolon_delimited ? ";" : "," } diff --git a/lib/has_content_tags.rb b/lib/has_content_tags.rb index a29343a5eec..79d4509310e 100644 --- a/lib/has_content_tags.rb +++ b/lib/has_content_tags.rb @@ -30,7 +30,7 @@ module HasContentTags def check_if_associated_content_tags_need_updating @associated_content_tags_need_updating = false return if self.new_record? - return if self.respond_to?(:context_type) && %w{SisBatch Folder}.include?(self.context_type) + return if self.respond_to?(:context_type) && %w[SisBatch Folder].include?(self.context_type) @associated_content_tags_need_updating = true if self.respond_to?(:title_changed?) && self.title_changed? @associated_content_tags_need_updating = true if self.respond_to?(:name_changed?) && self.name_changed? diff --git a/lib/lti/app_launch_collator.rb b/lib/lti/app_launch_collator.rb index 3c0c66708b3..3367249b6df 100644 --- a/lib/lti/app_launch_collator.rb +++ b/lib/lti/app_launch_collator.rb @@ -19,11 +19,11 @@ # module Lti class AppLaunchCollator - CONTENT_MESSAGE_TYPES = %w( + CONTENT_MESSAGE_TYPES = %w[ ContentItemSelection ContentItemSelectionRequest LtiDeepLinkingRequest - ).freeze + ].freeze class << self def external_tools_for(context, placements, options = {}) diff --git a/lib/lti/content_item_response.rb b/lib/lti/content_item_response.rb index 71c202f3aac..54a56b7911c 100644 --- a/lib/lti/content_item_response.rb +++ b/lib/lti/content_item_response.rb @@ -24,7 +24,7 @@ module Lti class ContentItemResponse MEDIA_TYPES = [:assignments, :discussion_topics, :modules, :module_items, :pages, :quizzes, :files].freeze - SUPPORTED_EXPORT_TYPES = %w(common_cartridge).freeze + SUPPORTED_EXPORT_TYPES = %w[common_cartridge].freeze def initialize(context, controller, current_user, media_types, export_type) @context = context diff --git a/lib/lti/content_item_selection_request.rb b/lib/lti/content_item_selection_request.rb index e22b0ba5413..c1e2172e5c2 100644 --- a/lib/lti/content_item_selection_request.rb +++ b/lib/lti/content_item_selection_request.rb @@ -129,7 +129,7 @@ module Lti end end - INDEX_MENU_TOOL_TYPES = %w{ + INDEX_MENU_TOOL_TYPES = %w[ assignment_index_menu assignment_group_menu discussion_topic_index_menu @@ -138,7 +138,7 @@ module Lti module_group_menu quiz_index_menu wiki_index_menu - }.freeze + ].freeze def placement_params(placement, assignment: nil) case placement @@ -161,19 +161,19 @@ module Lti end def migration_selection_params - accept_media_types = %w( + accept_media_types = %w[ application/vnd.ims.imsccv1p1 application/vnd.ims.imsccv1p2 application/vnd.ims.imsccv1p3 application/zip application/xml - ) + ] { accept_media_types: accept_media_types.join(','), accept_presentation_document_targets: 'download', accept_copy_advice: true, - ext_content_file_extensions: %w(zip imscc mbz xml).join(','), + ext_content_file_extensions: %w[zip imscc mbz xml].join(','), accept_unsigned: true, auto_create: false } @@ -181,8 +181,8 @@ module Lti def editor_button_params { - accept_media_types: %w(image/* text/html application/vnd.ims.lti.v1.ltilink */*).join(','), - accept_presentation_document_targets: %w(embed frame iframe window).join(','), + accept_media_types: %w[image/* text/html application/vnd.ims.lti.v1.ltilink */*].join(','), + accept_presentation_document_targets: %w[embed frame iframe window].join(','), accept_unsigned: true, accept_multiple: true, auto_create: false @@ -192,7 +192,7 @@ module Lti def lti_launch_selection_params { accept_media_types: 'application/vnd.ims.lti.v1.ltilink', - accept_presentation_document_targets: %w(frame window).join(','), + accept_presentation_document_targets: %w[frame window].join(','), accept_unsigned: true, auto_create: false } diff --git a/lib/lti/messages/deep_linking_request.rb b/lib/lti/messages/deep_linking_request.rb index 0796ec78b0e..7a13eb62e4f 100644 --- a/lib/lti/messages/deep_linking_request.rb +++ b/lib/lti/messages/deep_linking_request.rb @@ -35,77 +35,77 @@ module Lti::Messages DEEP_LINKING_DETAILS = { 'assignment_selection' => { accept_multiple: false, - accept_types: %w(ltiResourceLink).freeze, + accept_types: %w[ltiResourceLink].freeze, auto_create: false, - document_targets: %w(iframe window).freeze, - media_types: %w(application/vnd.ims.lti.v1.ltilink).freeze + document_targets: %w[iframe window].freeze, + media_types: %w[application/vnd.ims.lti.v1.ltilink].freeze }.freeze, 'collaboration' => { accept_multiple: false, - accept_types: %w(ltiResourceLink).freeze, + accept_types: %w[ltiResourceLink].freeze, auto_create: true, - document_targets: %w(iframe).freeze, - media_types: %w(application/vnd.ims.lti.v1.ltilink).freeze + document_targets: %w[iframe].freeze, + media_types: %w[application/vnd.ims.lti.v1.ltilink].freeze }.freeze, 'conference_selection' => { accept_multiple: false, - accept_types: %w(link html).freeze, + accept_types: %w[link html].freeze, auto_create: true, - document_targets: %w(iframe window).freeze, - media_types: %w(text/html */*).freeze + document_targets: %w[iframe window].freeze, + media_types: %w[text/html */*].freeze }.freeze, 'course_assignments_menu' => { accept_multiple: true, - accept_types: %w(ltiResourceLink).freeze, + accept_types: %w[ltiResourceLink].freeze, auto_create: false, - document_targets: %w(iframe window).freeze, - media_types: %w(application/vnd.ims.lti.v1.ltilink).freeze + document_targets: %w[iframe window].freeze, + media_types: %w[application/vnd.ims.lti.v1.ltilink].freeze }.freeze, 'editor_button' => { accept_multiple: true, - accept_types: %w(link file html ltiResourceLink image).freeze, + accept_types: %w[link file html ltiResourceLink image].freeze, auto_create: false, - document_targets: %w(embed iframe window).freeze, - media_types: %w(image/* text/html application/vnd.ims.lti.v1.ltilink */*).freeze + document_targets: %w[embed iframe window].freeze, + media_types: %w[image/* text/html application/vnd.ims.lti.v1.ltilink */*].freeze }.freeze, 'homework_submission' => { accept_multiple: false, - accept_types: %w(file ltiResourceLink).freeze, + accept_types: %w[file ltiResourceLink].freeze, auto_create: false, - document_targets: %w(iframe).freeze, - media_types: %w(*/*).freeze + document_targets: %w[iframe].freeze, + media_types: %w[*/*].freeze }.freeze, 'link_selection' => { accept_multiple: true, - accept_types: %w(ltiResourceLink).freeze, + accept_types: %w[ltiResourceLink].freeze, auto_create: false, - document_targets: %w(iframe window).freeze, - media_types: %w(application/vnd.ims.lti.v1.ltilink).freeze + document_targets: %w[iframe window].freeze, + media_types: %w[application/vnd.ims.lti.v1.ltilink].freeze }.freeze, 'migration_selection' => { accept_multiple: false, - accept_types: %w(file).freeze, + accept_types: %w[file].freeze, auto_create: false, - document_targets: %w(iframe).freeze, - media_types: %w(application/vnd.ims.imsccv1p1 application/vnd.ims.imsccv1p2 application/vnd.ims.imsccv1p3 application/zip application/xml).freeze + document_targets: %w[iframe].freeze, + media_types: %w[application/vnd.ims.imsccv1p1 application/vnd.ims.imsccv1p2 application/vnd.ims.imsccv1p3 application/zip application/xml].freeze }.freeze, 'module_index_menu_modal' => { accept_multiple: true, - accept_types: %w(ltiResourceLink).freeze, + accept_types: %w[ltiResourceLink].freeze, auto_create: true, - document_targets: %w(iframe window).freeze, - media_types: %w(application/vnd.ims.lti.v1.ltilink).freeze + document_targets: %w[iframe window].freeze, + media_types: %w[application/vnd.ims.lti.v1.ltilink].freeze }.freeze, 'submission_type_selection' => { accept_multiple: false, - accept_types: %w(ltiResourceLink).freeze, + accept_types: %w[ltiResourceLink].freeze, auto_create: false, - document_targets: %w(iframe window).freeze, - media_types: %w(application/vnd.ims.lti.v1.ltilink).freeze + document_targets: %w[iframe window].freeze, + media_types: %w[application/vnd.ims.lti.v1.ltilink].freeze }.freeze }.freeze - MODAL_PLACEMENTS = %w(editor_button assignment_selection link_selection migration_selection course_assignments_menu module_index_menu_modal).freeze + MODAL_PLACEMENTS = %w[editor_button assignment_selection link_selection migration_selection course_assignments_menu module_index_menu_modal].freeze def initialize(tool:, context:, user:, expander:, return_url:, opts: {}) super diff --git a/lib/lti/oauth2/access_token.rb b/lib/lti/oauth2/access_token.rb index 689090fc912..d2341403545 100644 --- a/lib/lti/oauth2/access_token.rb +++ b/lib/lti/oauth2/access_token.rb @@ -91,7 +91,7 @@ module Lti end def check_required_assertions(assertion_keys) - missing_assertions = (%w(iss sub exp aud iat nbf jti) - assertion_keys) + missing_assertions = (%w[iss sub exp aud iat nbf jti] - assertion_keys) if missing_assertions.present? raise InvalidTokenError, "the following assertions are missing: #{missing_assertions.join(',')}" end diff --git a/lib/lti/plagiarism_subscriptions_helper.rb b/lib/lti/plagiarism_subscriptions_helper.rb index ca424daf0f6..5d5c9570e2f 100644 --- a/lib/lti/plagiarism_subscriptions_helper.rb +++ b/lib/lti/plagiarism_subscriptions_helper.rb @@ -25,11 +25,11 @@ module Lti end SUBMISSION_EVENT_ID = 'vnd.Canvas.SubmissionEvent' - EVENT_TYPES = %w(submission_created + EVENT_TYPES = %w[submission_created plagiarism_resubmit submission_updated assignment_updated - assignment_created).freeze + assignment_created].freeze def initialize(tool_proxy) @tool_proxy = tool_proxy diff --git a/lib/lti/privacy_level_expander.rb b/lib/lti/privacy_level_expander.rb index ece8eb87fb7..15e39c60051 100644 --- a/lib/lti/privacy_level_expander.rb +++ b/lib/lti/privacy_level_expander.rb @@ -20,13 +20,13 @@ module Lti class PrivacyLevelExpander - EMAIL_ONLY = %w(Person.email.primary).freeze - INLCUDE_NAME = %w(Person.name.given Person.name.full Person.name.family).freeze - PUBLIC = %w(Person.sourcedId CourseOffering.sourcedId) + EMAIL_ONLY = %w[Person.email.primary].freeze + INLCUDE_NAME = %w[Person.name.given Person.name.full Person.name.family].freeze + PUBLIC = %w[Person.sourcedId CourseOffering.sourcedId] .concat(EMAIL_ONLY) .concat(INLCUDE_NAME) .freeze - ANONYMOUS = %w(com.instructure.contextLabel).freeze + ANONYMOUS = %w[com.instructure.contextLabel].freeze SUPPORTED_PARAMETERS_HASH = { public: PUBLIC, diff --git a/lib/lti/tool_proxy_validator.rb b/lib/lti/tool_proxy_validator.rb index 08c8d16bd3e..3d29d8db828 100644 --- a/lib/lti/tool_proxy_validator.rb +++ b/lib/lti/tool_proxy_validator.rb @@ -99,7 +99,7 @@ module Lti def restricted_security_profile_errors messages = {} - profiles = %w(oauth2_access_token_ws_security lti_jwt_ws_security) + profiles = %w[oauth2_access_token_ws_security lti_jwt_ws_security] if tool_proxy.tool_profile.security_profiles.select { |s| profiles.include?(s.security_profile_name) }.present? unless tool_proxy.enabled_capabilities.include?('Security.splitSecret') messages[:restricted_security_profiles] = ['Security.splitSecret is required'] diff --git a/lib/microsoft_sync/settings_validator.rb b/lib/microsoft_sync/settings_validator.rb index f73502b049d..831fd9a17e3 100644 --- a/lib/microsoft_sync/settings_validator.rb +++ b/lib/microsoft_sync/settings_validator.rb @@ -23,10 +23,10 @@ module MicrosoftSync # primary use is in the Accounts controller. class SettingsValidator # A list of all sync settings, as a final source of truth. - SYNC_SETTINGS = %i(microsoft_sync_enabled microsoft_sync_tenant microsoft_sync_login_attribute - microsoft_sync_login_attribute_suffix microsoft_sync_remote_attribute).freeze - VALID_SYNC_LOGIN_ATTRIBUTES = %w(email preferred_username sis_user_id integration_id).freeze - VALID_SYNC_REMOTE_ATTRIBUTES = %w(userPrincipalName mail mailNickname).freeze + SYNC_SETTINGS = %i[microsoft_sync_enabled microsoft_sync_tenant microsoft_sync_login_attribute + microsoft_sync_login_attribute_suffix microsoft_sync_remote_attribute].freeze + VALID_SYNC_LOGIN_ATTRIBUTES = %w[email preferred_username sis_user_id integration_id].freeze + VALID_SYNC_REMOTE_ATTRIBUTES = %w[userPrincipalName mail mailNickname].freeze attr_reader :settings, :account diff --git a/lib/notification_message_creator.rb b/lib/notification_message_creator.rb index 0aaec7f15c5..c851381d6f5 100644 --- a/lib/notification_message_creator.rb +++ b/lib/notification_message_creator.rb @@ -148,7 +148,7 @@ class NotificationMessageCreator policy = effective_policy_for(user, channel) # if the policy is not daily or weekly, it is either immediate which was # picked up before in build_immediate_message_for, or it's never. - return unless %w(daily weekly).include?(policy&.frequency) + return unless %w[daily weekly].include?(policy&.frequency) build_summary_for(user, policy) if policy end diff --git a/lib/sis/admin_importer.rb b/lib/sis/admin_importer.rb index 44f97b02f55..d422d5e6e97 100644 --- a/lib/sis/admin_importer.rb +++ b/lib/sis/admin_importer.rb @@ -64,7 +64,7 @@ module SIS raise ImportError, "No role_id or role given for admin" if role.blank? && role_id.blank? state = status.downcase.strip - raise ImportError, "Invalid status #{status} for admin" unless %w(active deleted).include? state + raise ImportError, "Invalid status #{status} for admin" unless %w[active deleted].include? state return if @batch.skip_deletes? && state == 'deleted' get_account(account_id) diff --git a/lib/sis/course_importer.rb b/lib/sis/course_importer.rb index ef770c6529c..f48661d66a7 100644 --- a/lib/sis/course_importer.rb +++ b/lib/sis/course_importer.rb @@ -107,7 +107,7 @@ module SIS course.sis_source_id = course_id active_state = status.casecmp?('published') ? 'available' : 'claimed' unless course.stuck_sis_fields.include?(:workflow_state) - if %w(active unpublished published).include?(status.downcase) + if %w[active unpublished published].include?(status.downcase) case course.workflow_state when 'completed' # not using active state here, because it has always been set to available diff --git a/lib/sis/csv/diff_generator.rb b/lib/sis/csv/diff_generator.rb index eb1c398b65b..56151d740a5 100644 --- a/lib/sis/csv/diff_generator.rb +++ b/lib/sis/csv/diff_generator.rb @@ -51,7 +51,7 @@ module SIS { :file_io => File.open(output_path, 'rb'), :row_count => row_count } end - VALID_ENROLLMENT_DROP_STATUS = %w(deleted inactive completed deleted_last_completed).freeze + VALID_ENROLLMENT_DROP_STATUS = %w[deleted inactive completed deleted_last_completed].freeze def generate_csvs(previous_csvs, current_csvs) generated = [] diff --git a/lib/sis/csv/import_refactored.rb b/lib/sis/csv/import_refactored.rb index 4ab43089fc7..031cd219282 100644 --- a/lib/sis/csv/import_refactored.rb +++ b/lib/sis/csv/import_refactored.rb @@ -34,11 +34,11 @@ module SIS # * Course must be imported before Section # * Course and Section must be imported before Xlist # * Course, Section, and User must be imported before Enrollment - IMPORTERS = %i{change_sis_id account term abstract_course course section + IMPORTERS = %i[change_sis_id account term abstract_course course section xlist user login enrollment admin group_category group group_membership - grade_publishing_results user_observer}.freeze + grade_publishing_results user_observer].freeze - HEADERS_TO_EXCLUDE_FOR_DOWNLOAD = %w{password ssha_password}.freeze + HEADERS_TO_EXCLUDE_FOR_DOWNLOAD = %w[password ssha_password].freeze def initialize(root_account, opts = {}) opts = opts.with_indifferent_access @@ -362,7 +362,7 @@ module SIS def is_last_parallel_importer_of_type?(parallel_importer) importer_type = parallel_importer.importer_type.to_sym - return false if @batch.parallel_importers.where(:importer_type => importer_type, :workflow_state => %w{queued running retry}).exists? + return false if @batch.parallel_importers.where(:importer_type => importer_type, :workflow_state => %w[queued running retry]).exists? SisBatch.transaction do @batch.reload(:lock => true) diff --git a/lib/sis/csv/login_importer.rb b/lib/sis/csv/login_importer.rb index 2462d2cdc15..1d77bbee093 100644 --- a/lib/sis/csv/login_importer.rb +++ b/lib/sis/csv/login_importer.rb @@ -23,7 +23,7 @@ module SIS # note these are account-level groups, not course groups class LoginImporter < CSVBaseImporter def self.login_csv?(row) - (row & %w{existing_user_id existing_integration_id existing_canvas_user_id}).any? + (row & %w[existing_user_id existing_integration_id existing_canvas_user_id]).any? end def self.identifying_fields diff --git a/lib/sis/csv/user_importer.rb b/lib/sis/csv/user_importer.rb index 018f6d352a5..67d3a6e0c7e 100644 --- a/lib/sis/csv/user_importer.rb +++ b/lib/sis/csv/user_importer.rb @@ -22,7 +22,7 @@ module SIS module CSV class UserImporter < CSVBaseImporter def self.user_csv?(row) - login_csv = (row & %w{existing_user_id existing_integration_id existing_canvas_user_id}.freeze).empty? + login_csv = (row & %w[existing_user_id existing_integration_id existing_canvas_user_id].freeze).empty? row.include?('user_id') && row.include?('login_id') && login_csv end diff --git a/lib/sis/enrollment_importer.rb b/lib/sis/enrollment_importer.rb index 39729b76513..be2a28a7b24 100644 --- a/lib/sis/enrollment_importer.rb +++ b/lib/sis/enrollment_importer.rb @@ -292,7 +292,7 @@ module SIS end @courses_to_touch_ids.add(enrollment.course_id) - if enrollment.should_update_user_account_association? && !%w{creation_pending deleted}.include?(user.workflow_state) + if enrollment.should_update_user_account_association? && !%w[creation_pending deleted].include?(user.workflow_state) if enrollment.new_record? && !@update_account_association_user_ids.include?(user.id) @incrementally_update_account_associations_user_ids.add(user.id) else @@ -447,8 +447,8 @@ module SIS end def enrollment_needs_due_date_recaching?(enrollment) - unless %w(active inactive).include? enrollment.workflow_state_before_last_save - return %w(active inactive).include? enrollment.workflow_state + unless %w[active inactive].include? enrollment.workflow_state_before_last_save + return %w[active inactive].include? enrollment.workflow_state end false diff --git a/lib/sis/grade_publishing_results_importer.rb b/lib/sis/grade_publishing_results_importer.rb index f5366e83a7e..d8005ba8acd 100644 --- a/lib/sis/grade_publishing_results_importer.rb +++ b/lib/sis/grade_publishing_results_importer.rb @@ -39,7 +39,7 @@ module SIS def add_grade_publishing_result(enrollment_id, grade_publishing_status, message = nil) raise ImportError, "No enrollment_id given" if enrollment_id.blank? raise ImportError, "No grade_publishing_status given for enrollment #{enrollment_id}" if grade_publishing_status.blank? - raise ImportError, "Improper grade_publishing_status \"#{grade_publishing_status}\" for enrollment #{enrollment_id}" unless %w{published error}.include?(grade_publishing_status.downcase) + raise ImportError, "Improper grade_publishing_status \"#{grade_publishing_status}\" for enrollment #{enrollment_id}" unless %w[published error].include?(grade_publishing_status.downcase) if Enrollment.where(:id => enrollment_id, :root_account_id => @root_account) .update_all(:grade_publishing_status => grade_publishing_status.downcase, diff --git a/lib/sis/term_importer.rb b/lib/sis/term_importer.rb index 1a23942b0e3..3bf035c2623 100644 --- a/lib/sis/term_importer.rb +++ b/lib/sis/term_importer.rb @@ -52,7 +52,7 @@ module SIS if date_override_enrollment_type # only configure the date override if this row is present raise ImportError, "Cannot set date override on non-existent term" if term.new_record? - unless %w(StudentEnrollment TeacherEnrollment TaEnrollment DesignerEnrollment).include?(date_override_enrollment_type) + unless %w[StudentEnrollment TeacherEnrollment TaEnrollment DesignerEnrollment].include?(date_override_enrollment_type) raise ImportError, "Invalid date_override_enrollment_type" end diff --git a/lib/tasks/canvas.rake b/lib/tasks/canvas.rake index 23a0d65b8e8..e6324ae7c15 100644 --- a/lib/tasks/canvas.rake +++ b/lib/tasks/canvas.rake @@ -217,7 +217,7 @@ unless $canvas_tasks_loaded block.call(servers) end - %w{db:pending_migrations db:skipped_migrations db:migrate:predeploy db:migrate:tagged}.each do |task_name| + %w[db:pending_migrations db:skipped_migrations db:migrate:predeploy db:migrate:tagged].each do |task_name| Switchman::Rake.shardify_task(task_name, categories: -> { Shard.categories }) end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 4b7d8ef3aa1..6a3983fc515 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -6,7 +6,7 @@ end # enhancing these _after_ switchman conveniently means it will execute only once, # not once per shard, and after the migrations have run -%w{db:migrate db:migrate:predeploy db:migrate:up db:migrate:down db:rollback}.each do |task_name| +%w[db:migrate db:migrate:predeploy db:migrate:up db:migrate:down db:rollback].each do |task_name| Rake::Task[task_name].enhance do MultiCache.delete("schema_cache") end diff --git a/lib/tasks/parallel_exclude.rb b/lib/tasks/parallel_exclude.rb index d3e31297e0e..71d86236721 100644 --- a/lib/tasks/parallel_exclude.rb +++ b/lib/tasks/parallel_exclude.rb @@ -28,6 +28,6 @@ module Tasks::ParallelExclude "spec/models/attachment_spec.rb" ].freeze - test_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium') + test_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r{spec_canvas/selenium}) + FileList['spec/**/*_spec.rb'].exclude(%r{spec/selenium}) AVAILABLE_FILES = FILES.select { |file_name| test_files.include?(file_name) } end diff --git a/lib/tasks/remove_schema_sig.rake b/lib/tasks/remove_schema_sig.rake index e3543f3bedc..7f5e9736e52 100644 --- a/lib/tasks/remove_schema_sig.rake +++ b/lib/tasks/remove_schema_sig.rake @@ -2,9 +2,9 @@ desc 'Removes the schema line in fixtures, models, and specs.' task :remove_schema_signature do - models = Dir.glob(File.join(File.dirname(__FILE__), %w(.. .. app models)) + "/*.rb") - specs = Dir.glob(File.join(File.dirname(__FILE__), %w(.. .. spec models)) + "/*.rb") - fixtures = Dir.glob(File.join(File.dirname(__FILE__), %w(.. .. spec fixtures)) + "/*.yml") + models = Dir.glob(File.join(File.dirname(__FILE__), %w[.. .. app models]) + "/*.rb") + specs = Dir.glob(File.join(File.dirname(__FILE__), %w[.. .. spec models]) + "/*.rb") + fixtures = Dir.glob(File.join(File.dirname(__FILE__), %w[.. .. spec fixtures]) + "/*.yml") files = models | specs | fixtures files.each { |file| remove_signature(file) } end diff --git a/lib/tasks/rspec.rake b/lib/tasks/rspec.rake index f1572432377..146e59f5db7 100644 --- a/lib/tasks/rspec.rake +++ b/lib/tasks/rspec.rake @@ -45,9 +45,9 @@ unless Rails.env.production? || ARGV.any? { |a| a.start_with?('gems') } # you can also do SPEC_OPTS='-e "test name"' but this is a little easier I # suppose. if ENV['SINGLE_TEST'] - t.spec_opts += ['-e', %{"#{ENV['SINGLE_TEST']}"}] + t.spec_opts += ['-e', %("#{ENV['SINGLE_TEST']}")] end - spec_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium') + spec_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r{spec_canvas/selenium}) + FileList['spec/**/*_spec.rb'].exclude(%r{spec/selenium}) Gem.loaded_specs.values.each do |spec| path = spec.full_gem_path spec_canvas_path = File.expand_path(path + "/spec_canvas") @@ -118,7 +118,7 @@ unless Rails.env.production? || ARGV.any? { |a| a.start_with?('gems') } desc "Run the code examples in {gems,vendor}/plugins (except RSpec's own)" klass.new(:coverage) do |t| t.spec_opts = ['--options', Shellwords.escape(Rails.root.join("spec/spec.opts"))] - t.send(spec_files_attr, FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium')) + t.send(spec_files_attr, FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r{spec_canvas/selenium}) + FileList['spec/**/*_spec.rb'].exclude(%r{spec/selenium})) end namespace :plugins do @@ -132,13 +132,13 @@ unless Rails.env.production? || ARGV.any? { |a| a.start_with?('gems') } # Setup specs for stats task :statsetup do require 'rails/code_statistics' - ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models') - ::STATS_DIRECTORIES << %w(Service\ specs spec/services) if File.exist?('spec/services') - ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views') - ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers') - ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers') - ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib') - ::STATS_DIRECTORIES << %w(Routing\ specs spec/lib) if File.exist?('spec/routing') + ::STATS_DIRECTORIES << %w[Model\ specs spec/models] if File.exist?('spec/models') + ::STATS_DIRECTORIES << %w[Service\ specs spec/services] if File.exist?('spec/services') + ::STATS_DIRECTORIES << %w[View\ specs spec/views] if File.exist?('spec/views') + ::STATS_DIRECTORIES << %w[Controller\ specs spec/controllers] if File.exist?('spec/controllers') + ::STATS_DIRECTORIES << %w[Helper\ specs spec/helpers] if File.exist?('spec/helpers') + ::STATS_DIRECTORIES << %w[Library\ specs spec/lib] if File.exist?('spec/lib') + ::STATS_DIRECTORIES << %w[Routing\ specs spec/lib] if File.exist?('spec/routing') ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models') ::CodeStatistics::TEST_TYPES << "Service specs" if File.exist?('spec/services') ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views') diff --git a/lib/user_list_v2.rb b/lib/user_list_v2.rb index 1b8ee15e60f..cb316fc2a93 100644 --- a/lib/user_list_v2.rb +++ b/lib/user_list_v2.rb @@ -31,7 +31,7 @@ class UserListV2 # - only search on particular columns # - don't worry about whether we can create users or not: they either exist or they don't - SEARCH_TYPES = %w{unique_id sis_user_id cc_path}.freeze + SEARCH_TYPES = %w[unique_id sis_user_id cc_path].freeze def initialize(list_in, root_account: Account.default, search_type: nil, current_user: nil, can_read_sis: false) @errors = [] diff --git a/lib/user_merge.rb b/lib/user_merge.rb index 2f97b6783be..668e763ed30 100644 --- a/lib/user_merge.rb +++ b/lib/user_merge.rb @@ -128,10 +128,10 @@ class UserMerge Attachment.delay.migrate_attachments(from_user, target_user) updates = {} - %w(access_tokens asset_user_accesses calendar_events collaborations + %w[access_tokens asset_user_accesses calendar_events collaborations context_module_progressions group_memberships ignores page_comments Polling::Poll rubric_assessments user_services - web_conference_participants web_conferences wiki_pages).each do |key| + web_conference_participants web_conferences wiki_pages].each do |key| updates[key] = "user_id" end updates['submission_comments'] = 'author_id' @@ -202,7 +202,7 @@ class UserMerge return from_user.preferences if from_user.shard == target_user.shard preferences = from_user.preferences.dup - %i{custom_colors course_nicknames}.each do |pref| + %i[custom_colors course_nicknames].each do |pref| preferences.delete(pref) new_pref = {} from_user.preferences[pref]&.each do |key, value| diff --git a/script/linter.rb b/script/linter.rb index e1f4816385e..5d9e6346b4b 100644 --- a/script/linter.rb +++ b/script/linter.rb @@ -89,7 +89,7 @@ class Linter def severe_levels return @severe_levels if @severe_levels - boyscout_mode ? %w(info warn error fatal) : %w(warn error fatal) + boyscout_mode ? %w[info warn error fatal] : %w[warn error fatal] end private diff --git a/spec/apis/api_spec_helper.rb b/spec/apis/api_spec_helper.rb index 876e2b24564..ff3c914b036 100644 --- a/spec/apis/api_spec_helper.rb +++ b/spec/apis/api_spec_helper.rb @@ -164,7 +164,7 @@ end # response from the api for that field, which will be verified for correctness. def should_translate_user_content(course, include_verifiers = true) attachment = attachment_model(:context => course) - content = %{ + content = <<~HTML

Hello, students.
This will explain everything: important @@ -173,7 +173,7 @@ def should_translate_user_content(course, include_verifiers = true) Also, watch this awesome video: And refer to this awesome wiki page.

- } + HTML html = yield content check_document(html, course, attachment, include_verifiers) diff --git a/spec/apis/auth_spec.rb b/spec/apis/auth_spec.rb index ffa83246aa2..0aa56054701 100644 --- a/spec/apis/auth_spec.rb +++ b/spec/apis/auth_spec.rb @@ -633,7 +633,7 @@ describe "API Authentication", type: :request do auth_header = { 'HTTP_AUTHORIZATION' => "Bearer #{expired_services_jwt}" } get "/api/v1/courses", headers: auth_header assert_status(401) - expect(response['WWW-Authenticate']).to eq %{Bearer realm="canvas-lms"} + expect(response['WWW-Authenticate']).to eq %(Bearer realm="canvas-lms") end it "requires an active pseudonym" do @@ -711,25 +711,25 @@ describe "API Authentication", type: :request do it "errors if the access token is expired or non-existent" do get "/api/v1/courses", headers: { 'HTTP_AUTHORIZATION' => "Bearer blahblah" } assert_status(401) - expect(response['WWW-Authenticate']).to eq %{Bearer realm="canvas-lms"} + expect(response['WWW-Authenticate']).to eq %(Bearer realm="canvas-lms") @token.update_attribute(:expires_at, 1.hour.ago) get "/api/v1/courses", headers: { 'HTTP_AUTHORIZATION' => "Bearer #{@token.full_token}" } assert_status(401) - expect(response['WWW-Authenticate']).to eq %{Bearer realm="canvas-lms"} + expect(response['WWW-Authenticate']).to eq %(Bearer realm="canvas-lms") end it "errors if the developer key is inactive" do @token.developer_key.deactivate! get "/api/v1/courses", headers: { 'HTTP_AUTHORIZATION' => "Bearer #{@token.full_token}" } assert_status(401) - expect(response['WWW-Authenticate']).to eq %{Bearer realm="canvas-lms"} + expect(response['WWW-Authenticate']).to eq %(Bearer realm="canvas-lms") end it "requires an active pseudonym for the access token user" do @user.pseudonym.destroy get "/api/v1/courses", headers: { 'HTTP_AUTHORIZATION' => "Bearer #{@token.full_token}" } assert_status(401) - expect(response['WWW-Authenticate']).to eq %{Bearer realm="canvas-lms"} + expect(response['WWW-Authenticate']).to eq %(Bearer realm="canvas-lms") json = JSON.parse(response.body) expect(json['errors'].first['message']).to eq "Invalid access token." end @@ -737,7 +737,7 @@ describe "API Authentication", type: :request do it "errors if no access token is given and authorization is required" do get "/api/v1/courses" assert_status(401) - expect(response['WWW-Authenticate']).to eq %{Bearer realm="canvas-lms"} + expect(response['WWW-Authenticate']).to eq %(Bearer realm="canvas-lms") json = json_parse expect(json["errors"].first["message"]).to eq "user authorization required" end diff --git a/spec/apis/file_uploads_spec_helper.rb b/spec/apis/file_uploads_spec_helper.rb index a8c8a26d4e4..de05a18e8ec 100644 --- a/spec/apis/file_uploads_spec_helper.rb +++ b/spec/apis/file_uploads_spec_helper.rb @@ -170,7 +170,7 @@ shared_examples_for "file uploads api" do expect(response).to be_successful attachment.reload json = json_parse(response.body) - expect(json).to eq attachment_json(attachment, { include: %w(enhanced_preview_url) }) + expect(json).to eq attachment_json(attachment, { include: %w[enhanced_preview_url] }) expect(attachment.file_state).to eq 'available' expect(attachment.content_type).to eq "application/msword" diff --git a/spec/apis/general_api_spec.rb b/spec/apis/general_api_spec.rb index e9e3237e25a..1de009e0e89 100644 --- a/spec/apis/general_api_spec.rb +++ b/spec/apis/general_api_spec.rb @@ -36,7 +36,7 @@ describe "API", type: :request do it "skips attribute filtering if obj doesn't respond" do course_with_teacher expect(@course.respond_to?(:filter_attributes_for_user)).to be_truthy - expect(@course.as_json(:include_root => false, :permissions => { :user => @user }, :only => %w(name sis_source_id)).keys.sort).to eq %w(name permissions sis_source_id) + expect(@course.as_json(:include_root => false, :permissions => { :user => @user }, :only => %w[name sis_source_id]).keys.sort).to eq %w[name permissions sis_source_id] end it "does attribute filtering if obj responds" do @@ -47,19 +47,19 @@ describe "API", type: :request do expect(session).to be_nil hash.delete('sis_source_id') end - expect(@course.as_json(:include_root => false, :permissions => { :user => @user }, :only => %w(name sis_source_id)).keys.sort).to eq %w(name permissions) + expect(@course.as_json(:include_root => false, :permissions => { :user => @user }, :only => %w[name sis_source_id]).keys.sort).to eq %w[name permissions] end it "does not return the permissions list if include_permissions is false" do course_with_teacher - expect(@course.as_json(:include_root => false, :permissions => { :user => @user, :include_permissions => false }, :only => %w(name sis_source_id)).keys.sort).to eq %w(name sis_source_id) + expect(@course.as_json(:include_root => false, :permissions => { :user => @user, :include_permissions => false }, :only => %w[name sis_source_id]).keys.sort).to eq %w[name sis_source_id] end it "serializes permissions if obj responds" do course_with_teacher expect(@course).to receive(:serialize_permissions).once.with(anything, @teacher, nil) - json = @course.as_json(:include_root => false, :permissions => { :user => @user, :session => nil, :include_permissions => true, :policies => ["update"] }, :only => %w(name)) - expect(json.keys.sort).to eq %w(name permissions) + json = @course.as_json(:include_root => false, :permissions => { :user => @user, :session => nil, :include_permissions => true, :policies => ["update"] }, :only => %w[name]) + expect(json.keys.sort).to eq %w[name permissions] end end diff --git a/spec/apis/locked_spec.rb b/spec/apis/locked_spec.rb index 7d3c64e05e6..9ed7791ab57 100644 --- a/spec/apis/locked_spec.rb +++ b/spec/apis/locked_spec.rb @@ -27,10 +27,10 @@ shared_examples_for 'a locked api item' do end def verify_locked(*lock_info_extra) - prohibited_fields = %w( + prohibited_fields = %w[ canvadoc_session_url crocodoc_session_url - ) + ] json = api_get_json diff --git a/spec/apis/lti/lti2_api_spec_helper.rb b/spec/apis/lti/lti2_api_spec_helper.rb index c613b7098a8..26a4024de00 100644 --- a/spec/apis/lti/lti2_api_spec_helper.rb +++ b/spec/apis/lti/lti2_api_spec_helper.rb @@ -40,7 +40,7 @@ RSpec.shared_context "lti2_api_spec_helper", :shared_context => :metadata do let(:raw_data) do rsp = ::IMS::LTI::Models::RestServiceProfile.new( service: "http://example.com/endpoint##{service_name}", - action: %w(get put delete post) + action: %w[get put delete post] ) ims_tp = ::IMS::LTI::Models::ToolProxy.new security_contract = ::IMS::LTI::Models::SecurityContract.new(tool_service: rsp) diff --git a/spec/apis/lti/lti_app_api_spec.rb b/spec/apis/lti/lti_app_api_spec.rb index 0ea9e98d96b..7a3facd19bb 100644 --- a/spec/apis/lti/lti_app_api_spec.rb +++ b/spec/apis/lti/lti_app_api_spec.rb @@ -43,7 +43,7 @@ module Lti course_with_teacher(active_all: true, user: user_with_pseudonym, account: account) json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', - placements: %w(resource_selection), course_id: @course.id.to_s }) + placements: %w[resource_selection], course_id: @course.id.to_s }) expect(json.detect { |j| j['definition_type'] == resource_tool.class.name && j['definition_id'] == resource_tool.id }).not_to be_nil expect(json.detect { |j| j['definition_type'] == @external_tool.class.name && j['definition_id'] == @external_tool.id }).to be_nil end @@ -73,7 +73,7 @@ module Lti resource_tool.settings[:resource_selection][:visibility] = 'admins' resource_tool.save! json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w(resource_selection) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w[resource_selection] }) expect(response.status).to eq 200 expect(json.count).to eq 0 @@ -85,7 +85,7 @@ module Lti resource_tool.settings[:resource_selection][:visibility] = 'members' resource_tool.save! json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w(resource_selection) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w[resource_selection] }) expect(response.status).to eq 200 expect(json.count).to eq 1 @@ -98,7 +98,7 @@ module Lti resource_tool.settings[:resource_selection][:visibility] = 'public' resource_tool.save! json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w(resource_selection) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w[resource_selection] }) expect(response.status).to eq 200 expect(json.count).to eq 1 @@ -109,7 +109,7 @@ module Lti course_with_student(active_all: true, user: user_with_pseudonym, account: account) resource_tool = new_valid_external_tool(account, true) json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w(resource_selection) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w[resource_selection] }) expect(response.status).to eq 200 expect(json.count).to eq 1 @@ -122,7 +122,7 @@ module Lti resource_tool.settings[:resource_selection][:visibility] = 'public' resource_tool.save! json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w(resource_selection) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w[resource_selection] }) expect(response.status).to eq 200 expect(json.count).to eq 1 @@ -131,7 +131,7 @@ module Lti it 'cannot get the definition of public stuff at the account level' do api_call(:get, "/api/v1/accounts/self/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', account_id: 'self', placements: %w(global_navigation) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', account_id: 'self', placements: %w[global_navigation] }) expect(response.status).to eq 401 end @@ -141,7 +141,7 @@ module Lti resource_tool.settings[:resource_selection][:visibility] = 'members' resource_tool.save! json = api_call(:get, "/api/v1/courses/#{@course.id}/lti_apps/launch_definitions", - { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w(resource_selection) }) + { controller: 'lti/lti_apps', action: 'launch_definitions', format: 'json', course_id: @course.id.to_s, placements: %w[resource_selection] }) expect(response.status).to eq 200 expect(json.count).to eq 0 diff --git a/spec/apis/lti/subscriptions_api_spec.rb b/spec/apis/lti/subscriptions_api_spec.rb index f5bc8327135..03598857296 100644 --- a/spec/apis/lti/subscriptions_api_spec.rb +++ b/spec/apis/lti/subscriptions_api_spec.rb @@ -62,7 +62,7 @@ module Lti end it 'creates subscriptions' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! post create_endpoint, params: { subscription: subscription }, headers: request_headers expect(response).to be_successful @@ -80,7 +80,7 @@ module Lti it 'renders 401 if Lti::ToolProxy#active_in_context? does not return true' do allow_any_instance_of(Lti::ToolProxy).to receive(:active_in_context?).with(an_instance_of(Account)).and_return(false) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! post create_endpoint, params: { subscription: subscription }, headers: request_headers expect(response).to be_unauthorized @@ -88,14 +88,14 @@ module Lti it 'gives error message if Lti::ToolProxy#active_in_context? does not return true' do allow_any_instance_of(Lti::ToolProxy).to receive(:active_in_context?).with(an_instance_of(Account)).and_return(false) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! post create_endpoint, params: { subscription: subscription }, headers: request_headers expect(JSON.parse(response.body)['error']).to eq 'Unauthorized subscription' end it 'requires JWT Access token' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! post create_endpoint, params: { subscription: subscription } expect(response).to be_unauthorized @@ -103,7 +103,7 @@ module Lti it 'gives 500 if the subscription service is not configured' do allow(subscription_service).to receive_messages(available?: false) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! post create_endpoint, params: { subscription: subscription }, headers: request_headers expect(response.status).to eq 500 @@ -111,7 +111,7 @@ module Lti it 'gives useful message if the subscription service is not configured' do allow(subscription_service).to receive_messages(available?: false) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! post create_endpoint, params: { subscription: subscription }, headers: request_headers expect(JSON.parse(response.body)['error']).to eq 'Subscription service not configured' @@ -121,7 +121,7 @@ module Lti describe '#destroy' do before do allow(subscription_service).to receive_messages(destroy_tool_proxy_subscription: delete_response) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! end @@ -159,7 +159,7 @@ module Lti describe '#show' do before do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! end @@ -198,7 +198,7 @@ module Lti describe '#update' do before do allow(subscription_service).to receive_messages(update_tool_proxy_subscription: ok_response) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! end @@ -229,7 +229,7 @@ module Lti it 'renders 401 if Lti::ToolProxy#active_in_context? does not return true' do allow_any_instance_of(Lti::ToolProxy).to receive(:active_in_context?).with(an_instance_of(Account)).and_return(false) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! put update_endpoint, params: { subscription: subscription }, headers: request_headers expect(response).to be_unauthorized @@ -237,7 +237,7 @@ module Lti it 'gives error message if Lti::ToolProxy#active_in_context? does not return true' do allow_any_instance_of(Lti::ToolProxy).to receive(:active_in_context?).with(an_instance_of(Account)).and_return(false) - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! put update_endpoint, params: { subscription: subscription }, headers: request_headers expect(JSON.parse(response.body)['error']).to eq 'Unauthorized subscription' @@ -263,7 +263,7 @@ module Lti describe '#index' do before do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] tool_proxy.save! end diff --git a/spec/apis/lti/subscriptions_validator_spec.rb b/spec/apis/lti/subscriptions_validator_spec.rb index b6f59ddb6a5..529675ec6db 100644 --- a/spec/apis/lti/subscriptions_validator_spec.rb +++ b/spec/apis/lti/subscriptions_validator_spec.rb @@ -90,13 +90,13 @@ module Lti end it 'allows subscription if vnd.instructure.webhooks.assignment.quiz_submitted enabled' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.quiz_submitted) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.quiz_submitted] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.not_to raise_error end it 'raises MissingCapability if missing capabilities' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.submission_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.submission_created] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.to raise_error SubscriptionsValidator::MissingCapability end @@ -134,7 +134,7 @@ module Lti end it 'raises MissingCapability if missing capabilities' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.quiz_submitted) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.quiz_submitted] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.to raise_error SubscriptionsValidator::MissingCapability end @@ -172,13 +172,13 @@ module Lti end it 'allows subscription if vnd.instructure.webhooks.assignment.attachment_created' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.attachment_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.attachment_created] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.not_to raise_error end it 'raises MissingCapability if missing capabilities' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.quiz_submitted) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.quiz_submitted] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.to raise_error SubscriptionsValidator::MissingCapability end @@ -216,13 +216,13 @@ module Lti end it 'allows subscription if vnd.instructure.webhooks.assignment.submission_created' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.submission_created) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.submission_created] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.not_to raise_error end it 'raises MissingCapability if missing capabilities' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.quiz_submitted) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.quiz_submitted] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.to raise_error SubscriptionsValidator::MissingCapability end @@ -260,13 +260,13 @@ module Lti end it 'allows subscription if vnd.instructure.webhooks.assignment.submission_updated' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.submission_updated) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.submission_updated] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.not_to raise_error end it 'raises MissingCapability if missing capabilities' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.quiz_submitted) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.quiz_submitted] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.to raise_error SubscriptionsValidator::MissingCapability end @@ -304,13 +304,13 @@ module Lti end it 'allows subscription if vnd.instructure.webhooks.assignment.submission_created' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.plagiarism_resubmit) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.plagiarism_resubmit] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.not_to raise_error end it 'raises MissingCapability if missing capabilities' do - tool_proxy[:raw_data]['enabled_capability'] = %w(vnd.instructure.webhooks.assignment.quiz_submitted) + tool_proxy[:raw_data]['enabled_capability'] = %w[vnd.instructure.webhooks.assignment.quiz_submitted] validator = SubscriptionsValidator.new(subscription, tool_proxy) expect { validator.check_required_capabilities! }.to raise_error SubscriptionsValidator::MissingCapability end diff --git a/spec/apis/lti/users_api_spec.rb b/spec/apis/lti/users_api_spec.rb index 63b8bf0efac..6316203a214 100644 --- a/spec/apis/lti/users_api_spec.rb +++ b/spec/apis/lti/users_api_spec.rb @@ -176,7 +176,7 @@ module Lti get group_index_endpoint, headers: request_headers parsed_body = JSON.parse(response.body) expected_json = group.users.map do |user| - user_json(user, user, nil, [], group.context, tool_includes: %w(email lti_id)) + user_json(user, user, nil, [], group.context, tool_includes: %w[email lti_id]) end expect(parsed_body.sort_by { |u| u[:id] }).to eq(expected_json.sort_by { |u| u[:id] }) end @@ -210,7 +210,7 @@ module Lti get group_index_endpoint, headers: request_headers parsed_body = JSON.parse(response.body) expected_json = group.users.map do |user| - user_json(user, user, nil, [], group.context, tool_includes: %w(email lti_id)) + user_json(user, user, nil, [], group.context, tool_includes: %w[email lti_id]) end expect(parsed_body.sort_by { |u| u[:id] }).to eq(expected_json.sort_by { |u| u[:id] }) end diff --git a/spec/apis/swagger/argument_view_spec.rb b/spec/apis/swagger/argument_view_spec.rb index 920a03ea557..c94574dd213 100644 --- a/spec/apis/swagger/argument_view_spec.rb +++ b/spec/apis/swagger/argument_view_spec.rb @@ -78,7 +78,7 @@ describe ArgumentView do end context "with types, enums, description" do - let(:view) { ArgumentView.new %{arg [Optional, String, "val1"|"val2"] argument} } + let(:view) { ArgumentView.new %(arg [Optional, String, "val1"|"val2"] argument) } it "has enums" do expect(view.enums).to eq ["val1", "val2"] @@ -94,7 +94,7 @@ describe ArgumentView do end context "with optional arg" do - let(:view) { ArgumentView.new %{arg [String]} } + let(:view) { ArgumentView.new %(arg [String]) } it "is optional" do expect(view.optional?).to be_truthy @@ -102,7 +102,7 @@ describe ArgumentView do end context "with required arg" do - let(:view) { ArgumentView.new %{arg [Required, String]} } + let(:view) { ArgumentView.new %(arg [Required, String]) } it "is required" do expect(view.required?).to be_truthy diff --git a/spec/apis/user_content_spec.rb b/spec/apis/user_content_spec.rb index c2b5567487e..cbafb948ba7 100644 --- a/spec/apis/user_content_spec.rb +++ b/spec/apis/user_content_spec.rb @@ -363,7 +363,7 @@ describe UserContent, type: :request do "http://www.example.com/api/v1/users/#{@teacher.id}/files/789" ] expect(doc.css('a').collect { |att| att['data-api-returntype'] }).to eq( - %w(Folder File) + %w[Folder File] ) end end @@ -426,7 +426,7 @@ describe UserContent, type: :request do end def confirm_url_stability(url) - link = %Q{what} + link = %Q(what) html = tester.process_incoming_html_content(link) doc = Nokogiri::HTML5.fragment(html) expect(doc.at_css('a')['href']).to eq url @@ -450,7 +450,7 @@ describe UserContent, type: :request do end def confirm_url_stability(url) - link = %Q{whata>} + link = %Q(whata>) html = tester.process_incoming_html_content(link) doc = Nokogiri::HTML5.fragment(html) expect(doc.at_css('a')['href']).to eq url @@ -493,7 +493,7 @@ describe UserContent, type: :request do describe "latex_to_mathml" do it "returns mathml on success" do valid_latex = '\frac{a}{b}' - expect(UserContent.latex_to_mathml(valid_latex)).to eql(%{ab}) + expect(UserContent.latex_to_mathml(valid_latex)).to eql(%(ab)) end it "returns empty string on parse error" do diff --git a/spec/apis/v1/account_notifications_api_spec.rb b/spec/apis/v1/account_notifications_api_spec.rb index 960dc2b6fee..fa434774d72 100644 --- a/spec/apis/v1/account_notifications_api_spec.rb +++ b/spec/apis/v1/account_notifications_api_spec.rb @@ -44,7 +44,7 @@ describe 'Account Notification API', type: :request do second_announcement json = api_call(:get, @path, @api_params,) expect(json.length).to eq 2 - expect(json.map { |r| r["message"] }).to match_array(%w{default second}) + expect(json.map { |r| r["message"] }).to match_array(%w[default second]) end it "still works on the old endpoint" do @@ -55,7 +55,7 @@ describe 'Account Notification API', type: :request do user_id: @admin.id.to_s, account_id: @admin.account.id.to_s }) - expect(json.map { |r| r["message"] }).to eq %w{default} + expect(json.map { |r| r["message"] }).to eq %w[default] end it "catches a user_id mismatch on the old endpoint" do diff --git a/spec/apis/v1/account_reports_api_spec.rb b/spec/apis/v1/account_reports_api_spec.rb index eecbd320ca7..302273b1388 100644 --- a/spec/apis/v1/account_reports_api_spec.rb +++ b/spec/apis/v1/account_reports_api_spec.rb @@ -61,7 +61,7 @@ describe 'Account Reports API', type: :request do report = api_call(:post, "/api/v1/accounts/#{@admin.account.id}/reports/#{@report.report_type}", { report: @report.report_type, controller: 'account_reports', action: 'create', format: 'json', account_id: @admin.account.id.to_s }) - keys = %w(id progress parameters current_line status report created_at started_at ended_at file_url) + keys = %w[id progress parameters current_line status report created_at started_at ended_at file_url] expect(report['status']).to eq 'created' expect(keys - report.keys).to be_empty end diff --git a/spec/apis/v1/accounts_api_spec.rb b/spec/apis/v1/accounts_api_spec.rb index 3dc35b723a1..9439a77cbf0 100644 --- a/spec/apis/v1/accounts_api_spec.rb +++ b/spec/apis/v1/accounts_api_spec.rb @@ -1605,28 +1605,28 @@ describe "Accounts API", type: :request do json = api_call(:get, "/api/v1/accounts/#{@a.id}/courses?blueprint=true", { :controller => 'accounts', :action => 'courses_api', :account_id => @a.to_param, :format => 'json', :blueprint => true }) - expect(json.map { |c| c['name'] }).to match_array %w(MasterCourse) + expect(json.map { |c| c['name'] }).to match_array %w[MasterCourse] end it 'filters out blueprint courses' do json = api_call(:get, "/api/v1/accounts/#{@a.id}/courses?blueprint=false", { :controller => 'accounts', :action => 'courses_api', :account_id => @a.to_param, :format => 'json', :blueprint => false }) - expect(json.map { |c| c['name'] }).to match_array %w(ChildCourse OtherCourse) + expect(json.map { |c| c['name'] }).to match_array %w[ChildCourse OtherCourse] end it 'filters in associated courses' do json = api_call(:get, "/api/v1/accounts/#{@a.id}/courses?blueprint_associated=true", { :controller => 'accounts', :action => 'courses_api', :account_id => @a.to_param, :format => 'json', :blueprint_associated => true }) - expect(json.map { |c| c['name'] }).to match_array %w(ChildCourse) + expect(json.map { |c| c['name'] }).to match_array %w[ChildCourse] end it 'filters out associated courses' do json = api_call(:get, "/api/v1/accounts/#{@a.id}/courses?blueprint_associated=false", { :controller => 'accounts', :action => 'courses_api', :account_id => @a.to_param, :format => 'json', :blueprint_associated => false }) - expect(json.map { |c| c['name'] }).to match_array %w(MasterCourse OtherCourse) + expect(json.map { |c| c['name'] }).to match_array %w[MasterCourse OtherCourse] end end end @@ -1635,14 +1635,14 @@ describe "Accounts API", type: :request do it "returns permissions" do json = api_call(:get, "/api/v1/accounts/#{@a1.id}/permissions?permissions[]=become_user&permissions[]=manage_blarghs", :controller => 'accounts', :action => 'permissions', :account_id => @a1.to_param, - :format => 'json', :permissions => %w(become_user manage_blarghs)) + :format => 'json', :permissions => %w[become_user manage_blarghs]) expect(json).to eq({ "become_user" => true, "manage_blarghs" => false }) end it "requires :read permission on the account" do api_call(:get, "/api/v1/accounts/#{@a3.id}/permissions?permissions[]=become_user", { :controller => 'accounts', :action => 'permissions', :account_id => @a3.to_param, :format => 'json', - :permissions => %w(become_user) }, {}, {}, { :expected_status => 401 }) + :permissions => %w[become_user] }, {}, {}, { :expected_status => 401 }) end end diff --git a/spec/apis/v1/assignments_api_spec.rb b/spec/apis/v1/assignments_api_spec.rb index 34bec4a204b..5e2fcc3f9e7 100644 --- a/spec/apis/v1/assignments_api_spec.rb +++ b/spec/apis/v1/assignments_api_spec.rb @@ -195,28 +195,28 @@ describe AssignmentsApiController, type: :request do # [assignment_groups.position, assignments.position] json = api_get_assignments_index_from_course(@course) order = json.map { |a| a['name'] } - expect(order).to eq %w(assignment2 + expect(order).to eq %w[assignment2 assignment1 assignment6 assignment3 assignment5 assignment8 assignment7 - assignment4) + assignment4] end it 'only returns post_to_sis assignments' do Assignment.where(assignment_group_id: [@group1, @group2]).update_all(post_to_sis: true) json = api_get_assignments_index_from_course(@course, post_to_sis: true) post_to_sis = json.map { |a| a['name'] } - expect(post_to_sis).to eq %w(assignment2 assignment1 assignment6 assignment3 assignment5) + expect(post_to_sis).to eq %w[assignment2 assignment1 assignment6 assignment3 assignment5] end it 'only returns assignments that do not have post_to_sis' do Assignment.where(assignment_group_id: [@group1, @group2]).update_all(post_to_sis: true) json = api_get_assignments_index_from_course(@course, post_to_sis: false) post_to_sis = json.map { |a| a['name'] } - expect(post_to_sis).to eq %w(assignment8 assignment7 assignment4) + expect(post_to_sis).to eq %w[assignment8 assignment7 assignment4] end it 'fails for post_to_sis assignments when user cannot manage assignments' do @@ -239,14 +239,14 @@ describe AssignmentsApiController, type: :request do # [assignment_groups.position, assignments.position] json = api_get_assignments_index_from_course(@course, order_by: 'name') order = json.map { |a| a['name'] } - expect(order).to eq %w(assignment1 + expect(order).to eq %w[assignment1 assignment2 assignment3 assignment4 assignment5 assignment6 assignment7 - assignment8) + assignment8] end context 'by due date' do @@ -258,7 +258,7 @@ describe AssignmentsApiController, type: :request do @student2 = student_in_course(name: 'student2', active_all: true, section: @section2).user due_at = 1.month.ago - @course.assignments.where(title: %w(assignment1 assignment4 assignment7)).each do |a| + @course.assignments.where(title: %w[assignment1 assignment4 assignment7]).each do |a| a.due_at = due_at a.save! end @@ -267,7 +267,7 @@ describe AssignmentsApiController, type: :request do due_at: 2.months.from_now) due_at = 1.month.from_now - @course.assignments.where(title: %w(assignment2 assignment3 assignment5)).each do |a| + @course.assignments.where(title: %w[assignment2 assignment3 assignment5]).each do |a| a.due_at = due_at a.save! end @@ -283,19 +283,19 @@ describe AssignmentsApiController, type: :request do it "sorts the returned list of assignments by latest due date for teachers (nulls last)" do json = api_get_assignments_user_index(@teacher, @course, @teacher, order_by: 'due_at') - order = %w(assignment1 assignment7 assignment2 assignment5 assignment4 assignment3 assignment6 assignment8) + order = %w[assignment1 assignment7 assignment2 assignment5 assignment4 assignment3 assignment6 assignment8] expect(json.map { |a| a['name'] }).to eq order expect(json.sort_by { |a| [a['due_at'] || CanvasSort::Last, a['name']] }.map { |a| a['name'] }).to eq order end it "sorts the returned list of assignments by overridden due date for students (nulls last)" do json = api_get_assignments_user_index(@student1, @course, @teacher, order_by: 'due_at') - order = %w(assignment1 assignment7 assignment2 assignment3 assignment5 assignment4 assignment6 assignment8) + order = %w[assignment1 assignment7 assignment2 assignment3 assignment5 assignment4 assignment6 assignment8] expect(json.map { |a| a['name'] }).to eq order expect(json.sort_by { |a| [a['due_at'] || CanvasSort::Last, a['name']] }.map { |a| a['name'] }).to eq order json = api_get_assignments_user_index(@student2, @course, @teacher, order_by: 'due_at') - order = %w(assignment3 assignment1 assignment4 assignment7 assignment2 assignment5 assignment6 assignment8) + order = %w[assignment3 assignment1 assignment4 assignment7 assignment2 assignment5 assignment6 assignment8] expect(json.map { |a| a['name'] }).to eq order expect(json.sort_by { |a| [a['due_at'] || CanvasSort::Last, a['name']] }.map { |a| a['name'] }).to eq order end @@ -5939,7 +5939,7 @@ describe AssignmentsApiController, type: :request do end it "does not update integration_data when lacking permission" do - json = %{{"key": "value"}} + json = %({"key": "value"}) params = ActionController::Parameters.new({ "integration_data" => json }) update_from_params(@assignment, params, @user) @@ -5947,7 +5947,7 @@ describe AssignmentsApiController, type: :request do end it "updates integration_data with permission" do - json = %{{"key": "value"}} + json = %({"key": "value"}) params = ActionController::Parameters.new({ "integration_data" => json }) account_admin_user_with_role_changes( :role_changes => { :manage_sis => true } @@ -6613,7 +6613,7 @@ describe AssignmentsApiController, type: :request do end it "sets can_edit on each date if requested" do - json = api_get_assignments_index_from_course(@course, include: %w(all_dates can_edit)) + json = api_get_assignments_index_from_course(@course, include: %w[all_dates can_edit]) a0_json = json.detect { |a| a['id'] == @a0.id } expect(a0_json['can_edit']).to eq true expect(a0_json['all_dates'].map { |d| d['can_edit'] }).to eq [true] @@ -6638,7 +6638,7 @@ describe AssignmentsApiController, type: :request do it "allows account admins to edit whatever they want" do account_admin_user - json = api_get_assignments_index_from_course(@course, include: %w(all_dates can_edit)) + json = api_get_assignments_index_from_course(@course, include: %w[all_dates can_edit]) a0_json = json.detect { |a| a['id'] == @a0.id } expect(a0_json['can_edit']).to eq true expect(a0_json['all_dates'].map { |d| d['can_edit'] }).to eq [true] @@ -6679,7 +6679,7 @@ describe AssignmentsApiController, type: :request do end it "sets can_edit on each date if requested" do - json = api_get_assignments_index_from_course(@course, include: %w(all_dates can_edit)) + json = api_get_assignments_index_from_course(@course, include: %w[all_dates can_edit]) a0_json = json.detect { |a| a['id'] == @a0.id } expect(a0_json['can_edit']).to eq false diff --git a/spec/apis/v1/authentication_audit_api_spec.rb b/spec/apis/v1/authentication_audit_api_spec.rb index e7f9fa86a09..4f50c63011c 100644 --- a/spec/apis/v1/authentication_audit_api_spec.rb +++ b/spec/apis/v1/authentication_audit_api_spec.rb @@ -109,7 +109,7 @@ describe "AuthenticationAudit API", type: :request do end it "has correct root keys" do - expect(@json.keys.sort).to eq %w{events linked links} + expect(@json.keys.sort).to eq %w[events linked links] end it "has a formatted links key" do @@ -123,7 +123,7 @@ describe "AuthenticationAudit API", type: :request do end it "has a formatted linked key" do - expect(@json['linked'].keys.sort).to eq %w{accounts logins page_views users} + expect(@json['linked'].keys.sort).to eq %w[accounts logins page_views users] expect(@json['linked']['accounts'].is_a?(Array)).to be_truthy expect(@json['linked']['logins'].is_a?(Array)).to be_truthy expect(@json['linked']['page_views'].is_a?(Array)).to be_truthy diff --git a/spec/apis/v1/collaborations_api_spec.rb b/spec/apis/v1/collaborations_api_spec.rb index e853c7373e2..4a072087b2e 100644 --- a/spec/apis/v1/collaborations_api_spec.rb +++ b/spec/apis/v1/collaborations_api_spec.rb @@ -159,7 +159,7 @@ describe CollaborationsController, type: :request do it 'is formatted by collaborator_json' do json = api_call(:get, url, url_options) - expect(json.first.keys.sort).to eq %w{collaborator_id id name type} + expect(json.first.keys.sort).to eq %w[collaborator_id id name type] end it 'includes groups' do diff --git a/spec/apis/v1/content_exports_api_spec.rb b/spec/apis/v1/content_exports_api_spec.rb index f1be64ddcc4..31128e97314 100644 --- a/spec/apis/v1/content_exports_api_spec.rb +++ b/spec/apis/v1/content_exports_api_spec.rb @@ -777,8 +777,8 @@ describe ContentExportsApiController, type: :request do expect(export.attachment.display_name).to eql 'course_files_export.zip' tf = export.attachment.open need_local_file: true Zip::File.open(tf) do |zf| - expect(zf.entries.select { |entry| entry.ftype == :file }.map(&:name)).to match_array %w(file1.txt hidden.txt teh_folder/file2.txt) - expect(zf.entries.select { |entry| entry.ftype == :directory }.map(&:name)).to match_array %w(teh_folder/ teh_folder/empty_folder/) + expect(zf.entries.select { |entry| entry.ftype == :file }.map(&:name)).to match_array %w[file1.txt hidden.txt teh_folder/file2.txt] + expect(zf.entries.select { |entry| entry.ftype == :directory }.map(&:name)).to match_array %w[teh_folder/ teh_folder/empty_folder/] end end @@ -794,7 +794,7 @@ describe ContentExportsApiController, type: :request do expect(export.attachment.display_name).to eql 'course_files_export.zip' tf = export.attachment.open need_local_file: true Zip::File.open(tf) do |zf| - expect(zf.entries.map(&:name)).to match_array %w(teh_folder/ teh_folder/file2.txt teh_folder/empty_folder/ file3.txt) + expect(zf.entries.map(&:name)).to match_array %w[teh_folder/ teh_folder/file2.txt teh_folder/empty_folder/ file3.txt] end end @@ -815,7 +815,7 @@ describe ContentExportsApiController, type: :request do expect(export.settings["errors"].map(&:first)).to include("Skipped file file1.txt due to error") tf = export.attachment.open need_local_file: true Zip::File.open(tf) do |zf| - expect(zf.entries.select { |entry| entry.ftype == :file }.map(&:name)).to match_array %w(hidden.txt teh_folder/file2.txt) + expect(zf.entries.select { |entry| entry.ftype == :file }.map(&:name)).to match_array %w[hidden.txt teh_folder/file2.txt] end end @@ -850,7 +850,7 @@ describe ContentExportsApiController, type: :request do expect(export.attachment).to be_present tf = export.attachment.open need_local_file: true Zip::File.open(tf) do |zf| - expect(zf.entries.map(&:name)).to match_array %w(file1.txt) + expect(zf.entries.map(&:name)).to match_array %w[file1.txt] end end @@ -865,7 +865,7 @@ describe ContentExportsApiController, type: :request do expect(export.attachment).to be_present tf = export.attachment.open need_local_file: true Zip::File.open(tf) do |zf| - expect(zf.entries.map(&:name)).to match_array %w(file1.txt) + expect(zf.entries.map(&:name)).to match_array %w[file1.txt] end end diff --git a/spec/apis/v1/context_modules_api_spec.rb b/spec/apis/v1/context_modules_api_spec.rb index f32d9daca0e..4e5c8e71c33 100644 --- a/spec/apis/v1/context_modules_api_spec.rb +++ b/spec/apis/v1/context_modules_api_spec.rb @@ -172,7 +172,7 @@ describe "Modules API", type: :request do it "includes items if requested" do json = api_call(:get, "/api/v1/courses/#{@course.id}/modules?include[]=items", :controller => "context_modules_api", :action => "index", :format => "json", - :course_id => @course.id.to_s, :include => %w(items)) + :course_id => @course.id.to_s, :include => %w[items]) expect(json.map { |mod| mod['items'].size }).to eq [5, 2, 0] end @@ -187,7 +187,7 @@ describe "Modules API", type: :request do json = api_call(:get, "/api/v1/courses/#{@course.id}/modules?include[]=items", :controller => "context_modules_api", :action => "index", :format => "json", - :course_id => @course.id.to_s, :include => %w(items)) + :course_id => @course.id.to_s, :include => %w[items]) expect(json.map { |mod| mod['items'].size }).to eq [4, 3] end @@ -195,7 +195,7 @@ describe "Modules API", type: :request do let(:json) do api_call(:get, "/api/v1/courses/#{@course.id}/modules?include[]=items&include[]=content_details", :controller => "context_modules_api", :action => "index", :format => "json", - :course_id => @course.id.to_s, :include => %w(items content_details)) + :course_id => @course.id.to_s, :include => %w[items content_details]) end let(:assignment_details) { json.find { |mod| mod['id'] == @module1.id }['items'].find { |item| item['id'] == @assignment_tag.id }['content_details'] } let(:wiki_page_details) { json.find { |mod| mod['id'] == @module2.id }['items'].find { |item| item['id'] == @wiki_page_tag.id }['content_details'] } @@ -234,7 +234,7 @@ describe "Modules API", type: :request do Setting.set('api_max_per_page', '3') json = api_call(:get, "/api/v1/courses/#{@course.id}/modules?include[]=items", :controller => "context_modules_api", :action => "index", :format => "json", - :course_id => @course.id.to_s, :include => %w(items)) + :course_id => @course.id.to_s, :include => %w[items]) expect(json.map { |mod| mod['items'].try(:size) }).to eq [nil, 2, 0] end @@ -288,7 +288,7 @@ describe "Modules API", type: :request do json = api_call(:get, "/api/v1/courses/#{@course.id}/modules?include[]=items&search_term=spur", :controller => "context_modules_api", :action => "index", :format => "json", - :course_id => @course.id.to_s, :include => %w{items}, :search_term => "spur") + :course_id => @course.id.to_s, :include => %w[items], :search_term => "spur") expect(json.size).to eq 4 expect(json.map { |mod| mod['id'] }.sort).to eq (matching_mods + nonmatching_mods).map(&:id).sort @@ -322,12 +322,12 @@ describe "Modules API", type: :request do let(:module1_json) do api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@module1.id}?include[]=items&include[]=content_details", :controller => "context_modules_api", :action => "show", :format => "json", - :course_id => @course.id.to_s, :include => %w(items content_details), :id => @module1.id.to_s) + :course_id => @course.id.to_s, :include => %w[items content_details], :id => @module1.id.to_s) end let(:module2_json) do api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@module2.id}?include[]=items&include[]=content_details", :controller => "context_modules_api", :action => "show", :format => "json", - :course_id => @course.id.to_s, :include => %w(items content_details), :id => @module2.id.to_s) + :course_id => @course.id.to_s, :include => %w[items content_details], :id => @module2.id.to_s) end let(:assignment_details) { module1_json['items'].find { |item| item['id'] == @assignment_tag.id }['content_details'] } let(:wiki_page_details) { module2_json['items'].find { |item| item['id'] == @wiki_page_tag.id }['content_details'] } @@ -370,15 +370,15 @@ describe "Modules API", type: :request do it "includes items if requested" do json = api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@module1.id}?include[]=items", :controller => "context_modules_api", :action => "show", :format => "json", - :course_id => @course.id.to_s, :id => @module1.id.to_param, :include => %w(items)) - expect(json['items'].map { |item| item['type'] }).to eq %w(Assignment Quiz Discussion SubHeader ExternalUrl) + :course_id => @course.id.to_s, :id => @module1.id.to_param, :include => %w[items]) + expect(json['items'].map { |item| item['type'] }).to eq %w[Assignment Quiz Discussion SubHeader ExternalUrl] end it "does not include items if there are too many" do Setting.set('api_max_per_page', '3') json = api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@module1.id}?include[]=items", :controller => "context_modules_api", :action => "show", :format => "json", - :course_id => @course.id.to_s, :id => @module1.id.to_param, :include => %w(items)) + :course_id => @course.id.to_s, :id => @module1.id.to_param, :include => %w[items]) expect(json['items']).to be_nil end end @@ -402,7 +402,7 @@ describe "Modules API", type: :request do it "publishes modules (and their tags)" do json = api_call(:put, @path, @path_opts, { :event => 'publish', :module_ids => @ids_to_update }) expect(json['completed'].sort).to eq @ids_to_update - expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w(active active unpublished active) + expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w[active active unpublished active] @wiki_page_tag.reload expect(@wiki_page_tag.active?).to eq true @@ -413,19 +413,19 @@ describe "Modules API", type: :request do it "unpublishes modules" do json = api_call(:put, @path, @path_opts, { :event => 'unpublish', :module_ids => @ids_to_update }) expect(json['completed'].sort).to eq @ids_to_update - expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w(active unpublished unpublished unpublished) + expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w[active unpublished unpublished unpublished] end it "deletes modules" do json = api_call(:put, @path, @path_opts, { :event => 'delete', :module_ids => @ids_to_update }) expect(json['completed'].sort).to eq @ids_to_update - expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w(active deleted unpublished deleted) + expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w[active deleted unpublished deleted] end it "converts module ids to integer and ignore non-numeric ones" do - json = api_call(:put, @path, @path_opts, { :event => 'publish', :module_ids => %w(lolcats abc123) + @ids_to_update.map(&:to_s) }) + json = api_call(:put, @path, @path_opts, { :event => 'publish', :module_ids => %w[lolcats abc123] + @ids_to_update.map(&:to_s) }) expect(json['completed'].sort).to eq @ids_to_update - expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w(active active unpublished active) + expect(@test_modules.map { |tm| tm.reload.workflow_state }).to eq %w[active active unpublished active] end it "does not update soft-deleted modules" do @@ -799,12 +799,12 @@ describe "Modules API", type: :request do let(:module1_json) do api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@module1.id}?include[]=items&include[]=content_details", :controller => "context_modules_api", :action => "show", :format => "json", - :course_id => @course.id.to_s, :include => %w(items content_details), :id => @module1.id.to_s) + :course_id => @course.id.to_s, :include => %w[items content_details], :id => @module1.id.to_s) end let(:module2_json) do api_call(:get, "/api/v1/courses/#{@course.id}/modules/#{@module2.id}?include[]=items&include[]=content_details", :controller => "context_modules_api", :action => "show", :format => "json", - :course_id => @course.id.to_s, :include => %w(items content_details), :id => @module2.id.to_s) + :course_id => @course.id.to_s, :include => %w[items content_details], :id => @module2.id.to_s) end let(:assignment_details) { module1_json['items'].find { |item| item['id'] == @assignment_tag.id }['content_details'] } let(:wiki_page_details) { module2_json['items'].find { |item| item['id'] == @wiki_page_tag.id }['content_details'] } @@ -964,7 +964,7 @@ describe "Modules API", type: :request do {}, {}, { :expected_status => 401 }) api_call(:put, "/api/v1/courses/#{@course.id}/modules?event=publish&module_ids[]=1", { :controller => "context_modules_api", :action => "batch_update", :event => 'publish', - :module_ids => %w(1), :format => "json", :course_id => @course.id.to_s }, + :module_ids => %w[1], :format => "json", :course_id => @course.id.to_s }, {}, {}, { :expected_status => 401 }) api_call(:put, "/api/v1/courses/#{@course.id}/modules/#{@module1.id}", { :controller => "context_modules_api", :action => "update", :format => "json", diff --git a/spec/apis/v1/conversations_api_spec.rb b/spec/apis/v1/conversations_api_spec.rb index 6e2ea3a4c6b..7ae1f8f4bdd 100644 --- a/spec/apis/v1/conversations_api_spec.rb +++ b/spec/apis/v1/conversations_api_spec.rb @@ -2156,7 +2156,7 @@ describe ConversationsController, type: :request do # it "should mark conversations as subscribed" # it "should mark conversations as unsubscribed" it "archives conversations" do - conversations = %w(archived read unread).map do |state| + conversations = %w[archived read unread].map do |state| conversation(@me, @bob, :workflow_state => state) end expect(@me.reload.unread_conversations_count).to eql(1) diff --git a/spec/apis/v1/courses_api_spec.rb b/spec/apis/v1/courses_api_spec.rb index 85547f484f1..6098becade9 100644 --- a/spec/apis/v1/courses_api_spec.rb +++ b/spec/apis/v1/courses_api_spec.rb @@ -457,7 +457,7 @@ describe Api::V1::Course do end describe CoursesController, type: :request do - let(:user_api_fields) { %w(id name sortable_name short_name created_at) } + let(:user_api_fields) { %w[id name sortable_name short_name created_at] } before :once do course_with_teacher(:active_all => true, :user => user_with_pseudonym(:name => 'UWP')) @@ -631,7 +631,7 @@ describe CoursesController, type: :request do c4 = course_with_student(user: @student, course_name: 'xyz', active_all: true).course @student.set_preference(:course_nicknames, c4.id, 'ghi') json = api_call(:get, "/api/v1/courses.json", controller: 'courses', action: 'index', format: 'json') - expect(json.map { |course| course['name'] }).to eq %w(abc def ghi jkl) + expect(json.map { |course| course['name'] }).to eq %w[abc def ghi jkl] end it "excludes master courses if requested" do @@ -2761,7 +2761,7 @@ describe CoursesController, type: :request do { :state => ['available'] }) expect(json.collect { |c| c['id'].to_i }.sort).to eq [@course1.id, @course2.id].sort json.collect { |c| c['workflow_state'] }.each do |s| - expect(%w{available}).to include(s) + expect(%w[available]).to include(s) end end @@ -2771,7 +2771,7 @@ describe CoursesController, type: :request do { :state => ['unpublished'] }) expect(json.collect { |c| c['id'].to_i }.sort).to eq [@course3.id, @course4.id].sort json.collect { |c| c['workflow_state'] }.each do |s| - expect(%w{unpublished}).to include(s) + expect(%w[unpublished]).to include(s) end end @@ -2781,7 +2781,7 @@ describe CoursesController, type: :request do { :state => ['unpublished', 'available'] }) expect(json.collect { |c| c['id'].to_i }.sort).to eq [@course1.id, @course2.id, @course3.id, @course4.id].sort json.collect { |c| c['workflow_state'] }.each do |s| - expect(%w{available unpublished}).to include(s) + expect(%w[available unpublished]).to include(s) end end @@ -2793,7 +2793,7 @@ describe CoursesController, type: :request do expect(json[0]['enrollments']).to eq [{ 'type' => 'teacher', 'role' => 'SuperTeacher', 'role_id' => @role.id, 'user_id' => @me.id, 'enrollment_state' => 'invited', "limit_privileges_to_course_section" => false }] json.collect { |c| c['workflow_state'] }.each do |s| - expect(%w{unpublished}).to include(s) + expect(%w[unpublished]).to include(s) end end @@ -2929,7 +2929,7 @@ describe CoursesController, type: :request do @user = @me json = api_call(:get, "/api/v1/courses/#{@course2.id}/students.json", { :controller => 'courses', :action => 'students', :course_id => @course2.id.to_s, :format => 'json' }) - %w{sis_user_id unique_id}.each do |attribute| + %w[sis_user_id unique_id].each do |attribute| expect(json.map { |u| u[attribute] }).to eq [nil, nil] end end @@ -3325,7 +3325,7 @@ describe CoursesController, type: :request do expect(normal['login_id']).to eq @user.pseudonym.unique_id secret = json.detect { |h| h['id'] == secretstudent.id } - expect(secret.keys & %w{email login_id}).to be_empty + expect(secret.keys & %w[email login_id]).to be_empty end end @@ -3368,7 +3368,7 @@ describe CoursesController, type: :request do { :controller => 'courses', :action => 'users', :course_id => @course1.to_param, :format => 'json' }, :enrollment_type => ['student', 'student_view', 'teacher'], :include => ['enrollments']) - expect(json.map { |u| u['enrollments'].map { |e| e['type'] } }.flatten.uniq.sort).to eq %w{StudentEnrollment StudentViewEnrollment TeacherEnrollment} + expect(json.map { |u| u['enrollments'].map { |e| e['type'] } }.flatten.uniq.sort).to eq %w[StudentEnrollment StudentViewEnrollment TeacherEnrollment] end describe "enrollment_role" do @@ -3407,7 +3407,7 @@ describe CoursesController, type: :request do it "accepts an array of enrollment roles" do json = api_call(:get, "/api/v1/courses/#{@course1.id}/users.json", { :controller => 'courses', :action => 'users', :course_id => @course1.id.to_s, :format => 'json' }, - :enrollment_role => %w{StudentEnrollment EliteStudent}) + :enrollment_role => %w[StudentEnrollment EliteStudent]) expect(json.map { |x| x["id"].to_i }.sort).to eq [@student1, @student2, @student3].map(&:id).sort end @@ -3469,7 +3469,7 @@ describe CoursesController, type: :request do { :controller => 'courses', :action => 'users', :course_id => @course2.id.to_s, :format => 'json' }, :enrollment_type => 'student') expect(json.length).to eq 2 - %w{sis_user_id unique_id}.each do |attribute| + %w[sis_user_id unique_id].each do |attribute| expect(json.map { |u| u[attribute] }).to eq [nil, nil] end end @@ -3554,7 +3554,7 @@ describe CoursesController, type: :request do json = api_call(:get, "/api/v1/courses/#{@course1.to_param}/users", { :controller => 'courses', :action => 'users', :course_id => @course1.to_param, :format => 'json' }, - { :include => %w{email} }) + { :include => %w[email] }) json.each do |u| if u['id'] == @user.id expect(u['email']).to eq @user.email @@ -3646,7 +3646,7 @@ describe CoursesController, type: :request do it "includes custom links if requested" do json = api_call(:get, "/api/v1/courses/#{@course1.id}/users.json?include[]=custom_links", { :controller => 'courses', :action => 'users', :course_id => @course1.id.to_s, - :format => 'json', :include => %w(custom_links) }) + :format => 'json', :include => %w[custom_links] }) expect(json.first).to have_key 'custom_links' end @@ -3659,7 +3659,7 @@ describe CoursesController, type: :request do it "puts analytics 2 in custom links if installed" do json = api_call_as_user(@ta, :get, "/api/v1/courses/#{@course1.id}/users.json?include[]=custom_links", { :controller => 'courses', :action => 'users', :course_id => @course1.to_param, - :format => 'json', :include => %w(custom_links) }) + :format => 'json', :include => %w[custom_links] }) student1_json = json.find { |u| u['id'] == @student1.id } expect(student1_json['custom_links']).to include({ 'text' => 'Analytics 2', @@ -3674,7 +3674,7 @@ describe CoursesController, type: :request do it "respects tool permissions" do json = api_call_as_user(@student1, :get, "/api/v1/courses/#{@course1.id}/users.json?include[]=custom_links", { :controller => 'courses', :action => 'users', :course_id => @course1.id.to_s, - :format => 'json', :include => %w(custom_links) }) + :format => 'json', :include => %w[custom_links] }) student2_json = json.find { |u| u['id'] == @student2.id } expect(student2_json['custom_links'].map { |l| l['tool_id'] }).not_to include ContextExternalTool::ANALYTICS_2 end @@ -4277,7 +4277,7 @@ describe CoursesController, type: :request do it "sanitizes html and process links" do @user = @teacher attachment_model(:context => @course) - html = %{

Click!

} + html = %(

Click!

) json = api_call(:post, "/api/v1/courses/#{@course.id}/preview_html", { :controller => 'courses', :action => 'preview_html', :course_id => @course.to_param, :format => 'json' }, { :html => html }) diff --git a/spec/apis/v1/custom_gradebook_columns_api_spec.rb b/spec/apis/v1/custom_gradebook_columns_api_spec.rb index af9d54a308a..472757c365e 100644 --- a/spec/apis/v1/custom_gradebook_columns_api_spec.rb +++ b/spec/apis/v1/custom_gradebook_columns_api_spec.rb @@ -176,7 +176,7 @@ describe CustomGradebookColumnsApiController, type: :request do describe 'reorder' do it 'works' do - names = %w(A B C) + names = %w[A B C] c1, c2, c3 = Array.new(3) do |i| c = @course.custom_gradebook_columns.build(title: names.shift) c.position = i diff --git a/spec/apis/v1/enrollments_api_spec.rb b/spec/apis/v1/enrollments_api_spec.rb index 71a70ba24f1..eb3ee0e83fe 100644 --- a/spec/apis/v1/enrollments_api_spec.rb +++ b/spec/apis/v1/enrollments_api_spec.rb @@ -973,14 +973,14 @@ describe EnrollmentsApiController, type: :request do course0 = @course course_with_student user: @student, enrollment_state: 'invited', active_course: true - json = api_call_as_user @student, :get, @user_path, @user_params.merge(state: %w(invited active)) + json = api_call_as_user @student, :get, @user_path, @user_params.merge(state: %w[invited active]) expect(json.map { |e| e['course_id'] }).to match_array [course0.id, @course.id] @course.start_at = 1.month.ago @course.conclude_at = 1.week.ago @course.restrict_enrollments_to_course_dates = true @course.save! - json = api_call_as_user @student, :get, @user_path, @user_params.merge(state: %w(invited active)) + json = api_call_as_user @student, :get, @user_path, @user_params.merge(state: %w[invited active]) expect(json.map { |e| e['course_id'] }).to match_array [course0.id] end @@ -1434,7 +1434,7 @@ describe EnrollmentsApiController, type: :request do # with a state[] filter json = api_call(:get, "#{@user_path}?state[]=active", - @user_params.merge(:state => %w{active})) + @user_params.merge(:state => %w[active])) expect(json.map { |e| e['id'] }).to include enrollment.id end @@ -1523,7 +1523,7 @@ describe EnrollmentsApiController, type: :request do it "accepts an array of enrollment roles" do json = api_call(:get, "#{@user_path}?role[]=StudentEnrollment&role[]=CustomStudent", - @user_params.merge(:role => %w{StudentEnrollment CustomStudent})) + @user_params.merge(:role => %w[StudentEnrollment CustomStudent])) expect(json.map { |e| e['course_id'].to_i }.sort).to eq [@original_course.id, @course.id].sort end end @@ -1576,7 +1576,7 @@ describe EnrollmentsApiController, type: :request do it "accepts an array of enrollment roles" do json = api_call(:get, "#{@path}?role[]=StudentEnrollment&role[]=CustomStudent", - @params.merge(:role => %w{StudentEnrollment CustomStudent})) + @params.merge(:role => %w[StudentEnrollment CustomStudent])) expect(json.map { |e| e['user_id'].to_i }.sort).to eq [@original_student.id, @student.id].sort end end @@ -1591,7 +1591,7 @@ describe EnrollmentsApiController, type: :request do @user = current_user json = api_call(:get, @path, @params) - enrollments = %w{observer student ta teacher}.inject([]) do |res, type| + enrollments = %w[observer student ta teacher].inject([]) do |res, type| res + @course.send("#{type}_enrollments").eager_load(:user).order(User.sortable_name_order_by_clause("users")) end expect(json).to match_array(enrollments.map do |e| @@ -1676,7 +1676,7 @@ describe EnrollmentsApiController, type: :request do it "filters by enrollment workflow_state" do @teacher.enrollments.first.update_attribute(:workflow_state, 'completed') - json = api_call(:get, "#{@path}?state[]=completed", @params.merge(:state => %w{completed})) + json = api_call(:get, "#{@path}?state[]=completed", @params.merge(:state => %w[completed])) expect(json.count).to be > 0 json.each { |e| expect(e['enrollment_state']).to eql 'completed' } end @@ -1868,7 +1868,7 @@ describe EnrollmentsApiController, type: :request do @course.save json = api_call(:get, @user_path, @user_params) - expect(json[0]['grades'].keys).to eql %w{html_url} + expect(json[0]['grades'].keys).to eql %w[html_url] end it "does not show enrollments for courses that aren't published" do @@ -1883,7 +1883,7 @@ describe EnrollmentsApiController, type: :request do # Request w/ a state[] filter. json = api_call(:get, @user_path, - @user_params.merge(:state => %w{active}, :type => %w{StudentEnrollment})) + @user_params.merge(:state => %w[active], :type => %w[StudentEnrollment])) expect(json.map { |e| e['id'] }).not_to include enrollment.id end @@ -1894,7 +1894,7 @@ describe EnrollmentsApiController, type: :request do enrollment.update_attribute(:workflow_state, 'active') json = api_call(:get, @user_path, - @user_params.merge(:state => %w{current_and_future}, :type => %w{StudentEnrollment})) + @user_params.merge(:state => %w[current_and_future], :type => %w[StudentEnrollment])) expect(json.map { |e| e['id'] }).to include enrollment.id end @@ -1906,7 +1906,7 @@ describe EnrollmentsApiController, type: :request do expect(enrollment.enrollment_state.state).to eq "pending_active" json = api_call(:get, @user_path, - @user_params.merge(:state => %w{current_and_future}, :type => %w{StudentEnrollment})) + @user_params.merge(:state => %w[current_and_future], :type => %w[StudentEnrollment])) expect(json.map { |e| e['id'] }).to include enrollment.id end @@ -1917,7 +1917,7 @@ describe EnrollmentsApiController, type: :request do enrollment.update_attribute(:workflow_state, 'completed') json = api_call(:get, @user_path, - @user_params.merge(:state => %w{active completed})) + @user_params.merge(:state => %w[active completed])) expect(json.map { |e| e['id'].to_i }.sort).to eq @user.enrollments.map(&:id).sort end @@ -1939,7 +1939,7 @@ describe EnrollmentsApiController, type: :request do it "does not include the users' sis and login ids" do json = api_call(:get, @path, @params) json.each do |res| - %w{sis_user_id login_id}.each { |key| expect(res['user']).not_to include(key) } + %w[sis_user_id login_id].each { |key| expect(res['user']).not_to include(key) } end end end @@ -1951,7 +1951,7 @@ describe EnrollmentsApiController, type: :request do it "includes users' sis and login ids" do json = api_call(:get, @path, @params) - enrollments = %w{observer student ta teacher}.inject([]) do |res, type| + enrollments = %w[observer student ta teacher].inject([]) do |res, type| res + @course.send("#{type}_enrollments").preload(:user) end enrollments = enrollments.sort_by { |e| [e.type, e.user.sortable_name] } @@ -2286,7 +2286,7 @@ describe EnrollmentsApiController, type: :request do shared_examples_for 'numeric pagination' do it "properly paginates" do json = api_call(:get, "#{@path}?page=1&per_page=1", @params.merge(:page => 1.to_param, :per_page => 1.to_param)) - enrollments = %w{observer student ta teacher}.inject([]) { |res, type| + enrollments = %w[observer student ta teacher].inject([]) { |res, type| res + @course.send("#{type}_enrollments").preload(:user) }.map do |e| h = { @@ -2349,7 +2349,7 @@ describe EnrollmentsApiController, type: :request do shared_examples_for 'bookmarked pagination' do it "properly paginates" do json = api_call(:get, "#{@path}?page=1&per_page=1", @params.merge(:page => 1.to_param, :per_page => 1.to_param)) - enrollments = %w{observer student ta teacher}.inject([]) { |res, type| + enrollments = %w[observer student ta teacher].inject([]) { |res, type| res + @course.send("#{type}_enrollments").preload(:user) }.map do |e| h = { @@ -2699,7 +2699,7 @@ describe EnrollmentsApiController, type: :request do describe "filters" do it "properly filters by a single enrollment type" do - json = api_call(:get, "#{@path}?type[]=StudentEnrollment", @params.merge(:type => %w{StudentEnrollment})) + json = api_call(:get, "#{@path}?type[]=StudentEnrollment", @params.merge(:type => %w[StudentEnrollment])) expect(json).to eql(@course.student_enrollments.map do |e| { 'root_account_id' => e.root_account_id, @@ -2746,7 +2746,7 @@ describe EnrollmentsApiController, type: :request do @course.enroll_user(@new_user, 'TaEnrollment', :enrollment_state => 'active') @course.enroll_user(@new_user, 'ObserverEnrollment', :enrollment_state => 'active') @user = request_user - json = api_call(:get, "#{@path}?type[]=StudentEnrollment&type[]=TeacherEnrollment", @params.merge(:type => %w{StudentEnrollment TeacherEnrollment})) + json = api_call(:get, "#{@path}?type[]=StudentEnrollment&type[]=TeacherEnrollment", @params.merge(:type => %w[StudentEnrollment TeacherEnrollment])) enrollments = (@course.student_enrollments + @course.teacher_enrollments).sort_by { |e| [e.type, e.user.sortable_name] } expect(json).to eq(enrollments.map { |e| @@ -2795,7 +2795,7 @@ describe EnrollmentsApiController, type: :request do site_admin_user(:active_all => true) json = api_call(:get, "#{@user_path}?type[]=TeacherEnrollment", - @user_params.merge(:type => %w{TeacherEnrollment})) + @user_params.merge(:type => %w[TeacherEnrollment])) expect(json).to be_empty end diff --git a/spec/apis/v1/feature_flags_api_spec.rb b/spec/apis/v1/feature_flags_api_spec.rb index 2ad52e3be65..4d778d80541 100644 --- a/spec/apis/v1/feature_flags_api_spec.rb +++ b/spec/apis/v1/feature_flags_api_spec.rb @@ -139,34 +139,34 @@ describe "Feature Flags API", type: :request do json += api_call_as_user(t_root_admin, :get, "/api/v1/accounts/#{t_root_account.id}/features?per_page=3&page=2", { controller: 'feature_flags', action: 'index', format: 'json', account_id: t_root_account.to_param, per_page: '3', page: '2' }) expect(json.size).to eql 5 - expect(json.map { |f| f['feature'] }.sort).to match_array %w(account_feature course_feature root_account_feature root_opt_in_feature compact_live_event_payloads) + expect(json.map { |f| f['feature'] }.sort).to match_array %w[account_feature course_feature root_account_feature root_opt_in_feature compact_live_event_payloads] end it "returns only relevant features" do json = api_call_as_user(t_root_admin, :get, "/api/v1/accounts/#{t_sub_account.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', account_id: t_sub_account.to_param }) - expect(json.map { |f| f['feature'] }.sort).to eql %w(account_feature course_feature) + expect(json.map { |f| f['feature'] }.sort).to eql %w[account_feature course_feature] end it "respects root_opt_in" do t_root_account.feature_flags.create! feature: 'root_opt_in_feature' json = api_call_as_user(t_root_admin, :get, "/api/v1/accounts/#{t_sub_account.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', account_id: t_sub_account.to_param }) - expect(json.map { |f| f['feature'] }.sort).to eql %w(account_feature course_feature root_opt_in_feature) + expect(json.map { |f| f['feature'] }.sort).to eql %w[account_feature course_feature root_opt_in_feature] end describe "hidden" do it "shows hidden features on site admin" do json = api_call_as_user(site_admin_user, :get, "/api/v1/accounts/#{t_site_admin.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', account_id: t_site_admin.id.to_s }) - expect(json.map { |f| f['feature'] }).to match_array %w(account_feature course_feature hidden_feature hidden_user_feature root_account_feature root_opt_in_feature user_feature compact_live_event_payloads) + expect(json.map { |f| f['feature'] }).to match_array %w[account_feature course_feature hidden_feature hidden_user_feature root_account_feature root_opt_in_feature user_feature compact_live_event_payloads] expect(json.find { |f| f['feature'] == 'hidden_feature' }['feature_flag']['hidden']).to eq true end it "shows hidden features on root accounts to a site admin user" do json = api_call_as_user(site_admin_user, :get, "/api/v1/accounts/#{t_root_account.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', account_id: t_root_account.to_param }) - expect(json.map { |f| f['feature'] }).to match_array %w(account_feature course_feature hidden_feature root_account_feature root_opt_in_feature compact_live_event_payloads) + expect(json.map { |f| f['feature'] }).to match_array %w[account_feature course_feature hidden_feature root_account_feature root_opt_in_feature compact_live_event_payloads] expect(json.find { |f| f['feature'] == 'hidden_feature' }['feature_flag']['hidden']).to eq true end @@ -175,7 +175,7 @@ describe "Feature Flags API", type: :request do json = api_call_as_user(t_root_admin, :get, "/api/v1/accounts/#{t_root_account.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', account_id: t_root_account.to_param }) expect(json.find { |f| f['feature'] == 'hidden_feature' }['feature_flag']['hidden']).to be_nil - expect(json.map { |f| f['feature'] }).to match_array %w(account_feature course_feature hidden_feature root_account_feature root_opt_in_feature compact_live_event_payloads) + expect(json.map { |f| f['feature'] }).to match_array %w[account_feature course_feature hidden_feature root_account_feature root_opt_in_feature compact_live_event_payloads] end it "shows 'hidden' tag to site admin on the feature flag that un-hides a hidden feature" do @@ -222,13 +222,13 @@ describe "Feature Flags API", type: :request do }) json = api_call_as_user(t_teacher, :get, "/api/v1/courses/#{t_course.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', course_id: t_course.to_param }) - expect(json.map { |f| f['feature'] }).to eql %w(course_feature) + expect(json.map { |f| f['feature'] }).to eql %w[course_feature] end it "operates on a user" do json = api_call_as_user(t_teacher, :get, "/api/v1/users/#{t_teacher.id}/features", { controller: 'feature_flags', action: 'index', format: 'json', user_id: t_teacher.to_param }) - expect(json.map { |f| f['feature'] }).to eql %w(user_feature) + expect(json.map { |f| f['feature'] }).to eql %w[user_feature] end end @@ -243,7 +243,7 @@ describe "Feature Flags API", type: :request do t_root_account.feature_flags.create! feature: 'course_feature', state: 'on' json = api_call_as_user(t_root_admin, :get, "/api/v1/accounts/#{t_root_account.id}/features/enabled", { controller: 'feature_flags', action: 'enabled_features', format: 'json', account_id: t_root_account.to_param }) - expect(json.sort).to eql %w(account_feature course_feature) + expect(json.sort).to eql %w[account_feature course_feature] end end diff --git a/spec/apis/v1/files_controller_api_spec.rb b/spec/apis/v1/files_controller_api_spec.rb index f4d749758d7..49e37588279 100644 --- a/spec/apis/v1/files_controller_api_spec.rb +++ b/spec/apis/v1/files_controller_api_spec.rb @@ -541,7 +541,7 @@ describe "Files API", type: :request do it "lists files in alphabetical order" do json = api_call(:get, @files_path, @files_path_options, {}) res = json.map { |f| f['display_name'] } - expect(res).to eq %w{atest3.txt mtest2.txt ztest.txt} + expect(res).to eq %w[atest3.txt mtest2.txt ztest.txt] json.map { |f| f['url'] }.each { |url| expect(url).to include 'verifier=' } end @@ -564,7 +564,7 @@ describe "Files API", type: :request do it "lists files in saved order if flag set" do json = api_call(:get, @files_path + "?sort_by=position", @files_path_options.merge(:sort_by => 'position'), {}) res = json.map { |f| f['display_name'] } - expect(res).to eq %w{ztest.txt atest3.txt mtest2.txt} + expect(res).to eq %w[ztest.txt atest3.txt mtest2.txt] end it "does not list locked file if not authed" do @@ -624,7 +624,7 @@ describe "Files API", type: :request do it "only returns names if requested" do json = api_call(:get, @files_path, @files_path_options, { :only => ['names'] }) res = json.map { |f| f['display_name'] } - expect(res).to eq %w{atest3.txt mtest2.txt ztest.txt} + expect(res).to eq %w[atest3.txt mtest2.txt ztest.txt] expect(json.any? { |f| f['url'] }).to be_falsey end @@ -638,14 +638,14 @@ describe "Files API", type: :request do it "matches one content-type" do json = api_call(:get, @files_path + "?content_types=image", @files_path_options.merge(:content_types => 'image'), {}) res = json.map { |f| f['display_name'] } - expect(res).to eq %w(thing.gif thing.png) + expect(res).to eq %w[thing.gif thing.png] end it "matches multiple content-types" do json = api_call(:get, @files_path + "?content_types[]=text&content_types[]=image/gif", @files_path_options.merge(:content_types => ['text', 'image/gif'])) res = json.map { |f| f['display_name'] } - expect(res).to eq %w(thing.gif thing.txt) + expect(res).to eq %w[thing.gif thing.txt] end end @@ -781,13 +781,13 @@ describe "Files API", type: :request do it "lists files in alphabetical order" do json = api_call(:get, @files_path, @files_path_options, {}) res = json.map { |f| f['display_name'] } - expect(res).to eq %w{atest3.txt mtest2.txt ztest.txt} + expect(res).to eq %w[atest3.txt mtest2.txt ztest.txt] end it "lists files in saved order if flag set" do json = api_call(:get, @files_path + "?sort_by=position", @files_path_options.merge(:sort_by => 'position'), {}) res = json.map { |f| f['display_name'] } - expect(res).to eq %w{ztest.txt atest3.txt mtest2.txt} + expect(res).to eq %w[ztest.txt atest3.txt mtest2.txt] end it "sorts by size" do @@ -801,7 +801,7 @@ describe "Files API", type: :request do Timecop.freeze(1.hour.ago) { @a1.touch } json = api_call(:get, @files_path + "?sort=updated_at", @files_path_options.merge(sort: 'updated_at')) res = json.map { |f| f['display_name'] } - expect(res).to eq %w{mtest2.txt ztest.txt atest3.txt} + expect(res).to eq %w[mtest2.txt ztest.txt atest3.txt] end it "sorts by content_type" do @@ -885,14 +885,14 @@ describe "Files API", type: :request do it "matches one content-type" do json = api_call(:get, @files_path + "?content_types=image", @files_path_options.merge(:content_types => 'image'), {}) res = json.map { |f| f['display_name'] } - expect(res).to eq %w(thing.gif thing.png) + expect(res).to eq %w[thing.gif thing.png] end it "matches multiple content-types" do json = api_call(:get, @files_path + "?content_types[]=text&content_types[]=image/gif", @files_path_options.merge(:content_types => ['text', 'image/gif'])) res = json.map { |f| f['display_name'] } - expect(res).to eq %w(thing.gif thing.txt) + expect(res).to eq %w[thing.gif thing.txt] end end @@ -1067,10 +1067,10 @@ describe "Files API", type: :request do end def should_be_locked(json) - prohibited_fields = %w( + prohibited_fields = %w[ canvadoc_session_url crocodoc_session_url - ) + ] expect(json['url']).to eq "" expect(json['thumbnail_url']).to eq "" diff --git a/spec/apis/v1/folders_controller_api_spec.rb b/spec/apis/v1/folders_controller_api_spec.rb index f6e5a6a33be..52ac954a703 100644 --- a/spec/apis/v1/folders_controller_api_spec.rb +++ b/spec/apis/v1/folders_controller_api_spec.rb @@ -42,14 +42,14 @@ describe "Folders API", type: :request do it "lists folders in alphabetical order" do json = api_call(:get, @folders_path + "/#{@root.id}/folders", @folders_path_options, {}) res = json.map { |f| f['name'] } - expect(res).to eq %w{11folder aafolder folder1 folder2 zzfolder} + expect(res).to eq %w[11folder aafolder folder1 folder2 zzfolder] end it "lists folders in saved order if flag set" do json = api_call(:get, @folders_path + "/#{@root.id}/folders?sort_by=position", @folders_path_options.merge(:action => "api_index", :sort_by => 'position'), {}) res = json.map { |f| f['name'] } - expect(res).to eq %w{folder1 folder2 11folder zzfolder aafolder} + expect(res).to eq %w[folder1 folder2 11folder zzfolder aafolder] end it "allows getting locked folder if authed" do @@ -953,7 +953,7 @@ describe "Folders API", type: :request do json = api_call(:get, "/api/v1/courses/#{@course.id}/folders", { :controller => "folders", :action => "list_all_folders", :format => "json", :course_id => @course.id.to_param }) res = json.map { |f| f['name'] } - expect(res).to eq %w{course\ files folder1 folder2 folder2.1 folder2.1.1 folderhidden folderlocked} + expect(res).to eq %w[course\ files folder1 folder2 folder2.1 folder2.1.1 folderhidden folderlocked] end it "does not show hidden and locked files to unauthorized users" do @@ -961,7 +961,7 @@ describe "Folders API", type: :request do json = api_call(:get, "/api/v1/courses/#{@course.id}/folders", { :controller => "folders", :action => "list_all_folders", :format => "json", :course_id => @course.id.to_param }) res = json.map { |f| f['name'] } - expect(res).to eq %w{course\ files folder1 folder2 folder2.1 folder2.1.1} + expect(res).to eq %w[course\ files folder1 folder2 folder2.1 folder2.1.1] end it "returns a 401 for unauthorized users" do @@ -1001,7 +1001,7 @@ describe "Folders API", type: :request do json = api_call(:get, "/api/v1/groups/#{@group.id}/folders", { :controller => "folders", :action => "list_all_folders", :format => "json", :group_id => @group.id.to_param }) res = json.map { |f| f['name'] } - expect(res).to eq %w{files folder1 folder2 folder2.1 folder2.1.1 folderhidden folderlocked} + expect(res).to eq %w[files folder1 folder2 folder2.1 folder2.1.1 folderhidden folderlocked] end end @@ -1012,7 +1012,7 @@ describe "Folders API", type: :request do json = api_call(:get, "/api/v1/users/#{@user.id}/folders", { :controller => "folders", :action => "list_all_folders", :format => "json", :user_id => @user.id.to_param }) res = json.map { |f| f['name'] } - expect(res).to eq %w{folder1 folder2 folder2.1 folder2.1.1 folderhidden folderlocked my\ files} + expect(res).to eq %w[folder1 folder2 folder2.1 folder2.1.1 folderhidden folderlocked my\ files] end end end diff --git a/spec/apis/v1/group_categories_api_spec.rb b/spec/apis/v1/group_categories_api_spec.rb index dab7c29a680..94b09bc7007 100644 --- a/spec/apis/v1/group_categories_api_spec.rb +++ b/spec/apis/v1/group_categories_api_spec.rb @@ -199,7 +199,7 @@ describe "Group Categories API", type: :request do end it "returns users in a group_category" do - expected_keys = %w{id name sortable_name short_name} + expected_keys = %w[id name sortable_name short_name] json = api_call(:get, api_url, api_route) expect(json.count).to eq 8 json.each do |user| @@ -221,7 +221,7 @@ describe "Group Categories API", type: :request do end it "returns a list of users" do - expected_keys = %w{id name sortable_name short_name} + expected_keys = %w[id name sortable_name short_name] json = api_call(:get, api_url, api_route, { :search_term => 'waldo' }) @@ -233,7 +233,7 @@ describe "Group Categories API", type: :request do end it "returns a list of unassigned users" do - expected_keys = %w{id name sortable_name short_name} + expected_keys = %w[id name sortable_name short_name] json = api_call(:get, api_url, api_route, { :search_term => 'antisocial', :unassigned => 'true' }) diff --git a/spec/apis/v1/groups_api_spec.rb b/spec/apis/v1/groups_api_spec.rb index 6a63bd003ab..aedac53bf6c 100644 --- a/spec/apis/v1/groups_api_spec.rb +++ b/spec/apis/v1/groups_api_spec.rb @@ -897,7 +897,7 @@ describe "Groups API", type: :request do end it "returns users in a group" do - expected_keys = %w{id name sortable_name short_name} + expected_keys = %w[id name sortable_name short_name] json = api_call(:get, "/api/v1/groups/#{@community.id}/users", { :controller => 'groups', :action => 'users', :group_id => @community.to_param, :format => 'json' }) expect(json.count).to eq 2 @@ -921,7 +921,7 @@ describe "Groups API", type: :request do end it "returns a list of users" do - expected_keys = %w{id name sortable_name short_name} + expected_keys = %w[id name sortable_name short_name] json = api_call(:get, api_url, api_route, { :search_term => 'value' }) @@ -1033,7 +1033,7 @@ describe "Groups API", type: :request do it "sanitizes html and process links" do @user = @teacher attachment_model(:context => @group) - html = %{

Click!

} + html = %(

Click!

) json = api_call(:post, "/api/v1/groups/#{@group.id}/preview_html", { :controller => 'groups', :action => 'preview_html', :group_id => @group.to_param, :format => 'json' }, { :html => html }) @@ -1061,14 +1061,14 @@ describe "Groups API", type: :request do @group.add_user(@student) json = api_call(:get, "/api/v1/groups/#{@group.id}/permissions?permissions[]=send_messages&permissions[]=manage_blarghs", :controller => 'groups', :action => 'permissions', :group_id => @group.to_param, - :format => 'json', :permissions => %w(send_messages manage_blarghs)) + :format => 'json', :permissions => %w[send_messages manage_blarghs]) expect(json).to eq({ "send_messages" => true, "manage_blarghs" => false }) end it "requires :read permission on the group" do api_call(:get, "/api/v1/groups/#{@group.id}/permissions?permissions[]=send_messages", { :controller => 'groups', :action => 'permissions', :group_id => @group.to_param, :format => 'json', - :permissions => %w(send_messages) }, {}, {}, { :expected_status => 401 }) + :permissions => %w[send_messages] }, {}, {}, { :expected_status => 401 }) end end end diff --git a/spec/apis/v1/outcome_results_api_spec.rb b/spec/apis/v1/outcome_results_api_spec.rb index 75887162e90..4d6c25c983c 100644 --- a/spec/apis/v1/outcome_results_api_spec.rb +++ b/spec/apis/v1/outcome_results_api_spec.rb @@ -239,19 +239,19 @@ describe "Outcome Results API", type: :request do api_call(:get, outcome_rollups_url(outcome_course), controller: 'outcome_results', action: 'rollups', format: 'json', course_id: outcome_course.id.to_s) json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(meta rollups) + expect(json.keys.sort).to eq %w[meta rollups] expect(json['rollups'].size).to eq 1 json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) - expect(rollup['links'].keys.sort).to eq %w(section user) + expect(rollup.keys.sort).to eq %w[links scores] + expect(rollup['links'].keys.sort).to eq %w[section user] expect(rollup['links']['section']).to eq @course.course_sections.first.id.to_s expect(rollup['links']['user']).to eq outcome_student.id.to_s expect(rollup['scores'].size).to eq 1 rollup['scores'].each do |score| - expect(score.keys.sort).to eq %w(count hide_points links score submitted_at title) + expect(score.keys.sort).to eq %w[count hide_points links score submitted_at title] expect(score['count']).to eq 1 expect(score['score']).to eq first_outcome_rating[:points] - expect(score['links'].keys.sort).to eq %w(outcome) + expect(score['links'].keys.sort).to eq %w[outcome] expect(score['links']['outcome']).to eq outcome_object.id.to_s end end @@ -496,23 +496,23 @@ describe "Outcome Results API", type: :request do api_call(:get, outcome_rollups_url(outcome_course, user_ids: student_id_str, include: ['users']), controller: 'outcome_results', action: 'rollups', format: 'json', course_id: outcome_course.id.to_s, user_ids: student_id_str, include: ['users']) json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(linked meta rollups) + expect(json.keys.sort).to eq %w[linked meta rollups] expect(json['rollups'].size).to eq 2 json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) - expect(rollup['links'].keys.sort).to eq %w(section user) + expect(rollup.keys.sort).to eq %w[links scores] + expect(rollup['links'].keys.sort).to eq %w[section user] expect(rollup['links']['section']).to eq @course.course_sections.first.id.to_s expect(student_ids).to be_include(rollup['links']['user']) expect(rollup['scores'].size).to eq 1 rollup['scores'].each do |score| - expect(score.keys.sort).to eq %w(count hide_points links score submitted_at title) + expect(score.keys.sort).to eq %w[count hide_points links score submitted_at title] expect(score['count']).to eq 1 expect([0, 1]).to be_include(score['score']) - expect(score['links'].keys.sort).to eq %w(outcome) + expect(score['links'].keys.sort).to eq %w[outcome] expect(score['links']['outcome']).to eq outcome_object.id.to_s end end - expect(json['linked'].keys.sort).to eq %w(users) + expect(json['linked'].keys.sort).to eq %w[users] expect(json['linked']['users'].size).to eq 2 end @@ -555,23 +555,23 @@ describe "Outcome Results API", type: :request do api_call(:get, outcome_rollups_url(outcome_course, section_id: outcome_course_sections[0].id, include: ['users']), controller: 'outcome_results', action: 'rollups', format: 'json', course_id: outcome_course.id.to_s, section_id: outcome_course_sections[0].id.to_s, include: ['users']) json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(linked meta rollups) + expect(json.keys.sort).to eq %w[linked meta rollups] expect(json['rollups'].size).to eq 2 json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) - expect(rollup['links'].keys.sort).to eq %w(section user) + expect(rollup.keys.sort).to eq %w[links scores] + expect(rollup['links'].keys.sort).to eq %w[section user] expect(rollup['links']['section']).to eq outcome_course_sections[0].id.to_s expect(outcome_course_sections[0].student_ids.map(&:to_s)).to be_include(rollup['links']['user']) expect(rollup['scores'].size).to eq 1 rollup['scores'].each do |score| - expect(score.keys.sort).to eq %w(count hide_points links score submitted_at title) + expect(score.keys.sort).to eq %w[count hide_points links score submitted_at title] expect(score['count']).to eq 1 expect([0, 2]).to be_include(score['score']) - expect(score['links'].keys.sort).to eq %w(outcome) + expect(score['links'].keys.sort).to eq %w[outcome] expect(score['links']['outcome']).to eq outcome_object.id.to_s end end - expect(json['linked'].keys.sort).to eq %w(users) + expect(json['linked'].keys.sort).to eq %w[users] expect(json['linked']['users'].size).to eq outcome_course_sections[0].students.count end end @@ -706,17 +706,17 @@ describe "Outcome Results API", type: :request do controller: 'outcome_results', action: 'rollups', format: 'json', course_id: outcome_course.id.to_s, aggregate: 'course') json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(rollups) + expect(json.keys.sort).to eq %w[rollups] expect(json['rollups'].size).to eq 1 json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) + expect(rollup.keys.sort).to eq %w[links scores] expect(rollup['links']['course']).to eq @course.id.to_s expect(rollup['scores'].size).to eq 1 rollup['scores'].each do |score| - expect(score.keys.sort).to eq %w(count hide_points links score submitted_at title) + expect(score.keys.sort).to eq %w[count hide_points links score submitted_at title] expect(score['count']).to eq 1 expect(score['score']).to eq first_outcome_rating[:points] - expect(score['links'].keys.sort).to eq %w(outcome) + expect(score['links'].keys.sort).to eq %w[outcome] end end end @@ -731,17 +731,17 @@ describe "Outcome Results API", type: :request do course_id: outcome_course.id.to_s, aggregate: 'course', user_ids: student_id_str) json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(rollups) + expect(json.keys.sort).to eq %w[rollups] expect(json['rollups'].size).to eq 1 json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) + expect(rollup.keys.sort).to eq %w[links scores] expect(rollup['links']['course']).to eq @course.id.to_s expect(rollup['scores'].size).to eq 1 rollup['scores'].each do |score| - expect(score.keys.sort).to eq %w(count hide_points links score submitted_at title) + expect(score.keys.sort).to eq %w[count hide_points links score submitted_at title] expect(score['count']).to eq 2 expect(score['score']).to eq 0.5 - expect(score['links'].keys.sort).to eq %w(outcome) + expect(score['links'].keys.sort).to eq %w[outcome] end end end @@ -756,17 +756,17 @@ describe "Outcome Results API", type: :request do course_id: outcome_course.id.to_s, aggregate: 'course', section_id: outcome_course_sections[0].id.to_s) json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(rollups) + expect(json.keys.sort).to eq %w[rollups] expect(json['rollups'].size).to eq 1 json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) + expect(rollup.keys.sort).to eq %w[links scores] expect(rollup['links']['course']).to eq outcome_course.id.to_s expect(rollup['scores'].size).to eq 1 rollup['scores'].each do |score| - expect(score.keys.sort).to eq %w(count hide_points links score submitted_at title) + expect(score.keys.sort).to eq %w[count hide_points links score submitted_at title] expect(score['count']).to eq outcome_course_sections[0].enrollments.count expect(score['score']).to eq 1 - expect(score['links'].keys.sort).to eq %w(outcome) + expect(score['links'].keys.sort).to eq %w[outcome] end end end @@ -825,13 +825,13 @@ describe "Outcome Results API", type: :request do api_call(:get, outcome_rollups_url(outcome_course), controller: 'outcome_results', action: 'rollups', format: 'json', course_id: outcome_course.id.to_s) json = JSON.parse(response.body) - expect(json.keys.sort).to eq %w(meta rollups) + expect(json.keys.sort).to eq %w[meta rollups] expect(json['rollups'].size).to eq 2 expect(json['rollups'].collect { |x| x['links']['user'] }.sort).to eq [student.id.to_s, student2.id.to_s].sort json['rollups'].each do |rollup| - expect(rollup.keys.sort).to eq %w(links scores) + expect(rollup.keys.sort).to eq %w[links scores] expect(rollup['scores'].size).to eq 1 - expect(rollup['links'].keys.sort).to eq %w(section user) + expect(rollup['links'].keys.sort).to eq %w[section user] end end end diff --git a/spec/apis/v1/pages_api_spec.rb b/spec/apis/v1/pages_api_spec.rb index e4dab871b64..91c54728882 100644 --- a/spec/apis/v1/pages_api_spec.rb +++ b/spec/apis/v1/pages_api_spec.rb @@ -133,7 +133,7 @@ describe "Pages API", type: :request do it "lists pages, including hidden ones", priority: "1", test_id: 126789 do json = api_call(:get, "/api/v1/courses/#{@course.id}/pages", :controller => 'wiki_pages_api', :action => 'index', :format => 'json', :course_id => @course.to_param) - expect(json.map { |entry| entry.slice(*%w(hide_from_students url created_at updated_at title front_page)) }).to eq( + expect(json.map { |entry| entry.slice(*%w[hide_from_students url created_at updated_at title front_page]) }).to eq( [{ "hide_from_students" => false, "url" => @front_page.url, "created_at" => @front_page.created_at.as_json, "updated_at" => @front_page.revised_at.as_json, "title" => @front_page.title, "front_page" => true }, { "hide_from_students" => true, "url" => @hidden_page.url, "created_at" => @hidden_page.created_at.as_json, "updated_at" => @hidden_page.revised_at.as_json, "title" => @hidden_page.title, "front_page" => false }] ) @@ -349,7 +349,7 @@ describe "Pages API", type: :request do describe "revisions" do before :once do - @timestamps = %w(2013-01-01 2013-01-02 2013-01-03).map { |d| Time.zone.parse(d) } + @timestamps = %w[2013-01-01 2013-01-02 2013-01-03].map { |d| Time.zone.parse(d) } course_with_ta :course => @course, :active_all => true Timecop.freeze(@timestamps[0]) do # rev 1 @vpage = @course.wiki_pages.build :title => 'version test page' @@ -1068,7 +1068,7 @@ describe "Pages API", type: :request do it "lists pages, excluding hidden ones" do json = api_call(:get, "/api/v1/courses/#{@course.id}/pages", :controller => 'wiki_pages_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s) - expect(json.map { |entry| entry.slice(*%w(hide_from_students url created_at updated_at title)) }).to eq( + expect(json.map { |entry| entry.slice(*%w[hide_from_students url created_at updated_at title]) }).to eq( [{ "hide_from_students" => false, "url" => @front_page.url, "created_at" => @front_page.created_at.as_json, "updated_at" => @front_page.revised_at.as_json, "title" => @front_page.title }] ) end @@ -1543,7 +1543,7 @@ describe "Pages API", type: :request do course_id: @course.id, url: page.url, revision_id: 1) end - let(:calls) { %i(get_show put_update get_revisions get_show_revision post_revert) } + let(:calls) { %i[get_show put_update get_revisions get_show_revision post_revert] } def calls_succeed(page, opts = { except: [] }) get_index diff --git a/spec/apis/v1/peer_reviews_api_spec.rb b/spec/apis/v1/peer_reviews_api_spec.rb index 247e9261124..a9758f0d962 100644 --- a/spec/apis/v1/peer_reviews_api_spec.rb +++ b/spec/apis/v1/peer_reviews_api_spec.rb @@ -261,14 +261,14 @@ describe PeerReviewsApiController, type: :request do end it 'includes user information' do - json = api_call(:get, @resource_path, @resource_params, { :include => %w(user) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[user] }) expect(json.count).to eq(1) expect(json[0]).to eq(@assessment_with_user) end it 'includes submission comments' do @comment = @submission.add_comment(:author => @student2, :comment => "student2 comment") - json = api_call(:get, @resource_path, @resource_params, { :include => %w(submission_comments) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[submission_comments] }) expect(json.count).to eq(1) expect(json[0]).to eq(assessment_with_comments(@comment)) end @@ -298,7 +298,7 @@ describe PeerReviewsApiController, type: :request do it 'includes user information' do @user = @teacher - json = api_call(:get, @resource_path, @resource_params, { :include => %w(user) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[user] }) expect(json.count).to eq(1) expect(json[0]).to eq(@assessment_with_user) end @@ -306,7 +306,7 @@ describe PeerReviewsApiController, type: :request do it 'includes submission comments' do @user = @teacher @comment = @submission.add_comment(:author => @student2, :comment => "student2 comment") - json = api_call(:get, @resource_path, @resource_params, { :include => %w(submission_comments) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[submission_comments] }) expect(json.count).to eq(1) expect(json[0]).to eq(assessment_with_comments(@comment)) end @@ -344,7 +344,7 @@ describe PeerReviewsApiController, type: :request do it 'includes user information' do @assignment1.update_attribute(:anonymous_peer_reviews, false) @user = @student1 - json = api_call(:get, @resource_path, @resource_params, { :include => %w(user) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[user] }) expect(json.count).to eq(1) expect(json[0]).to eq(@assessment_with_user) end @@ -352,7 +352,7 @@ describe PeerReviewsApiController, type: :request do it 'does not include assessor information when peer reviews are enabled' do @assignment1.update_attribute(:anonymous_peer_reviews, true) @user = @student1 - json = api_call(:get, @resource_path, @resource_params, { :include => %w(user) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[user] }) expect(json.count).to eq(1) expect(json[0]).to eq({ "asset_id" => @submission.id, "asset_type" => "Submission", @@ -370,7 +370,7 @@ describe PeerReviewsApiController, type: :request do @assignment1.update_attribute(:anonymous_peer_reviews, false) @comment = @submission.add_comment(:author => @student2, :comment => "student2 comment") @user = @student1 - json = api_call(:get, @resource_path, @resource_params, { :include => %w(submission_comments) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[submission_comments] }) expect(json.count).to eq(1) expect(json[0]).to eq(assessment_with_comments(@comment)) end @@ -380,7 +380,7 @@ describe PeerReviewsApiController, type: :request do @assignment1.update_attribute(:anonymous_peer_reviews, true) @comment = @submission.add_comment(:author => @student2, :comment => "review comment") @user = @student1 - json = api_call(:get, @resource_path, @resource_params, { :include => %w(submission_comments) }) + json = api_call(:get, @resource_path, @resource_params, { :include => %w[submission_comments] }) expect(json.count).to eq(1) expect(json[0]).to eq( { diff --git a/spec/apis/v1/pseudonyms_api_spec.rb b/spec/apis/v1/pseudonyms_api_spec.rb index f0eac47dba2..a370877c71c 100644 --- a/spec/apis/v1/pseudonyms_api_spec.rb +++ b/spec/apis/v1/pseudonyms_api_spec.rb @@ -55,7 +55,7 @@ describe PseudonymsController, type: :request do end it "returns multiple pseudonyms if they exist" do - %w{one@example.com two@example.com}.each { |id| @student.pseudonyms.create!(:unique_id => id) } + %w[one@example.com two@example.com].each { |id| @student.pseudonyms.create!(:unique_id => id) } json = api_call(:get, @account_path, @account_path_options, { :user => { :id => @student.id } }) @@ -63,7 +63,7 @@ describe PseudonymsController, type: :request do end it "paginates results" do - %w{one@example.com two@example.com}.each { |id| @student.pseudonyms.create!(:unique_id => id) } + %w[one@example.com two@example.com].each { |id| @student.pseudonyms.create!(:unique_id => id) } json = api_call(:get, "#{@account_path}?per_page=1", @account_path_options.merge({ :per_page => '1' }), { :user => { :id => @student.id } }) @@ -85,7 +85,7 @@ describe PseudonymsController, type: :request do end it "does not included deleted pseudonyms" do - %w{one@example.com two@example.com}.each { |id| @student.pseudonyms.create!(:unique_id => id) } + %w[one@example.com two@example.com].each { |id| @student.pseudonyms.create!(:unique_id => id) } to_delete = @student.pseudonyms.create!(:unique_id => "to-delete@example.com") to_delete.destroy diff --git a/spec/apis/v1/quizzes/quiz_reports_api_spec.rb b/spec/apis/v1/quizzes/quiz_reports_api_spec.rb index 61aad31c8bc..ddd755f306a 100644 --- a/spec/apis/v1/quizzes/quiz_reports_api_spec.rb +++ b/spec/apis/v1/quizzes/quiz_reports_api_spec.rb @@ -122,7 +122,7 @@ describe Quizzes::QuizReportsController, type: :request do before :once do teacher_in_course(:active_all => true) @me = @user - simple_quiz_with_submissions %w{T T T}, %w{T T T}, %w{T F F}, %w{T F T}, :user => @user, :course => @course + simple_quiz_with_submissions %w[T T T], %w[T T T], %w[T F F], %w[T F T], :user => @user, :course => @course @user = @me end @@ -213,7 +213,7 @@ describe Quizzes::QuizReportsController, type: :request do before :once do teacher_in_course(:active_all => true) - simple_quiz_with_submissions %w{T T T}, %w{T T T}, %w{T F F}, %w{T F T}, { + simple_quiz_with_submissions %w[T T T], %w[T T T], %w[T F F], %w[T F T], { user: @teacher, course: @course } diff --git a/spec/apis/v1/quizzes/quiz_statistics_api_spec.rb b/spec/apis/v1/quizzes/quiz_statistics_api_spec.rb index 4b083d776e3..e2ae3e65d60 100644 --- a/spec/apis/v1/quizzes/quiz_statistics_api_spec.rb +++ b/spec/apis/v1/quizzes/quiz_statistics_api_spec.rb @@ -43,7 +43,7 @@ describe Quizzes::QuizStatisticsController, type: :request do teacher = @user - simple_quiz_with_submissions %w{T T T}, %w{T T T}, %w{T F F}, %w{T F T}, + simple_quiz_with_submissions %w[T T T], %w[T T T], %w[T F F], %w[T F T], :user => @user, :course => @course diff --git a/spec/apis/v1/quizzes/quiz_submission_events_api_spec.rb b/spec/apis/v1/quizzes/quiz_submission_events_api_spec.rb index e70cd967cd5..cf020d76e25 100644 --- a/spec/apis/v1/quizzes/quiz_submission_events_api_spec.rb +++ b/spec/apis/v1/quizzes/quiz_submission_events_api_spec.rb @@ -55,7 +55,7 @@ describe Quizzes::QuizSubmissionEventsApiController, type: :request do before :once do course_with_teacher :active_all => true - simple_quiz_with_submissions %w{T T T}, %w{T T T}, %w{T F F}, %w{T F T}, + simple_quiz_with_submissions %w[T T T], %w[T T T], %w[T F F], %w[T F T], :user => @user, :course => @course diff --git a/spec/apis/v1/roles_api_spec.rb b/spec/apis/v1/roles_api_spec.rb index d72f24b2c53..09ea5191bd6 100644 --- a/spec/apis/v1/roles_api_spec.rb +++ b/spec/apis/v1/roles_api_spec.rb @@ -120,7 +120,7 @@ describe "Roles API", type: :request do it "lists inactive roles" do json = api_call(:get, "/api/v1/accounts/#{@account.id}/roles?state[]=inactive", - { :controller => 'role_overrides', :action => 'api_index', :format => 'json', :account_id => @account.id.to_param, :state => %w(inactive) }) + { :controller => 'role_overrides', :action => 'api_index', :format => 'json', :account_id => @account.id.to_param, :state => %w[inactive] }) expect(json.size).to eq 1 expect(json[0]['role']).to eq 'inactive_role' end @@ -134,7 +134,7 @@ describe "Roles API", type: :request do it "accepts multiple states" do json = api_call(:get, "/api/v1/accounts/#{@account.id}/roles?state[]=inactive&state[]=active", - { :controller => 'role_overrides', :action => 'api_index', :format => 'json', :account_id => @account.id.to_param, :state => %w(inactive active) }) + { :controller => 'role_overrides', :action => 'api_index', :format => 'json', :account_id => @account.id.to_param, :state => %w[inactive active] }) expect(json.size).to eq 7 expect(json.map { |role| role['role'] }).to be_include 'inactive_role' end diff --git a/spec/apis/v1/sections_api_spec.rb b/spec/apis/v1/sections_api_spec.rb index 86e24a7e506..fa007295b80 100644 --- a/spec/apis/v1/sections_api_spec.rb +++ b/spec/apis/v1/sections_api_spec.rb @@ -22,7 +22,7 @@ require_relative '../api_spec_helper' describe SectionsController, type: :request do describe '#index' do - let(:user_api_fields) { %w(id name sortable_name short_name created_at) } + let(:user_api_fields) { %w[id name sortable_name short_name created_at] } before :once do course_with_teacher(:active_all => true, :user => user_with_pseudonym(:name => 'UWP')) diff --git a/spec/apis/v1/services_api_spec.rb b/spec/apis/v1/services_api_spec.rb index 508776efadd..1899be93d18 100644 --- a/spec/apis/v1/services_api_spec.rb +++ b/spec/apis/v1/services_api_spec.rb @@ -67,7 +67,7 @@ describe "Services API", type: :request do allow(CanvasKaltura::ClientV3).to receive(:new).and_return(kal) json = api_call(:post, "/api/v1/services/kaltura_session", :controller => "services_api", :action => "start_kaltura_session", :format => "json") - expect(json.delete_if { |k| %w(serverTime).include?(k) }).to eq({ + expect(json.delete_if { |k| %w[serverTime].include?(k) }).to eq({ 'ks' => "new_session_id_here", 'subp_id' => '10000', 'partner_id' => '100', @@ -82,7 +82,7 @@ describe "Services API", type: :request do json = api_call(:post, "/api/v1/services/kaltura_session", :controller => "services_api", :action => "start_kaltura_session", :format => "json", :include_upload_config => 1) - expect(json.delete_if { |k| %w(serverTime).include?(k) }).to eq({ + expect(json.delete_if { |k| %w[serverTime].include?(k) }).to eq({ 'ks' => "new_session_id_here", 'subp_id' => '10000', 'partner_id' => '100', diff --git a/spec/apis/v1/submissions_api_spec.rb b/spec/apis/v1/submissions_api_spec.rb index f6919957a4c..5a44a21fb26 100644 --- a/spec/apis/v1/submissions_api_spec.rb +++ b/spec/apis/v1/submissions_api_spec.rb @@ -70,7 +70,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :section_id => @default_section.id.to_s, :assignment_id => @a1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) expect(json.size).to eq 0 json = api_call(:get, @@ -78,7 +78,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) expect(json.size).to eq 1 expect(json.first['user_id']).to eq @student1.id @@ -339,7 +339,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :section_id => @section.id.to_s, :assignment_id => @a1.id.to_s }, - { :include => %w(user) }) + { :include => %w[user] }) expect(json.size).to eq 1 expect(json[0]['user']).not_to be_nil expect(json[0]['user']['id']).to eq(@student1.id) @@ -352,7 +352,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :section_id => @section.id.to_s, :assignment_id => @a1.id.to_s }, - { :include => %w(visibility), :student_ids => [@student1.id] }) + { :include => %w[visibility], :student_ids => [@student1.id] }) expect(json[0]["assignment_visible"]).to eq true end @@ -390,7 +390,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'update', :format => 'json', :section_id => @section.id.to_s, :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :submission => { :posted_grade => '75%' }, :include => %w(visibility) }) + { :submission => { :posted_grade => '75%' }, :include => %w[visibility] }) expect(json["assignment_visible"]).to eq true expect(json["all_submissions"][0]["assignment_visible"]).to eq true end @@ -413,7 +413,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) expect(json['user_id']).to eq @student1.id end @@ -430,9 +430,9 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :include => %w(submission_comments rubric_assessment) }) + { :include => %w[submission_comments rubric_assessment] }) - %w(score published_grade published_score grade).each do |a| + %w[score published_grade published_score grade].each do |a| expect(json[a]).to be_nil end @@ -446,7 +446,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :include => %w(submission_comments rubric_assessment) }) + { :include => %w[submission_comments rubric_assessment] }) expect(json["submission_comments"].size).to eq 2 expect(json["grade"]).to eq "5" @@ -458,7 +458,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :include => %w(submission_comments rubric_assessment) }) + { :include => %w[submission_comments rubric_assessment] }) expect(json["submission_comments"].size).to eq 2 expect(json["grade"]).to eq "5" end @@ -477,7 +477,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :include => %w(submission_comments) }) + { :include => %w[submission_comments] }) end it 'returns only published comments' do @@ -523,7 +523,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :section_id => 'sis_section_id:my-section-sis-id', :assignment_id => @a1.id.to_s, :user_id => @student1.id.to_s }, - { :include => %w(submission_comments rubric_assessment) }) + { :include => %w[submission_comments rubric_assessment] }) expect(json['rubric_assessment']).to be_nil end @@ -649,7 +649,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment.id.to_s, :user_id => @student.id.to_s }, - { :exclude_response_fields => %w(discussion_entries) }) + { :exclude_response_fields => %w[discussion_entries] }) expect(json['discussion_entries']).to be_nil end @@ -733,7 +733,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment.id.to_s }, - { :include => %w(submission_comments) }) + { :include => %w[submission_comments] }) expect(json.first["submission_comments"].size).to eq 1 comment = json.first["submission_comments"].first @@ -777,7 +777,7 @@ describe 'Submissions API', type: :request do :assignment_ids => [@assignment.to_param], :student_ids => [reviewed.to_param] }, { - :include => %w(submission_comments) + :include => %w[submission_comments] }) comment_json = json.first['submission_comments'].first @@ -850,7 +850,7 @@ describe 'Submissions API', type: :request do "/api/v1/courses/#{@course.id}/students/submissions.json", { :controller => 'submissions_api', :action => 'for_students', :format => 'json', :course_id => @course.to_param }, - { :student_ids => [@student.to_param], :include => %w(submission_history), :grouped => 1 }) + { :student_ids => [@student.to_param], :include => %w[submission_history], :grouped => 1 }) expect(json.first["submissions"].first["submission_history"]).to be_present # ungrouped @@ -858,7 +858,7 @@ describe 'Submissions API', type: :request do "/api/v1/courses/#{@course.id}/students/submissions.json", { :controller => 'submissions_api', :action => 'for_students', :format => 'json', :course_id => @course.to_param }, - { :student_ids => [@student.to_param], :include => %w(submission_history) }) + { :student_ids => [@student.to_param], :include => %w[submission_history] }) expect(json.first["submission_history"]).to be_present end @@ -887,7 +887,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment.id.to_s }, - { :include => %w(submission_comments) }) + { :include => %w[submission_comments] }) expect(json.first["submission_comments"].size).to eq 1 comment = json.first["submission_comments"].first @@ -908,7 +908,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => a1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) preview_url = json.first['preview_url'] expect(Rack::Utils.parse_query(URI(preview_url).query)['version'].to_i).to eq sub.quiz_submission_version @@ -937,7 +937,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => quiz.assignment.id.to_s }, - { :include => %w(submission_history) }) + { :include => %w[submission_history] }) expect(json.first['submission_history'].count).to eq 2 expect(json.first['submission_history'].first.include? "submission_data").to be_truthy expect(json.first['submission_history'][0]['preview_url']).to include '&version=2' @@ -958,7 +958,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @quiz.assignment.id.to_s }, - { :include => %w(submission_history) }) + { :include => %w[submission_history] }) submission_dates = json.first['submission_history'].map { |hash| hash['submitted_at'] } expect(submission_dates.first).not_to eq(submission_dates.last) end @@ -985,7 +985,7 @@ describe 'Submissions API', type: :request do { :controller => "submissions_api", :action => "show", :format => "json", :course_id => @course.id.to_s, :assignment_id => a1.id.to_s, :user_id => student1.id.to_s }, - { :include => %w(submission_comments) }) + { :include => %w[submission_comments] }) expect(json).to eql({ "id" => sub1.id, @@ -1045,7 +1045,7 @@ describe 'Submissions API', type: :request do { :controller => "submissions_api", :action => "show", :format => "json", :course_id => @course.id.to_s, :assignment_id => a1.id.to_s, :user_id => student1.id.to_s }, - { :include => %w(submission_comments) }) + { :include => %w[submission_comments] }) assert_status(401) end @@ -1093,7 +1093,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => a1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) url = json[0]['attachments'][0]['url'] get(url) follow_redirect! while response.redirect? @@ -1119,7 +1119,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => a1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) url = json[0]['media_comment']['url'] get(url) expect(response).to be_redirect @@ -1166,7 +1166,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s, :assignment_id => a1.id.to_s }, - { :include => %w(submission_history submission_comments rubric_assessment) }) + { :include => %w[submission_history submission_comments rubric_assessment] }) sub1.reload sub2.reload @@ -2263,7 +2263,7 @@ describe 'Submissions API', type: :request do end def call_to_submissions_show(opts = {}) - includes = %w(submission_comments rubric_assessment) + includes = %w[submission_comments rubric_assessment] includes.concat(opts[:includes]) if opts[:includes] helper_method = opts[:as_student] ? [:api_call_as_user, @student] : [:api_call] args = helper_method + [:get, @@ -2296,7 +2296,7 @@ describe 'Submissions API', type: :request do "/api/v1/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}.json", { :controller => 'submissions_api', :action => 'show', :format => 'json', :course_id => @course.to_param, :assignment_id => @assignment.id.to_s, :user_id => @student.id.to_s }, - { :include => %w(submission_comments rubric_assessment) }, {}, expected_status: 401) + { :include => %w[submission_comments rubric_assessment] }, {}, expected_status: 401) end it "returns the submission if it is graded" do @@ -2326,7 +2326,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment1.id.to_s, :user_id => @student.id.to_s }, - { :include => %w(full_rubric_assessment) }) + { :include => %w[full_rubric_assessment] }) expect(json).not_to have_key 'full_rubric_assessment' end @@ -2345,7 +2345,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment2.id.to_s, :user_id => @student.id.to_s }, - { :include => %w(full_rubric_assessment) }) + { :include => %w[full_rubric_assessment] }) expect(json).to have_key 'full_rubric_assessment' expect(json['full_rubric_assessment']).to have_key 'data' expect(json['full_rubric_assessment']).to have_key 'assessor_name' @@ -2358,7 +2358,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment2.id.to_s, :user_id => @student.id.to_s }, - { :include => %w(full_rubric_assessment) }) + { :include => %w[full_rubric_assessment] }) expect(json['full_rubric_assessment']).not_to be_nil end @@ -2370,7 +2370,7 @@ describe 'Submissions API', type: :request do { :controller => 'submissions_api', :action => 'show', :format => 'json', :course_id => @course.id.to_s, :assignment_id => @assignment2.id.to_s, :user_id => @student.id.to_s }, - { :include => %w(full_rubric_assessment) }, {}, expected_status: 401) + { :include => %w[full_rubric_assessment] }, {}, expected_status: 401) end end end @@ -4438,12 +4438,16 @@ describe 'Submissions API', type: :request do it "creates a online text submission" do @assignment.update(:submission_types => 'online_text_entry') - json = do_submit(:submission_type => 'online_text_entry', :body => %{

- This is some text. The sanitization will take effect. -

}) - expect(json['body']).to eq %{

- This is some text. The sanitization will take effect. -

} + json = do_submit(:submission_type => 'online_text_entry', :body => <<~HTML) +

+ This is some text. The sanitization will take effect. +

+ HTML + expect(json['body']).to eq <<~HTML +

+ This is some text. The sanitization will take effect. +

+ HTML expect(json['body']).to eq @submission.body end @@ -5561,7 +5565,7 @@ describe 'Submissions API', type: :request do end it 'includes the group_id and group_name if include[]=group is passed' do - params[:include] = %w/group/ + params[:include] = %w[group] json = api_call_as_user(teacher, :get, path, params) expect(json.first.fetch('group').fetch('id')).to eq group.id expect(json.first.fetch('group').fetch('name')).to eq group.name diff --git a/spec/apis/v1/tabs_api_spec.rb b/spec/apis/v1/tabs_api_spec.rb index 2fd180ac845..81f2966a615 100644 --- a/spec/apis/v1/tabs_api_spec.rb +++ b/spec/apis/v1/tabs_api_spec.rb @@ -716,7 +716,7 @@ describe TabsController, type: :request do end it 'correctly labels navigation items as unused' do - unused_tabs = %w{announcements assignments pages files outcomes quizzes modules} + unused_tabs = %w[announcements assignments pages files outcomes quizzes modules] json = api_call(:get, "/api/v1/courses/#{@course.id}/tabs", { :controller => 'tabs', :action => 'index', :course_id => @course.to_param, :format => 'json' }) json.each do |t| @@ -749,8 +749,8 @@ describe TabsController, type: :request do it 'correctly sets visibility' do hidden_tabs = [3, 8, 5] - public_visibility = %w{home people syllabus} - admins_visibility = %w{announcements assignments pages files outcomes rubrics quizzes modules settings discussions grades} + public_visibility = %w[home people syllabus] + admins_visibility = %w[announcements assignments pages files outcomes rubrics quizzes modules settings discussions grades] @course.tab_configuration = @tab_ids.map do |n| hash = { 'id' => n } hash['hidden'] = true if hidden_tabs.include?(n) diff --git a/spec/apis/v1/todo_items_api_spec.rb b/spec/apis/v1/todo_items_api_spec.rb index d5615491565..8928ac3bc87 100644 --- a/spec/apis/v1/todo_items_api_spec.rb +++ b/spec/apis/v1/todo_items_api_spec.rb @@ -267,7 +267,7 @@ describe UsersController, type: :request do json = api_call :get, "/api/v1/courses/#{@student_course.id}/todo?include[]=ungraded_quizzes", :controller => "courses", :action => "todo_items", - :format => "json", :course_id => @student_course.to_param, :include => %w(ungraded_quizzes) + :format => "json", :course_id => @student_course.to_param, :include => %w[ungraded_quizzes] expect(json.filter_map { |el| el['quiz'] && el['quiz']['id'] }).to eql([survey.id]) # user endpoint @@ -275,7 +275,7 @@ describe UsersController, type: :request do expect(json.filter_map { |el| el['quiz'] && el['quiz']['id'] }).to eql([]) json = api_call :get, "/api/v1/users/self/todo?include[]=ungraded_quizzes", :controller => "users", - :action => "todo_items", :format => "json", :include => %w(ungraded_quizzes) + :action => "todo_items", :format => "json", :include => %w[ungraded_quizzes] expect(json.filter_map { |el| el['quiz'] && el['quiz']['id'] }).to eql([survey.id]) end @@ -290,7 +290,7 @@ describe UsersController, type: :request do survey2.assignment_overrides.create!(:set => section) json = api_call :get, "/api/v1/users/self/todo?include[]=ungraded_quizzes", :controller => "users", - :action => "todo_items", :format => "json", :include => %w(ungraded_quizzes) + :action => "todo_items", :format => "json", :include => %w[ungraded_quizzes] expect(json.filter_map { |el| el['quiz'] && el['quiz']['id'] }).to eql([survey.id]) end @@ -308,12 +308,12 @@ describe UsersController, type: :request do past_survey.publish! json = api_call :get, "/api/v1/users/self/todo?include[]=ungraded_quizzes", :controller => "users", - :action => "todo_items", :format => "json", :include => %w(ungraded_quizzes) + :action => "todo_items", :format => "json", :include => %w[ungraded_quizzes] expect(json.filter_map { |el| el['quiz'] && el['quiz']['id'] }).to eql([]) json = api_call :get, "/api/v1/courses/#{@student_course.id}/todo?include[]=ungraded_quizzes", :controller => "courses", :action => "todo_items", - :format => "json", :course_id => @student_course.to_param, :include => %w(ungraded_quizzes) + :format => "json", :course_id => @student_course.to_param, :include => %w[ungraded_quizzes] expect(json.filter_map { |el| el['quiz'] && el['quiz']['id'] }).to eql([]) end @@ -341,7 +341,7 @@ describe UsersController, type: :request do it "includes assignments/quizzes with no due_at (users controller)" do json = api_call(:get, "/api/v1/users/self/todo?include[]=ungraded_quizzes", :controller => "users", :action => "todo_items", - :format => "json", :include => %w(ungraded_quizzes)) + :format => "json", :include => %w[ungraded_quizzes]) expect(json.count).to be(2) end @@ -349,7 +349,7 @@ describe UsersController, type: :request do json = api_call(:get, "/api/v1/courses/#{@course.id}/todo?include[]=ungraded_quizzes", :controller => "courses", :action => "todo_items", :format => "json", :course_id => @course.to_param, - :include => %w(ungraded_quizzes)) + :include => %w[ungraded_quizzes]) expect(json.count).to be(2) end end diff --git a/spec/apis/v1/user_profiles_api_spec.rb b/spec/apis/v1/user_profiles_api_spec.rb index 8cbd063fce7..4f08281d17e 100644 --- a/spec/apis/v1/user_profiles_api_spec.rb +++ b/spec/apis/v1/user_profiles_api_spec.rb @@ -216,7 +216,7 @@ describe "User Profile API", type: :request do json = api_call(:get, "/api/v1/users/#{@student.id}/profile?include[]=user_services", :controller => "profile", :action => "settings", :user_id => @student.to_param, :format => "json", - :include => %w(user_services)) + :include => %w[user_services]) expect(json["user_services"]).to eq [ { "service" => "twitter", "visible" => true, "service_user_link" => "http://www.twitter.com/user" }, ] @@ -230,7 +230,7 @@ describe "User Profile API", type: :request do json = api_call(:get, "/api/v1/users/#{@student.id}/profile?include[]=links", :controller => "profile", :action => "settings", :user_id => @student.to_param, :format => "json", - :include => %w(links)) + :include => %w[links]) expect(json["links"]).to eq [ { "url" => "http://instructure.com", "title" => "Instructure" } ] diff --git a/spec/apis/v1/users_api_spec.rb b/spec/apis/v1/users_api_spec.rb index e8bdd2b3db7..2b74c89bd32 100644 --- a/spec/apis/v1/users_api_spec.rb +++ b/spec/apis/v1/users_api_spec.rb @@ -994,7 +994,7 @@ describe "Users API", type: :request do it "returns a list of users filtered by search_term" do @account = Account.default - expected_keys = %w{id name sortable_name short_name} + expected_keys = %w[id name sortable_name short_name] users = [] [['Test User1', 'test@example.com'], ['Test User2', 'test2@example.com'], ['Test User3', 'test3@example.com']].each_with_index do |u, i| diff --git a/spec/controllers/developer_keys_controller_spec.rb b/spec/controllers/developer_keys_controller_spec.rb index 340160762e0..00b5187d888 100644 --- a/spec/controllers/developer_keys_controller_spec.rb +++ b/spec/controllers/developer_keys_controller_spec.rb @@ -199,8 +199,8 @@ describe DeveloperKeysController do describe 'scopes' do let(:valid_scopes) do - %w(url:POST|/api/v1/courses/:course_id/quizzes/:id/validate_access_code - url:GET|/api/v1/audit/grade_change/courses/:course_id/assignments/:assignment_id/graders/:grader_id) + %w[url:POST|/api/v1/courses/:course_id/quizzes/:id/validate_access_code + url:GET|/api/v1/audit/grade_change/courses/:course_id/assignments/:assignment_id/graders/:grader_id] end let(:invalid_scopes) { ['url:POST/banana', 'url:POST/invalid/scope'] } let(:root_account) { account_model } @@ -254,8 +254,8 @@ describe DeveloperKeysController do describe 'scopes' do let(:valid_scopes) do - %w(url:POST|/api/v1/courses/:course_id/quizzes/:id/validate_access_code - url:GET|/api/v1/audit/grade_change/courses/:course_id/assignments/:assignment_id/graders/:grader_id) + %w[url:POST|/api/v1/courses/:course_id/quizzes/:id/validate_access_code + url:GET|/api/v1/audit/grade_change/courses/:course_id/assignments/:assignment_id/graders/:grader_id] end let(:invalid_scopes) { ['url:POST|/api/v1/banana', 'not_a_scope'] } let(:root_account) { account_model } diff --git a/spec/controllers/files_controller_spec.rb b/spec/controllers/files_controller_spec.rb index 0ac208c72b4..942b658ec5f 100644 --- a/spec/controllers/files_controller_spec.rb +++ b/spec/controllers/files_controller_spec.rb @@ -1509,7 +1509,7 @@ describe FilesController do describe "public_url" do before :once do - assignment_model :course => @course, :submission_types => %w(online_upload) + assignment_model :course => @course, :submission_types => %w[online_upload] attachment_model :context => @student @submission = @assignment.submit_homework @student, :attachments => [@attachment] end diff --git a/spec/controllers/info_controller_spec.rb b/spec/controllers/info_controller_spec.rb index 56d46cbce26..3060fbc3bfb 100644 --- a/spec/controllers/info_controller_spec.rb +++ b/spec/controllers/info_controller_spec.rb @@ -70,7 +70,7 @@ describe InfoController do get "health_prognosis" expect(response).to be_server_error body = response.body - %w{messages_partition quizzes_submission_events_partition versions_partition}.each do |type| + %w[messages_partition quizzes_submission_events_partition versions_partition].each do |type| expect(body).to include(type) end end diff --git a/spec/controllers/lti/ims/concerns/advantage_services_shared_context.rb b/spec/controllers/lti/ims/concerns/advantage_services_shared_context.rb index 2fc4f6e1056..badb2963e48 100644 --- a/spec/controllers/lti/ims/concerns/advantage_services_shared_context.rb +++ b/spec/controllers/lti/ims/concerns/advantage_services_shared_context.rb @@ -32,7 +32,7 @@ shared_context 'advantage services context' do dk end let(:access_token_scopes) do - %w( + %w[ https://purl.imsglobal.org/spec/lti-ags/scope/lineitem https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly @@ -50,7 +50,7 @@ shared_context 'advantage services context' do https://canvas.instructure.com/lti/account_external_tools/scope/list https://canvas.instructure.com/lti/account_external_tools/scope/show https://canvas.instructure.com/lti/account_external_tools/scope/destroy - ).join(' ') + ].join(' ') end let(:access_token_signing_key) { Canvas::Security.encryption_key } let(:test_request_host) { 'test.host' } 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 1afbdcb1d3d..5ffa4e30d83 100644 --- a/spec/controllers/lti/ims/concerns/lti_services_shared_examples.rb +++ b/spec/controllers/lti/ims/concerns/lti_services_shared_examples.rb @@ -174,7 +174,7 @@ shared_examples_for "lti services" do end context 'with missing access token claims' do - let(:access_token_jwt_hash) { super().delete_if { |k| %i(sub aud exp iat jti iss).include?(k) } } + let(:access_token_jwt_hash) { super().delete_if { |k| %i[sub aud exp iat jti iss].include?(k) } } it_behaves_like 'mime_type check' diff --git a/spec/controllers/lti/message_controller_spec.rb b/spec/controllers/lti/message_controller_spec.rb index 48ddf3b75b7..8b0ff82ee1d 100644 --- a/spec/controllers/lti/message_controller_spec.rb +++ b/spec/controllers/lti/message_controller_spec.rb @@ -25,11 +25,11 @@ module Lti describe MessageController do include_context 'lti2_spec_helper' let(:enabled_capability) { - %w(ToolConsumerInstance.guid + %w[ToolConsumerInstance.guid Message.documentTarget Message.locale Membership.role - Context.id) + Context.id] } let(:default_resource_handler) do @@ -497,7 +497,7 @@ module Lti end it 'does custom variable expansion for tool settings' do - parameters = %w(LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url).map do |key| + parameters = %w[LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url].map do |key| ::IMS::LTI::Models::Parameter.new(name: key.underscore, variable: key) end message_handler.parameters = parameters.as_json @@ -531,7 +531,7 @@ module Lti end it 'adds module item substitutions' do - parameters = %w(Canvas.module.id Canvas.moduleItem.id).map do |key| + parameters = %w[Canvas.module.id Canvas.moduleItem.id].map do |key| ::IMS::LTI::Models::Parameter.new(name: key.underscore, variable: key) end message_handler.parameters = parameters.as_json diff --git a/spec/controllers/lti_api_controllers_spec.rb b/spec/controllers/lti_api_controllers_spec.rb index d8d668d65f3..859852a43d7 100644 --- a/spec/controllers/lti_api_controllers_spec.rb +++ b/spec/controllers/lti_api_controllers_spec.rb @@ -96,13 +96,13 @@ describe LtiApiController, type: :request do end it "responds 'unsupported' for any unknown xml body" do - body = %{} + body = %() make_call('body' => body) check_failure end it "adds xml to an error report if the xml is invalid according to spec" do - body = %{} + body = %() expect(Canvas::Errors).to receive(:capture) { |_, opts| expect(opts[:extra][:xml]).to be_present {} @@ -116,7 +116,7 @@ describe LtiApiController, type: :request do end it "fail when the XML encoding is invalid" do - body = %{} + body = %() make_call('body' => body) check_failure('unsupported', 'Invalid XML: unknown encoding name - utf8') end diff --git a/spec/controllers/oauth2_provider_controller_spec.rb b/spec/controllers/oauth2_provider_controller_spec.rb index ffbb7a8fbe1..8d6b6525bd7 100644 --- a/spec/controllers/oauth2_provider_controller_spec.rb +++ b/spec/controllers/oauth2_provider_controller_spec.rb @@ -474,8 +474,8 @@ describe OAuth2ProviderController do let(:redis) do redis = double('Redis') allow(redis).to receive(:get) - allow(redis).to receive(:get).with(valid_code_redis_key).and_return(%Q{{"client_id": #{key.id}, "user": #{user.id}}}) - allow(redis).to receive(:del).with(valid_code_redis_key).and_return(%Q{{"client_id": #{key.id}, "user": #{user.id}}}) + allow(redis).to receive(:get).with(valid_code_redis_key).and_return(%Q({"client_id": #{key.id}, "user": #{user.id}})) + allow(redis).to receive(:del).with(valid_code_redis_key).and_return(%Q({"client_id": #{key.id}, "user": #{user.id}})) redis end @@ -486,7 +486,7 @@ describe OAuth2ProviderController do let(:success_setup) do expect(redis).to receive(:del).with(valid_code_redis_key).at_least(:once) end - let(:success_token_keys) { %w(access_token refresh_token user expires_in token_type) } + let(:success_token_keys) { %w[access_token refresh_token user expires_in token_type] } end it 'renders a 302 if a code is not provided for an authorization_code grant' do @@ -535,7 +535,7 @@ describe OAuth2ProviderController do it_behaves_like 'common oauth2 token checks' do let(:success_params) { { refresh_token: refresh_token } } - let(:success_token_keys) { %w(access_token user expires_in token_type) } + let(:success_token_keys) { %w[access_token user expires_in token_type] } end it 'does not generate a new access_token with an invalid refresh_token' do @@ -603,7 +603,7 @@ describe OAuth2ProviderController do it_behaves_like 'common oauth2 token checks' do let(:success_params) { client_credentials_params } let(:overrides) { client_credentials_params } - let(:success_token_keys) { %w(access_token token_type expires_in scope) } + let(:success_token_keys) { %w[access_token token_type expires_in scope] } end describe 'additional client_credentials checks' do diff --git a/spec/controllers/oauth_proxy_controller_spec.rb b/spec/controllers/oauth_proxy_controller_spec.rb index 71229995f68..d99ec6930ee 100644 --- a/spec/controllers/oauth_proxy_controller_spec.rb +++ b/spec/controllers/oauth_proxy_controller_spec.rb @@ -38,12 +38,12 @@ describe OAuthProxyController do get :redirect_proxy, params: { state: Canvas::Security.create_jwt({ redirect_uri: 'http://example.com' }) } jwt = URI.decode_www_form(URI.parse(response.location).query).first.last params = Canvas::Security.decode_jwt(jwt) - expect(params.keys & %w(controller action)).to be_empty + expect(params.keys & %w[controller action]).to be_empty end it 'handles redirect urls with an existing query' do get :redirect_proxy, params: { state: Canvas::Security.create_jwt({ redirect_uri: 'http://example.com/test?foo=bar' }) } keys = URI.decode_www_form(URI.parse(response.location).query).map { |a| a[0] } - expect(keys).to eq %w(foo state) + expect(keys).to eq %w[foo state] end end diff --git a/spec/controllers/planner_controller_spec.rb b/spec/controllers/planner_controller_spec.rb index 37e04bc9d90..8b5d5c17bf5 100644 --- a/spec/controllers/planner_controller_spec.rb +++ b/spec/controllers/planner_controller_spec.rb @@ -291,7 +291,7 @@ describe PlannerController do end it "includes objects from concluded courses if specified" do - get :index, params: { include: %w{concluded} } + get :index, params: { include: %w[concluded] } response_json = json_parse(response.body) items = response_json.map { |i| [i["plannable_type"], i["plannable"]["id"]] } expect(items).to include ['assignment', @a1.id] diff --git a/spec/controllers/profile_controller_spec.rb b/spec/controllers/profile_controller_spec.rb index 7daa128fc6c..323cde4f074 100644 --- a/spec/controllers/profile_controller_spec.rb +++ b/spec/controllers/profile_controller_spec.rb @@ -246,8 +246,8 @@ describe ProfileController do @user.reload expect(@user.profile.links.map { |l| [l.url, l.title] }).to eq [ - %w(http://example.com Example.com), - %w(http://foo.com Foo) + %w[http://example.com Example.com], + %w[http://foo.com Foo] ] end diff --git a/spec/controllers/security_controller_spec.rb b/spec/controllers/security_controller_spec.rb index 3f239d034d2..2ebf50ed4a5 100644 --- a/spec/controllers/security_controller_spec.rb +++ b/spec/controllers/security_controller_spec.rb @@ -51,7 +51,7 @@ RSpec.describe SecurityController, type: :request do it 'returns well-formed public key jwks' do get url - expected_keys = %w(kid kty alg e n use) + expected_keys = %w[kid kty alg e n use] json['keys'].each do |key| expect(key.keys - expected_keys).to be_empty end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 788d274bd2b..a6d3e46430c 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -285,7 +285,7 @@ describe UsersController do it "sorts the results of manageable_courses by name" do course_with_teacher_logged_in(:course_name => "B", :active_all => 1) - %w(c d a).each do |name| + %w[c d a].each do |name| course_with_teacher(:course_name => name, :user => @teacher, :active_all => 1) end @@ -293,7 +293,7 @@ describe UsersController do expect(response).to be_successful courses = json_parse - expect(courses.map { |c| c['label'] }).to eq %w(a B c d) + expect(courses.map { |c| c['label'] }).to eq %w[a B c d] end it "sorts the results of manageable_courses by term with default term first then alphabetically" do @@ -302,11 +302,11 @@ describe UsersController do future_term = EnrollmentTerm.create(start_at: 1.day.from_now, root_account: @teacher.account) past_term = EnrollmentTerm.create(start_at: 1.day.ago, root_account: @teacher.account) # Future terms - %w(b a).each do |name| + %w[b a].each do |name| course_with_teacher(:course_name => name, :user => @teacher, :active_all => 1, :enrollment_term_id => future_term.id) end # Past terms - %w(d c).each do |name| + %w[d c].each do |name| course_with_teacher(:course_name => name, :user => @teacher, :active_all => 1, :enrollment_term_id => past_term.id) end @@ -314,7 +314,7 @@ describe UsersController do expect(response).to be_successful courses = json_parse - expect(courses.map { |c| c['label'] }).to eq %w(E c d a b) + expect(courses.map { |c| c['label'] }).to eq %w[E c d a b] end it "does not include courses that an admin can't content-manage" do @@ -335,7 +335,7 @@ describe UsersController do expect(response).to be_successful courses = json_parse - expect(courses.map { |c| c['label'] }).to eq %w(A C) + expect(courses.map { |c| c['label'] }).to eq %w[A C] end it "does not include courses that an admin doesn't have rights to see" do @@ -352,7 +352,7 @@ describe UsersController do expect(response).to be_successful courses = json_parse - expect(courses.map { |c| c['label'] }).to eq %w(A C) + expect(courses.map { |c| c['label'] }).to eq %w[A C] end context "query matching" do diff --git a/spec/factory_bot_spec_helper.rb b/spec/factory_bot_spec_helper.rb index 876891e0c57..f27cefbf4d9 100644 --- a/spec/factory_bot_spec_helper.rb +++ b/spec/factory_bot_spec_helper.rb @@ -29,8 +29,8 @@ RSpec.configure do |config| config.include FactoryBot::Syntax::Methods config.before(:suite) do - unless FactoryBot.definition_file_paths == %w{spec/factory_bot} # already loaded - FactoryBot.definition_file_paths = %w{spec/factory_bot} + unless FactoryBot.definition_file_paths == %w[spec/factory_bot] # already loaded + FactoryBot.definition_file_paths = %w[spec/factory_bot] FactoryBot.find_definitions end end diff --git a/spec/graphql/loaders/discussion_entry_loader_spec.rb b/spec/graphql/loaders/discussion_entry_loader_spec.rb index 810c4a2a53a..4aa2e1310cc 100644 --- a/spec/graphql/loaders/discussion_entry_loader_spec.rb +++ b/spec/graphql/loaders/discussion_entry_loader_spec.rb @@ -194,7 +194,7 @@ describe Loaders::DiscussionEntryLoader do current_user: @teacher, filter: 'drafts' ).load(@discussion).then do |discussion_entries| - expect(discussion_entries.map(&:message)).to match_array(%w(hey howdy)) + expect(discussion_entries.map(&:message)).to match_array(%w[hey howdy]) end end end @@ -207,7 +207,7 @@ describe Loaders::DiscussionEntryLoader do current_user: @teacher, filter: 'drafts' ).load(@discussion).then do |discussion_entries| - expect(discussion_entries.map(&:message)).to match_array(%w(howdy)) + expect(discussion_entries.map(&:message)).to match_array(%w[howdy]) end end end diff --git a/spec/graphql/mutations/delete_conversation_messages_spec.rb b/spec/graphql/mutations/delete_conversation_messages_spec.rb index 7a6be1d328e..2c0c82fc192 100644 --- a/spec/graphql/mutations/delete_conversation_messages_spec.rb +++ b/spec/graphql/mutations/delete_conversation_messages_spec.rb @@ -59,7 +59,7 @@ describe Mutations::DeleteConversationMessages do result = execute_with_input(query) expect(result['errors']).to be_nil expect(result.dig('data', 'deleteConversationMessages', 'errors')).to be_nil - expect(result.dig('data', 'deleteConversationMessages', 'conversationMessageIds')).to match_array %W(#{message.id}) + expect(result.dig('data', 'deleteConversationMessages', 'conversationMessageIds')).to match_array %W[#{message.id}] expect(sender.all_conversations.find_by(conversation: message.conversation).messages.length).to eq 0 end @@ -95,7 +95,7 @@ describe Mutations::DeleteConversationMessages do result = execute_with_input(query) expect(result['errors']).to be_nil expect(result.dig('data', 'deleteConversationMessages', 'errors')).to be_nil - expect(result.dig('data', 'deleteConversationMessages', 'conversationMessageIds')).to match_array %W(#{message.id} #{message2.id}) + expect(result.dig('data', 'deleteConversationMessages', 'conversationMessageIds')).to match_array %W[#{message.id} #{message2.id}] expect(sender.all_conversations.find_by(conversation: message.conversation).messages.length).to eq 0 end end diff --git a/spec/graphql/mutations/delete_conversations_spec.rb b/spec/graphql/mutations/delete_conversations_spec.rb index 87c4c3478c6..bce53d38671 100644 --- a/spec/graphql/mutations/delete_conversations_spec.rb +++ b/spec/graphql/mutations/delete_conversations_spec.rb @@ -51,7 +51,7 @@ describe Mutations::DeleteConversations do result = execute_with_input(query) expect(result['errors']).to be_nil expect(result.dig('data', 'deleteConversations', 'errors')).to be_nil - expect(result.dig('data', 'deleteConversations', 'conversationIds')).to match_array %W(#{conv.id}) + expect(result.dig('data', 'deleteConversations', 'conversationIds')).to match_array %W[#{conv.id}] expect(sender.all_conversations.find_by(conversation: conv).messages.length).to eq 0 end @@ -92,7 +92,7 @@ describe Mutations::DeleteConversations do result = execute_with_input(query) expect(result['errors']).to be_nil expect(result.dig('data', 'deleteConversations', 'errors')).to be_nil - expect(result.dig('data', 'deleteConversations', 'conversationIds')).to match_array %W(#{conv.id} #{conv2.id}) + expect(result.dig('data', 'deleteConversations', 'conversationIds')).to match_array %W[#{conv.id} #{conv2.id}] expect(sender.all_conversations.find_by(conversation: conv).messages.length).to eq 0 expect(sender.all_conversations.find_by(conversation: conv2).messages.length).to eq 0 end @@ -117,7 +117,7 @@ describe Mutations::DeleteConversations do result = execute_with_input(query) expect_error(result, another_conv.id, 'Insufficient permissions') expect_error(result, invalid_id, 'Unable to find Conversation') - expect(result.dig('data', 'deleteConversations', 'conversationIds')).to match_array %W(#{conv.id}) + expect(result.dig('data', 'deleteConversations', 'conversationIds')).to match_array %W[#{conv.id}] expect(sender.all_conversations.find_by(conversation: conv).messages.length).to eq 0 end end diff --git a/spec/graphql/mutations/update_conversation_participants_spec.rb b/spec/graphql/mutations/update_conversation_participants_spec.rb index dfe4dd1d4ed..0701f627d0b 100644 --- a/spec/graphql/mutations/update_conversation_participants_spec.rb +++ b/spec/graphql/mutations/update_conversation_participants_spec.rb @@ -116,7 +116,7 @@ describe Mutations::UpdateConversationParticipants do expect(result['errors']).to be_nil expect(result.dig('data', 'updateConversationParticipants', 'errors')).to be_nil updated_attrs = result.dig('data', 'updateConversationParticipants', 'conversationParticipants') - expect(updated_attrs.map { |i| i["label"] }).to match_array %w(starred starred) + expect(updated_attrs.map { |i| i["label"] }).to match_array %w[starred starred] participant1 = participant1.reload expect(participant1.starred).to be_truthy diff --git a/spec/graphql/types/assignment_type_spec.rb b/spec/graphql/types/assignment_type_spec.rb index f8a8ba6c46f..5d25f63293c 100644 --- a/spec/graphql/types/assignment_type_spec.rb +++ b/spec/graphql/types/assignment_type_spec.rb @@ -188,7 +188,7 @@ describe Types::AssignmentType do context "description" do before do - assignment.update description: %|Hi Content| + assignment.update description: %(Hi Content) end it "includes description when lock settings allow" do diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 5b2ab13983f..635f90a8bd1 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -91,7 +91,7 @@ describe Types::QueryType do } let_once(:admin) { account_admin_user(account: Account.default) } - %w/account course assignment assignmentGroup term/.each do |type| + %w[account course assignment assignmentGroup term].each do |type| it "doesn't allow searching #{type} when given both types of ids" do expect( CanvasSchema.execute("{#{type}(id: \"123\", sisId: \"123\") { id }}").dig("errors", 0, "message") diff --git a/spec/helpers/quizzes_helper_spec.rb b/spec/helpers/quizzes_helper_spec.rb index 47f7e98a6a1..f5a3528c6b0 100644 --- a/spec/helpers/quizzes_helper_spec.rb +++ b/spec/helpers/quizzes_helper_spec.rb @@ -186,7 +186,7 @@ describe QuizzesHelper do context 'fill_in_multiple_blanks_question' do before do - @question_text = %q|| + @question_text = %q() @answer_list = [] @answers = [] @@ -205,7 +205,7 @@ describe QuizzesHelper do :answers => @answers ) - expect(html).to eq %q|| + expect(html).to eq %q() end it 'sanitizes user input' do diff --git a/spec/initializers/active_record_spec.rb b/spec/initializers/active_record_spec.rb index 090b4b8b1f7..6508edf0cb7 100644 --- a/spec/initializers/active_record_spec.rb +++ b/spec/initializers/active_record_spec.rb @@ -32,7 +32,7 @@ module ActiveRecord end it 'escapes special characters in the query' do - %w(% _).each do |char| + %w[% _].each do |char| expect(Base.wildcard_pattern('some' + char + 'string')).to include('some\\' + char + 'string') end end @@ -314,7 +314,7 @@ module ActiveRecord end it "accepts an array" do - expect(ActiveRecord::Base.parse_asset_string_list(%w{course_1 course_2 user_3})) + expect(ActiveRecord::Base.parse_asset_string_list(%w[course_1 course_2 user_3])) .to eq({ 'Course' => [1, 2], 'User' => [3] }) end end diff --git a/spec/integration/oauth_token_spec.rb b/spec/integration/oauth_token_spec.rb index 4cafa66c057..0f16525e859 100644 --- a/spec/integration/oauth_token_spec.rb +++ b/spec/integration/oauth_token_spec.rb @@ -18,7 +18,7 @@ # with this program. If not, see . # -%w{Twitter}.each do |integration| +%w[Twitter].each do |integration| describe integration do before do course_with_student_logged_in(:active_all => true) diff --git a/spec/lib/api/v1/custom_gradebook_column_spec.rb b/spec/lib/api/v1/custom_gradebook_column_spec.rb index 501df487a63..3254edb676a 100644 --- a/spec/lib/api/v1/custom_gradebook_column_spec.rb +++ b/spec/lib/api/v1/custom_gradebook_column_spec.rb @@ -31,7 +31,7 @@ describe "Api::V1::CustomGradebookColumn" do describe "custom_gradebook_column_json" do it "works" do - json = @col.attributes.slice(*%w(id title position teacher_notes read_only)) + json = @col.attributes.slice(*%w[id title position teacher_notes read_only]) json["hidden"] = false expect(controller.custom_gradebook_column_json(@col, @teacher, nil)).to eq json end @@ -40,7 +40,7 @@ describe "Api::V1::CustomGradebookColumn" do describe "custom_gradebook_column_json" do it "works" do expect(controller.custom_gradebook_column_datum_json(@datum, @teacher, nil)) - .to eq @datum.attributes.slice(*%w(user_id content)) + .to eq @datum.attributes.slice(*%w[user_id content]) end end diff --git a/spec/lib/api/v1/planner_item_spec.rb b/spec/lib/api/v1/planner_item_spec.rb index fe7b8f656a5..e9bb125c61d 100644 --- a/spec/lib/api/v1/planner_item_spec.rb +++ b/spec/lib/api/v1/planner_item_spec.rb @@ -130,7 +130,7 @@ describe Api::V1::PlannerItem do context "default meeting url regex" do let(:valid_links) do - %w( + %w[ https://instructure.zoom.us/my/abcd.12345 https://instructure.zoom.us/j/9585021282 https://us01.zoom.us/j/9585001282? @@ -143,11 +143,11 @@ describe Api::V1::PlannerItem do https://meet146.webex.com/meet146/j.php?MTID=mb0f63c6586178c903f161b109886066b https://meet-146.webex.com/meet/pr-._25535050184 https://meet.google.com/sbs-ycbe-yhu - ) + ] end let(:invalid_links) do - %w( + %w[ http://instructure.zoom.us/my/abcd.12345 https://us01.zoom.us/j/abc123 https://zoom.us/j/9585021282?pwd=NlRIRURaRlRmTC9kVUU2QnIwQkJZZz09 @@ -164,7 +164,7 @@ describe Api::V1::PlannerItem do https://tea-ms.microsoft.com/l/meetup-join/19%3ameeting_MjAyMjU4Y2QtZTc0Mi00OTI1LTllYTUtNjEzNTBhMjY3OTZi%40thread.v2/0?context=%7B%22Tid%22%3A%22b8e866dc-ae4d-482d-8ebb-6ef626b97a42%22%2C%22Oid%22%3A%22ac200842-2ec5-494e-83db-dfddc8939907%22%7D https://teams.micro-soft.com/l/meetup-join/19%3ameeting_MjAyMjU4Y2QtZTc0Mi00OTI1LTllYTUtNjEzNTBhMjY3OTZi%40thread.v2/0?context=%7B%22Tid%22%3A%22b8e866dc-ae4d-482d-8ebb-6ef626b97a42%22%2C%22Oid%22%3A%22ac200842-2ec5-494e-83db-dfddc8939907%22%7D https://tea-ms.live.com/meet/93298311589140 - ) + ] end it "matches valid video conferencing links" do diff --git a/spec/lib/api/v1/submission_spec.rb b/spec/lib/api/v1/submission_spec.rb index 683fdebe707..aa24a46c0ca 100644 --- a/spec/lib/api/v1/submission_spec.rb +++ b/spec/lib/api/v1/submission_spec.rb @@ -476,12 +476,12 @@ describe Api::V1::Submission do end let(:urls) do - %w( + %w[ https://abcdef.com/uuurrrlll00 https://abcdef.com/uuurrrlll01 https://abcdef.com/uuurrrlll02 https://abcdef.com/uuurrrlll03 - ) + ] end let(:url_grades) do diff --git a/spec/lib/api_spec.rb b/spec/lib/api_spec.rb index 81be5982039..5726067e65d 100644 --- a/spec/lib/api_spec.rb +++ b/spec/lib/api_spec.rb @@ -700,11 +700,11 @@ describe Api do end it 'converts string ids to numeric' do - expect(Api.map_non_sis_ids(%w{5 4 3 2})).to eq [5, 4, 3, 2] + expect(Api.map_non_sis_ids(%w[5 4 3 2])).to eq [5, 4, 3, 2] end it "excludes things that don't look like ids" do - expect(Api.map_non_sis_ids(%w{1 2 lolrus 4chan 5 6!})).to eq [1, 2, 5] + expect(Api.map_non_sis_ids(%w[1 2 lolrus 4chan 5 6!])).to eq [1, 2, 5] end it "strips whitespace" do @@ -743,9 +743,11 @@ describe Api do it "ignores non-kaltura instructure_inline_media_comment links" do student_in_course - html = %{
This is an awesome youtube: -here -
} + html = <<~HTML +
This is an awesome youtube: + here +
+ HTML res = klass.new.api_user_content(html, @course, @student) expect(res).to eq html end @@ -830,29 +832,33 @@ describe Api do course_factory attachment_model(:context => @course) - html = %{
- Here are some bad links - here - here - here - here - here - here - but not here - absolute! -
} + html = <<~HTML +
+ Here are some bad links + here + here + here + here + here + here + but not here + absolute! +
+ HTML fixed_html = klass.process_incoming_html_content(html) - expect(fixed_html).to eq %{
- Here are some bad links - here - here - here - here - here - here - but not here - absolute! -
} + expect(fixed_html).to eq <<~HTML +
+ Here are some bad links + here + here + here + here + here + here + but not here + absolute! +
+ HTML end it 'passes host and port to Content.process_incoming' do @@ -861,7 +867,7 @@ describe Api do end it "doesn't explode with invalid mailtos" do - html = %{beephttp://some-host.com/linktotricktheparserintoparsinglinks} + html = %(beephttp://some-host.com/linktotricktheparserintoparsinglinks) expect(klass.process_incoming_html_content(html)).to eq html end end diff --git a/spec/lib/app_center/app_api_spec.rb b/spec/lib/app_center/app_api_spec.rb index 15baf7ac781..4ca048dc8c8 100644 --- a/spec/lib/app_center/app_api_spec.rb +++ b/spec/lib/app_center/app_api_spec.rb @@ -46,7 +46,7 @@ describe AppCenter::AppApi do 'meta' => { "next" => "https://www.example.com/api/v1/apps?offset=60" }, 'current_offset' => 0, 'limit' => 50, - 'objects' => %w(object1 object2 object3 object4) + 'objects' => %w[object1 object2 object3 object4] }.to_json ) response @@ -87,7 +87,7 @@ describe AppCenter::AppApi do end it "can omit next page" do - message = { "objects" => %w(object1 object2 object3 object4), "meta" => {} } + message = { "objects" => %w[object1 object2 object3 object4], "meta" => {} } allow(response).to receive(:body).and_return(message.to_json) endpoint = '/?myparam=value' per_page = 5 diff --git a/spec/lib/basic_lti/quizzes_next_lti_response_spec.rb b/spec/lib/basic_lti/quizzes_next_lti_response_spec.rb index 17916de010a..560def4ff94 100644 --- a/spec/lib/basic_lti/quizzes_next_lti_response_spec.rb +++ b/spec/lib/basic_lti/quizzes_next_lti_response_spec.rb @@ -65,7 +65,7 @@ describe BasicLTI::QuizzesNextLtiResponse do end def request_xml(source_id, launch_url, grade) - Nokogiri::XML.parse %{ + Nokogiri::XML.parse <<~XML @@ -97,7 +97,7 @@ describe BasicLTI::QuizzesNextLtiResponse do - } + XML end describe "#handle_replace_result" do diff --git a/spec/lib/basic_lti/quizzes_next_versioned_submission_spec.rb b/spec/lib/basic_lti/quizzes_next_versioned_submission_spec.rb index e0e5b4417c8..17f692c9c05 100644 --- a/spec/lib/basic_lti/quizzes_next_versioned_submission_spec.rb +++ b/spec/lib/basic_lti/quizzes_next_versioned_submission_spec.rb @@ -57,7 +57,7 @@ describe BasicLTI::QuizzesNextVersionedSubmission do end def request_xml(source_id, launch_url, grade) - Nokogiri::XML.parse %{ + Nokogiri::XML.parse <<~XML @@ -85,7 +85,7 @@ describe BasicLTI::QuizzesNextVersionedSubmission do - } + XML end describe "#grade_history" do @@ -138,12 +138,12 @@ describe BasicLTI::QuizzesNextVersionedSubmission do context "with multiple versions for each url" do let(:urls) do - %w( + %w[ https://abcdef.com/uuurrrlll00?p1=9&p2=1 https://abcdef.com/uuurrrlll01?p1=10&p2=2 https://abcdef.com/uuurrrlll02?p1=11&p2=3 https://abcdef.com/uuurrrlll03?p1=12&p2=4 - ) + ] end let(:url_grades) do diff --git a/spec/lib/canvas/oauth/client_credentials_provider_spec.rb b/spec/lib/canvas/oauth/client_credentials_provider_spec.rb index b321a1b5e09..a80a7af787d 100644 --- a/spec/lib/canvas/oauth/client_credentials_provider_spec.rb +++ b/spec/lib/canvas/oauth/client_credentials_provider_spec.rb @@ -34,7 +34,7 @@ module Canvas::OAuth it { is_expected.to be_a Hash } it 'has the correct expected keys' do - %i(access_token token_type expires_in scope).each do |key| + %i[access_token token_type expires_in scope].each do |key| expect(subject).to have_key key end end @@ -169,7 +169,7 @@ module Canvas::OAuth it { is_expected.to be_a Hash } it 'has the correct expected keys' do - %i(access_token token_type expires_in scope).each do |key| + %i[access_token token_type expires_in scope].each do |key| expect(subject).to have_key key end end @@ -320,7 +320,7 @@ module Canvas::OAuth it { is_expected.to be_a Hash } it 'has the correct expected keys' do - %i(access_token token_type expires_in scope).each do |key| + %i[access_token token_type expires_in scope].each do |key| expect(subject).to have_key key end end diff --git a/spec/lib/canvas/plugins/ticketing_system/custom_error_spec.rb b/spec/lib/canvas/plugins/ticketing_system/custom_error_spec.rb index 62f62ee19b1..a3241b946b0 100644 --- a/spec/lib/canvas/plugins/ticketing_system/custom_error_spec.rb +++ b/spec/lib/canvas/plugins/ticketing_system/custom_error_spec.rb @@ -154,7 +154,7 @@ module Canvas::Plugins::TicketingSystem it "maps an env hash to a json string" do report.http_env = { one: "two", three: "four" } - expect(delegate.pretty_http_env).to eq(%Q{one: "two"\nthree: "four"}) + expect(delegate.pretty_http_env).to eq(%Q(one: "two"\nthree: "four")) end end end diff --git a/spec/lib/cc/cc_exporter_spec.rb b/spec/lib/cc/cc_exporter_spec.rb index db745aa240b..a345ad3b118 100644 --- a/spec/lib/cc/cc_exporter_spec.rb +++ b/spec/lib/cc/cc_exporter_spec.rb @@ -440,7 +440,7 @@ describe "Common Cartridge exporting" do it "does not get confused by attachments with absolute paths" do @att = Attachment.create!(:filename => 'first.png', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course) - @q1 = @course.quizzes.create(:title => 'quiz1', :description => %Q{}) + @q1 = @course.quizzes.create(:title => 'quiz1', :description => %Q()) @ce.export_type = ContentExport::COMMON_CARTRIDGE run_export doc = Nokogiri::XML.parse(@zip_file.read("#{mig_id(@q1)}/assessment_meta.xml")) @@ -481,7 +481,7 @@ describe "Common Cartridge exporting" do it "deals with file URLs in anchor bodies" do @att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course) - link_thing = %{/courses/#{@course.id}/files/#{@att.id}/download?wrap=1} + link_thing = %(/courses/#{@course.id}/files/#{@att.id}/download?wrap=1) @course.syllabus_body = link_thing @course.save! @ag = @course.assignment_groups.create!(:name => 'group1') @@ -593,7 +593,7 @@ describe "Common Cartridge exporting" do it "exports CC 1.3 assignments" do @file = Attachment.create!(:filename => 'test.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course) - @course.assignments.create! name: 'test assignment', description: %Q{what?}, points_possible: 11, + @course.assignments.create! name: 'test assignment', description: %Q(what?), points_possible: 11, submission_types: 'online_text_entry,online_upload,online_url' @ce.export_type = ContentExport::COMMON_CARTRIDGE @ce.save! @@ -612,7 +612,7 @@ describe "Common Cartridge exporting" do expect(assignment_xml_doc.at_css('text').attribute('texttype').value).to eq 'text/html' expect(assignment_xml_doc.at_css('gradable').text).to eq 'true' expect(assignment_xml_doc.at_css('gradable').attribute('points_possible').value).to eq '11.0' - expect(assignment_xml_doc.css('submission_formats format').map { |fmt| fmt.attribute('type').value }).to match_array %w(html file url) + expect(assignment_xml_doc.css('submission_formats format').map { |fmt| fmt.attribute('type').value }).to match_array %w[html file url] # validate presence of canvas extension node extension_node = assignment_xml_doc.at_css('extensions').elements.first @@ -620,7 +620,7 @@ describe "Common Cartridge exporting" do expect(extension_node.namespace.href).to eq 'http://canvas.instructure.com/xsd/cccv1p0' # validate fallback html manifest resource - variant_tag = @manifest_doc.at_css(%Q{resource[identifier="#{assignment_id}_fallback"]}).elements.first + variant_tag = @manifest_doc.at_css(%Q(resource[identifier="#{assignment_id}_fallback"])).elements.first expect(variant_tag.name).to eq 'variant' expect(variant_tag.attribute('identifierref').value).to eql assignment_id expect(variant_tag.next_element.name).to eq 'file' @@ -930,8 +930,8 @@ describe "Common Cartridge exporting" do prerequisites: [{ :id => cm1.id, :type => "context_module", :name => cm1.name }] }) cm2.publish - cm1link = %{Mod 1} - cm2link = %{Mod 2} + cm1link = %(Mod 1) + cm2link = %(Mod 2) assignment = @course.assignments.create!({ title: 'Assignment 1', description: "go to module 1 at #{cm1link} and module 2 at #{cm2link}" diff --git a/spec/lib/cc/cc_helper_spec.rb b/spec/lib/cc/cc_helper_spec.rb index 1999404e04e..4c679d9e4f4 100644 --- a/spec/lib/cc/cc_helper_spec.rb +++ b/spec/lib/cc/cc_helper_spec.rb @@ -113,16 +113,16 @@ describe CC::CCHelper do it "ignores media links with no media comment id" do @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, :media_object_flavor => 'flash video') - html = %{McDerp Enterprises} + html = %(McDerp Enterprises) translated = @exporter.html_content(html) expect(translated).to eq html end it "translates new RCE media iframes" do @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user) - html = %{} + html = %() translated = @exporter.html_content(html) - expect(translated).to include %{src="$IMS-CC-FILEBASE$/media_objects/abcde.mp4"} + expect(translated).to include %(src="$IMS-CC-FILEBASE$/media_objects/abcde.mp4") expect(@exporter.media_object_infos[@obj.id]).not_to be_nil expect(@exporter.media_object_infos[@obj.id][:asset][:id]).to eq 'one' end @@ -133,9 +133,9 @@ describe CC::CCHelper do @obj.attachment = att @obj.save! @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user) - html = %{} + html = %() translated = @exporter.html_content(html) - expect(translated).to include %{src="$IMS-CC-FILEBASE$/something/lolcats.mp4"} + expect(translated).to include %(src="$IMS-CC-FILEBASE$/something/lolcats.mp4") end it "does not link media to file in another course" do @@ -147,14 +147,14 @@ describe CC::CCHelper do @obj.save! @course = temp @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user) - html = %{} + html = %() translated = @exporter.html_content(html) - expect(translated).to include %{src="$IMS-CC-FILEBASE$/media_objects/abcde.mp4"} + expect(translated).to include %(src="$IMS-CC-FILEBASE$/media_objects/abcde.mp4") end it "ignores new RCE media iframes with an unknown media id" do @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user) - html = %{} + html = %() translated = @exporter.html_content(html) expect(translated).to eq html expect(@exporter.media_object_infos).to be_empty @@ -171,7 +171,7 @@ describe CC::CCHelper do it "exports html with a utf-8 charset" do @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user) - html = %{
My Title\u0278
} + html = %(
My Title\u0278
) exported = @exporter.html_page(html, "my title page") doc = Nokogiri::HTML5(exported) expect(doc.encoding.upcase).to eq 'UTF-8' @@ -205,14 +205,14 @@ describe CC::CCHelper do it "interprets links to the files page as normal course pages" do @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, :for_course_copy => true) - html = %{File page index} + html = %(File page index) translated = @exporter.html_content(html) expect(translated).to match %r{\$CANVAS_COURSE_REFERENCE\$/files} end it "interprets links to the home page as normal course pages" do @exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, :for_course_copy => true) - html = %{Home page index} + html = %(Home page index) translated = @exporter.html_content(html) expect(translated).to match %r{\$CANVAS_COURSE_REFERENCE\$/} end @@ -279,12 +279,12 @@ describe CC::CCHelper do assignment = @course.assignments.create!(:name => "Thing") mod = @course.context_modules.create!(:name => "Stuff") tag = mod.content_tags.create! content: assignment, context: @course - html = %Q{ + html = <<~HTML Something Something Thing i-Tem - } + HTML translated = @exporter.html_content(html) expect(translated).to include "$WIKI_REFERENCE$/pages/something?embedded=true" expect(translated).to include "$WIKI_REFERENCE$/pages/#{other_page.url}?embedded=true" diff --git a/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb b/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb index 441c9a7927f..dc572de0a4c 100644 --- a/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb +++ b/spec/lib/cc/importer/canvas_cartridge_converter_spec.rb @@ -323,15 +323,15 @@ describe "Canvas Cartridge importing" do end it "imports v1 grading standards" do - doc = Nokogiri::XML(%{ - - - - Standard eh - [["A", 1], ["A-", 0.92], ["B+", 0.88], ["B", 0.84], ["B!-", 0.82], ["C+", 0.79], ["C", 0.76], ["C-", 0.73], ["D+", 0.69], ["D", 0.66], ["D-", 0.63], ["F", 0.6]] - - - }) + doc = Nokogiri::XML(<<~XML) + + + + Standard eh + [["A", 1], ["A-", 0.92], ["B+", 0.88], ["B", 0.84], ["B!-", 0.82], ["C+", 0.79], ["C", 0.76], ["C-", 0.73], ["D+", 0.69], ["D", 0.66], ["D-", 0.63], ["F", 0.6]] + + + XML hash = @converter.convert_grading_standards(doc) # import json into new course Importers::GradingStandardImporter.process_migration({ 'grading_standards' => hash }, @migration) @@ -555,7 +555,7 @@ describe "Canvas Cartridge importing" do expect(mod3_2.content_tags.length).to eq 2 expect(mod3_2.content_tags[0].url).to eq "http://a.example.com/" expect(mod3_2.content_tags[1].url).to eq "http://b.example.com/" - expect(@migration.old_warnings_format.first.first).to eq %{Import Error: Module Item - "Example 3"} + expect(@migration.old_warnings_format.first.first).to eq %(Import Error: Module Item - "Example 3") mod4_2 = @copy_to.context_modules.where(migration_id: CC::CCHelper.create_key(mod4)).first expect(mod4_2.content_tags.first.title).to eq att_tag.title @@ -671,10 +671,12 @@ describe "Canvas Cartridge importing" do allow_any_instance_of(Attachment).to receive(:media_object).and_return(double(:media_id => media_id)) path = CGI.escape(att.full_path) - body_with_links = %{

Watup? eh? + body_with_links = <<~HTML +

Watup? eh? wroks no wroks -

} +

+ HTML hash = { :migration_id => 'mig', @@ -705,7 +707,7 @@ describe "Canvas Cartridge importing" do allow_any_instance_of(Attachment).to receive(:media_object).and_return(double(:media_id => media_id)) path = CGI.escape(att.full_path) - body = %{

WHAT

} + body = %(

WHAT

) hash = { :migration_id => 'mig', @@ -744,7 +746,7 @@ describe "Canvas Cartridge importing" do path = to_att.full_display_path.gsub('course files/', '') @migration.attachment_path_id_lookup = { path => to_att.migration_id } - body_with_link = %{

Watup? eh? + body_with_link = %(

Watup? eh? Assignments Some file Assignments wiki link @@ -754,7 +756,7 @@ describe "Canvas Cartridge importing" do

-
} + ) page = @copy_from.wiki_pages.create!(:title => "some page", :body => body_with_link % [@copy_from.id, @copy_from.id, @copy_from.id, @copy_from.id, @copy_from.id, mod.id, @copy_from.id, from_att.id], :editing_roles => "teachers", :notify_of_update => true) page.workflow_state = 'unpublished' @copy_from.save! @@ -816,11 +818,11 @@ describe "Canvas Cartridge importing" do "description" => "yes", "grading_type" => "yes" }) - body_with_link = %{

Watup? eh?Assignments

+ body_with_link = %(

Watup? eh?Assignments

-
} +) asmnt = @copy_from.assignments.new asmnt.title = "Nothing Assignment" asmnt.description = body_with_link % @copy_from.id diff --git a/spec/lib/cc/importer/common_cartridge_converter_spec.rb b/spec/lib/cc/importer/common_cartridge_converter_spec.rb index a5d07823429..542ecabf8d4 100644 --- a/spec/lib/cc/importer/common_cartridge_converter_spec.rb +++ b/spec/lib/cc/importer/common_cartridge_converter_spec.rb @@ -40,7 +40,7 @@ describe "Standard Common Cartridge importing" do it "imports webcontent" do expect(@course.attachments.count).to eq 10 - atts = %w{I_00001_R I_00006_Media I_media_R f3 f4 f5 8612e3db71e452d5d2952ff64647c0d8 I_00003_R_IMAGERESOURCE 7acb90d1653008e73753aa2cafb16298 6a35b0974f59819404dc86d48fe39fc3} + atts = %w[I_00001_R I_00006_Media I_media_R f3 f4 f5 8612e3db71e452d5d2952ff64647c0d8 I_00003_R_IMAGERESOURCE 7acb90d1653008e73753aa2cafb16298 6a35b0974f59819404dc86d48fe39fc3] atts.each do |mig_id| expect(@course.attachments.where(migration_id: mig_id)).to be_exists end @@ -49,7 +49,7 @@ describe "Standard Common Cartridge importing" do it "imports files as assignments with intended_use set" do assignment = @course.assignments.where(:migration_id => "f5").first att = @course.attachments.where(:migration_id => "8612e3db71e452d5d2952ff64647c0d8").first - expect(assignment.description).to match_ignoring_whitespace(%{}) + expect(assignment.description).to match_ignoring_whitespace(%()) expect(assignment.title).to eq "Assignment 2" end @@ -59,11 +59,11 @@ describe "Standard Common Cartridge importing" do file2_id = @course.attachments.where(migration_id: "I_00006_Media").first.id dt = @course.discussion_topics.where(migration_id: "I_00006_R").first - expect(dt.message).to match_ignoring_whitespace(%{Your face is ugly.
}) + expect(dt.message).to match_ignoring_whitespace(%(Your face is ugly.
)) dt.attachment_id = file2_id dt = @course.discussion_topics.where(migration_id: "I_00009_R").first - expect(dt.message).to match_ignoring_whitespace(%{Monkeys: Go!\n}) + expect(dt.message).to match_ignoring_whitespace(%(Monkeys: Go!\n)) end # This also tests the WebLinks, they are just content tags and don't have their own class @@ -232,7 +232,7 @@ describe "Standard Common Cartridge importing" do it "imports webcontent" do expect(@course.attachments.active.count).to eq 10 - mig_ids = %w{I_00001_R I_00006_Media I_media_R f3 f4 I_00003_R_IMAGERESOURCE 7acb90d1653008e73753aa2cafb16298 6a35b0974f59819404dc86d48fe39fc3} + mig_ids = %w[I_00001_R I_00006_Media I_media_R f3 f4 I_00003_R_IMAGERESOURCE 7acb90d1653008e73753aa2cafb16298 6a35b0974f59819404dc86d48fe39fc3] mig_ids.each do |mig_id| atts = @course.attachments.where(migration_id: mig_id).to_a expect(atts.length).to eq 1 @@ -377,7 +377,7 @@ describe "Standard Common Cartridge importing" do mods = @course.context_modules.to_a expect(mods.map(&:position)).to eql [1, 2, 3, 4] - expect(mods.map(&:name)).to eql %w(ponies monsters monkeys last) + expect(mods.map(&:name)).to eql %w[ponies monsters monkeys last] end it "fixes position conflicts for assignment groups" do @@ -404,7 +404,7 @@ describe "Standard Common Cartridge importing" do ags = @course.assignment_groups.to_a expect(ags.map(&:position)).to eql [1, 2, 3, 4] - expect(ags.map(&:name)).to eql %w(monkeys ponies monsters last) + expect(ags.map(&:name)).to eql %w[monkeys ponies monsters last] end end diff --git a/spec/lib/content_zipper_spec.rb b/spec/lib/content_zipper_spec.rb index bb5ebac85db..b341105bd12 100644 --- a/spec/lib/content_zipper_spec.rb +++ b/spec/lib/content_zipper_spec.rb @@ -213,7 +213,7 @@ describe ContentZipper do students.each_with_index { |s, i| groups[i % groups.size].add_user(s) } a = @course.assignments.create! group_category_id: gc.id, grade_group_students_individually: false, - submission_types: %w(text_entry) + submission_types: %w[text_entry] a.submit_homework(students.first, body: "group 1 submission") a.submit_homework(students.second, body: "group 2 submission") diff --git a/spec/lib/course_link_validator_spec.rb b/spec/lib/course_link_validator_spec.rb index 1b0063f8bdc..1bfcbc4805d 100644 --- a/spec/lib/course_link_validator_spec.rb +++ b/spec/lib/course_link_validator_spec.rb @@ -29,14 +29,14 @@ describe CourseLinkValidator do bad_url = "http://www.notarealsitebutitdoesntmattercauseimstubbingitanwyay.com" bad_url2 = "/courses/#{@course.id}/file_contents/baaaad" bad_media_object_url = "/media_objects_iframe/junk" - html = %{ + html = <<~HTML Bad absolute link Bad file link Ok file link Ok other link Unpublished thing } + test_string = %() expect(convert_and_replace(test_string)).to eq test_string end it "handles and repair half broken new RCE media iframes" do - test_string = %{} - repaired_string = %{} + test_string = %() + repaired_string = %() expect(convert_and_replace(test_string)).to eq repaired_string end diff --git a/spec/lib/lti/capabilities_helper_spec.rb b/spec/lib/lti/capabilities_helper_spec.rb index ee4e413d290..d4f7b61766b 100644 --- a/spec/lib/lti/capabilities_helper_spec.rb +++ b/spec/lib/lti/capabilities_helper_spec.rb @@ -71,10 +71,10 @@ module Lti let(:variable_expander) { Lti::VariableExpander.new(root_account, account, controller, current_user: user, tool: tool) } - let(:invalid_enabled_caps) { %w(InvalidCap.Foo AnotherInvalid.Bar) } - let(:valid_enabled_caps) { %w(ToolConsumerInstance.guid Membership.role CourseSection.sourcedId) } + let(:invalid_enabled_caps) { %w[InvalidCap.Foo AnotherInvalid.Bar] } + let(:valid_enabled_caps) { %w[ToolConsumerInstance.guid Membership.role CourseSection.sourcedId] } let(:supported_capabilities) { - %w(ToolConsumerInstance.guid + %w[ToolConsumerInstance.guid Canvas.term.name CourseSection.sourcedId Membership.role @@ -115,7 +115,7 @@ module Lti com.instructure.Person.pronouns com.instructure.User.observees com.instructure.User.sectionNames - com.instructure.Observee.sisIds) + com.instructure.Observee.sisIds] } describe '#supported_capabilities' do @@ -137,7 +137,7 @@ module Lti end describe '#capability_params_hash' do - let(:valid_keys) { %w(tool_consumer_instance_guid roles lis_course_section_sourcedid) } + let(:valid_keys) { %w[tool_consumer_instance_guid roles lis_course_section_sourcedid] } it 'does not include a name (key) for invalid capabilities' do params_hash = CapabilitiesHelper.capability_params_hash(invalid_enabled_caps + valid_enabled_caps, variable_expander) diff --git a/spec/lib/lti/content_item_selection_request_spec.rb b/spec/lib/lti/content_item_selection_request_spec.rb index da852a7fa11..08988530c15 100644 --- a/spec/lib/lti/content_item_selection_request_spec.rb +++ b/spec/lib/lti/content_item_selection_request_spec.rb @@ -282,7 +282,7 @@ describe Lti::ContentItemSelectionRequest do assignment = assignment_model( course: course, submission_types: 'online_upload', - allowed_extensions: %w(txt jpg) + allowed_extensions: %w[txt jpg] ) opts = { assignment: assignment, launch_url: launch_url } lti_launch = lti_request.generate_lti_launch(placement: 'homework_submission', opts: opts) diff --git a/spec/lib/lti/plagiarism_subscriptions_helper_spec.rb b/spec/lib/lti/plagiarism_subscriptions_helper_spec.rb index 60ef9ed2ec8..062c8303738 100644 --- a/spec/lib/lti/plagiarism_subscriptions_helper_spec.rb +++ b/spec/lib/lti/plagiarism_subscriptions_helper_spec.rb @@ -59,11 +59,11 @@ describe Lti::PlagiarismSubscriptionsHelper do describe '#create_subscription' do let(:subscription_helper) { Lti::PlagiarismSubscriptionsHelper.new(tool_proxy) } let(:event_types) do - %w(submission_created + %w[submission_created plagiarism_resubmit submission_updated assignment_created - assignment_updated).freeze + assignment_updated].freeze end it 'creates a subscription and returns the id' do diff --git a/spec/lib/lti/privacy_level_expander_spec.rb b/spec/lib/lti/privacy_level_expander_spec.rb index 995acd72ee8..4a40d1f8176 100644 --- a/spec/lib/lti/privacy_level_expander_spec.rb +++ b/spec/lib/lti/privacy_level_expander_spec.rb @@ -75,13 +75,13 @@ describe Lti::PrivacyLevelExpander do let(:helper) { Lti::PrivacyLevelExpander.new(placement, variable_expander) } it 'includes all supported parameters if privacy level is public' do - expected_params = %w(com.instructure.contextLabel + expected_params = %w[com.instructure.contextLabel Person.sourcedId CourseOffering.sourcedId Person.email.primary Person.name.given Person.name.full - Person.name.family) + Person.name.family] expect(helper.supported_parameters).to match_array expected_params end end @@ -97,10 +97,10 @@ describe Lti::PrivacyLevelExpander do let(:helper) { Lti::PrivacyLevelExpander.new(placement, variable_expander) } it 'inlcudes anonymous and name only params if privacy level is name only' do - expected_params = %w(com.instructure.contextLabel + expected_params = %w[com.instructure.contextLabel Person.name.given Person.name.full - Person.name.family) + Person.name.family] expect(helper.supported_parameters).to match_array expected_params end end @@ -116,8 +116,8 @@ describe Lti::PrivacyLevelExpander do let(:helper) { Lti::PrivacyLevelExpander.new(placement, variable_expander) } it 'includes anonymous and email only params if privacy level is email only' do - expected_params = %w(com.instructure.contextLabel - Person.email.primary) + expected_params = %w[com.instructure.contextLabel + Person.email.primary] expect(helper.supported_parameters).to match_array expected_params end end @@ -133,7 +133,7 @@ describe Lti::PrivacyLevelExpander do let(:helper) { Lti::PrivacyLevelExpander.new(placement, variable_expander) } it 'includes anonymouse parameters only if privacy level is anonymous' do - expected_params = %w(com.instructure.contextLabel) + expected_params = %w[com.instructure.contextLabel] expect(helper.supported_parameters).to match_array expected_params end end diff --git a/spec/lib/lti/security_spec.rb b/spec/lib/lti/security_spec.rb index c65bdfebc32..d5265796f5c 100644 --- a/spec/lib/lti/security_spec.rb +++ b/spec/lib/lti/security_spec.rb @@ -56,14 +56,14 @@ describe Lti::Security do url = "http://test.example:3000/launch" signed_params = Lti::Security.signed_post_params(params, url, consumer_key, consumer_secret, true) - expect(Lti::Logging).to have_received(:lti_1_launch_generated).with(%W{ + expect(Lti::Logging).to have_received(:lti_1_launch_generated).with(%W[ POST&http%3A%2F%2Ftest.example%3A3000%2Flaunch&custom_a%3D1%26custom_b%3D2%26 oauth_consumer_key%3Dtest%26 oauth_nonce%3D#{signed_params['oauth_nonce']}%26 oauth_signature_method%3DHMAC-SHA1%26 oauth_timestamp%3D#{signed_params['oauth_timestamp']}%26 oauth_version%3D1.0 - }.join) + ].join) end end @@ -213,14 +213,14 @@ describe Lti::Security do nonce = signed_params['oauth_nonce'] timestamp = signed_params['oauth_timestamp'] - expect(Lti::Logging).to have_received(:lti_1_launch_generated).with(%W{ + expect(Lti::Logging).to have_received(:lti_1_launch_generated).with(%W[ POST&http%3A%2F%2Ftest.example%3A3000%2Flaunch&custom_a%3D1%26custom_b%3D2%26 oauth_consumer_key%3Dtest%26oauth_consumer_key%3Dtest%26 oauth_nonce%3D#{nonce}%26oauth_nonce%3D#{nonce}%26 oauth_signature_method%3DHMAC-SHA1%26oauth_signature_method%3DHMAC-SHA1%26 oauth_timestamp%3D#{timestamp}%26oauth_timestamp%3D#{timestamp}%26 oauth_version%3D1.0%26oauth_version%3D1.0 - }.join) + ].join) end end end diff --git a/spec/lib/lti/substitutions_helper_spec.rb b/spec/lib/lti/substitutions_helper_spec.rb index c3ee489121d..bac791e506e 100644 --- a/spec/lib/lti/substitutions_helper_spec.rb +++ b/spec/lib/lti/substitutions_helper_spec.rb @@ -483,7 +483,7 @@ module Lti end it "returns previous lti context_ids" do - expect(subject.previous_lti_context_ids.split(",")).to match_array %w{abc def} + expect(subject.previous_lti_context_ids.split(",")).to match_array %w[abc def] end end diff --git a/spec/lib/lti/variable_expander_spec.rb b/spec/lib/lti/variable_expander_spec.rb index 5cd55c53cf8..f7fbb4e32b8 100644 --- a/spec/lib/lti/variable_expander_spec.rb +++ b/spec/lib/lti/variable_expander_spec.rb @@ -245,7 +245,7 @@ module Lti describe '#enabled_capability_params' do let(:enabled_capability) { - %w(TestCapability.Foo + %w[TestCapability.Foo ToolConsumerInstance.guid CourseSection.sourcedId Membership.role @@ -259,7 +259,7 @@ module Lti User.image Message.documentTarget Message.locale - Context.id) + Context.id] } it 'does not use expansions that do not have default names' do diff --git a/spec/lib/sis/csv/group_importer_spec.rb b/spec/lib/sis/csv/group_importer_spec.rb index 522c0ddfe56..1c8dbaf79b5 100644 --- a/spec/lib/sis/csv/group_importer_spec.rb +++ b/spec/lib/sis/csv/group_importer_spec.rb @@ -60,9 +60,9 @@ describe SIS::CSV::GroupImporter do ) groups = Group.order(:id).to_a expect(groups.map(&:account_id)).to eq [@account.id, sub.id] - expect(groups.map(&:sis_source_id)).to eq %w(G001 G002) + expect(groups.map(&:sis_source_id)).to eq %w[G001 G002] expect(groups.map(&:name)).to eq ["Group 1", "Group 2"] - expect(groups.map(&:workflow_state)).to eq %w(available deleted) + expect(groups.map(&:workflow_state)).to eq %w[available deleted] end it "creates groups with no account id column" do @@ -73,9 +73,9 @@ describe SIS::CSV::GroupImporter do ) groups = Group.order(:id).to_a expect(groups.map(&:account_id)).to eq [@account.id] - expect(groups.map(&:sis_source_id)).to eq %w(G001) + expect(groups.map(&:sis_source_id)).to eq %w[G001] expect(groups.map(&:name)).to eq ["Group 1"] - expect(groups.map(&:workflow_state)).to eq %w(available) + expect(groups.map(&:workflow_state)).to eq %w[available] end it 'creates rollback data' do @@ -126,7 +126,7 @@ describe SIS::CSV::GroupImporter do groups = Group.order(:id).to_a expect(groups.map(&:name)).to eq ["Group 1-1", "Group 2-b"] expect(groups.map(&:root_account)).to eq [@account, @account] - expect(groups.map(&:workflow_state)).to eq %w(available deleted) + expect(groups.map(&:workflow_state)).to eq %w[available deleted] expect(groups.map(&:account)).to eq [@account, sub] end diff --git a/spec/lib/sis/csv/group_membership_importer_spec.rb b/spec/lib/sis/csv/group_membership_importer_spec.rb index 5c2f5213f84..2ce81f13889 100644 --- a/spec/lib/sis/csv/group_membership_importer_spec.rb +++ b/spec/lib/sis/csv/group_membership_importer_spec.rb @@ -58,7 +58,7 @@ describe SIS::CSV::GroupMembershipImporter do ms = GroupMembership.order(:id).to_a expect(ms.map(&:user_id)).to eq [@user1.id, @user3.id] expect(ms.map(&:group_id)).to eq [@group.id, @group.id] - expect(ms.map(&:workflow_state)).to eq %w(accepted deleted) + expect(ms.map(&:workflow_state)).to eq %w[accepted deleted] process_csv_data_cleanly( "group_id,user_id,status", @@ -68,7 +68,7 @@ describe SIS::CSV::GroupMembershipImporter do ms = GroupMembership.order(:id).to_a expect(ms.map(&:user_id)).to eq [@user1.id, @user3.id] expect(ms.map(&:group_id)).to eq [@group.id, @group.id] - expect(ms.map(&:workflow_state)).to eq %w(deleted deleted) + expect(ms.map(&:workflow_state)).to eq %w[deleted deleted] end it "adds users to groups that the user cannot access" do diff --git a/spec/lib/text_helper_spec.rb b/spec/lib/text_helper_spec.rb index acbd52f1a9a..e8384d25440 100644 --- a/spec/lib/text_helper_spec.rb +++ b/spec/lib/text_helper_spec.rb @@ -178,11 +178,11 @@ describe TextHelper do end it "allows wrapper with markdown" do - expect(th.mt(:foo, %{Dolore jerky bacon officia t-bone aute magna. Officia corned beef et ut bacon. + expect(th.mt(:foo, %(Dolore jerky bacon officia t-bone aute magna. Officia corned beef et ut bacon. Commodo in ham, *short ribs %{name} pastrami* sausage elit sunt dolore eiusmod ut ea proident ribeye. -Ad dolore andouille meatball irure, ham hock tail exercitation minim ribeye sint quis **eu short loin pancetta**.}, +Ad dolore andouille meatball irure, ham hock tail exercitation minim ribeye sint quis **eu short loin pancetta**.), :name => 'test'.html_safe, :wrapper => { '*' => '\1', diff --git a/spec/lib/unzip_attachment_spec.rb b/spec/lib/unzip_attachment_spec.rb index 8404008ce48..db59a68893d 100644 --- a/spec/lib/unzip_attachment_spec.rb +++ b/spec/lib/unzip_attachment_spec.rb @@ -20,7 +20,7 @@ describe UnzipAttachment do def fixture_filename(filename) - File.expand_path(File.join(File.dirname(__FILE__), %W(.. fixtures #{filename}))) + File.expand_path(File.join(File.dirname(__FILE__), %W[.. fixtures #{filename}])) end def add_folder_to_course(name) @@ -116,14 +116,14 @@ describe UnzipAttachment do filename = fixture_filename('alphabet_soup.zip') Zip::File.open(filename) do |zip| # make sure the files aren't read from the zip in alphabetical order (so it's not alphabetized by chance) - expect(zip.entries.map(&:name)).to eql(%w(f.txt d/e.txt d/d.txt c.txt b.txt a.txt)) + expect(zip.entries.map(&:name)).to eql(%w[f.txt d/e.txt d/d.txt c.txt b.txt a.txt]) end ua = UnzipAttachment.new(:course => @course, :filename => filename) ua.process expect(@course.attachments.count).to eq 6 - %w(a b c d e f).each_with_index do |letter, index| + %w[a b c d e f].each_with_index do |letter, index| expect(@course.attachments.where(position: index).first.display_name).to eq "#{letter}.txt" end end diff --git a/spec/lib/user_content_spec.rb b/spec/lib/user_content_spec.rb index 4892b2e6a17..11f10400e3b 100644 --- a/spec/lib/user_content_spec.rb +++ b/spec/lib/user_content_spec.rb @@ -154,7 +154,7 @@ describe UserContent do end it "matches absolute paths with https" do - expect(regex.match(%Q{}).to_a).to eq([ + expect(regex.match(%Q()).to_a).to eq([ "https://this-is-terrible.example.com/courses/#{rewriter.context.id}/pages/whatever?srsly=0", "https://this-is-terrible.example.com", "/courses/#{rewriter.context.id}", diff --git a/spec/lib/user_list_spec.rb b/spec/lib/user_list_spec.rb index b5b6b678dea..e182eed9499 100644 --- a/spec/lib/user_list_spec.rb +++ b/spec/lib/user_list_spec.rb @@ -67,8 +67,8 @@ describe UserList do end it "processes a list of irregular emails" do - ul = UserList.new(%{ Shaw "Ryan" , \"whoopsies\" , - guess what my name has an@sign , }) + ul = UserList.new(%( Shaw "Ryan" , \"whoopsies\" , + guess what my name has an@sign , )) expect(ul.addresses.map { |x| [x[:name], x[:address]] }).to eql([ ["Shaw \"Ryan\"", "ryankshaw@gmail.com"], ["whoopsies", "stuff@stuff.stuff"], @@ -90,7 +90,7 @@ describe UserList do end it "works with a mixed entry list" do - ul = UserList.new regular + "," + %{otherryankshaw@gmail.com, otherlastfirst@gmail.com} + ul = UserList.new regular + "," + %(otherryankshaw@gmail.com, otherlastfirst@gmail.com) expect(ul.addresses.map { |x| [x[:name], x[:address]] }).to eql([ ["Shaw, Ryan", "ryankshaw@gmail.com"], ["Last, First", "lastfirst@gmail.com"], @@ -180,7 +180,7 @@ describe UserList do p.sis_user_id = '9001' p.save! - ul = UserList.new regular + "," + %{user1,test@example.com,A112351243,"thomas walsh" , 9001, "walsh, thomas" }, :root_account => @account + ul = UserList.new regular + "," + %(user1,test@example.com,A112351243,"thomas walsh" , 9001, "walsh, thomas" ), :root_account => @account expect(ul.addresses.map { |x| [x[:name], x[:address], x[:type]] }).to eql([ ["Shaw, Ryan", "ryankshaw@gmail.com", :email], ["Last, First", "lastfirst@gmail.com", :email], @@ -200,7 +200,7 @@ describe UserList do user.pseudonyms.create!(:unique_id => "A112351243", :account => @account) user = User.create!(:name => 'user 1') user.pseudonyms.create!(:unique_id => "user1", :account => @account) - ul = UserList.new regular + "," + %{user1,test@example.com,A112351243,"thomas walsh" , "walsh, thomas" ,A4513454}, :root_account => @account + ul = UserList.new regular + "," + %(user1,test@example.com,A112351243,"thomas walsh" , "walsh, thomas" ,A4513454), :root_account => @account expect(ul.addresses.map { |x| [x[:name], x[:address], x[:type]] }).to eql([ ["Shaw, Ryan", "ryankshaw@gmail.com", :email], ["Last, First", "lastfirst@gmail.com", :email], @@ -569,9 +569,9 @@ describe UserList do end def regular - %{"Shaw, Ryan" , "Last, First" } + %("Shaw, Ryan" , "Last, First" ) end def without_brackets - %{ryankshaw@gmail.com, lastfirst@gmail.com} + %(ryankshaw@gmail.com, lastfirst@gmail.com) end diff --git a/spec/lib/user_merge_spec.rb b/spec/lib/user_merge_spec.rb index a153fec1bb8..2289ae116c4 100644 --- a/spec/lib/user_merge_spec.rb +++ b/spec/lib/user_merge_spec.rb @@ -309,7 +309,7 @@ describe UserMerge do ['i@instructure.com', 'retired'], ['o@instructure.com', 'retired'] ]) - %w{B@instructure.com F@instructure.com H@instructure.com}.each do |path| + %w[B@instructure.com F@instructure.com H@instructure.com].each do |path| expect(CommunicationChannel.where(user_id: [user1, user2]).by_path(path).detect { |cc| cc.path == path }).to be_nil end end diff --git a/spec/models/access_token_spec.rb b/spec/models/access_token_spec.rb index 3643bbbacf8..bc4d424ffe2 100644 --- a/spec/models/access_token_spec.rb +++ b/spec/models/access_token_spec.rb @@ -204,7 +204,7 @@ describe AccessToken do describe "token scopes" do let_once(:token) do token = AccessToken.new - token.scopes = %w{https://canvas.instructure.com/login/oauth2/auth/user_profile https://canvas.instructure.com/login/oauth2/auth/accounts} + token.scopes = %w[https://canvas.instructure.com/login/oauth2/auth/user_profile https://canvas.instructure.com/login/oauth2/auth/accounts] token end @@ -237,13 +237,13 @@ describe AccessToken do context "url scopes" do let(:token) do token = AccessToken.new - token.scopes = %w{ + token.scopes = %w[ blah/scope url:GET|/api/v1/accounts url:POST|/api/v1/courses url:PUT|/api/v1/courses/:id url:DELETE|/api/v1/courses/:course_id/assignments/:id - } + ] token end @@ -252,22 +252,22 @@ describe AccessToken do end it "accounts for format segments" do - token = AccessToken.new(scopes: %w{url:GET|/blah}) + token = AccessToken.new(scopes: %w[url:GET|/blah]) expect(token.url_scopes_for_method('GET')).to match_array [%r{^/blah(?:\.[^/]+|)$}] end it "accounts for glob segments" do - token = AccessToken.new(scopes: %w{url:GET|/*blah}) + token = AccessToken.new(scopes: %w[url:GET|/*blah]) expect(token.url_scopes_for_method('GET')).to match_array [%r{^/.+(?:\.[^/]+|)$}] end it "accounts for dynamic segments" do - token = AccessToken.new(scopes: %w{url:GET|/courses/:id}) + token = AccessToken.new(scopes: %w[url:GET|/courses/:id]) expect(token.url_scopes_for_method('GET')).to match_array [%r{^/courses/[^/]+(?:\.[^/]+|)$}] end it "accounts for optional segments" do - token = AccessToken.new(scopes: %w{url:GET|/courses(/:course_id)(/*blah)}) + token = AccessToken.new(scopes: %w[url:GET|/courses(/:course_id)(/*blah)]) expect(token.url_scopes_for_method('GET')).to match_array [%r{^/courses(?:/[^/]+|)(?:/.+|)(?:\.[^/]+|)$}] end end diff --git a/spec/models/assignment_spec.rb b/spec/models/assignment_spec.rb index ff294664b36..dbe387efe4e 100644 --- a/spec/models/assignment_spec.rb +++ b/spec/models/assignment_spec.rb @@ -7064,7 +7064,7 @@ describe Assignment do @students = create_users_in_course(@course, 3, return_type: :record) @assignment = @course.assignments.create! name: "zip upload test", - submission_types: %w(online_upload) + submission_types: %w[online_upload] end def zip_submissions @@ -7164,7 +7164,7 @@ describe Assignment do describe "newly-created comments" do before do - @assignment = @course.assignments.create!(name: "Mute Comment Test", submission_types: %w(online_upload)) + @assignment = @course.assignments.create!(name: "Mute Comment Test", submission_types: %w[online_upload]) end let(:added_comment) { @assignment.submission_for_student(@student).submission_comments.last } diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index 950a7994530..34e6cf6fc68 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -1211,11 +1211,11 @@ describe Attachment do describe "make_unique_filename" do it "finds a unique name for files" do - existing_files = %w(a.txt b.txt c.txt) + existing_files = %w[a.txt b.txt c.txt] expect(Attachment.make_unique_filename("d.txt", existing_files)).to eq "d.txt" expect(existing_files).not_to be_include(Attachment.make_unique_filename("b.txt", existing_files)) - existing_files = %w(/a/b/a.txt /a/b/b.txt /a/b/c.txt) + existing_files = %w[/a/b/a.txt /a/b/b.txt /a/b/c.txt] expect(Attachment.make_unique_filename("/a/b/d.txt", existing_files)).to eq "/a/b/d.txt" new_name = Attachment.make_unique_filename("/a/b/b.txt", existing_files) expect(existing_files).not_to be_include(new_name) diff --git a/spec/models/bookmark_service_spec.rb b/spec/models/bookmark_service_spec.rb index 42d5f528a2d..de730961b76 100644 --- a/spec/models/bookmark_service_spec.rb +++ b/spec/models/bookmark_service_spec.rb @@ -49,7 +49,7 @@ describe BookmarkService do :title => 'some title', :url => 'google.com', :comments => 'some comments', - :tags => %w(some tags) + :tags => %w[some tags] ) end @@ -70,7 +70,7 @@ describe BookmarkService do :title => 'some title', :url => 'google.com', :comments => 'some comments', - :tags => %w(some tags) + :tags => %w[some tags] ) end @@ -82,7 +82,7 @@ describe BookmarkService do :title => 'some title', :url => 'google.com', :comments => 'some comments', - :tags => %w(some tags) + :tags => %w[some tags] ) }.not_to raise_error end diff --git a/spec/models/calendar_event_spec.rb b/spec/models/calendar_event_spec.rb index 8b94c7c5e14..40212ac6ce7 100644 --- a/spec/models/calendar_event_spec.rb +++ b/spec/models/calendar_event_spec.rb @@ -241,7 +241,7 @@ describe CalendarEvent do it "does not add verifiers to files unless course or attachment is public" do attachment_model(:context => course_factory) - html = %{} + html = %() calendar_event_model(:start_at => "Sep 3 2008 12:00am", :description => html) ev = @event.to_ics(in_own_calendar: false) expect(ev.description).to_not include("verifier") @@ -271,7 +271,7 @@ describe CalendarEvent do @course.media_objects.create!(:media_id => '0_12345678') event = @course.default_section.calendar_events.create!(:start_at => "Sep 3 2008 12:00am", - :description => %{

media comment

}) + :description => %(

media comment

)) event.effective_context_code = @course.asset_string event.save! diff --git a/spec/models/communication_channel_spec.rb b/spec/models/communication_channel_spec.rb index 5c8a04e4dc4..51cb18d2ec6 100644 --- a/spec/models/communication_channel_spec.rb +++ b/spec/models/communication_channel_spec.rb @@ -447,7 +447,7 @@ describe CommunicationChannel do @cc1 = communication_channel_model(path: 'not_as_bouncy@example.edu') @cc2 = communication_channel_model(path: 'bouncy@example.edu') - %w{bouncy@example.edu Bouncy@example.edu bOuNcY@Example.edu bouncy@example.edu bouncy@example.edu}.each do |path| + %w[bouncy@example.edu Bouncy@example.edu bOuNcY@Example.edu bouncy@example.edu bouncy@example.edu].each do |path| CommunicationChannel.bounce_for_path( path: path, timestamp: nil, @@ -577,7 +577,7 @@ describe CommunicationChannel do # action that would need to happen for the bounce_for_path method. If it # does not need to happen, add it to the list below. If it does, handle # that, then add it to the list here. - accounted_for_callbacks = %i( + accounted_for_callbacks = %i[ after_save_collection_association assert_path_type autosave_associated_records_for_pseudonym @@ -588,7 +588,7 @@ describe CommunicationChannel do consider_building_pseudonym set_confirmation_code set_root_account_ids - ) + ] expect(CommunicationChannel._save_callbacks.collect(&:filter).select { |k| k.is_a? Symbol } - accounted_for_callbacks).to eq [] end @@ -703,7 +703,7 @@ describe CommunicationChannel do @cc3 = communication_channel_model(path: 'BOUNCY@example.edu') end - %w{bouncy@example.edu Bouncy@example.edu bOuNcY@Example.edu bouncy@example.edu bouncy@example.edu}.each do |path| + %w[bouncy@example.edu Bouncy@example.edu bOuNcY@Example.edu bouncy@example.edu bouncy@example.edu].each do |path| CommunicationChannel.bounce_for_path( path: path, timestamp: nil, diff --git a/spec/models/content_migration/course_copy_assignments_spec.rb b/spec/models/content_migration/course_copy_assignments_spec.rb index 3d9cf7e787d..f7a2851f243 100644 --- a/spec/models/content_migration/course_copy_assignments_spec.rb +++ b/spec/models/content_migration/course_copy_assignments_spec.rb @@ -760,7 +760,7 @@ describe ContentMigration do assign.save! @cm.copy_options = { 'everything' => '0', 'assignments' => { mig_id(assign) => "1" } } run_course_copy - expect(@copy_to.grading_standards.map(&:title)).to eql %w(Two) + expect(@copy_to.grading_standards.map(&:title)).to eql %w[Two] expect(@copy_to.assignments.first.grading_standard.title).to eql 'Two' end diff --git a/spec/models/content_migration/course_copy_attachments_spec.rb b/spec/models/content_migration/course_copy_attachments_spec.rb index a68630c9e42..b337795bf43 100644 --- a/spec/models/content_migration/course_copy_attachments_spec.rb +++ b/spec/models/content_migration/course_copy_attachments_spec.rb @@ -52,7 +52,7 @@ describe ContentMigration do expect(new_attachment).not_to be_nil expect(new_attachment.full_path).to eq "course files/dummy.txt" expect(new_attachment.folder).to eq to_root - expect(@copy_to.syllabus_body).to eq %{link} + expect(@copy_to.syllabus_body).to eq %(link) end it "copies files into the correct folders when the folders share the same name" do @@ -108,8 +108,8 @@ describe ContentMigration do att2 = Attachment.create!(:filename => 'second.jpg', :uploaded_data => StringIO.new('ohais'), :folder => Folder.root_folders(@copy_from).first, :context => @copy_from) Attachment.create!(:filename => 'third.jpg', :uploaded_data => StringIO.new('3333'), :folder => Folder.root_folders(@copy_from).first, :context => @copy_from) - asmnt_des = %{First file} - wiki_body = %{} + asmnt_des = %(First file) + wiki_body = %() asmnt = @copy_from.assignments.create!(:points_possible => 40, :grading_type => 'points', :description => (asmnt_des % [@copy_from.id, att.id]), :title => "assignment") wiki = @copy_from.wiki_pages.create!(:title => "wiki", :body => (wiki_body % [@copy_from.id, att2.id])) @@ -152,11 +152,11 @@ describe ContentMigration do it "preserves new-RCE mediahref iframes" do att = @copy_from.attachments.create!(:filename => 'videro.mov', :uploaded_data => StringIO.new('...'), :folder => Folder.root_folders(@copy_from).first) page = @copy_from.wiki_pages.create!(:title => "watch this y'all", :body => - %Q{