add "archived" workflow state to rubric models
closes EVAL-3659 flag=enhanced_rubrics test plan: - tests pass Change-Id: I264dd9141bda8cb9039249ab07a2ddcecd5ac653 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/332498 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Christopher Soto <christopher.soto@instructure.com> Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com> QA-Review: Derek Williams <derek.williams@instructure.com> Product-Review: Cameron Ray <cameron.ray@instructure.com>
This commit is contained in:
parent
dd4f9e10cb
commit
b0896433f1
|
@ -95,10 +95,25 @@ class Rubric < ActiveRecord::Base
|
|||
end
|
||||
|
||||
workflow do
|
||||
state :active
|
||||
state :active do
|
||||
event :archive, transitions_to: :archived
|
||||
end
|
||||
state :archived do
|
||||
event :unarchive, transitions_to: :active
|
||||
end
|
||||
state :deleted
|
||||
end
|
||||
|
||||
def archive
|
||||
# overrides 'archive' event in workflow to make sure the feature flag is enabled
|
||||
# remove this and 'unarchive' method when feature flag is removed
|
||||
super if enhanced_rubrics_enabled?
|
||||
end
|
||||
|
||||
def unarchive
|
||||
super if enhanced_rubrics_enabled?
|
||||
end
|
||||
|
||||
def self.aligned_to_outcomes
|
||||
where(
|
||||
ContentTag.learning_outcome_alignments
|
||||
|
@ -468,4 +483,8 @@ class Rubric < ActiveRecord::Base
|
|||
context&.root_account_id
|
||||
end
|
||||
end
|
||||
|
||||
def enhanced_rubrics_enabled?
|
||||
Account.site_admin.feature_enabled?(:enhanced_rubrics)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -342,6 +342,32 @@ describe Rubric do
|
|||
end
|
||||
end
|
||||
|
||||
it "changes workflow state properly when archiving when enhanced_rubrics FF enabled" do
|
||||
course_with_teacher
|
||||
rubric = rubric_model({ context: @course })
|
||||
rubric.archive
|
||||
expect(rubric.workflow_state).to eq "archived"
|
||||
end
|
||||
|
||||
it "changes workflow state propertly when unarchiving when enhanced_rubrics FF enabled" do
|
||||
course_with_teacher
|
||||
rubric = rubric_model({ context: @course })
|
||||
rubric.archive
|
||||
expect(rubric.workflow_state).to eq "archived"
|
||||
rubric.unarchive
|
||||
expect(rubric.workflow_state).to eq "active"
|
||||
end
|
||||
|
||||
it "does not change workflow state when archiving when enhanced_rubrics FF disabled" do
|
||||
# remove this test when FF is removed
|
||||
Account.site_admin.disable_feature!(:enhanced_rubrics)
|
||||
course_with_teacher
|
||||
rubric = rubric_model({ context: @course })
|
||||
rubric.archive
|
||||
expect(rubric.workflow_state).to eq "active"
|
||||
Account.site_admin.enable_feature!(:enhanced_rubrics)
|
||||
end
|
||||
|
||||
it "is cool about duplicate titles" do
|
||||
course_with_teacher
|
||||
|
||||
|
|
Loading…
Reference in New Issue