canvas-lms/gems
viktor.szpisjak 10f47ed85e Change date shift flow for assignment and classic quizzes
Assignments and classic quizzes will date shifting now become
an initial operation instead a late update to avoid
unnecessary lifecycle hook triggers.

refs CLAB-102

flag=pre_date_shift_for_assignment_importing

test plan:
# Setup
Create a course (SC) with:
 - Assignment
 - Quiz
 - Graded Discussion
On all 3 set due date to a past date and other dates to something.

# With flag off (current behavior)
Create a new course
go to courses/{id}/content_migrations
use Copy a Canvas course
Source course should be SC
Select All content
Select Adjust events and due dates
Click remove dates
Import

Go to imported resources and verify that
due dates and other dates are gone.

Create a new course, do same import but
adjust dates instead of removing them.
Verify dates were adjusted as expected.

# With flag on
Enable pre_date_shift_for_assignment_importing
Create a new course
Test both scenarios of Adjust events and due dates
Expect same results

# Race condition
Ensure flag is on
Testing the race condition with SubmissionLifecycleManager
Create a new course
Create a student user, add to course, accept invite

in AssignmentImporter#try_to_save_with_date_shift
add "binding.irb" on line 607

open terminal
cd canvas-lms
docker compose stop jobs
docker compose run jobs (do the same in another terminal)
bundle exec script/delayed_job run (in both shells)

Import SC into new course
one of the job processes will pick up the job
and give you an irb
"item.save_without_broadcasting"
"SubmissionLifecycleManager.recompute(item)"
"item.submissions" should be empty or should have no graded subs

Change-Id: Ide39a552b625c099c0c87fc6166cd9bd37a0ab15
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/357178
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rajmund Csehil <rajmund.csehil@instructure.com>
QA-Review: Rajmund Csehil <rajmund.csehil@instructure.com>
Product-Review: Rajmund Csehil <rajmund.csehil@instructure.com>
QA-Review: Ferenc Marcsó <ferenc.marcso@instructure.com>
2024-09-18 14:22:20 +00:00
..
activesupport-suspend_callbacks bundle update minitest 2024-08-23 14:11:12 +00:00
acts_as_list bundle update minitest 2024-08-23 14:11:12 +00:00
adheres_to_policy bundle update minitest 2024-08-23 14:11:12 +00:00
attachment_fu Ensure found media attachments have media id and approx content type 2024-07-05 19:56:35 +00:00
autoextend bundle update irb 2024-07-09 20:31:31 +00:00
bookmarked_collection bundle update minitest 2024-08-23 14:11:12 +00:00
broadcast_policy bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_breach_mitigation bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_cache bundle update redis 2024-08-23 14:17:07 +00:00
canvas_cassandra bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_color Revert "Revert "bundle update --bundler"" 2024-05-29 16:33:13 +00:00
canvas_crummy bundle update docile 2024-08-01 16:47:20 +00:00
canvas_dynamodb bundle update aws-sdk 2024-08-23 14:13:27 +00:00
canvas_errors bundle update fugit 2024-08-23 14:13:27 +00:00
canvas_ext bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_http bundle update redis 2024-08-23 14:17:07 +00:00
canvas_kaltura bundle update redis 2024-08-23 14:17:07 +00:00
canvas_mimetype_fu bundle update docile 2024-08-01 16:47:20 +00:00
canvas_panda_pub bundle update uri 2024-09-05 15:59:17 +00:00
canvas_partman bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_quiz_statistics bundle update sanitize 2024-08-23 14:18:26 +00:00
canvas_sanitize bundle update sanitize 2024-08-23 14:18:26 +00:00
canvas_security bundle update uri 2024-09-05 15:59:17 +00:00
canvas_slug bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
canvas_sort bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
canvas_stringex bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_text_helper bundle update concurrent-ruby 2024-08-23 14:11:12 +00:00
canvas_time bundle update minitest 2024-08-23 14:11:12 +00:00
canvas_unzip bundle update minitest 2024-08-23 14:11:12 +00:00
config_file bundle update minitest 2024-08-23 14:11:12 +00:00
csv_diff bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
diigo bundle update nokogiri 2024-08-01 16:48:23 +00:00
dr_diff bundle update irb 2024-07-09 20:31:31 +00:00
dynamic_settings bundle update uri 2024-09-05 15:59:17 +00:00
event_stream bundle update minitest 2024-08-23 14:11:12 +00:00
google_drive bundle update uri 2024-09-05 15:59:17 +00:00
html_text_helper bundle update sanitize 2024-08-23 14:18:26 +00:00
i18n_extraction bundle update minitest 2024-08-23 14:11:12 +00:00
i18n_tasks bundle update minitest 2024-08-23 14:11:12 +00:00
incoming_mail_processor bundle update sanitize 2024-08-23 14:18:26 +00:00
json_token bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
legacy_multipart bundle update mime-types-data 2024-08-23 14:13:27 +00:00
live_events bundle update aws-sdk 2024-08-23 14:13:27 +00:00
lti-advantage bundle update uri 2024-09-05 15:59:17 +00:00
lti_outbound bundle update minitest 2024-08-23 14:11:12 +00:00
paginated_collection bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
plugins Change date shift flow for assignment and classic quizzes 2024-09-18 14:22:20 +00:00
request_context bundle update uri 2024-09-05 15:59:17 +00:00
rubocop-canvas bundle update rubocop-ast 2024-08-23 14:18:26 +00:00
stringify_ids bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
tatl_tael bundle update timecop 2024-06-24 23:20:11 +00:00
turnitin_api bundle update uri 2024-09-05 15:59:17 +00:00
twitter bundle update sanitize 2024-08-23 14:18:26 +00:00
utf8_cleaner bundle update rspec-expectations 2024-06-24 23:18:15 +00:00
workflow bundle update minitest 2024-08-23 14:11:12 +00:00
README.md Remove auditor cassandra support 2023-04-03 15:40:22 +00:00
gemfile_prefix.rb add Rails 7.1 lockfiles for embedded gems 2024-02-14 22:30:10 +00:00
test_all_gems.sh remove broken vendored gems html reports 2021-06-15 16:53:17 +00:00

README.md

Gems

This folder is a place to extract modular functionality from canvas. Canvas's Gemfile arrangement is enabled to read gems from this path locally without installing from a remote source. This is valuable for a few reasons:

  • it prevents circular dependencies (bundler won't allow it)
  • modularized code cannot bind to specific domain concepts on canvas models
  • gems can have their specs run independently, without needing to load all of canvas, saving iteration time
  • it allows for eventual build optimization via only running specs for the transitive closure of parents depending on a gem where a change is.

There are some tradeoffs:

  • spreads canvas over more subdirectories, giving some mental overhad to traversing the entire codebase.
  • modular tests necessarily don't test integration with canvas concepts, so solid integration tests in the app are still a requirement.
  • total SERIALIZED build time goes up because each gem loads it's specs in a new process rather than all running within an already booted canvas process.

[TODO] eventually write more on whether we feel like those tradeoffs are good ones, and what the best practices are to leverage this pattern for max-gain/min-pain.

Testing

To test all the gems:

cd gems
./test_all_gems.sh

To test an individual gem

Run ./test.sh inside the gem's folder. This is basically the same as:

cd gems/google_drive
bundle
rspec