spec: Add discussion spec
Test Plan 1. Pass Jenkins Change-Id: Idac4ee9f19ca639e8d7316d19132a078a944e1ce Reviewed-on: https://gerrit.instructure.com/156796 Tested-by: Jenkins Reviewed-by: Robert Lamb <rlamb@instructure.com> Product-Review: Robert Lamb <rlamb@instructure.com> QA-Review: Robert Lamb <rlamb@instructure.com>
This commit is contained in:
parent
bbaa102b5f
commit
9b3f78b563
|
@ -96,5 +96,38 @@ describe 'Discussions', :pact do
|
|||
expect(response[0]['id']).to eq 1
|
||||
expect(response[0]['title']).to eq 'No Title'
|
||||
end
|
||||
|
||||
it 'should Post Discussion' do
|
||||
canvas_lms_api.given('a teacher enrolled in a course').
|
||||
upon_receiving('Post Discussion').
|
||||
with(
|
||||
method: :post,
|
||||
headers: {
|
||||
'Authorization': 'Bearer some_token',
|
||||
'Auth-User': 'Teacher1',
|
||||
'Connection': 'close',
|
||||
'Host': PactConfig.mock_provider_service_base_uri,
|
||||
'Version': 'HTTP/1.1',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
'path' => '/api/v1/courses/1/discussion_topics',
|
||||
'body' =>
|
||||
{
|
||||
'discussion_topic':
|
||||
{
|
||||
'title': 'New Discussion'
|
||||
}
|
||||
},
|
||||
query: ''
|
||||
).
|
||||
will_respond_with(
|
||||
status: 200,
|
||||
body: Pact.like('id': 1, 'title': 'New Discussion')
|
||||
)
|
||||
discussions_api.authenticate_as_user('Teacher1')
|
||||
response = discussions_api.post_discussion(1, 'New Discussion')
|
||||
expect(response['id']).to eq 1
|
||||
expect(response['title']).to eq 'New Discussion'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -31,6 +31,24 @@ module Helper
|
|||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
def post_discussion(course_id, discussion_name)
|
||||
JSON.parse(
|
||||
self.class.post(
|
||||
"/api/v1/courses/#{course_id}/discussion_topics",
|
||||
:body =>
|
||||
{
|
||||
:discussion_topic =>
|
||||
{
|
||||
:title => discussion_name
|
||||
}
|
||||
}.to_json,
|
||||
:headers => {'Content-Type' => 'application/json'}
|
||||
).body
|
||||
)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue