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 'text_helper'
|
|
|
|
require 'canvas/lock_explanation'
|
|
|
|
require 'active_model_serializers'
|
|
|
|
require 'action_controller'
|
|
|
|
require 'active_support'
|
|
|
|
require 'active_record'
|
|
|
|
require 'mocha/api'
|
|
|
|
require 'api'
|
|
|
|
|
|
|
|
# You can include just this file if your serializer doesn't need too much
|
|
|
|
# from the whole stack to run your tests faster!
|
|
|
|
|
|
|
|
module ActiveModel
|
|
|
|
class FakeController
|
|
|
|
if CANVAS_RAILS2
|
|
|
|
include ActionController::PolymorphicRoutes
|
|
|
|
include ActionController::UrlWriter
|
|
|
|
self.default_url_options[:host] = 'example.com'
|
|
|
|
else
|
|
|
|
include Rails.application.routes.url_helpers
|
|
|
|
def default_url_options
|
|
|
|
{ host: 'example.com' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
attr_accessor :accepts_jsonapi, :stringify_json_ids, :session, :context
|
|
|
|
|
|
|
|
def initialize(options={})
|
|
|
|
@accepts_jsonapi = options.fetch(:accepts_jsonapi, true)
|
|
|
|
@stringify_json_ids = options.fetch(:stringify_json_ids, true)
|
|
|
|
@session = options[:session]
|
|
|
|
@context = options[:context]
|
|
|
|
end
|
|
|
|
|
|
|
|
def accepts_jsonapi?
|
|
|
|
!!accepts_jsonapi
|
|
|
|
end
|
|
|
|
|
|
|
|
def stringify_json_ids?
|
|
|
|
!!stringify_json_ids
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-11 05:37:21 +08:00
|
|
|
require File.expand_path(File.dirname(__FILE__)) + '/../app/serializers/canvas/api_serialization.rb'
|
|
|
|
require File.expand_path(File.dirname(__FILE__)) + '/../app/serializers/canvas/api_serializer.rb'
|
|
|
|
require File.expand_path(File.dirname(__FILE__)) + '/../app/serializers/canvas/api_array_serializer.rb'
|
|
|
|
|
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
|
|
|
Dir[File.expand_path(File.dirname(__FILE__) + '/../app/serializers/*.rb')].each do |file|
|
|
|
|
require file
|
|
|
|
end
|