Sha256: cb316b7a10cc6f90bf85af8fb980ba0addc2f5c90f0c10f4a4eb85ea33a85d26

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8

# Global requires
require 'multi_json'

# Local requires
require 'gooddata/models/models'

require_relative '../environment/environment'

GoodData::Environment.load

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

    ENVIRONMENT = 'TESTING'

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

    def self.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 self.create_random_user(client)
      num = rand(1e7)
      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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooddata-0.6.20 spec/helpers/project_helper.rb
gooddata-0.6.19 spec/helpers/project_helper.rb