spec: Add pact states

Add grading standards and assignment with override state.

Change-Id: Ifc576c2e7111afd67c95685a936cfef922d800fe
Reviewed-on: https://gerrit.instructure.com/159382
Reviewed-by: Robert Lamb <rlamb@instructure.com>
Product-Review: Robert Lamb <rlamb@instructure.com>
QA-Review: Robert Lamb <rlamb@instructure.com>
Tested-by: Jenkins
This commit is contained in:
Eka Tjung 2018-08-01 11:40:22 -07:00 committed by Eka Purnama Tjung
parent a605a22c00
commit 46b44fcf50
3 changed files with 70 additions and 1 deletions

View File

@ -44,5 +44,20 @@ PactConfig::Consumers::ALL.each do |consumer|
assignment.save!
end
end
provider_state 'an assignment with overrides' do
set_up do
course = Pact::Canvas.base_state.course
student = Pact::Canvas.base_state.students.first
assignment = course.assignments.create({
name: 'Assignment Override',
due_at: Time.zone.now + 1.day,
submission_types: 'online_text_entry'
})
override = assignment.assignment_overrides.create!
override.assignment_override_students.create!(:user => student)
end
end
end
end

View File

@ -0,0 +1,53 @@
#
# Copyright (C) 2018 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
PactConfig::Consumers::ALL.each do |consumer|
Pact.provider_states_for consumer do
# Account ID: 2
provider_state 'an account with grading standards' do
set_up do
@account = Pact::Canvas.base_state.account
grading_standard = @account.grading_standards.build(title: "Number Before Letter")
grading_standard.data = {
"A" => 0.9,
"B" => 0.8,
"C" => 0.7,
"D" => 0.6,
"F" => 0,
}
grading_standard.save!
end
end
# Course ID: 1
provider_state 'a course with grading standards' do
set_up do
@course = Pact::Canvas.base_state.course
grading_standard = @course.grading_standards.build(title: "Number Before Letter")
grading_standard.data = {
"A" => 0.9,
"B" => 0.8,
"C" => 0.7,
"D" => 0.6,
"F" => 0,
}
grading_standard.save!
end
end
end
end

View File

@ -32,12 +32,13 @@ module PactConfig
module Consumers
my_broker_host = ENV.fetch('PACT_BROKER_HOST', 'pact-broker.docker')
if my_broker_host.include?(EXTERNAL_BROKER_HOST)
# extrnal consumers
# external consumers
GENERIC_CONSUMER = 'Generic Consumer'.freeze
else
# internal consumers
GENERIC_CONSUMER = 'Generic Consumer'.freeze
QUIZ_LTI = 'Quiz LTI'.freeze
SISTEMIC = 'Sistemic'.freeze
end
ALL = Consumers.constants.map { |c| Consumers.const_get(c) }.freeze
end