|
|
|
@ -1,23 +1,37 @@
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
require_relative '../../lib/cartodb/central'
|
|
|
|
|
|
|
|
|
|
def config_present?
|
|
|
|
|
Cartodb.config[:cartodb_central_api].present? &&
|
|
|
|
|
Cartodb.config[:cartodb_central_api]['username'].present? &&
|
|
|
|
|
Cartodb.config[:cartodb_central_api]['password'].present?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe Cartodb::Central do
|
|
|
|
|
|
|
|
|
|
before(:all) do
|
|
|
|
|
@organization = create_organization_with_users(name: 'test-org')
|
|
|
|
|
@user = @organization.users.first
|
|
|
|
|
@user.username = 'user1'
|
|
|
|
|
@user.save
|
|
|
|
|
@cartodb_central_client = Cartodb::Central.new
|
|
|
|
|
@org_path = "/api/organizations/#{ @organization.name }"
|
|
|
|
|
@users_path = "#{ @org_path }/users"
|
|
|
|
|
@user_path = "#{ @users_path }/#{ @user.username }"
|
|
|
|
|
if config_present?
|
|
|
|
|
@organization = create_organization_with_users(name: 'test-org')
|
|
|
|
|
@user = @organization.users.first
|
|
|
|
|
@user.username = 'user1'
|
|
|
|
|
@user.save
|
|
|
|
|
@cartodb_central_client = Cartodb::Central.new
|
|
|
|
|
@org_path = "/api/organizations/#{ @organization.name }"
|
|
|
|
|
@users_path = "#{ @org_path }/users"
|
|
|
|
|
@user_path = "#{ @users_path }/#{ @user.username }"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
after(:all) do
|
|
|
|
|
@user.destroy
|
|
|
|
|
@user && @user.destroy
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Central synchronization client" do
|
|
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
|
pending "Central API credentials not present in app_config.yml" unless config_present?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Organization users" do
|
|
|
|
|
it "gets all users from an organization" do
|
|
|
|
|
request = @cartodb_central_client.build_request(@users_path, nil, :get)
|
|
|
|
|