add support for specifying domain root account to api spec helper
test plan: n/a Change-Id: I8e45bc88d9bcbea29b9ede3be0431487ee4e3cf8 Reviewed-on: https://gerrit.instructure.com/7428 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
parent
43c5f0e835
commit
61c8670bc3
|
@ -4,13 +4,15 @@ class LoadAccount
|
|||
end
|
||||
|
||||
def call(env)
|
||||
domain_root_account = Account.default
|
||||
domain_root_account = LoadAccount.default_domain_root_account
|
||||
configure_for_root_account(domain_root_account)
|
||||
|
||||
env['canvas.domain_root_account'] = domain_root_account
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
def self.default_domain_root_account; Account.default; end
|
||||
|
||||
protected
|
||||
|
||||
def configure_for_root_account(domain_root_account)
|
||||
|
|
|
@ -33,8 +33,8 @@ end
|
|||
# params generated by the Rails routing engine. body_params are params in a
|
||||
# PUT/POST that are included in the body rather than the URI, and therefore
|
||||
# don't affect routing.
|
||||
def api_call(method, path, params, body_params = {}, headers = {})
|
||||
raw_api_call(method, path, params, body_params, headers)
|
||||
def api_call(method, path, params, body_params = {}, headers = {}, opts = {})
|
||||
raw_api_call(method, path, params, body_params, headers, opts)
|
||||
response.should be_success, response.body
|
||||
case params[:format]
|
||||
when 'json'
|
||||
|
@ -56,7 +56,7 @@ def api_call(method, path, params, body_params = {}, headers = {})
|
|||
end
|
||||
|
||||
# like api_call, but don't assume success and a json response.
|
||||
def raw_api_call(method, path, params, body_params = {}, headers = {})
|
||||
def raw_api_call(method, path, params, body_params = {}, headers = {}, opts = {})
|
||||
path = path.sub(%r{\Ahttps?://[^/]+}, '') # remove protocol+host
|
||||
enable_forgery_protection do
|
||||
params_from_with_nesting(method, path).should == params
|
||||
|
@ -67,6 +67,8 @@ def raw_api_call(method, path, params, body_params = {}, headers = {})
|
|||
params[:access_token] = token.token
|
||||
end
|
||||
|
||||
LoadAccount.stubs(:default_domain_root_account).returns(opts[:domain_root_account]) if opts.has_key?(:domain_root_account)
|
||||
|
||||
__send__(method, path, params.reject { |k,v| %w(controller action).include?(k.to_s) }.merge(body_params), headers)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue