Check new_sis_integrations on account level

Check whether the new_sis_integrations feature flag is enabled on the
root account level rather than the site-admin level, since it is set on
the former and not the latter.

fixes EVAL-1256
flag=disable_post_to_sis_when_grading_period_closed

Test plan:
- For a root account:
  - Enable the "Enable new SIS Integration Settings" flag
  - Enable the "Disable Post to SIS for Assignment in Closed Grading
    Periods" flag
  - In the account settings, enable the "SIS Syncing" checkbox to cause
    the below checkbox to appear
  - In the account settings, enable the 'Automatically disable "Post to
    SIS" on assignments when grading period closes' checkbox

- Set up a grading period with a close date within the past 20 minutes
- Have a course with at least one student
- Set up an assignment with a due date within that grading period
  - Set post_to_sis on the assignment to true

- Have delayed_jobs running and wait five minutes, OR run the following
  in a Rails console:
  > Assignment.disable_post_to_sis_if_grading_period_closed
- Check the assignment you created above
  - It should now have post_to_sis set to false

Change-Id: I6aa63b4a35fea95aedb221a13b63c600d7772cb5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249623
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
This commit is contained in:
Adrian Packel 2020-10-08 11:56:03 -05:00
parent 9e0aa875d2
commit d9353fcb20
4 changed files with 11 additions and 13 deletions

View File

@ -2029,9 +2029,8 @@ class Account < ActiveRecord::Base
def allow_disable_post_to_sis_when_grading_period_closed?
return false unless root_account?
return false unless feature_enabled?(:disable_post_to_sis_when_grading_period_closed)
Account.site_admin.feature_enabled?(:new_sis_integrations)
feature_enabled?(:disable_post_to_sis_when_grading_period_closed) && feature_enabled?(:new_sis_integrations)
end
class << self

View File

@ -3503,10 +3503,9 @@ class Assignment < ActiveRecord::Base
end
def self.disable_post_to_sis_if_grading_period_closed
return unless Account.site_admin.feature_enabled?(:new_sis_integrations)
eligible_root_accounts = Account.root_accounts.active.select do |account|
account.feature_enabled?(:disable_post_to_sis_when_grading_period_closed) &&
account.feature_enabled?(:new_sis_integrations) &&
account.disable_post_to_sis_when_grading_period_closed?
end
return unless eligible_root_accounts.any?

View File

@ -2034,27 +2034,27 @@ describe Account do
let(:subaccount) { Account.create!(root_account: root_account) }
it "returns false if the account is not a root account" do
Account.site_admin.enable_feature!(:new_sis_integrations)
root_account.enable_feature!(:new_sis_integrations)
root_account.enable_feature!(:disable_post_to_sis_when_grading_period_closed)
expect(subaccount).not_to be_allow_disable_post_to_sis_when_grading_period_closed
end
context "for a root account" do
it "returns false if the site admin account does not enable new_sis_integrations" do
it "returns false if the root account does not enable the relevant feature flag" do
root_account.enable_feature!(:disable_post_to_sis_when_grading_period_closed)
expect(root_account).not_to be_allow_disable_post_to_sis_when_grading_period_closed
end
it "returns false if this account does not enable the relevant feature flag" do
Account.site_admin.enable_feature!(:new_sis_integrations)
it "returns false if this account does not enable the new_sis_integrations feature flag" do
root_account.enable_feature!(:new_sis_integrations)
expect(root_account).not_to be_allow_disable_post_to_sis_when_grading_period_closed
end
it "returns true when the relevant feature flags are enabled" do
Account.site_admin.enable_feature!(:new_sis_integrations)
root_account.enable_feature!(:new_sis_integrations)
root_account.enable_feature!(:disable_post_to_sis_when_grading_period_closed)
expect(root_account).to be_allow_disable_post_to_sis_when_grading_period_closed

View File

@ -9172,7 +9172,7 @@ describe Assignment do
context "when the account has SIS-related features active and the setting enabled" do
before(:once) do
Account.site_admin.enable_feature!(:new_sis_integrations)
account.enable_feature!(:new_sis_integrations)
account.enable_feature!(:disable_post_to_sis_when_grading_period_closed)
account.settings[:disable_post_to_sis_when_grading_period_closed] = true
account.save!
@ -9280,7 +9280,7 @@ describe Assignment do
end
end
it "does not run when the site-admin 'new_sis_integrations' flag is not enabled" do
it "does not run when the root account 'new_sis_integrations' flag is not enabled" do
account.enable_feature!(:disable_post_to_sis_when_grading_period_closed)
account.settings[:disable_post_to_sis_when_grading_period_closed] = true
account.save!
@ -9291,7 +9291,7 @@ describe Assignment do
end
it "does not run when the feature flag governing the setting is not enabled for the account" do
Account.site_admin.enable_feature!(:new_sis_integrations)
account.enable_feature!(:new_sis_integrations)
account.settings[:disable_post_to_sis_when_grading_period_closed] = true
account.save!
@ -9301,7 +9301,7 @@ describe Assignment do
end
it "does not run when the account does not have the setting enabled" do
Account.site_admin.enable_feature!(:new_sis_integrations)
account.enable_feature!(:new_sis_integrations)
account.enable_feature!(:disable_post_to_sis_when_grading_period_closed)
expect {