Sha256: b51daab07b88fc0c1d1fe8ca268c98870472144c79bffdc89425674f44e4ae51

Contents?: true

Size: 1.71 KB

Versions: 5

Compression:

Stored size: 1.71 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Global requires
require 'multi_json'

# Local requires
require 'gooddata/models/models'

require_relative '../environment/environment'

GoodData::Environment.load

module GoodData
  module Helpers
    module ProjectHelper
      include GoodData::Environment::ProjectHelper

      ENVIRONMENT = 'TESTING'

      class << self
        def get_default_project(opts = { :client => GoodData.connection })
          GoodData::Project[GoodData::Helpers::ProjectHelper::PROJECT_ID, opts]
        end

        def delete_old_projects(opts = { :client => GoodData.connection })
          projects = opts[:client].projects
          projects.each do |project|
            next if project.json['project']['meta']['author'] != client.user.uri
            next if project.pid == 'we1vvh4il93r0927r809i3agif50d7iz'
            begin
              puts "Deleting project #{project.title}"
              project.delete
            rescue e
              puts 'ERROR: ' + e.to_s
            end
          end
        end

        def create_random_user(client, opts = {})
          num = rand(1e7)
          login = opts[:login] || "gemtest#{num}@gooddata.com"

          opts = {
            email: login,
            login: login,
            first_name: 'the',
            last_name: num.to_s,
            role: 'editor',
            password: CryptoHelper.generate_password,
            domain: ConnectionHelper::DEFAULT_DOMAIN
          }
          GoodData::Membership.create(opts, client: client)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gooddata-0.6.54 spec/helpers/project_helper.rb
gooddata-0.6.53 spec/helpers/project_helper.rb
gooddata-0.6.52 spec/helpers/project_helper.rb
gooddata-0.6.51 spec/helpers/project_helper.rb
gooddata-0.6.50 spec/helpers/project_helper.rb