spec: refactor courses specs

closes QA-528

Test Plan:
1. Pass Jenkins

Change-Id: I997655b18d52216c2c0fe8879110712a735b8458
Reviewed-on: https://gerrit.instructure.com/156134
Tested-by: Jenkins
Reviewed-by: Robert Lamb <rlamb@instructure.com>
Product-Review: Robert Lamb <rlamb@instructure.com>
QA-Review: Robert Lamb <rlamb@instructure.com>
This commit is contained in:
Luke Kingsley 2018-07-03 15:09:38 -06:00
parent 2d901e43be
commit d355b0a7bd
3 changed files with 504 additions and 582 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,9 +20,6 @@ require 'spec/factories/course_factory'
require 'spec/factories/user_factory'
PactConfig::Consumers::ALL.each do |consumer|
# if consumer == 'Generic Consumer'
# next
# end
Pact.provider_states_for consumer do
set_up do

View File

@ -18,84 +18,30 @@
PactConfig::Consumers::ALL.each do |consumer|
Pact.provider_states_for consumer do
# Creates a student in a course with a discussion.
# Possible API endpoints: get, put and delete
# Used by the spec: 'List Discussions'
# Teacher ID: 3 || Name: Teacher1
# Course ID: 1
# Discussion ID: 1
provider_state 'a student in a course with a discussion' do
set_up do
course_with_teacher(active_all: true, name: 'User_Teacher')
@course = Pact::Canvas.base_state.course
@teacher = Pact::Canvas.base_state.teachers.first
@course.discussion_topics.create!(title: "title", message: nil, user: @teacher, discussion_type: 'threaded')
end
end
# Creates a student in a course with a quiz.
# Possible API endpoints: get, put and delete
# Used by the spec: 'List Quizzes'
# Course ID: 1
# Quizzes ID: 1
provider_state 'a quiz in a course' do
set_up do
course_with_teacher(active_all: true, name: 'User_Teacher')
@course.quizzes.create(title:'Test Quiz', description: 'Its a Quiz figure it out', due_at: 'Whenever')
@course = Pact::Canvas.base_state.course
@course.quizzes.create(title:'Test Quiz', description: 'Its a Quiz figure it out', due_at: 'Whenever')
end
end
# Creates a student in a course.
# Possible API endpoints: get and post.
# Used by the spec: 'List Courses' 'List Students' 'List To Do Count for User'
provider_state 'a student in a course' do
set_up do
course_with_student(active_all: true, name: 'User_Student')
@teacher.name = 'User_Teacher'
@teacher.save!
end
end
# Creates a teacher in a course.
# Possible API endpoints: get, post, delete and put
# Used by the spec: 'Post Assignments' 'List Teachers' 'Delete a Course'
provider_state 'a teacher in a course' do
set_up do
course_with_teacher(active_all: true, name: 'User_Teacher')
Pseudonym.create!(user: @teacher, unique_id: 'testuser@instructure.com')
end
end
# Creates a ta in a course.
# Possible API endpoints: get, post, delete and put
# Used by the spec: 'List TAs'
provider_state 'a ta in a course' do
set_up do
course_with_ta(active_all: true, name: 'User_TA')
Pseudonym.create!(user: @ta, unique_id: 'testuser@instructure.com')
end
end
# Creates an observer in a course.
# Possible API endpoints: get, post, delete and put
# Used by the spec: 'List Observers'
provider_state 'an observer in a course' do
set_up do
course_with_observer(active_all: true)
teach = User.create!(name: 'User_Teacher')
@course.enroll_user(teach, 'TeacherEnrollment')
end
end
# Creates an admin in a course.
# Possible API endpoints: get, post, put, delete.
# Used by the spec: 'Create a Course' 'Update a Course'
provider_state 'an admin in a course' do
set_up do
@admin = account_admin_user(name: 'User_Admin')
@course = course_model
end
end
# Creates a course with multiple sections.
# Possible API endpoints: get, post, put, delete.
# Used by the spec:
# Course ID: 1
provider_state 'multiple sections in a course' do
set_up do
course_with_teacher(active_all: true, name: 'User_Teacher')
@course = Pact::Canvas.base_state.course
add_section("section1", @course)
add_section("section2", @course)
add_section("section3", @course)
@ -103,32 +49,31 @@ PactConfig::Consumers::ALL.each do |consumer|
end
end
# Creates a course with a wiki page.
# Possible API endpoints: get, post, put, delete.
# Used by the spec: 'List Wiki Pages'
# Course ID: 1
# Wiki Page ID: 1
provider_state 'a wiki page in a course' do
set_up do
course_with_teacher(active_all: true, name: 'User_Teacher')
@course = Pact::Canvas.base_state.course
@course.wiki_pages.create!(title: "wiki_page")
end
end
# Creates a student in a course with a submitted assignment.
# Possible API endpoints: get, put, delete.
# Used by the spec:
# Student ID: 5 || Name: Student1
# Course ID: 1
# Quizzes ID: 1
provider_state 'a student in a course with a submitted assignment' do
set_up do
course_with_student_and_submitted_homework(name: 'User_Student')
Pseudonym.create!(user: @teacher, unique_id: 'testuser@instructure.com')
@student = Pact::Canvas.base_state.students.first
@course = Pact::Canvas.base_state.course
@assignment = @course.assignments.create!({ title: "some assignment", submission_types: "online_url,online_upload" })
@submission = @assignment.submit_homework(@student, { submission_type: "online_url", url: "http://www.google.com" })
end
end
# Creates a student in a course with a missing assignment.
# Possible API endpoints: get, put, delete.
# Used by the spec:
# Course ID: 1
provider_state 'a student in a course with a missing assignment' do
set_up do
course_with_student(name: 'User_Student')
@course = Pact::Canvas.base_state.course
Assignment.create!(context: @course, title: "Missing Assignment", due_at: Time.zone.now - 2)
end
end