Add Assignment created/updated_at to the API

closes CNVS-13682

Test Plan:
- Ensure there is a assignment in your test instance
- Request the assignment from the API
- The API response should include the created_at and updated_at elements
  in the returned JSON

Change-Id: Ib3067c9b204be95aa890d783de629162f4cc01f9
Reviewed-on: https://gerrit.instructure.com/36625
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cameron Sutter <csutter@instructure.com>
Product-Review: Tyler Pickett <tpickett+gerrit@instructure.com>
QA-Review: Anna Koalenz <akoalenz@instructure.com>
This commit is contained in:
Tyler Pickett 2014-06-18 21:03:21 -06:00
parent 9b960aae30
commit 30b3640197
5 changed files with 19 additions and 7 deletions

View File

@ -213,6 +213,16 @@
# "example": "<p>Do the following:</p>...",
# "type": "string"
# },
# "created_at": {
# "description": "The time at which this assignment was originally created",
# "example": "2012-07-01T23:59:00-06:00",
# "type": "datetime"
# },
# "updated_at": {
# "description": "The time at which this assignment was last modified in any way",
# "example": "2012-07-01T23:59:00-06:00",
# "type": "datetime"
# },
# "due_at": {
# "description": "the due date for the assignment. returns null if not present. NOTE: If this assignment has assignment overrides, this field will be the due date as it applies to the user requesting information from the API.",
# "example": "2012-07-01T23:59:00-06:00",

View File

@ -29,6 +29,8 @@ module Api::V1::Assignment
description
points_possible
grading_type
created_at
updated_at
due_at
lock_at
unlock_at

View File

@ -197,6 +197,7 @@ describe AssignmentGroupsController, type: :request do
override.due_at = 1.day.ago
override.due_at_overridden = true
end
a1.reload
json = api_call(:get,
"/api/v1/courses/#{@course.id}/assignment_groups.json?include[]=assignments&include[]=all_dates",

View File

@ -268,6 +268,8 @@ describe UsersController, type: :request do
@assignment.reload
assign_json = assignment_json(@assignment, @user, session,
include_discussion_topic: false)
assign_json['created_at'] = @assignment.created_at.as_json
assign_json['updated_at'] = @assignment.updated_at.as_json
assign_json['title'] = @assignment.title
json.should == [{
'id' => StreamItem.last.id,
@ -367,6 +369,8 @@ describe UsersController, type: :request do
@assignment.reload
assign_json = assignment_json(@assignment, @user, session,
include_discussion_topic: false)
assign_json['created_at'] = @assignment.created_at.as_json
assign_json['updated_at'] = @assignment.updated_at.as_json
assign_json['title'] = @assignment.title
json.should == [{
'id' => StreamItem.last.id,

View File

@ -344,13 +344,8 @@ describe AssignmentsController do
course_with_teacher_logged_in(:active_all => true)
course_assignment
get 'edit', :course_id => @course.id, :id => @assignment.id
expected_assignment_json = subject.send(:assignment_json, @assignment,
assigns[:current_user], session)
expected_assignment_json[:has_submitted_submissions] = @assignment.has_submitted_submissions?
assigns[:js_env][:ASSIGNMENT].should == expected_assignment_json
assigns[:js_env][:ASSIGNMENT_OVERRIDES].should ==
subject.send(:assignment_overrides_json,
AssignmentOverrideApplicator.overrides_for_assignment_and_user(@assignment, assigns[:current_user]))
assigns[:js_env][:ASSIGNMENT]['id'].should == @assignment.id
assigns[:js_env][:ASSIGNMENT_OVERRIDES].should == []
end
end