Created
November 8, 2014 19:12
-
-
Save tcoulter/d8f9fa0ec4737612264f to your computer and use it in GitHub Desktop.
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
describe Api::V2::FolderController do | |
# Create an organization, a user, and populate that organization with a folder. | |
let!(:organization) { ... } | |
let!(:folder) { ..., parent: organization } | |
let!(:user) { ..., email: "realuser@company.com" } | |
describe "folder api" do | |
let(:path) { ... } # Path to api call | |
context "payload as external user" do | |
let!(:other_user) { ..., email: "somebody@nobody.com" } | |
let!(:private_folder_one) { ..., parent: organization } | |
let!(:private_folder_two) { ..., parent: organization } | |
# Setup and preconditions | |
before(:each) do | |
# Ensure our preconditions are correct (or else, why run the test?) | |
expect(organization.projects.size).to eq 3 | |
# Make one folder public | |
folder.is_public = true | |
folder.save! | |
# Add the first user (the real user) as an admin on the organization. | |
# Remember: the external user isn't part of the organization. | |
organization.add_admin user | |
Api::V2::BaseController.any_instance.stub(:current_user) { other_user } | |
get path | |
end | |
# Actual test | |
it "returns only public folders" do | |
# Assert that we only respond with one folder. | |
expect(last_response.body).to have_json_size(1).at_path("organizations/folders") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment