spec: Refactor wiki page spec
Test Plan: 1. Pass Jenkins Change-Id: I3f87bb6e429bf244ecdf8d4dabe7edd6367d8fb7 Reviewed-on: https://gerrit.instructure.com/156655 Tested-by: Jenkins Reviewed-by: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Luke Kingsley <lkingsley@instructure.com> QA-Review: Luke Kingsley <lkingsley@instructure.com>
This commit is contained in:
parent
6e2d127d8d
commit
49cf468a73
|
@ -317,42 +317,6 @@ describe 'Courses', :pact do
|
|||
expect(response['delete']).to eq true
|
||||
end
|
||||
|
||||
it 'Should List Wiki Pages' do
|
||||
canvas_lms_api.given('a wiki page in a course').
|
||||
upon_receiving('List Wiki Pages').
|
||||
with(
|
||||
method: :get,
|
||||
headers: {
|
||||
'Authorization': 'Bearer some_token',
|
||||
'Auth-User': 'Teacher1',
|
||||
'Connection': 'close',
|
||||
'Host': PactConfig.mock_provider_service_base_uri,
|
||||
'Version': 'HTTP/1.1'
|
||||
},
|
||||
'path' => '/api/v1/courses/1/pages/',
|
||||
query: ''
|
||||
).
|
||||
will_respond_with(
|
||||
status: 200,
|
||||
body: Pact.each_like(
|
||||
"title": "WIKI Page",
|
||||
"created_at": "2018-05-30T22:50:18Z",
|
||||
"url": "wiki-page",
|
||||
"editing_roles": "teachers",
|
||||
"page_id": 1,
|
||||
"published": true,
|
||||
"hide_from_students": false,
|
||||
"front_page": false,
|
||||
"html_url": "http://localhost:3000/courses/3/pages/wiki-page",
|
||||
"updated_at": "2018-05-30T22:50:18Z",
|
||||
"locked_for_user": false
|
||||
)
|
||||
)
|
||||
courses_api.authenticate_as_user('Teacher1')
|
||||
response = courses_api.list_wiki_pages(1)
|
||||
expect(response[0]['title']).to eq "WIKI Page"
|
||||
end
|
||||
|
||||
it 'should Create a Course' do
|
||||
canvas_lms_api.given('a site admin').
|
||||
upon_receiving('Create a Course').
|
||||
|
|
|
@ -33,12 +33,6 @@ module Helper
|
|||
nil
|
||||
end
|
||||
|
||||
def list_wiki_pages(course_id)
|
||||
JSON.parse(self.class.get("/api/v1/courses/#{course_id}/pages/").body)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
def list_quizzes(course_id)
|
||||
JSON.parse(self.class.get("/api/v1/courses/#{course_id}/quizzes").body)
|
||||
rescue
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require 'httparty'
|
||||
require 'json'
|
||||
require_relative '../../../pact_config'
|
||||
require_relative '../api_client_base'
|
||||
|
||||
module Helper
|
||||
module ApiClient
|
||||
class WikiPages < ApiClientBase
|
||||
include HTTParty
|
||||
base_uri PactConfig.mock_provider_service_base_uri
|
||||
headers 'Authorization' => 'Bearer some_token'
|
||||
|
||||
def list_wiki_pages(course_id)
|
||||
JSON.parse(self.class.get("/api/v1/courses/#{course_id}/pages/").body)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,59 @@
|
|||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_relative 'helper'
|
||||
require_relative '../pact_helper'
|
||||
|
||||
describe 'Wiki Pages', :pact do
|
||||
subject(:wiki_page_api) { Helper::ApiClient::WikiPages.new }
|
||||
|
||||
it 'should List Wiki Pages' do
|
||||
canvas_lms_api.given('a wiki page in a course').
|
||||
upon_receiving('List Wiki Pages').
|
||||
with(
|
||||
method: :get,
|
||||
headers: {
|
||||
'Authorization': 'Bearer some_token',
|
||||
'Auth-User': 'Teacher1',
|
||||
'Connection': 'close',
|
||||
'Host': PactConfig.mock_provider_service_base_uri,
|
||||
'Version': 'HTTP/1.1'
|
||||
},
|
||||
'path' => '/api/v1/courses/1/pages/',
|
||||
query: ''
|
||||
).
|
||||
will_respond_with(
|
||||
status: 200,
|
||||
body: Pact.each_like(
|
||||
"title": "WIKI Page",
|
||||
"created_at": "2018-05-30T22:50:18Z",
|
||||
"url": "wiki-page",
|
||||
"editing_roles": "teachers",
|
||||
"page_id": 1,
|
||||
"published": true,
|
||||
"hide_from_students": false,
|
||||
"front_page": false,
|
||||
"html_url": "http://localhost:3000/courses/3/pages/wiki-page",
|
||||
"updated_at": "2018-05-30T22:50:18Z",
|
||||
"locked_for_user": false
|
||||
)
|
||||
)
|
||||
wiki_page_api.authenticate_as_user('Teacher1')
|
||||
response = wiki_page_api.list_wiki_pages(1)
|
||||
expect(response[0]['title']).to eq "WIKI Page"
|
||||
end
|
||||
end
|
|
@ -38,15 +38,6 @@ PactConfig::Consumers::ALL.each do |consumer|
|
|||
end
|
||||
end
|
||||
|
||||
# Course ID: 1
|
||||
# Wiki Page ID: 1
|
||||
provider_state 'a wiki page in a course' do
|
||||
set_up do
|
||||
@course = Pact::Canvas.base_state.course
|
||||
@course.wiki_pages.create!(title: "wiki_page")
|
||||
end
|
||||
end
|
||||
|
||||
# Student ID: 5 || Name: Student1
|
||||
# Course ID: 1
|
||||
# Quizzes ID: 1
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
PactConfig::Consumers::ALL.each do |consumer|
|
||||
Pact.provider_states_for consumer do
|
||||
|
||||
# Course ID: 1
|
||||
# Wiki Page ID: 1
|
||||
provider_state 'a wiki page in a course' do
|
||||
set_up do
|
||||
@course = Pact::Canvas.base_state.course
|
||||
@course.wiki_pages.create!(title: "wiki_page")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue