add course uuid to api response

closes OUT-1317

Test plan:
1.  Create a course in Canvas
2.  Visit
      domain.canvas/api/v1/courses/<course_id>
3.  Verify that "uuid" field is present in JSON
    response

Change-Id: I4a504061a0af55ce635be13e71fa873abd88748c
Reviewed-on: https://gerrit.instructure.com/114839
Tested-by: Jenkins
Reviewed-by: Matt Berns <mberns@instructure.com>
QA-Review: Leo Abner <rabner@instructure.com>
Product-Review: Michael Brewer-Davis <mbd@instructure.com>
This commit is contained in:
Michael Brewer-Davis 2017-06-08 20:31:33 -05:00
parent 8d3d156d05
commit 346fa6f0b9
5 changed files with 18 additions and 7 deletions

View File

@ -88,6 +88,11 @@ require 'securerandom'
# "description": "the SIS identifier for the course, if defined. This field is only included if the user has permission to view SIS information.",
# "type": "string"
# },
# "uuid": {
# "description": "the UUID of the course",
# "example": "WvAHhY5FINzq5IyRIJybGeiXyFkG3SqHUPb7jZY5",
# "type": "string"
# },
# "integration_id": {
# "description": "the integration identifier for the course, if defined. This field is only included if the user has permission to view SIS information.",
# "type": "string"

View File

@ -75,7 +75,8 @@ module Api::V1::Course
# "hide_final_grades" => false,
# "apply_assignment_group_weights" => false,
# "calendar" => { "ics" => "http://localhost:3000/feeds/calendars/course_Y6uXZZPu965ziva2pqI7c0QR9v1yu2QZk9X0do2D.ics" },
# "permissions" => { :create_discussion_topic => true }
# "permissions" => { :create_discussion_topic => true },
# "uuid" => "WvAHhY5FINzq5IyRIJybGeiXyFkG3SqHUPb7jZY5"
# }
#
def course_json(course, user, session, includes, enrollments)

View File

@ -19,7 +19,7 @@ module Api::V1
class CourseJson
BASE_ATTRIBUTES = %w(id name course_code account_id start_at default_view enrollment_term_id is_public
grading_standard_id root_account_id).freeze
grading_standard_id root_account_id uuid).freeze
INCLUDE_CHECKERS = {grading: 'needs_grading_count', syllabus: 'syllabus_body',
url: 'html_url', description: 'public_description', permissions: 'permissions'}.freeze

View File

@ -552,7 +552,8 @@ describe CoursesController, type: :request do
expect(new_course.time_zone.tzinfo.name).to eql 'America/Juneau'
course_response.merge!(
'id' => new_course.id,
'calendar' => { 'ics' => "http://www.example.com/feeds/calendars/course_#{new_course.uuid}.ics" }
'calendar' => { 'ics' => "http://www.example.com/feeds/calendars/course_#{new_course.uuid}.ics" },
'uuid' => new_course.uuid
)
course_response.delete 'term_id' #not included in the response
expect(json).to eql course_response
@ -603,7 +604,8 @@ describe CoursesController, type: :request do
expect(new_course.enrollment_term_id).to eql term.id
course_response.merge!(
'id' => new_course.id,
'calendar' => { 'ics' => "http://www.example.com/feeds/calendars/course_#{new_course.uuid}.ics" }
'calendar' => { 'ics' => "http://www.example.com/feeds/calendars/course_#{new_course.uuid}.ics" },
'uuid' => new_course.uuid
)
expect(json).to eql course_response
end
@ -2825,7 +2827,8 @@ describe CoursesController, type: :request do
'apply_assignment_group_weights' => false,
'enrollment_term_id' => @course.enrollment_term_id,
'restrict_enrollments_to_course_dates' => false,
'time_zone' => 'America/Los_Angeles'
'time_zone' => 'America/Los_Angeles',
'uuid' => @course1.uuid
})
end

View File

@ -441,7 +441,8 @@ describe UsersController, type: :request do
'storage_quota_mb' => @course.storage_quota_mb,
'apply_assignment_group_weights' => false,
'restrict_enrollments_to_course_dates' => false,
'time_zone' => 'America/Denver'
'time_zone' => 'America/Denver',
'uuid' => @course.uuid
},
'user' => {
@ -558,7 +559,8 @@ describe UsersController, type: :request do
'storage_quota_mb' => @course.storage_quota_mb,
'apply_assignment_group_weights' => false,
'restrict_enrollments_to_course_dates' => false,
'time_zone' => 'America/Denver'
'time_zone' => 'America/Denver',
'uuid' => @course.uuid
},
'user' => {