spec: add discussion spec
Added a post response test Test Plan 1. Pass Jenkins Change-Id: I45cb5288b8131f02b0e4bc5886d0ec9880704970 Reviewed-on: https://gerrit.instructure.com/157178 Tested-by: Jenkins Reviewed-by: Anju Reddy <areddy@instructure.com> Product-Review: Luke Kingsley <lkingsley@instructure.com> QA-Review: Luke Kingsley <lkingsley@instructure.com>
This commit is contained in:
parent
e1a58a0239
commit
74598eacea
|
@ -158,5 +158,53 @@ describe 'Discussions', :pact do
|
||||||
expect(response['id']).to eq 1
|
expect(response['id']).to eq 1
|
||||||
expect(response['title']).to eq 'New Discussion'
|
expect(response['title']).to eq 'New Discussion'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should Post a Discussion Response' do
|
||||||
|
canvas_lms_api.given('a teacher in a course with a discussion').
|
||||||
|
upon_receiving('Post a Discussion Response').
|
||||||
|
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/1/entries',
|
||||||
|
'body' =>
|
||||||
|
{
|
||||||
|
'message': 'Great Discussion!'
|
||||||
|
},
|
||||||
|
query: ''
|
||||||
|
).
|
||||||
|
will_respond_with(
|
||||||
|
status: 201,
|
||||||
|
body: Pact.like(
|
||||||
|
"id": 1,
|
||||||
|
"user_id": 7,
|
||||||
|
"parent_id": nil,
|
||||||
|
"created_at": "2018-07-12T17:55:37Z",
|
||||||
|
"updated_at": "2018-07-12T17:55:37Z",
|
||||||
|
"rating_count": nil,
|
||||||
|
"rating_sum": nil,
|
||||||
|
"user_name": "T1",
|
||||||
|
"message": "Great Discussion!",
|
||||||
|
"user": {
|
||||||
|
"id": 7,
|
||||||
|
"display_name": "T1",
|
||||||
|
"avatar_image_url": "http://canvas.instructure.com/images/messages/avatar-50.png",
|
||||||
|
"html_url": "http://localhost:3000/courses/3/users/7"
|
||||||
|
},
|
||||||
|
"read_state": "read",
|
||||||
|
"forced_read_state": false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
discussions_api.authenticate_as_user('Teacher1')
|
||||||
|
response = discussions_api.post_discussion_response(1, 1, 'Great Discussion!')
|
||||||
|
expect(response['id']).to eq 1
|
||||||
|
expect(response['message']).to eq 'Great Discussion!'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,22 @@ module Helper
|
||||||
}
|
}
|
||||||
}.to_json,
|
}.to_json,
|
||||||
:headers => {'Content-Type' => 'application/json'}
|
:headers => {'Content-Type' => 'application/json'}
|
||||||
).body
|
).body
|
||||||
|
)
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_discussion_response(course_id, topic_id, discussion_response)
|
||||||
|
JSON.parse(
|
||||||
|
self.class.post(
|
||||||
|
"/api/v1/courses/#{course_id}/discussion_topics/#{topic_id}/entries",
|
||||||
|
:body =>
|
||||||
|
{
|
||||||
|
:message => discussion_response
|
||||||
|
}.to_json,
|
||||||
|
:headers => {'Content-Type' => 'application/json'}
|
||||||
|
).body
|
||||||
)
|
)
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
|
|
Loading…
Reference in New Issue