quiz_export_complete live event contract test

Fixes: QUIZ-4399

Test Plan:  See https://gerrit.instructure.com/161182

Change-Id: Ia4090ecacadd8e5aea80499870e28403b721029e
Reviewed-on: https://gerrit.instructure.com/161184
Reviewed-by: David Tan <dtan@instructure.com>
Tested-by: Jenkins
QA-Review: Sven Thirion <sthirion@instructure.com>
Product-Review: Robin Kuss <rkuss@instructure.com>
This commit is contained in:
Robin Kuss 2018-08-17 13:09:05 -05:00
parent 354bf2df06
commit 29bf0b577f
1 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,74 @@
#
# Copyright (C) 2015 - 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/>.
#
require_relative '../live_events_pact_helper'
RSpec.describe 'Canvas LMS Live Events', :pact_live_events do
describe 'quiz_export_complete' do
let(:live_event) do
LiveEvents::PactHelper::Event.new(
event_name: 'quiz_export_complete',
event_subscriber: PactConfig::Consumers::QUIZ_LTI
)
end
it 'keeps the contract' do
live_event.emit_with do
params = {
:name => "Quizzes.Next",
:url => 'http://example.com/launch',
:domain => "example.com",
:consumer_key => 'test_key',
:shared_secret => 'test_secret',
:privacy_level => 'public',
:tool_id => 'Quizzes 2'
}
Account.default.enable_feature!(:lor_for_account)
Account.default.context_external_tools.create!(params)
course = course_model
course.root_account.settings[:provision] = {'lti' => 'lti url'}
course.root_account.save!
course.enable_feature!(:quizzes_next)
@quiz = course.quizzes.create!(
title: 'quiz 1',
quiz_type: 'assignment'
)
@ce = course.content_exports.create!(
export_type: ContentExport::QUIZZES2,
selected_content: @quiz.id
)
@quizzes2 = Exporters::Quizzes2Exporter.new(@ce)
@quizzes2.export
@ce.settings[:quizzes2] = @quizzes2.build_assignment_payload
@ce.settings[:quizzes2][:qti_export] = {}
@ce.settings[:quizzes2][:qti_export][:url] = "fake_url.com"
@ce.progress = 100
@ce.mark_exported
@ce.save!
end
expect(live_event).to have_kept_the_contract
end
end
end