import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-03-05 00:38:40 +08:00
|
|
|
describe Quizzes::QuizSerializer do
|
2014-03-05 00:33:05 +08:00
|
|
|
|
|
|
|
def quiz_serializer(options={})
|
|
|
|
options.reverse_merge!({
|
|
|
|
controller: controller,
|
|
|
|
scope: @user,
|
|
|
|
session: @session
|
|
|
|
})
|
|
|
|
Quizzes::QuizSerializer.new(@quiz, options)
|
|
|
|
end
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
let(:quiz) { @quiz }
|
|
|
|
let(:context ) { @context }
|
|
|
|
let(:serializer) { @serializer }
|
|
|
|
let(:host_name) { 'example.com' }
|
|
|
|
let(:json) { @json }
|
|
|
|
let(:session) { @session }
|
|
|
|
let(:controller) do
|
|
|
|
ActiveModel::FakeController.new(accepts_jsonapi: true, stringify_json_ids: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
@context = Course.new
|
|
|
|
@context.id = 1
|
2014-01-15 06:11:27 +08:00
|
|
|
@quiz = Quizzes::Quiz.new title: 'test quiz'
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
@quiz.id = 1
|
|
|
|
@quiz.context = @context
|
|
|
|
@user = User.new
|
|
|
|
@quiz.stubs(:locked_for?).returns false
|
|
|
|
@quiz.stubs(:grants_right?).returns true
|
2014-02-25 04:42:19 +08:00
|
|
|
@session = stub(:[] => nil)
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
controller.stubs(:session).returns session
|
|
|
|
controller.stubs(:context).returns context
|
2014-01-24 00:23:26 +08:00
|
|
|
@quiz.stubs(:grants_right?).at_least_once.returns true
|
2014-03-05 00:33:05 +08:00
|
|
|
@serializer = quiz_serializer
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
@json = @serializer.as_json[:quiz]
|
|
|
|
end
|
|
|
|
|
|
|
|
[
|
|
|
|
:title, :description, :quiz_type, :hide_results,
|
|
|
|
:time_limit, :shuffle_answers, :show_correct_answers, :scoring_policy,
|
|
|
|
:allowed_attempts, :one_question_at_a_time, :question_count,
|
|
|
|
:points_possible, :cant_go_back, :access_code, :ip_filter, :due_at,
|
|
|
|
:lock_at, :unlock_at, :published, :show_correct_answers_at,
|
|
|
|
:hide_correct_answers_at
|
|
|
|
].each do |attribute|
|
|
|
|
|
|
|
|
it "serializes #{attribute}" do
|
|
|
|
json[attribute].should == quiz.send(attribute)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "serializes mobile_url" do
|
2014-01-15 06:11:27 +08:00
|
|
|
json[:mobile_url].should == 'http://example.com/courses/1/quizzes/1?force_user=1&persist_headless=1'
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "serializes html_url" do
|
2014-01-15 06:11:27 +08:00
|
|
|
json[:html_url].should == 'http://example.com/courses/1/quizzes/1'
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
end
|
|
|
|
|
2014-02-14 05:27:11 +08:00
|
|
|
it "serializes speed_grader_url" do
|
|
|
|
# No assignment, so it should be nil
|
|
|
|
json[:speed_grader_url].should be_nil
|
|
|
|
assignment = Assignment.new
|
|
|
|
assignment.id = 1
|
|
|
|
assignment.context_id = @context.id
|
|
|
|
@quiz.stubs(:assignment).returns assignment
|
|
|
|
|
|
|
|
# nil when quiz is unpublished
|
|
|
|
@quiz.stubs(:published?).returns false
|
|
|
|
@serializer.as_json[:quiz][:speed_grader_url].should be_nil
|
|
|
|
|
|
|
|
# nil when context doesn't allow speedgrader
|
|
|
|
@quiz.stubs(:published?).returns true
|
|
|
|
@context.expects(:allows_speed_grader?).returns false
|
|
|
|
@serializer.as_json[:quiz][:speed_grader_url].should be_nil
|
|
|
|
|
|
|
|
@context.expects(:allows_speed_grader?).returns true
|
|
|
|
json = @serializer.as_json[:quiz]
|
|
|
|
json[:speed_grader_url].should ==
|
|
|
|
controller.send(:speed_grader_course_gradebook_url, @quiz.context, assignment_id: @quiz.assignment.id)
|
|
|
|
|
|
|
|
# Students shouldn't be able to see speed_grader_url
|
|
|
|
@quiz.stubs(:grants_right?).returns false
|
|
|
|
@serializer.as_json[:quiz].should_not have_key :speed_grader_url
|
|
|
|
end
|
|
|
|
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
it "doesn't include the access code unless the user can grade" do
|
|
|
|
quiz.expects(:grants_right?).with(@user, @session, :grade).
|
|
|
|
at_least_once.returns true
|
|
|
|
serializer.as_json[:quiz].should have_key :access_code
|
|
|
|
|
|
|
|
quiz.expects(:grants_right?).with(@user, @session, :grade).
|
|
|
|
at_least_once.returns false
|
|
|
|
serializer.as_json[:quiz].should_not have_key :access_code
|
|
|
|
end
|
|
|
|
|
2014-05-13 13:34:48 +08:00
|
|
|
it "doesn't include the section count unless the user can grade" do
|
|
|
|
quiz.expects(:grants_right?).with(@user, @session, :grade).
|
|
|
|
at_least_once.returns true
|
|
|
|
serializer.as_json[:quiz].should have_key :section_count
|
|
|
|
|
|
|
|
quiz.expects(:grants_right?).with(@user, @session, :grade).
|
|
|
|
at_least_once.returns false
|
|
|
|
serializer.as_json[:quiz].should_not have_key :section_count
|
|
|
|
end
|
|
|
|
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
it "uses available_question_count for question_count" do
|
|
|
|
quiz.stubs(:available_question_count).returns 5
|
|
|
|
serializer.as_json[:quiz][:question_count].should == 5
|
|
|
|
end
|
|
|
|
|
2014-03-05 00:33:05 +08:00
|
|
|
it "sends the message_students_url when user can grade" do
|
|
|
|
quiz.expects(:grants_right?).at_least_once.returns true
|
|
|
|
serializer.as_json[:quiz][:message_students_url].should ==
|
|
|
|
controller.send(:api_v1_course_quiz_submission_users_message_url, quiz, quiz.context)
|
|
|
|
|
|
|
|
quiz.expects(:grants_right?).at_least_once.returns false
|
|
|
|
serializer.as_json[:quiz].should_not have_key :message_students_url
|
|
|
|
end
|
|
|
|
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
describe "id" do
|
|
|
|
|
|
|
|
it "stringifys when stringify_json_ids? is true" do
|
|
|
|
controller.expects(:accepts_jsonapi?).at_least_once.returns false
|
|
|
|
controller.expects(:stringify_json_ids?).at_least_once.returns true
|
|
|
|
serializer.as_json[:quiz][:id].should == quiz.id.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
it "when stringify_json_ids? is false" do
|
|
|
|
controller.expects(:accepts_jsonapi?).at_least_once.returns false
|
|
|
|
serializer.as_json[:quiz][:id].should == quiz.id
|
|
|
|
serializer.as_json[:quiz][:id].is_a?(Fixnum).should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "lock_info" do
|
|
|
|
it "includes lock_info when appropriate" do
|
|
|
|
quiz.expects(:locked_for?).
|
|
|
|
with(@user, check_policies: true, context: @context).
|
|
|
|
returns({due_at: true})
|
2014-03-05 00:33:05 +08:00
|
|
|
json = quiz_serializer.as_json[:quiz]
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
json.should have_key :lock_info
|
|
|
|
json.should have_key :lock_explanation
|
|
|
|
json[:locked_for_user].should == true
|
|
|
|
|
|
|
|
quiz.expects(:locked_for?).
|
|
|
|
with(@user, check_policies: true, context: @context).
|
|
|
|
returns false
|
2014-03-05 00:33:05 +08:00
|
|
|
json = quiz_serializer.as_json[:quiz]
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
json.should_not have_key :lock_info
|
|
|
|
json.should_not have_key :lock_explanation
|
|
|
|
json[:locked_for_user].should == false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "unpublishable" do
|
|
|
|
|
|
|
|
it "is not present unless the user can manage the quiz's assignments" do
|
|
|
|
quiz.expects(:grants_right?).with(@user, session, :manage).returns true
|
2014-01-24 00:23:26 +08:00
|
|
|
serializer.filter(serializer.class._attributes).should include :unpublishable
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
quiz.unstub(:grants_right?)
|
|
|
|
quiz.expects(:grants_right?).with(@user, session, :grade).at_least_once.returns false
|
|
|
|
quiz.expects(:grants_right?).with(@user, session, :manage).at_least_once.returns false
|
2014-01-24 00:23:26 +08:00
|
|
|
serializer.filter(serializer.class._attributes).should_not include :unpublishable
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-15 08:22:39 +08:00
|
|
|
describe "takeable" do
|
|
|
|
|
|
|
|
before do
|
|
|
|
course_with_teacher_logged_in(active_all: true)
|
|
|
|
course_quiz(true)
|
|
|
|
quiz_with_graded_submission([], user: @teacher, quiz: @quiz)
|
|
|
|
@serializer = quiz_serializer(quiz_submissions: { @quiz.id => @quiz_submission })
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is true when there is no quiz submision" do
|
|
|
|
Quizzes::QuizSubmission.delete_all
|
|
|
|
quiz_serializer.as_json[:quiz][:takeable].should == true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is true when quiz_submission is present but not completed" do
|
|
|
|
@quiz_submission.workflow_state = "settings_only"
|
|
|
|
@serializer.as_json[:quiz][:takeable].should == true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is true when the quiz submission is completed but quiz has unlimited attempts" do
|
|
|
|
@quiz_submission.workflow_state = "complete"
|
|
|
|
@quiz.allowed_attempts = -1
|
|
|
|
@serializer.as_json[:quiz][:takeable].should == true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is true when quiz submission is completed, !quiz.unlimited_attempts" do
|
|
|
|
@quiz_submission.workflow_state = "complete"
|
|
|
|
@quiz.allowed_attempts = 2
|
|
|
|
# false when attempts left attempts is 0
|
|
|
|
@quiz_submission.expects(:attempts_left).at_least_once.returns 0
|
|
|
|
@serializer.as_json[:quiz][:takeable].should == false
|
|
|
|
# true when than attempts left greater than 0
|
|
|
|
@quiz_submission.expects(:attempts_left).at_least_once.returns 1
|
|
|
|
@serializer.as_json[:quiz][:takeable].should == true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
describe "links" do
|
|
|
|
|
|
|
|
describe "assignment_group" do
|
|
|
|
|
|
|
|
context "controller accepts_jsonapi?" do
|
|
|
|
|
|
|
|
it "serialize the assignment group's url when present" do
|
|
|
|
@quiz.stubs(:context).returns course = Course.new
|
|
|
|
course.id = 1
|
|
|
|
@quiz.assignment_group = assignment_group = AssignmentGroup.new
|
|
|
|
assignment_group.id = 1
|
2014-01-11 05:37:21 +08:00
|
|
|
serializer.as_json[:quiz]['links']['assignment_group'].should ==
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
controller.send(:api_v1_course_assignment_group_url, course.id,
|
|
|
|
assignment_group.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't serialize the assignment group's url if not present" do
|
|
|
|
serializer.as_json[:quiz].should_not have_key(:links)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "controller doesn't accept jsonapi" do
|
|
|
|
|
|
|
|
it "serialized the assignment_group as assignment_group_id" do
|
|
|
|
controller.expects(:accepts_jsonapi?).at_least_once.returns false
|
|
|
|
serializer.as_json[:quiz]['assignment_group_id'].should be_nil
|
|
|
|
|
|
|
|
group = quiz.assignment_group = AssignmentGroup.new
|
|
|
|
group.id = 1
|
|
|
|
serializer.as_json[:quiz]['assignment_group_id'].should == 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-02-25 04:42:19 +08:00
|
|
|
|
2014-05-08 05:23:56 +08:00
|
|
|
describe "student_quiz_submissions" do
|
2014-02-25 04:42:19 +08:00
|
|
|
|
|
|
|
it "sends the url for all submissions when user may grade" do
|
|
|
|
course_with_teacher_logged_in(active_all: true)
|
|
|
|
quiz_with_graded_submission([], course: @course)
|
2014-03-05 00:33:05 +08:00
|
|
|
serializer = quiz_serializer(scope: @teacher)
|
2014-05-08 05:23:56 +08:00
|
|
|
serializer.as_json[:quiz]['links']['student_quiz_submissions'].should ==
|
2014-02-25 04:42:19 +08:00
|
|
|
controller.send(:api_v1_course_quiz_submissions_url, @quiz.context.id, @quiz.id)
|
|
|
|
end
|
|
|
|
|
2014-05-08 05:23:56 +08:00
|
|
|
it "sends nil unless the user can grade" do
|
2014-02-25 04:42:19 +08:00
|
|
|
course_with_student_logged_in(active_all: true)
|
|
|
|
quiz_with_graded_submission([], user: @student, course: @course)
|
2014-03-05 00:33:05 +08:00
|
|
|
serializer = quiz_serializer(scope: @student)
|
2014-05-08 05:23:56 +08:00
|
|
|
serializer.as_json[:quiz]['links']['student_quiz_submissions'].should be_nil
|
2014-02-25 04:42:19 +08:00
|
|
|
end
|
2014-05-08 05:23:56 +08:00
|
|
|
end
|
2014-02-25 04:42:19 +08:00
|
|
|
|
2014-05-08 05:23:56 +08:00
|
|
|
describe "quiz_submission" do
|
|
|
|
it "includes the quiz_submission in the response if it is present" do
|
2014-02-25 04:42:19 +08:00
|
|
|
course_with_student_logged_in(active_all: true)
|
2014-05-08 05:23:56 +08:00
|
|
|
quiz_with_graded_submission([], user: @student, course: @course)
|
2014-03-05 00:33:05 +08:00
|
|
|
serializer = quiz_serializer(scope: @student)
|
2014-05-08 05:23:56 +08:00
|
|
|
json = serializer.as_json
|
|
|
|
json['quiz_submissions'].length.should == 1
|
|
|
|
json[:quiz]['links']['quiz_submission'].should == @quiz_submission.id.to_s
|
2014-02-25 04:42:19 +08:00
|
|
|
end
|
|
|
|
end
|
Quiz Reports API - Index
An endpoint for retrieving all quiz reports for a given quiz.
Closes CNVS-12172
CHANGES
-------
The biggest effort in this patch was to normalize the way QuizReport
objects are interfaced with, and the generation of their CSV attachments
in particular:
- Quiz#current_statistics_for() now ALWAYS returns a persisted object
while still considering the freshness of the stats
- Quiz#statistics_csv() is no longer responsible for testing whether
the attachment should be generated or not, but instead ensures
that the CSV will be generated ASAP
- QuizStatistics#generate_csv() now guards against generating multiple
attachments
- QuizStatistics#generate_csv_in_background() now guards against
queueing multiple generation jobs (by testing the status of the
Progress object)
QuizReport API changes:
- new property: "generatable"
- new property: "readable_type"
- new property: "url"
- now accepts JSON-API format for all endpoints:
- JSON-API allows you to embed file and progress objects directly in
the QuizReport document, just pass ?include=file,progress
Quizzes API changes:
- new property (JSON): "quiz_reports_url"
- new property (JSON-API): "links.quiz_reports"
Some AMS changes:
- added support for accepting side-loading requests from controllers
by passing an :includes array to the serializer initializer
- added support for embedding objects in root, using `embed: :object
and embed_in_root: true` for has_one associations
- also, in that same scenario, AMS's default behavior is to wrap
single objects (has_one) in an array, which didn't work for me, so I
added a new option called "wrap_in_array" which you can set to false
when defining the association to override this behavior
Other changes:
- covered the front-end/javascript that utilizes the reports and
allows teachers to generate them
- QuizReport in the front-end no longer relies on magical course_id
exposed in window.ENV, but instead uses its URL to construct the
generation URL (see QuizReport#baseURL)
- Attachment now has a shallow-AMSerializer that proxies to the legacy
one in lib/api/v1 which allows us to at least side-load them
- Progress now has an AMS
- QuizReport legacy serializer in lib/api/v1 removed entirely,
replaced by the new AMS one
TEST PLAN
---- ----
Endpoint: [GET] /api/v1/courses/:course_id/quizzes/:quiz_id/reports
- as a teacher, make a request to the endpoint above:
- it should return a set of two quiz report objects
- add a parameter "includes_all_versions=true" to the query parameters
and verify that the "student_analysis" report in the returned set
now reflects the new value (the reports have a field called
"includes_all_versions" which should be true in this case, false
otherwise)
- as a student, make the request and verify that it rejects you
Endpoint: [GET] /api/v1/courses/:course_id/quizzes/:quiz_id/reports/:id
- turn on JSON-API mode
- as a teacher:
- don't generate the report from the UI yet
- make the request, and verify that you get only the report
- generate
- repeat the request, verify that you still get only the report
- add a ?include=file query parameter
- you should read the file document now
- add a ?include=progress query parameter
- you should read the progress document now
- turn off JSON-API mode
- as a teacher:
- make the request, and verify you get the "progress_url" field and
that the file document is embedded automatically without having to
specify the ?include= parameter
Front-end testing:
- go to the statistics page
- generate all reports:
- verify that the progress bar updates
- verify that you can download them
- verify that auto-download occurs unless you refresh the page
before the report is generated
- toggle on the "Count All Attempts" button and repeat the above:
- verify that Item Analysis is not generatable anymore since it's
not affected by that parameter
Please note that "item_analysis" reports will always have
"includes_all_versions" as true.
Change-Id: I0dc6d5108cbcef78b2fa17ba0476f470d33d402d
Reviewed-on: https://gerrit.instructure.com/32731
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-04-02 12:52:00 +08:00
|
|
|
|
|
|
|
describe 'quiz_reports' do
|
|
|
|
it 'sends the url' do
|
|
|
|
quiz.stubs(context: Course.new.tap { |c| c.id = 3 })
|
|
|
|
serializer.as_json[:quiz]['links']['quiz_reports'].should ==
|
|
|
|
controller.send(:api_v1_course_quiz_reports_url, 3, quiz.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sends the url as quiz_reports_url' do
|
|
|
|
controller.expects(:accepts_jsonapi?).at_least_once.returns false
|
|
|
|
quiz.stubs(context: Course.new.tap { |c| c.id = 3 })
|
|
|
|
serializer.as_json[:quiz][:quiz_reports_url].should ==
|
|
|
|
controller.send(:api_v1_course_quiz_reports_url, 3, quiz.id)
|
|
|
|
end
|
|
|
|
end
|
2014-03-03 21:00:35 +08:00
|
|
|
|
|
|
|
describe "quiz_statistics" do
|
|
|
|
it "sends the url" do
|
|
|
|
quiz.stubs(context: Course.new.tap { |c| c.id = 3 })
|
|
|
|
serializer.as_json[:quiz]['links']['quiz_statistics'].should ==
|
|
|
|
controller.send(:api_v1_course_quiz_statistics_url, 3, quiz.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sends the url in non-JSONAPI too" do
|
|
|
|
controller.expects(:accepts_jsonapi?).at_least_once.returns false
|
|
|
|
quiz.stubs(context: Course.new.tap { |c| c.id = 3 })
|
|
|
|
serializer.as_json[:quiz][:quiz_statistics_url].should ==
|
|
|
|
controller.send(:api_v1_course_quiz_statistics_url, 3, quiz.id)
|
|
|
|
end
|
|
|
|
end
|
2014-03-05 00:33:05 +08:00
|
|
|
|
|
|
|
describe "submitted_students" do
|
|
|
|
|
|
|
|
it "sends nil if user can't grade" do
|
|
|
|
course_with_student_logged_in(active_all: true)
|
|
|
|
@quiz.unstub(:grants_right?)
|
|
|
|
serializer = quiz_serializer(scope: @student)
|
|
|
|
serializer.as_json[:quiz]['links'].should_not have_key 'unsubmitted_students'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sends a url if there are submissions and user can grade" do
|
|
|
|
course_with_teacher_logged_in(active_all: true)
|
|
|
|
course_with_student_logged_in(active_all: true, course: @course)
|
|
|
|
quiz_with_graded_submission([], user: @student, course: @course)
|
|
|
|
serializer = quiz_serializer(scope: @teacher)
|
|
|
|
serializer.as_json[:quiz]['links']['submitted_students'].
|
|
|
|
should == controller.send(:api_v1_course_quiz_submission_users_url,
|
|
|
|
@quiz.context,
|
|
|
|
@quiz,
|
|
|
|
submitted: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "unsubmitted_students" do
|
|
|
|
|
|
|
|
it "sends nil if user can't grade" do
|
|
|
|
@quiz.unstub(:grants_right?)
|
|
|
|
course_with_student_logged_in(active_all: true)
|
|
|
|
serializer = quiz_serializer(scope: @student)
|
|
|
|
serializer.as_json[:quiz]['links'].should_not have_key 'unsubmitted_students'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sends a url if there are submissions and user can grade" do
|
|
|
|
course_with_teacher_logged_in(active_all: true)
|
|
|
|
course_with_student_logged_in(active_all: true, course: @course)
|
|
|
|
course_with_student_logged_in(active_all: true, course: @course)
|
|
|
|
quiz_with_graded_submission([], user: @student, course: @course)
|
|
|
|
serializer = quiz_serializer(scope: @teacher)
|
|
|
|
serializer.as_json[:quiz]['links']['unsubmitted_students'].
|
|
|
|
should == controller.send(:api_v1_course_quiz_submission_users_url,
|
|
|
|
@quiz.context,
|
|
|
|
@quiz,
|
|
|
|
submitted: 'false')
|
|
|
|
end
|
|
|
|
end
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
end
|
|
|
|
|
2014-04-18 03:54:20 +08:00
|
|
|
describe "quiz_submission_html_url" do
|
|
|
|
it "includes a url to the quiz_submission html only if JSONAPI request" do
|
|
|
|
serializer.as_json[:quiz][:quiz_submission_html_url].should ==
|
|
|
|
controller.send(:course_quiz_submission_html_url, context.id, quiz.id)
|
|
|
|
controller.expects(:accepts_jsonapi?).at_least_once.returns false
|
|
|
|
serializer.as_json[:quiz].should_not have_key :quiz_submission_html_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-24 00:23:26 +08:00
|
|
|
describe "permissions" do
|
|
|
|
it "serializes permissions" do
|
|
|
|
serializer.as_json[:quiz][:permissions].should == {
|
|
|
|
read: true,
|
|
|
|
submit: true,
|
|
|
|
review_grades: true,
|
|
|
|
create: true,
|
|
|
|
update: true,
|
|
|
|
read_statistics: true,
|
|
|
|
manage: true,
|
|
|
|
delete: true,
|
|
|
|
grade: true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2014-02-13 17:23:06 +08:00
|
|
|
|
|
|
|
it 'displays overridden dates for students' do
|
2014-02-12 06:11:25 +08:00
|
|
|
course_with_student_logged_in(active_all: true)
|
|
|
|
course_quiz(true)
|
|
|
|
serializer = quiz_serializer(scope: @student)
|
2014-02-13 17:23:06 +08:00
|
|
|
student_overrides = {
|
|
|
|
due_at: 5.minutes.from_now,
|
|
|
|
lock_at: nil,
|
|
|
|
unlock_at: 3.minutes.from_now
|
|
|
|
}
|
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
serializer.stubs(:due_dates).returns [student_overrides]
|
2014-02-13 17:23:06 +08:00
|
|
|
|
|
|
|
output = serializer.as_json[:quiz]
|
|
|
|
output.should_not have_key :all_dates
|
|
|
|
|
|
|
|
[ :due_at, :lock_at, :unlock_at ].each do |key|
|
|
|
|
output[key].should == student_overrides[key]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays quiz dates for students if not overridden' do
|
2014-02-12 06:11:25 +08:00
|
|
|
student_overrides = []
|
|
|
|
|
2014-02-13 17:23:06 +08:00
|
|
|
quiz.expects(:due_at).at_least_once.returns 5.minutes.from_now
|
|
|
|
quiz.expects(:lock_at).at_least_once.returns nil
|
|
|
|
quiz.expects(:unlock_at).at_least_once.returns 3.minutes.from_now
|
2014-02-12 06:11:25 +08:00
|
|
|
serializer.stubs(:due_dates).returns student_overrides
|
2014-02-13 17:23:06 +08:00
|
|
|
|
|
|
|
output = serializer.as_json[:quiz]
|
|
|
|
|
|
|
|
[ :due_at, :lock_at, :unlock_at ].each do |key|
|
|
|
|
output[key].should == quiz.send(key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes all_dates for teachers and observers' do
|
|
|
|
quiz.due_at = 1.hour.from_now
|
|
|
|
|
|
|
|
teacher_overrides = [{
|
|
|
|
due_at: quiz.due_at,
|
|
|
|
lock_at: nil,
|
|
|
|
unlock_at: nil,
|
|
|
|
base: true
|
|
|
|
}, {
|
|
|
|
due_at: 30.minutes.from_now,
|
|
|
|
lock_at: 1.hour.from_now,
|
|
|
|
unlock_at: 10.minutes.from_now,
|
|
|
|
title: 'Some Section'
|
|
|
|
}]
|
|
|
|
|
|
|
|
quiz.expects(:due_at).at_least_once
|
2014-02-12 06:11:25 +08:00
|
|
|
serializer.stubs(:all_dates).returns teacher_overrides
|
|
|
|
serializer.stubs(:include_all_dates?).returns true
|
2014-02-13 17:23:06 +08:00
|
|
|
|
|
|
|
output = serializer.as_json[:quiz]
|
|
|
|
output.should have_key :all_dates
|
|
|
|
output[:all_dates].length.should == 2
|
|
|
|
output[:all_dates].detect { |e| e[:base] }.should == teacher_overrides[0]
|
|
|
|
output[:all_dates].detect { |e| !e[:base] }.should == teacher_overrides[1]
|
|
|
|
output[:due_at].should == quiz.due_at
|
|
|
|
end
|
|
|
|
|
import ActiveModel::Serializers port and convert quizzes api to it
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-05 03:06:32 +08:00
|
|
|
end
|