gooddata-edge 0.6.27.edge
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +36 -0
- data/.rspec +3 -0
- data/.rubocop.yml +89 -0
- data/.yardopts +22 -0
- data/CHANGELOG.md +196 -0
- data/CLI.md +439 -0
- data/DEPENDENCIES.md +817 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE +22 -0
- data/LICENSE.rb +5 -0
- data/README.md +75 -0
- data/Rakefile +179 -0
- data/TODO.md +32 -0
- data/authors.sh +4 -0
- data/bin/gooddata +7 -0
- data/dependency_decisions.yml +104 -0
- data/gooddata +9 -0
- data/gooddata.gemspec +63 -0
- data/lib/gooddata.rb +31 -0
- data/lib/gooddata/app/app.rb +16 -0
- data/lib/gooddata/bricks/base_downloader.rb +86 -0
- data/lib/gooddata/bricks/brick.rb +38 -0
- data/lib/gooddata/bricks/bricks.rb +15 -0
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +29 -0
- data/lib/gooddata/bricks/middleware/base_middleware.rb +56 -0
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +24 -0
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +37 -0
- data/lib/gooddata/bricks/middleware/decode_params_middleware.rb +20 -0
- data/lib/gooddata/bricks/middleware/fs_download_middleware.rb +48 -0
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +36 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +39 -0
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +29 -0
- data/lib/gooddata/bricks/middleware/middleware.rb +12 -0
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +61 -0
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +23 -0
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +29 -0
- data/lib/gooddata/bricks/middleware/undot_params_middleware.rb +37 -0
- data/lib/gooddata/bricks/pipeline.rb +32 -0
- data/lib/gooddata/bricks/utils.rb +18 -0
- data/lib/gooddata/cli/cli.rb +27 -0
- data/lib/gooddata/cli/commands/auth_cmd.rb +29 -0
- data/lib/gooddata/cli/commands/domain_cmd.rb +28 -0
- data/lib/gooddata/cli/commands/project_cmd.rb +45 -0
- data/lib/gooddata/cli/hooks.rb +57 -0
- data/lib/gooddata/cli/shared.rb +61 -0
- data/lib/gooddata/cli/terminal.rb +20 -0
- data/lib/gooddata/client.rb +67 -0
- data/lib/gooddata/commands/api.rb +64 -0
- data/lib/gooddata/commands/auth.rb +107 -0
- data/lib/gooddata/commands/base.rb +12 -0
- data/lib/gooddata/commands/commands.rb +12 -0
- data/lib/gooddata/commands/datasets.rb +148 -0
- data/lib/gooddata/commands/datawarehouse.rb +20 -0
- data/lib/gooddata/commands/domain.rb +40 -0
- data/lib/gooddata/commands/process.rb +67 -0
- data/lib/gooddata/commands/project.rb +175 -0
- data/lib/gooddata/commands/projects.rb +20 -0
- data/lib/gooddata/commands/role.rb +36 -0
- data/lib/gooddata/commands/runners.rb +47 -0
- data/lib/gooddata/commands/scaffold.rb +69 -0
- data/lib/gooddata/commands/user.rb +39 -0
- data/lib/gooddata/connection.rb +127 -0
- data/lib/gooddata/core/core.rb +12 -0
- data/lib/gooddata/core/logging.rb +105 -0
- data/lib/gooddata/core/nil_logger.rb +23 -0
- data/lib/gooddata/core/project.rb +74 -0
- data/lib/gooddata/core/rest.rb +149 -0
- data/lib/gooddata/core/user.rb +20 -0
- data/lib/gooddata/data/data.rb +12 -0
- data/lib/gooddata/data/guesser.rb +122 -0
- data/lib/gooddata/exceptions/attr_element_not_found.rb +16 -0
- data/lib/gooddata/exceptions/command_failed.rb +11 -0
- data/lib/gooddata/exceptions/exceptions.rb +12 -0
- data/lib/gooddata/exceptions/execution_limit_exceeded.rb +13 -0
- data/lib/gooddata/exceptions/filter_maqlization.rb +16 -0
- data/lib/gooddata/exceptions/malformed_user.rb +15 -0
- data/lib/gooddata/exceptions/no_project_error.rb +15 -0
- data/lib/gooddata/exceptions/object_migration.rb +32 -0
- data/lib/gooddata/exceptions/project_not_found.rb +13 -0
- data/lib/gooddata/exceptions/segment_not_empty.rb +18 -0
- data/lib/gooddata/exceptions/uncomputable_report.rb +13 -0
- data/lib/gooddata/exceptions/user_in_different_domain.rb +15 -0
- data/lib/gooddata/exceptions/validation_error.rb +16 -0
- data/lib/gooddata/extensions/big_decimal.rb +17 -0
- data/lib/gooddata/extensions/enumerable.rb +39 -0
- data/lib/gooddata/extensions/extensions.rb +10 -0
- data/lib/gooddata/extensions/false.rb +15 -0
- data/lib/gooddata/extensions/hash.rb +38 -0
- data/lib/gooddata/extensions/nil.rb +15 -0
- data/lib/gooddata/extensions/numeric.rb +15 -0
- data/lib/gooddata/extensions/object.rb +27 -0
- data/lib/gooddata/extensions/symbol.rb +15 -0
- data/lib/gooddata/extensions/true.rb +15 -0
- data/lib/gooddata/extract.rb +21 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +159 -0
- data/lib/gooddata/helpers/auth_helpers.rb +75 -0
- data/lib/gooddata/helpers/csv_helper.rb +61 -0
- data/lib/gooddata/helpers/data_helper.rb +116 -0
- data/lib/gooddata/helpers/global_helpers.rb +331 -0
- data/lib/gooddata/helpers/global_helpers_params.rb +172 -0
- data/lib/gooddata/helpers/helpers.rb +10 -0
- data/lib/gooddata/mixins/author.rb +26 -0
- data/lib/gooddata/mixins/content_getter.rb +15 -0
- data/lib/gooddata/mixins/content_property_reader.rb +17 -0
- data/lib/gooddata/mixins/content_property_writer.rb +17 -0
- data/lib/gooddata/mixins/contributor.rb +20 -0
- data/lib/gooddata/mixins/data_getter.rb +15 -0
- data/lib/gooddata/mixins/data_property_reader.rb +19 -0
- data/lib/gooddata/mixins/data_property_writer.rb +19 -0
- data/lib/gooddata/mixins/inspector.rb +53 -0
- data/lib/gooddata/mixins/is_attribute.rb +17 -0
- data/lib/gooddata/mixins/is_dimension.rb +17 -0
- data/lib/gooddata/mixins/is_fact.rb +17 -0
- data/lib/gooddata/mixins/is_label.rb +19 -0
- data/lib/gooddata/mixins/links.rb +15 -0
- data/lib/gooddata/mixins/md_finders.rb +77 -0
- data/lib/gooddata/mixins/md_grantees.rb +42 -0
- data/lib/gooddata/mixins/md_id_to_uri.rb +34 -0
- data/lib/gooddata/mixins/md_json.rb +15 -0
- data/lib/gooddata/mixins/md_lock.rb +87 -0
- data/lib/gooddata/mixins/md_object_id.rb +15 -0
- data/lib/gooddata/mixins/md_object_indexer.rb +64 -0
- data/lib/gooddata/mixins/md_object_query.rb +128 -0
- data/lib/gooddata/mixins/md_relations.rb +43 -0
- data/lib/gooddata/mixins/meta_getter.rb +17 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +19 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +19 -0
- data/lib/gooddata/mixins/mixins.rb +19 -0
- data/lib/gooddata/mixins/not_attribute.rb +17 -0
- data/lib/gooddata/mixins/not_exportable.rb +15 -0
- data/lib/gooddata/mixins/not_fact.rb +17 -0
- data/lib/gooddata/mixins/not_group.rb +17 -0
- data/lib/gooddata/mixins/not_label.rb +19 -0
- data/lib/gooddata/mixins/not_metric.rb +19 -0
- data/lib/gooddata/mixins/obj_id.rb +15 -0
- data/lib/gooddata/mixins/rest_getters.rb +17 -0
- data/lib/gooddata/mixins/rest_resource.rb +47 -0
- data/lib/gooddata/mixins/root_key_getter.rb +15 -0
- data/lib/gooddata/mixins/root_key_setter.rb +15 -0
- data/lib/gooddata/mixins/timestamps.rb +19 -0
- data/lib/gooddata/mixins/to_json.rb +11 -0
- data/lib/gooddata/mixins/uri_getter.rb +9 -0
- data/lib/gooddata/models/blueprint/anchor_field.rb +64 -0
- data/lib/gooddata/models/blueprint/attribute_field.rb +29 -0
- data/lib/gooddata/models/blueprint/blueprint.rb +11 -0
- data/lib/gooddata/models/blueprint/blueprint_field.rb +70 -0
- data/lib/gooddata/models/blueprint/dashboard_builder.rb +30 -0
- data/lib/gooddata/models/blueprint/dataset_blueprint.rb +449 -0
- data/lib/gooddata/models/blueprint/date_dimension.rb +14 -0
- data/lib/gooddata/models/blueprint/fact_field.rb +20 -0
- data/lib/gooddata/models/blueprint/label_field.rb +43 -0
- data/lib/gooddata/models/blueprint/project_blueprint.rb +746 -0
- data/lib/gooddata/models/blueprint/project_builder.rb +83 -0
- data/lib/gooddata/models/blueprint/reference_field.rb +43 -0
- data/lib/gooddata/models/blueprint/schema_blueprint.rb +160 -0
- data/lib/gooddata/models/blueprint/schema_builder.rb +89 -0
- data/lib/gooddata/models/blueprint/to_manifest.rb +181 -0
- data/lib/gooddata/models/blueprint/to_wire.rb +154 -0
- data/lib/gooddata/models/client.rb +182 -0
- data/lib/gooddata/models/client_synchronization_result.rb +31 -0
- data/lib/gooddata/models/client_synchronization_result_details.rb +41 -0
- data/lib/gooddata/models/datawarehouse.rb +92 -0
- data/lib/gooddata/models/domain.rb +479 -0
- data/lib/gooddata/models/execution.rb +115 -0
- data/lib/gooddata/models/execution_detail.rb +81 -0
- data/lib/gooddata/models/from_wire.rb +160 -0
- data/lib/gooddata/models/invitation.rb +75 -0
- data/lib/gooddata/models/links.rb +50 -0
- data/lib/gooddata/models/membership.rb +441 -0
- data/lib/gooddata/models/metadata.rb +272 -0
- data/lib/gooddata/models/metadata/attribute.rb +134 -0
- data/lib/gooddata/models/metadata/dashboard.rb +108 -0
- data/lib/gooddata/models/metadata/dashboard/dashboard_item.rb +76 -0
- data/lib/gooddata/models/metadata/dashboard/filter_apply_item.rb +37 -0
- data/lib/gooddata/models/metadata/dashboard/filter_item.rb +64 -0
- data/lib/gooddata/models/metadata/dashboard/geo_chart_item.rb +56 -0
- data/lib/gooddata/models/metadata/dashboard/headline_item.rb +56 -0
- data/lib/gooddata/models/metadata/dashboard/iframe_item.rb +46 -0
- data/lib/gooddata/models/metadata/dashboard/report_item.rb +92 -0
- data/lib/gooddata/models/metadata/dashboard/text_item.rb +55 -0
- data/lib/gooddata/models/metadata/dashboard_tab.rb +141 -0
- data/lib/gooddata/models/metadata/dataset.rb +64 -0
- data/lib/gooddata/models/metadata/dimension.rb +54 -0
- data/lib/gooddata/models/metadata/fact.rb +44 -0
- data/lib/gooddata/models/metadata/label.rb +128 -0
- data/lib/gooddata/models/metadata/metadata.rb +12 -0
- data/lib/gooddata/models/metadata/metric.rb +198 -0
- data/lib/gooddata/models/metadata/report.rb +247 -0
- data/lib/gooddata/models/metadata/report_definition.rb +264 -0
- data/lib/gooddata/models/metadata/scheduled_mail.rb +274 -0
- data/lib/gooddata/models/metadata/scheduled_mail/dashboard_attachment.rb +62 -0
- data/lib/gooddata/models/metadata/scheduled_mail/report_attachment.rb +64 -0
- data/lib/gooddata/models/metadata/variable.rb +91 -0
- data/lib/gooddata/models/model.rb +282 -0
- data/lib/gooddata/models/models.rb +12 -0
- data/lib/gooddata/models/module_constants.rb +31 -0
- data/lib/gooddata/models/process.rb +316 -0
- data/lib/gooddata/models/profile.rb +426 -0
- data/lib/gooddata/models/project.rb +1514 -0
- data/lib/gooddata/models/project_creator.rb +126 -0
- data/lib/gooddata/models/project_metadata.rb +67 -0
- data/lib/gooddata/models/project_role.rb +79 -0
- data/lib/gooddata/models/report_data_result.rb +266 -0
- data/lib/gooddata/models/schedule.rb +518 -0
- data/lib/gooddata/models/segment.rb +201 -0
- data/lib/gooddata/models/tab_builder.rb +27 -0
- data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +76 -0
- data/lib/gooddata/models/user_filters/user_filter.rb +100 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +512 -0
- data/lib/gooddata/models/user_filters/user_filters.rb +13 -0
- data/lib/gooddata/models/user_filters/variable_user_filter.rb +31 -0
- data/lib/gooddata/models/user_group.rb +241 -0
- data/lib/gooddata/rest/README.md +37 -0
- data/lib/gooddata/rest/client.rb +389 -0
- data/lib/gooddata/rest/connection.rb +765 -0
- data/lib/gooddata/rest/object.rb +69 -0
- data/lib/gooddata/rest/object_factory.rb +76 -0
- data/lib/gooddata/rest/resource.rb +27 -0
- data/lib/gooddata/rest/rest.rb +24 -0
- data/lib/gooddata/version.rb +23 -0
- data/lib/templates/bricks/brick.rb.erb +7 -0
- data/lib/templates/bricks/main.rb.erb +5 -0
- data/lib/templates/project/Goodfile.erb +4 -0
- data/lib/templates/project/data/commits.csv +4 -0
- data/lib/templates/project/data/devs.csv +4 -0
- data/lib/templates/project/data/repos.csv +3 -0
- data/lib/templates/project/model/model.rb.erb +20 -0
- data/spec/bricks/bricks_spec.rb +112 -0
- data/spec/bricks/default-config.json +8 -0
- data/spec/data/.gooddata +4 -0
- data/spec/data/blueprints/additional_dataset_module.json +32 -0
- data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
- data/spec/data/blueprints/invalid_blueprint.json +103 -0
- data/spec/data/blueprints/m_n_model.json +104 -0
- data/spec/data/blueprints/model_module.json +25 -0
- data/spec/data/blueprints/test_blueprint.json +38 -0
- data/spec/data/blueprints/test_project_model_spec.json +106 -0
- data/spec/data/cc/data/source/commits.csv +4 -0
- data/spec/data/cc/data/source/devs.csv +4 -0
- data/spec/data/cc/data/source/repos.csv +3 -0
- data/spec/data/cc/devel.prm +0 -0
- data/spec/data/cc/graph/graph.grf +11 -0
- data/spec/data/cc/workspace.prm +19 -0
- data/spec/data/column_based_permissions.csv +7 -0
- data/spec/data/column_based_permissions2.csv +6 -0
- data/spec/data/gd_gse_data_blueprint.json +1371 -0
- data/spec/data/gd_gse_data_manifest.json +1424 -0
- data/spec/data/gd_gse_data_model.json +1772 -0
- data/spec/data/gooddata_version_process/gooddata_version.rb +9 -0
- data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
- data/spec/data/hello_world_process/hello_world.rb +9 -0
- data/spec/data/hello_world_process/hello_world.zip +0 -0
- data/spec/data/line_based_permissions.csv +3 -0
- data/spec/data/manifests/test_blueprint.json +32 -0
- data/spec/data/manifests/test_project.json +107 -0
- data/spec/data/reports/left_attr_report.json +108 -0
- data/spec/data/reports/metric_only_one_line.json +83 -0
- data/spec/data/reports/report_1.json +197 -0
- data/spec/data/reports/top_attr_report.json +108 -0
- data/spec/data/ruby_params_process/ruby_params.rb +9 -0
- data/spec/data/ruby_process/deep_files/deep_stuff.txt +1 -0
- data/spec/data/ruby_process/process.rb +8 -0
- data/spec/data/ruby_process/stuff.txt +1 -0
- data/spec/data/superfluous_titles_view.json +81 -0
- data/spec/data/test-ci-data.csv +2 -0
- data/spec/data/users.csv +12 -0
- data/spec/data/wire_models/model_view.json +1775 -0
- data/spec/data/wire_models/nu_model.json +3046 -0
- data/spec/data/wire_models/test_blueprint.json +63 -0
- data/spec/data/wire_test_project.json +150 -0
- data/spec/environment/default.rb +41 -0
- data/spec/environment/develop.rb +31 -0
- data/spec/environment/environment.rb +18 -0
- data/spec/environment/hotfix.rb +21 -0
- data/spec/environment/production.rb +35 -0
- data/spec/environment/release.rb +21 -0
- data/spec/environment/staging.rb +30 -0
- data/spec/environment/staging_3.rb +36 -0
- data/spec/helpers/blueprint_helper.rb +26 -0
- data/spec/helpers/cli_helper.rb +36 -0
- data/spec/helpers/connection_helper.rb +41 -0
- data/spec/helpers/crypto_helper.rb +17 -0
- data/spec/helpers/csv_helper.rb +18 -0
- data/spec/helpers/process_helper.rb +33 -0
- data/spec/helpers/project_helper.rb +59 -0
- data/spec/helpers/schedule_helper.rb +31 -0
- data/spec/helpers/spec_helper.rb +15 -0
- data/spec/integration/blueprint_updates_spec.rb +101 -0
- data/spec/integration/blueprint_with_grain_spec.rb +72 -0
- data/spec/integration/clients_spec.rb +134 -0
- data/spec/integration/command_datawarehouse_spec.rb +39 -0
- data/spec/integration/command_projects_spec.rb +32 -0
- data/spec/integration/create_from_template_spec.rb +22 -0
- data/spec/integration/create_project_spec.rb +24 -0
- data/spec/integration/date_dim_switch_spec.rb +142 -0
- data/spec/integration/deprecated_load_spec.rb +58 -0
- data/spec/integration/full_process_schedule_spec.rb +298 -0
- data/spec/integration/full_project_spec.rb +569 -0
- data/spec/integration/over_to_user_filters_spec.rb +94 -0
- data/spec/integration/partial_md_export_import_spec.rb +42 -0
- data/spec/integration/project_spec.rb +264 -0
- data/spec/integration/rest_spec.rb +213 -0
- data/spec/integration/schedule_spec.rb +626 -0
- data/spec/integration/segments_spec.rb +141 -0
- data/spec/integration/user_filters_spec.rb +290 -0
- data/spec/integration/user_group_spec.rb +127 -0
- data/spec/integration/variables_spec.rb +188 -0
- data/spec/logging_in_logging_out_spec.rb +93 -0
- data/spec/spec_helper.rb +95 -0
- data/spec/unit/bricks/bricks_spec.rb +35 -0
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +51 -0
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +15 -0
- data/spec/unit/cli/cli_spec.rb +17 -0
- data/spec/unit/cli/commands/cmd_auth_spec.rb +17 -0
- data/spec/unit/commands/command_projects_spec.rb +22 -0
- data/spec/unit/core/connection_spec.rb +57 -0
- data/spec/unit/core/logging_spec.rb +133 -0
- data/spec/unit/core/nil_logger_spec.rb +13 -0
- data/spec/unit/core/project_spec.rb +54 -0
- data/spec/unit/extensions/hash_spec.rb +23 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +78 -0
- data/spec/unit/helpers/csv_helper_spec.rb +22 -0
- data/spec/unit/helpers/data_helper_spec.rb +61 -0
- data/spec/unit/helpers/global_helpers_spec.rb +111 -0
- data/spec/unit/helpers_spec.rb +86 -0
- data/spec/unit/models/blueprint/attributes_spec.rb +29 -0
- data/spec/unit/models/blueprint/dataset_spec.rb +121 -0
- data/spec/unit/models/blueprint/labels_spec.rb +44 -0
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +648 -0
- data/spec/unit/models/blueprint/reference_spec.rb +29 -0
- data/spec/unit/models/blueprint/schema_builder_spec.rb +38 -0
- data/spec/unit/models/blueprint/to_wire_spec.rb +174 -0
- data/spec/unit/models/domain_spec.rb +144 -0
- data/spec/unit/models/execution_spec.rb +108 -0
- data/spec/unit/models/from_wire_spec.rb +296 -0
- data/spec/unit/models/invitation_spec.rb +17 -0
- data/spec/unit/models/membership_spec.rb +132 -0
- data/spec/unit/models/metadata_spec.rb +104 -0
- data/spec/unit/models/metric_spec.rb +117 -0
- data/spec/unit/models/model_spec.rb +82 -0
- data/spec/unit/models/params_spec.rb +118 -0
- data/spec/unit/models/profile_spec.rb +215 -0
- data/spec/unit/models/project_creator_spec.rb +127 -0
- data/spec/unit/models/project_role_spec.rb +94 -0
- data/spec/unit/models/project_spec.rb +162 -0
- data/spec/unit/models/report_result_data_spec.rb +199 -0
- data/spec/unit/models/schedule_spec.rb +418 -0
- data/spec/unit/models/to_manifest_spec.rb +63 -0
- data/spec/unit/models/unit_project_spec.rb +125 -0
- data/spec/unit/models/user_filters_spec.rb +95 -0
- data/spec/unit/models/variable_spec.rb +265 -0
- data/spec/unit/rest/polling_spec.rb +89 -0
- data/spec/unit/rest/resource_spec.rb +10 -0
- data/yard-server.sh +3 -0
- metadata +1125 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
6
|
+
|
7
|
+
require 'gooddata/models/segment'
|
8
|
+
require 'securerandom'
|
9
|
+
|
10
|
+
describe GoodData::Segment do
|
11
|
+
TOKEN = 'mustangs'
|
12
|
+
|
13
|
+
before(:all) do
|
14
|
+
@client = GoodData.connect('mustang@gooddata.com', 'jindrisska', server: 'https://mustangs.intgdc.com', verify_ssl: false )
|
15
|
+
@domain = @client.domain('mustangs')
|
16
|
+
end
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
@uuid = SecureRandom.uuid
|
20
|
+
@master_project = @client.create_project(title: "Test MASTER project for #{@uuid}", auth_token: TOKEN)
|
21
|
+
@segment_name = "segment-#{@uuid}"
|
22
|
+
@segment = @domain.create_segment(segment_id: @segment_name, master_project: @master_project)
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) do
|
26
|
+
@segment && @segment.delete(force: true)
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:all) do
|
30
|
+
@master_project.delete if @master_project
|
31
|
+
@client.disconnect
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#[]' do
|
35
|
+
it 'Returns all segments when :all passed' do
|
36
|
+
res = @domain.segments
|
37
|
+
expect(res).to be_an_instance_of(Array)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'Returns specific segment when segment ID passed' do
|
41
|
+
s = @domain.segments(@segment_name)
|
42
|
+
@segment.uri == s.uri
|
43
|
+
expect(s).to be_an_instance_of(GoodData::Segment)
|
44
|
+
expect(@segment).to be_an_instance_of(GoodData::Segment)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#delete' do
|
49
|
+
it 'Deletes particular segment' do
|
50
|
+
old_count = @domain.segments.count
|
51
|
+
s = @domain.segments(@segment_name)
|
52
|
+
s.delete
|
53
|
+
expect(@domain.segments.length).to eq (old_count - 1)
|
54
|
+
# prevent delete attempt in the after hook
|
55
|
+
@segment = nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#save' do
|
60
|
+
it 'can update a segment master project' do
|
61
|
+
different_master = @client.create_project(title: 'Test project', auth_token: TOKEN)
|
62
|
+
@segment.master_project = different_master
|
63
|
+
@segment.save
|
64
|
+
@segment = @domain.segments(@segment_name)
|
65
|
+
expect(@segment.master_project_uri).not_to eq @master_project.uri
|
66
|
+
expect(@segment.master_project_uri).to eq different_master.uri
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'cannot update a segment id' do
|
70
|
+
@segment.segment_id = 'different_id'
|
71
|
+
expect {
|
72
|
+
@segment.save
|
73
|
+
}.to raise_error RestClient::BadRequest
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#create_client' do
|
78
|
+
it 'can create a new client in a segment' do
|
79
|
+
begin
|
80
|
+
client_project = @client.create_project(title: 'client_1 project', auth_token: TOKEN)
|
81
|
+
segment_client = @segment.create_client(id: 'tenant_1', project: client_project)
|
82
|
+
expect(segment_client).to be_an_instance_of(GoodData::Client)
|
83
|
+
expect(@segment.clients.count).to eq 1
|
84
|
+
ensure
|
85
|
+
segment_client && segment_client.delete
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#provision_client_projects' do
|
91
|
+
it 'can create a new client in a segment without project and then provision' do
|
92
|
+
begin
|
93
|
+
segment_client = @segment.create_client(id: 'tenant_1')
|
94
|
+
expect(segment_client).to be_an_instance_of(GoodData::Client)
|
95
|
+
expect(@segment.clients.count).to eq 1
|
96
|
+
@domain.synchronize_clients
|
97
|
+
@domain.provision_client_projects
|
98
|
+
expect(@domain.segments.flat_map { |s| s.clients.to_a }.all?(&:project?)).to be_truthy
|
99
|
+
ensure
|
100
|
+
segment_client && segment_client.delete
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#update_clients' do
|
106
|
+
it 'can create a new client in a segment without project and then provision' do
|
107
|
+
begin
|
108
|
+
uuid_2 = SecureRandom.uuid
|
109
|
+
master_project_2 = @client.create_project(title: "Test MASTER project for #{uuid_2}", auth_token: TOKEN)
|
110
|
+
segment_name_2 = "segment-#{uuid_2}"
|
111
|
+
segment_2 = @domain.create_segment(segment_id: segment_name_2, master_project: master_project_2)
|
112
|
+
|
113
|
+
client_1 = "client-#{SecureRandom.uuid}"
|
114
|
+
client_2 = "client-#{SecureRandom.uuid}"
|
115
|
+
data = [{id: client_1, segment: segment_name_2 },
|
116
|
+
{id: client_2, segment: @segment_name }]
|
117
|
+
res = @domain.update_clients(data)
|
118
|
+
expect(@domain.segments.map(&:id)).to include(@segment.id, segment_2.id)
|
119
|
+
expect(@domain.segments.pmapcat {|s| s.clients.to_a }.map(&:id)).to include(client_1, client_2)
|
120
|
+
|
121
|
+
client_3 = "client-#{SecureRandom.uuid}"
|
122
|
+
client_4 = "client-#{SecureRandom.uuid}"
|
123
|
+
data = [{id: client_3, segment: segment_name_2 },
|
124
|
+
{id: client_4, segment: @segment_name }]
|
125
|
+
res = @domain.update_clients(data)
|
126
|
+
expect(@domain.segments.pmapcat {|s| s.clients.to_a }.map(&:id)).to include(client_1, client_2, client_3, client_4)
|
127
|
+
|
128
|
+
# bring the projects
|
129
|
+
@domain.synchronize_clients
|
130
|
+
@domain.provision_client_projects
|
131
|
+
projects_to_delete = @domain.segments.pmapcat {|s| s.clients.to_a }.select { |c| [client_1, client_2].include?(c.id) }.map(&:project)
|
132
|
+
res = @domain.update_clients(data, delete_extra: true)
|
133
|
+
expect(@domain.segments.pmapcat {|s| s.clients.to_a }.map(&:id)).to include(client_3, client_4)
|
134
|
+
expect(@domain.segments.pmapcat {|s| s.clients.to_a }.map(&:id)).not_to include(client_1, client_2)
|
135
|
+
expect(projects_to_delete.pmap(&:reload!).map(&:state)).to eq [:deleted, :deleted]
|
136
|
+
ensure
|
137
|
+
segment_2.delete(force: true) if segment_2
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,290 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
6
|
+
|
7
|
+
require 'gooddata'
|
8
|
+
|
9
|
+
describe "User filters implementation", :constraint => 'slow' do
|
10
|
+
before(:all) do
|
11
|
+
@spec = JSON.parse(File.read("./spec/data/blueprints/test_project_model_spec.json"), :symbolize_names => true)
|
12
|
+
@client = ConnectionHelper::create_default_connection
|
13
|
+
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
14
|
+
@project = @client.create_project_from_blueprint(blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
15
|
+
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
16
|
+
|
17
|
+
@label = GoodData::Attribute.find_first_by_title('Dev', client: @client, project: @project).label_by_name('email')
|
18
|
+
|
19
|
+
commits_data = [
|
20
|
+
["lines_changed","committed_on","dev_id","repo_id"],
|
21
|
+
[1,"01/01/2014",1,1],
|
22
|
+
[3,"01/02/2014",2,2],
|
23
|
+
[5,"05/02/2014",3,1],
|
24
|
+
[6,"05/02/2014",1,2]]
|
25
|
+
@project.upload(commits_data, blueprint, 'dataset.commits')
|
26
|
+
|
27
|
+
devs_data = [
|
28
|
+
["dev_id", "email"],
|
29
|
+
[1, "tomas@gooddata.com"],
|
30
|
+
[2, "petr@gooddata.com"],
|
31
|
+
[3, "jirka@gooddata.com"]]
|
32
|
+
@project.upload(devs_data, blueprint, 'dataset.devs')
|
33
|
+
|
34
|
+
repos_data = [
|
35
|
+
["repo_id", "repo_name"],
|
36
|
+
[1, "goodot"],
|
37
|
+
[2, "bam"],
|
38
|
+
[3, "infra"]]
|
39
|
+
@project.upload(repos_data, blueprint, 'dataset.repos')
|
40
|
+
end
|
41
|
+
|
42
|
+
after(:all) do
|
43
|
+
@project.delete if @project
|
44
|
+
end
|
45
|
+
|
46
|
+
after(:each) do
|
47
|
+
@project.data_permissions.pmap &:delete
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should create a mandatory user filter" do
|
51
|
+
filters = [[ConnectionHelper::DEFAULT_USERNAME, @label.uri, 'tomas@gooddata.com', 'jirka@gooddata.com']]
|
52
|
+
|
53
|
+
metric = @project.create_metric("SELECT SUM(#\"Lines Changed\")", :title => 'x')
|
54
|
+
# [jirka@gooddata.com | petr@gooddata.com | tomas@gooddata.com]
|
55
|
+
# [5.0 | 3.0 | 1.0 ]
|
56
|
+
|
57
|
+
metric.execute.should == 15
|
58
|
+
@project.add_data_permissions(filters)
|
59
|
+
metric.execute.should == 12
|
60
|
+
r = @project.compute_report(left: [metric], top: [@label.attribute])
|
61
|
+
r.include_column?(['tomas@gooddata.com', 7]).should == true
|
62
|
+
r.include_column?(['jirka@gooddata.com', 5]).should == true
|
63
|
+
r.include_column?(['petr@gooddata.com', 3]).should == false
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return errors when asked to set a user not in project. Some filters are set up though." do
|
67
|
+
filters = [
|
68
|
+
['nonexistent_user@gooddata.com', @label.uri, "tomas@gooddata.com"],
|
69
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com"]
|
70
|
+
]
|
71
|
+
results = @project.add_data_permissions(filters)
|
72
|
+
expect(results[:results].any? { |r| r[:status] == :failed }).to be_truthy
|
73
|
+
expect(@project.data_permissions.count).to eq 2
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should pass and set users that are in the projects" do
|
77
|
+
filters = [
|
78
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com"]
|
79
|
+
]
|
80
|
+
@project.add_data_permissions(filters)
|
81
|
+
expect(@project.data_permissions.count).to eq 1
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should pass and set only users that are in the projects if asked" do
|
85
|
+
filters = [
|
86
|
+
['nonexistent_user@gooddata.com', @label.uri, 'tomas@gooddata.com'],
|
87
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, 'tomas@gooddata.com']
|
88
|
+
]
|
89
|
+
# note that filters will be set up even for nonexistent users but they will not be assigned
|
90
|
+
@project.add_data_permissions(filters, users_must_exist: false)
|
91
|
+
expect(@project.data_permissions.select(&:related_uri).count).to eq 1
|
92
|
+
expect(@project.data_permissions.select(&:related_uri).first.pretty_expression).to eq "[Dev] IN ([tomas@gooddata.com])"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should fail when asked to set a value not in the project" do
|
96
|
+
filters = [
|
97
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, '%^&*( nonexistent value', 'tomas@gooddata.com']]
|
98
|
+
expect do
|
99
|
+
@project.add_data_permissions(filters)
|
100
|
+
end.to raise_error
|
101
|
+
begin
|
102
|
+
@project.add_data_permissions(filters)
|
103
|
+
rescue GoodData::FilterMaqlizationError => e
|
104
|
+
expect(e.errors.count).to eq 1
|
105
|
+
end
|
106
|
+
expect(@project.data_permissions.count).to eq 0
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should fail but return all values if specified' do
|
110
|
+
domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
111
|
+
u = domain.users.find { |u| u.login != ConnectionHelper::DEFAULT_USERNAME }
|
112
|
+
filters = [
|
113
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, '%^&*( nonexistent value', 'tomas@gooddata.com'],
|
114
|
+
[u.login, @label.uri, '%^&*( other nonexistent value', 'jirka@gooddata.com']
|
115
|
+
]
|
116
|
+
expect do
|
117
|
+
@project.add_data_permissions(filters, fail_early: false)
|
118
|
+
end.to raise_error
|
119
|
+
begin
|
120
|
+
@project.add_data_permissions(filters, fail_early: false)
|
121
|
+
rescue GoodData::FilterMaqlizationError => e
|
122
|
+
expect(e.errors.count).to eq 2
|
123
|
+
end
|
124
|
+
expect(@project.data_permissions.count).to eq 0
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should add a filter with nonexistent values when asked" do
|
128
|
+
filters = [[ConnectionHelper::DEFAULT_USERNAME, @label.uri, '%^&*( nonexistent value', 'jirka@gooddata.com']]
|
129
|
+
@project.add_data_permissions(filters, ignore_missing_values: true)
|
130
|
+
|
131
|
+
expect(@project.data_permissions.pmap {|m| m.pretty_expression}).to eq ["[Dev] IN ([jirka@gooddata.com])"]
|
132
|
+
expect(@project.data_permissions.count).to eq 1
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should be able to add mandatory filter to a user not in the project if domain is provided" do
|
136
|
+
domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
137
|
+
u = domain.users.find { |u| u.login != ConnectionHelper::DEFAULT_USERNAME }
|
138
|
+
|
139
|
+
filters = [[u.login, @label.uri, "tomas@gooddata.com"]]
|
140
|
+
results = @project.add_data_permissions(filters)
|
141
|
+
filters = @project.data_permissions
|
142
|
+
expect(filters.first.related.login).to eq u.login
|
143
|
+
expect(filters.select(&:related_uri).count).to eq 1
|
144
|
+
expect(filters.first.pretty_expression).to eq "[Dev] IN ([tomas@gooddata.com])"
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should be able to print data permissions in a human readable form" do
|
148
|
+
filters = [[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com"]]
|
149
|
+
@project.add_data_permissions(filters)
|
150
|
+
perms = @project.data_permissions
|
151
|
+
pretty = perms.pmap {|f| [f.related.login, f.pretty_expression]}
|
152
|
+
expect(perms.first.related).to eq @client.user
|
153
|
+
expect(pretty).to eq [[ConnectionHelper::DEFAULT_USERNAME, "[Dev] IN ([tomas@gooddata.com])"]]
|
154
|
+
end
|
155
|
+
|
156
|
+
it "sets up mandatory users based on the state given as an end state by default." do
|
157
|
+
# first let's prepare some user filters
|
158
|
+
user_with_already_set_up_filter = @project.get_user(ConnectionHelper::DEFAULT_USERNAME)
|
159
|
+
|
160
|
+
filters = [
|
161
|
+
[user_with_already_set_up_filter.login, @label.uri, "tomas@gooddata.com"]
|
162
|
+
]
|
163
|
+
@project.add_data_permissions(filters)
|
164
|
+
expect(@project.data_permissions.map {|f| [f.related.login, f.pretty_expression] })
|
165
|
+
.to eq [[ConnectionHelper::DEFAULT_USERNAME, "[Dev] IN ([tomas@gooddata.com])"]]
|
166
|
+
|
167
|
+
# Now let's add user filter to a different user. If we do not explicitely state that
|
168
|
+
# user_with_already_set_up_filter should keep his filter it will be removed
|
169
|
+
another_user = @domain.users.find { |u| u.login != ConnectionHelper::DEFAULT_USERNAME }
|
170
|
+
@project.add_user(another_user, 'Admin', domain: @domain)
|
171
|
+
new_filters = [
|
172
|
+
[another_user.login, @label.uri, "tomas@gooddata.com"]
|
173
|
+
]
|
174
|
+
@project.add_data_permissions(new_filters)
|
175
|
+
expect(@project.data_permissions.map {|f| [f.related.login, f.pretty_expression] })
|
176
|
+
.to eq [[another_user.login, "[Dev] IN ([tomas@gooddata.com])"]]
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should set up false if all values are nonexistent" do
|
180
|
+
metric = GoodData::Fact.find_first_by_title('Lines Changed', client: @client, project: @project).create_metric
|
181
|
+
|
182
|
+
filters = [[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "NONEXISTENT1", "NONEXISTENT2", "NONEXISTENT3"]]
|
183
|
+
@project.add_data_permissions(filters, ignore_missing_values: true)
|
184
|
+
expect(metric.execute).to eq 15
|
185
|
+
@project.add_data_permissions(filters, ignore_missing_values: true, restrict_if_missing_all_values: true)
|
186
|
+
expect(metric.execute).to eq nil
|
187
|
+
end
|
188
|
+
|
189
|
+
it "you can switch the updates. Whatever is not mentioned will not be touched" do
|
190
|
+
# first let's prepare some user filters
|
191
|
+
user_with_already_set_up_filter = @project.get_user(ConnectionHelper::DEFAULT_USERNAME)
|
192
|
+
|
193
|
+
filters = [
|
194
|
+
[user_with_already_set_up_filter.login, @label.uri, "tomas@gooddata.com"]
|
195
|
+
]
|
196
|
+
@project.add_data_permissions(filters)
|
197
|
+
expect(@project.data_permissions.map {|f| [f.related.login, f.pretty_expression] })
|
198
|
+
.to eq [[ConnectionHelper::DEFAULT_USERNAME, "[Dev] IN ([tomas@gooddata.com])"]]
|
199
|
+
|
200
|
+
# Now let's add user filter to a different user. If we do not explicitely state that
|
201
|
+
# user_with_already_set_up_filter should keep his filter it will be removed
|
202
|
+
another_user = @domain.users.find { |u| u.login != ConnectionHelper::DEFAULT_USERNAME }
|
203
|
+
@project.add_user(another_user, 'Admin', domain: @domain)
|
204
|
+
new_filters = [
|
205
|
+
[another_user.login, @label.uri, "tomas@gooddata.com"]
|
206
|
+
]
|
207
|
+
@project.add_data_permissions(new_filters, do_not_touch_filters_that_are_not_mentioned: true)
|
208
|
+
expect(@project.data_permissions.map {|f| [f.related.login, f.pretty_expression] })
|
209
|
+
.to include([ConnectionHelper::DEFAULT_USERNAME, "[Dev] IN ([tomas@gooddata.com])"], [another_user.login, "[Dev] IN ([tomas@gooddata.com])"])
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should be able to update the filter value" do
|
213
|
+
pending 'FIXME: We cannot swap filters yet'
|
214
|
+
|
215
|
+
filters = [[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com", "jirka@gooddata.com"]]
|
216
|
+
@project.add_data_permissions(filters)
|
217
|
+
perm = @project.data_permissions.first
|
218
|
+
filters = [[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com"]]
|
219
|
+
@project.add_data_permissions(filters)
|
220
|
+
expect(perm.reload!.pretty_expression).to eq '[Dev] IN ([tomas@gooddata.com, jirka@gooddata.com])'
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should not create any superfluous filters if things go well' do
|
224
|
+
# first create some filters. This will error out and some filters will stay there
|
225
|
+
filters = [
|
226
|
+
['nonexistent_user@gooddata.com', @label.uri, "tomas@gooddata.com"],
|
227
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com"]
|
228
|
+
]
|
229
|
+
results = @project.add_data_permissions(filters)
|
230
|
+
|
231
|
+
# now let's do a correct run
|
232
|
+
filters = [
|
233
|
+
[ConnectionHelper::DEFAULT_USERNAME, @label.uri, "tomas@gooddata.com"]
|
234
|
+
]
|
235
|
+
results = @project.add_data_permissions(filters)
|
236
|
+
expect(results[:results].all? { |r| r[:status] == :successful }).to be_truthy
|
237
|
+
expect(results[:results].select {|r| r[:type] == :create }.count).to eq 1
|
238
|
+
expect(@project.data_permissions.count).to eq 1
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should create a mandatory user filter with double filters" do
|
242
|
+
|
243
|
+
repo_label = @project.labels('some_attr_label_id')
|
244
|
+
metric = @project.create_metric("SELECT SUM(#\"Lines Changed\")")
|
245
|
+
|
246
|
+
# we want to compute stuff on different user than we are setting it on
|
247
|
+
u = @domain.users.find { |u| u.login != ConnectionHelper::DEFAULT_USERNAME }
|
248
|
+
password = 'abcd1234'
|
249
|
+
u.json['accountSetting']['password'] = password
|
250
|
+
@domain.update_user(u)
|
251
|
+
@project.add_user(u, 'admin')
|
252
|
+
|
253
|
+
computation_client = GoodData.connect(u.login, password, verify_ssl: false)
|
254
|
+
computation_project = computation_client.projects(@project.pid)
|
255
|
+
|
256
|
+
# verify we are set up
|
257
|
+
r = computation_project.compute_report(left: [metric, 'some_attr_label_id'], top: [@label])
|
258
|
+
expect(r.column(4)).to eq ["tomas@gooddata.com", 6, 1]
|
259
|
+
|
260
|
+
# lets restrict tomas to goodot only
|
261
|
+
filters = [[u.login, @label.uri, 'tomas@gooddata.com'],
|
262
|
+
[u.login, repo_label.uri, 'goodot']]
|
263
|
+
results = @project.add_data_permissions(filters)
|
264
|
+
expect(@project.data_permissions.pmap {|f| [f.related.login, f.pretty_expression]}).to eq [
|
265
|
+
[u.login, "[Dev] IN ([tomas@gooddata.com])"],
|
266
|
+
[u.login, "[Repository Name] IN ([goodot])"]]
|
267
|
+
|
268
|
+
r = computation_project.compute_report(left: [metric, 'some_attr_label_id'], top: [@label])
|
269
|
+
expect(r.column(2)).to eq ["tomas@gooddata.com", 1]
|
270
|
+
|
271
|
+
# Now lets change repo to bam
|
272
|
+
filters = [[u.login, @label.uri, 'tomas@gooddata.com'],
|
273
|
+
[u.login, repo_label.uri, 'bam']]
|
274
|
+
results = @project.add_data_permissions(filters)
|
275
|
+
|
276
|
+
expect(@project.data_permissions.pmap {|f| [f.related.login, f.pretty_expression]}).to eq [
|
277
|
+
[u.login, "[Dev] IN ([tomas@gooddata.com])"],
|
278
|
+
[u.login, "[Repository Name] IN ([bam])"]]
|
279
|
+
|
280
|
+
r = computation_project.compute_report(left: [metric, 'some_attr_label_id'], top: [@label])
|
281
|
+
expect(r.column(2)).to eq ["tomas@gooddata.com", 6]
|
282
|
+
|
283
|
+
# let's remove the repo restriction
|
284
|
+
filters = [[u.login, @label.uri, 'tomas@gooddata.com']]
|
285
|
+
results = @project.add_data_permissions(filters)
|
286
|
+
|
287
|
+
r = computation_project.compute_report(left: [metric, 'some_attr_label_id'], top: [@label])
|
288
|
+
expect(r.column(2)).to eq ["tomas@gooddata.com", 6, 1]
|
289
|
+
end
|
290
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
6
|
+
|
7
|
+
describe GoodData::UserGroup do
|
8
|
+
before(:all) do
|
9
|
+
@bulk_size = 3
|
10
|
+
|
11
|
+
@user_group_name = 'My Test Group'
|
12
|
+
@user_group_description = 'My Test Description'
|
13
|
+
|
14
|
+
@client = ConnectionHelper::create_default_connection
|
15
|
+
@project = @client.create_project(title: 'UserGroup Testing Project', token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
16
|
+
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
17
|
+
|
18
|
+
users = (1..5).to_a.map do |x|
|
19
|
+
{
|
20
|
+
user: ProjectHelper.create_random_user(@client),
|
21
|
+
role: 'Admin'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
@project.add_users(users)
|
26
|
+
@users = @project.users.to_a
|
27
|
+
|
28
|
+
@group = @project.add_user_group(:name => @user_group_name, :description => @user_group_description)
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:all) do
|
32
|
+
@group && @group.delete
|
33
|
+
@project && @project.delete
|
34
|
+
@client.disconnect
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#[]' do
|
38
|
+
it 'Should list user groups as Array' do
|
39
|
+
res = GoodData::UserGroup[:all, :client => @client, :project => @project]
|
40
|
+
expect(res).to be_kind_of(Array)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#add_members' do
|
45
|
+
it 'Should add member' do
|
46
|
+
users = @users.to_a.take(@bulk_size)
|
47
|
+
|
48
|
+
old_count = @group.members.to_a.length
|
49
|
+
@group.add_member(users)
|
50
|
+
|
51
|
+
new_count = @group.members.to_a.length
|
52
|
+
expect(new_count).to eq (old_count + 1)
|
53
|
+
|
54
|
+
group_members = @group.members.to_a
|
55
|
+
|
56
|
+
users.each do |user|
|
57
|
+
res = group_members.find do |group_member|
|
58
|
+
group_member.uri == user.uri
|
59
|
+
end
|
60
|
+
expect(res).to be_a_kind_of(GoodData::Profile)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#set_members' do
|
66
|
+
it 'Should set new members' do
|
67
|
+
users = @users.to_a.take(@bulk_size)
|
68
|
+
|
69
|
+
@group.set_members(users)
|
70
|
+
|
71
|
+
group_members = @group.members.to_a
|
72
|
+
expect(group_members.length).to eq users.length
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#remove_members' do
|
77
|
+
it 'Should remove existing members' do
|
78
|
+
users = @users.to_a.take(@bulk_size)
|
79
|
+
|
80
|
+
@group.set_members(users)
|
81
|
+
|
82
|
+
group_members = @group.members.to_a
|
83
|
+
expect(group_members.length).to eq users.length
|
84
|
+
|
85
|
+
@group.remove_members(users)
|
86
|
+
group_members = @group.members.to_a
|
87
|
+
expect(group_members.length).to eq 0
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#members' do
|
92
|
+
it 'Should return members as array' do
|
93
|
+
expect(@group.members).to be_a_kind_of(Enumerator)
|
94
|
+
|
95
|
+
members = @group.members.to_a
|
96
|
+
expect(members).to be_kind_of(Array)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#name' do
|
101
|
+
it 'Should return name of user group' do
|
102
|
+
expect(@group.name).to eq @user_group_name
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#name=' do
|
107
|
+
it 'Should assign name of user group' do
|
108
|
+
new_name = 'This is new name'
|
109
|
+
@group.name = new_name
|
110
|
+
expect(@group.name).to eq new_name
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#description' do
|
115
|
+
it 'Should return name of user group' do
|
116
|
+
expect(@group.description).to eq @user_group_description
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#description=' do
|
121
|
+
it 'Should assign description of user group' do
|
122
|
+
new_description = 'This is new description'
|
123
|
+
@group.description = new_description
|
124
|
+
expect(@group.description).to eq new_description
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|