This repository has been archived by the owner on May 2, 2020. It is now read-only.
forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint to list all external tool collaborations
Fixes PLAT-1556 Test Plan: - Create a collaboration in the context of a course. The collaboration_type should be 'external_tool_collaboration' This should be done via rails console or something similar as creation of these new types of collaborations is not complete - Hit /api/v1/courses/<course_id>/collaborations and notice that your newly created collaboration will show up and should include a field called user_name that has the creating users name - Try accessing the endpoint as a non member of the collaboration - you should not see the collaboration - Create another collaboration in the context of a group - As a member of the group hit /api/v1/groups/<group_id>/collaborations and notice the newly create collaboration will show up and should include a field called user_name that has the creating users name Change-Id: I06045fa4bfa25722c3c790d4b7ff493098ec2670 Reviewed-on: https://gerrit.instructure.com/80235 Reviewed-by: Steven Burnett <[email protected]> Tested-by: Jenkins QA-Review: Deepeeca Soundarrajan <[email protected]> Product-Review: Matthew Sessions <[email protected]>
- Loading branch information
Matthew Sessions
committed
Jun 6, 2016
1 parent
48a8970
commit 5b8173a
Showing
8 changed files
with
222 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (C) 2016 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/>. | ||
# | ||
|
||
module Api::V1::Collaboration | ||
include Api::V1::Json | ||
|
||
def collaboration_json(collaboration, current_user, session) | ||
attribute_whitelist = %w{id collaboration_type document_id user_id context_id context_type url created_at updated_at description title} | ||
api_json(collaboration, current_user, session, :only => attribute_whitelist).tap do |hash| | ||
hash['user_name'] = collaboration.user[:name] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,3 @@ def collaborator_json(collaborator, current_user, session) | |
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# Copyright (C) 2016 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 File.expand_path(File.dirname(__FILE__) + '/../api_spec_helper') | ||
|
||
include Api::V1::Collaboration | ||
|
||
describe Api::V1::Collaboration do | ||
before(:once) do | ||
@current_user = user_with_pseudonym(:active_all => true) | ||
@collaboration = Collaboration.new(:title => 'Test collaboration', | ||
:description => 'Let us collaborate', | ||
:collaboration_type => 'external_tool_collaboration', | ||
:url => 'https://google.com', | ||
:user => @current_user) | ||
@collaboration.save! | ||
end | ||
|
||
it 'should properly serialize' do | ||
json = collaboration_json(@collaboration, @current_user, nil) | ||
|
||
expect(json['id']).to eq @collaboration.id | ||
expect(json['collaboration_type']).to eq @collaboration.collaboration_type | ||
expect(json['document_id']).to eq @collaboration.document_id | ||
expect(json['user_id']).to eq @collaboration.user_id | ||
expect(json['context_id']).to eq @collaboration.context_id | ||
expect(json['context_type']).to eq @collaboration.context_type | ||
expect(json['url']).to eq @collaboration.url | ||
expect(json['created_at']).to eq @collaboration.created_at | ||
expect(json['updated_at']).to eq @collaboration.updated_at | ||
expect(json['title']).to eq @collaboration.title | ||
expect(json['description']).to eq @collaboration.description | ||
|
||
expect(json['data']).to eq nil | ||
expect(json['deleted_at']).to eq nil | ||
end | ||
|
||
it 'should includes the owning users name' do | ||
json = collaboration_json(@collaboration, @current_user, nil) | ||
|
||
expect(json['user_name']).to eq @current_user.name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters