make grade overrides dependent on new gradebook
make grade overrides dependent on new gradebook

closes: GRADE-1964

Test Plan
=========
This patchset will require careful setup, since the environment can be
considered "tainted" if you've ever had New Gradebook enabled and created a
late policy or also had enabled the Final Grade Override Feature Flag.
For the sake of a "clean slate" I recommend creating a fresh canvas
install or creating a new shard and only trying these steps out there.
Due to the nature of this "one-way" feature, it's difficult to undo
certain steps.

One way to force a reset is to do so via the rails console like so:

    account = Account.find(account_id)
    course = account.courses.find(course_id)
    account.feature_flags.where(
      context: [account, course],
      feature: [:new_gradebook, :final_grades_override]
    ).update_all(state: :off)

If the following instructions say "Reset Flags" this code snippet should
be ran before proceeding. It's assumed that other backwards incompatible
features are not introduced during this process (e.g. late policies).

Base Cases
----------
* Given a Course in an Account
* When the Account New Gradebook is "Off"
* Then the Account New Gradebook can be changed to "Allow"
* Then the Account New Gradebook can be changed to "On"
* Then the Account Final Grade Override is locked to "Off"
* Then the Course New Gradebook is locked to "Off"
* Then the Course Final Grade Override is locked to "Off"

* Given the Account New Gradebook is "Allow" and the page is reloaded
* When the Account New Gradebook is changed to "On"
* Then the flag successfully changes

* Given the Account New Gradebook is "Allow" and the page is reloaded
* When the Account New Gradebook is changed to "Off"
* Then the flag successfully changes

* Given the Account New Gradebook is "On" and the page is reloaded
* When the Account New Gradebook is changed to "Allow"
* Then the flag successfully changes

* Given the Account New Gradebook is "On" and the page is reloaded
* When the Account New Gradebook is changed to "Off"
* Then the flag successfully changes

* Given the Account New Gradebook is "Allow"
* When the Course New Gradebook is set to "On"
* Then the Account New Gradebook cannot be changed to "Off"

* When the Account New Gradebook is "On"
* Then the Course New Gradebook is locked to "On"

New Behavior
------------
* When the Account New Gradebook is "Allow" and the page is reloaded
* Then the Account Final Grade Override is set to "Off" and can be
  set to "Allow" and "On" is not available
* Then the Course New Gradebook is "Off" and can be set to "On"
* Then the Course Final Grade Override is locked to "Off"
* Reset Flags

* When the Account New Gradebook and Final Grade Override flags are
  "Allow" (reload necessary to change second flag)
* Then the Course New Gradebook is "Off" and can be set to "On"
* Then the Course Final Grade Override is locked to "Off"
* Reset Flags

* Given the Account New Gradebook and Final Grade Override flags are
  "Allow" (reload necessary to change second flag)
* When the Course New Gradebook is "On" and the page is reloaded
* Then the Course Final Grade Override is "Off" and can be set to "On"
* Reset Flags

* Given the Account New Gradebook and Final Grade Override flags are
  "Allow" (reload necessary to change second flag)
* Given the Course New Gradebook is "On" and the page is reloaded
* When the Course Final Grade Override is changed to "On" and the
  page is reloaded
* Then the Course Final Grade Override is locked "On"
* Then the Account New Gradebook cannot be changed to "Off"
* Then the Account Final Grade Override cannot be changed to "Off"
* Reset Flags

* Given the Account New Gradebook is "On" and the page is reloaded
* Given the Account Final Grade Override is "Allow"
* When the Course Final Grade Override is changed to "On" and the
  page is reloaded
* Then the Course Final Grade Override is locked "On"
* Then the Account New Gradebook cannot be changed to "Off"
* Then the Account Final Grade Override cannot be changed to "Off"
* Reset Flags

* Given the Account New Gradebook is "On" and the page is reloaded
* When the Account Final Grade Override is "On" and the page is reloaded
* Then both flags are locked to "On" and cannot be changed
* Then both Course flags are locked to "On" and cannot be changed
* Rest Flags

Change-Id: I40bc544914a7f3f8b3753c10615dc789c5aeffc2
Reviewed-on: https://gerrit.instructure.com/180049
Reviewed-by: Keith Garner <a1a80143a840c140f31c3495ebbd9ec906e09fed@instructure.com>
QA-Review: James Butters <4c5a489c9bb72d41f20b3b22aaf4c9b864e32f20@instructure.com>
Tested-by: Jenkins
Product-Review: Keith Garner <a1a80143a840c140f31c3495ebbd9ec906e09fed@instructure.com>

instructure/canvas-lms,instructure/canvas-lms,sfu/canvas-lms,instructure/canvas-lms,instructure/canvas-lms,djbender/canvas-lms,instructure/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,djbender/canvas-lms,djbender/canvas-lms,sfu/canvas-lms,sfu/canvas-lms,djbender/canvas-lms,sfu/canvas-lms,instructure/canvas-lms,instructure/canvas-lms