Add self_registration_type to terms of service api

fixes MBL-14696
flag = none

test plan:
- disable self registration for an account
- hit /api/v1/accounts/:accountID/terms_of_service
  - self_registration_type should be 'none'
- allow self registration for All account types
- hit /api/v1/accounts/:accountID/terms_of_service
  - self_registration_type should be 'all'
- allow self registration for Observer accounts only
- hit /api/v1/accounts/:accountID/terms_of_service
  - self_registration_type should be 'observer'

Change-Id: I68007f96b5e53da31cd6c9951d968a8156d2c4e9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/246291
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
QA-Review: August Thornton <august@instructure.com>
This commit is contained in:
Nate Armstrong 2020-08-27 17:12:36 -06:00
parent 25a83f3cff
commit 636bcefd3f
2 changed files with 27 additions and 0 deletions

View File

@ -136,6 +136,11 @@ require 'csv'
# "description": "Content of the Terms of Service",
# "example": "To be or not to be that is the question",
# "type": "string"
# },
# "self_registration_type": {
# "description": "The type of self registration allowed",
# "example": ["none", "observer", "all"],
# "type": "string"
# }
# }
# }
@ -448,6 +453,7 @@ class AccountsController < ApplicationController
tos = @account.root_account.terms_of_service
res = tos.attributes.slice(*keys)
res['content'] = tos.terms_of_service_content&.content
res['self_registration_type'] = @account.self_registration_type
render :json => res
end

View File

@ -920,6 +920,27 @@ describe AccountsController do
expect(response).to be_successful
expect(response.body).to match(/\"content\":\"custom content\"/)
end
it "should return default self_registration_type" do
@account.update_terms_of_service(terms_type: "custom", content: "custom content")
remove_user_session
get 'terms_of_service', params: {account_id: @account.id}
expect(response).to be_successful
expect(response.body).to match(/\"self_registration_type\":\"none\"/)
end
it "should return other self_registration_type" do
@account.update_terms_of_service(terms_type: "custom", content: "custom content")
@account.canvas_authentication_provider.update_attribute(:self_registration, 'observer')
remove_user_session
get 'terms_of_service', params: {account_id: @account.id}
expect(response).to be_successful
expect(response.body).to match(/\"self_registration_type\":\"observer\"/)
end
end
describe "help links" do