gooddata 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -1
  3. data/README.md +10 -2
  4. data/TODO.md +32 -0
  5. data/gooddata.gemspec +5 -0
  6. data/lib/gooddata.rb +4 -0
  7. data/lib/gooddata/app/app.rb +12 -0
  8. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +4 -3
  9. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +2 -1
  10. data/lib/gooddata/cli/commands/console_cmd.rb +23 -5
  11. data/lib/gooddata/cli/commands/domain_cmd.rb +9 -10
  12. data/lib/gooddata/cli/commands/process_cmd.rb +11 -9
  13. data/lib/gooddata/cli/commands/project_cmd.rb +25 -27
  14. data/lib/gooddata/cli/commands/projects_cmd.rb +2 -2
  15. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +1 -1
  16. data/lib/gooddata/cli/commands/user_cmd.rb +2 -2
  17. data/lib/gooddata/cli/hooks.rb +4 -2
  18. data/lib/gooddata/cli/shared.rb +1 -1
  19. data/lib/gooddata/cli/terminal.rb +1 -1
  20. data/lib/gooddata/commands/api.rb +1 -1
  21. data/lib/gooddata/commands/auth.rb +4 -28
  22. data/lib/gooddata/commands/domain.rb +9 -4
  23. data/lib/gooddata/commands/process.rb +26 -23
  24. data/lib/gooddata/commands/project.rb +74 -50
  25. data/lib/gooddata/commands/projects.rb +3 -2
  26. data/lib/gooddata/commands/role.rb +9 -3
  27. data/lib/gooddata/commands/user.rb +6 -4
  28. data/lib/gooddata/connection.rb +11 -45
  29. data/lib/gooddata/core/logging.rb +0 -1
  30. data/lib/gooddata/core/project.rb +22 -22
  31. data/lib/gooddata/core/rest.rb +9 -8
  32. data/lib/gooddata/core/user.rb +0 -11
  33. data/lib/gooddata/exceptions/project_not_found.rb +1 -0
  34. data/lib/gooddata/extensions/enumerable.rb +10 -0
  35. data/lib/gooddata/extensions/hash.rb +25 -0
  36. data/lib/gooddata/goodzilla/goodzilla.rb +4 -4
  37. data/lib/gooddata/helper/class_helper.rb +1 -0
  38. data/lib/gooddata/helper/helpers.rb +8 -0
  39. data/lib/gooddata/helpers/auth_helpers.rb +41 -0
  40. data/lib/gooddata/mixins/author.rb +1 -1
  41. data/lib/gooddata/mixins/contributor.rb +1 -1
  42. data/lib/gooddata/mixins/data_property_reader.rb +2 -0
  43. data/lib/gooddata/mixins/data_property_writer.rb +2 -0
  44. data/lib/gooddata/mixins/inspector.rb +49 -0
  45. data/lib/gooddata/mixins/md_finders.rb +16 -8
  46. data/lib/gooddata/mixins/md_id_to_uri.rb +12 -4
  47. data/lib/gooddata/mixins/md_object_indexer.rb +15 -4
  48. data/lib/gooddata/mixins/md_object_query.rb +42 -20
  49. data/lib/gooddata/mixins/md_relations.rb +21 -12
  50. data/lib/gooddata/mixins/meta_getter.rb +2 -0
  51. data/lib/gooddata/mixins/meta_property_reader.rb +2 -0
  52. data/lib/gooddata/mixins/meta_property_writer.rb +2 -0
  53. data/lib/gooddata/mixins/rest_resource.rb +32 -10
  54. data/lib/gooddata/mixins/root_key_getter.rb +1 -1
  55. data/lib/gooddata/models/data_result.rb +3 -1
  56. data/lib/gooddata/models/domain.rb +31 -22
  57. data/lib/gooddata/models/empty_result.rb +22 -0
  58. data/lib/gooddata/models/invitation.rb +11 -9
  59. data/lib/gooddata/models/links.rb +5 -3
  60. data/lib/gooddata/models/membership.rb +23 -28
  61. data/lib/gooddata/models/metadata.rb +35 -35
  62. data/lib/gooddata/models/metadata/attribute.rb +10 -8
  63. data/lib/gooddata/models/metadata/dashboard.rb +1 -1
  64. data/lib/gooddata/models/metadata/fact.rb +3 -3
  65. data/lib/gooddata/models/metadata/label.rb +4 -4
  66. data/lib/gooddata/models/metadata/metric.rb +76 -38
  67. data/lib/gooddata/models/metadata/report.rb +52 -17
  68. data/lib/gooddata/models/metadata/report_definition.rb +178 -28
  69. data/lib/gooddata/models/model.rb +13 -6
  70. data/lib/gooddata/models/process.rb +93 -30
  71. data/lib/gooddata/models/profile.rb +18 -20
  72. data/lib/gooddata/models/project.rb +344 -127
  73. data/lib/gooddata/models/project_creator.rb +32 -22
  74. data/lib/gooddata/models/project_metadata.rb +26 -14
  75. data/lib/gooddata/models/project_role.rb +15 -17
  76. data/lib/gooddata/models/report_data_result.rb +4 -0
  77. data/lib/gooddata/models/schedule.rb +51 -20
  78. data/lib/gooddata/models/schema_blueprint.rb +9 -3
  79. data/lib/gooddata/rest/README.md +37 -0
  80. data/lib/gooddata/rest/client.rb +318 -0
  81. data/lib/gooddata/rest/connection.rb +235 -0
  82. data/lib/gooddata/rest/connections/connections.rb +8 -0
  83. data/lib/gooddata/rest/connections/dummy_connection.rb +52 -0
  84. data/lib/gooddata/rest/connections/rest_client_connection.rb +177 -0
  85. data/lib/gooddata/rest/object.rb +32 -0
  86. data/lib/gooddata/rest/object_factory.rb +67 -0
  87. data/lib/gooddata/rest/resource.rb +17 -0
  88. data/lib/gooddata/rest/rest.rb +20 -0
  89. data/lib/gooddata/version.rb +1 -1
  90. data/spec/data/cc/data/source/commits.csv +4 -0
  91. data/spec/data/cc/data/source/devs.csv +4 -0
  92. data/spec/data/cc/data/source/repos.csv +3 -0
  93. data/spec/data/cc/devel.prm +0 -0
  94. data/spec/data/cc/graph/graph.grf +11 -0
  95. data/spec/data/cc/workspace.prm +19 -0
  96. data/spec/data/hello_world_process/hello_world.rb +1 -0
  97. data/spec/data/hello_world_process/hello_world.zip +0 -0
  98. data/spec/data/users.csv +12 -12
  99. data/spec/helpers/connection_helper.rb +6 -0
  100. data/spec/helpers/process_helper.rb +12 -0
  101. data/spec/helpers/project_helper.rb +2 -2
  102. data/spec/integration/command_projects_spec.rb +11 -9
  103. data/spec/integration/create_from_template_spec.rb +6 -2
  104. data/spec/integration/full_process_schedule_spec.rb +49 -36
  105. data/spec/integration/full_project_spec.rb +221 -256
  106. data/spec/integration/partial_md_export_import_spec.rb +18 -17
  107. data/spec/logging_in_logging_out_spec.rb +17 -8
  108. data/spec/spec_helper.rb +4 -2
  109. data/spec/unit/cli/commands/cmd_api_spec.rb +1 -1
  110. data/spec/unit/cli/commands/cmd_auth_spec.rb +1 -1
  111. data/spec/unit/cli/commands/cmd_domain_spec.rb +29 -3
  112. data/spec/unit/cli/commands/cmd_process_spec.rb +1 -1
  113. data/spec/unit/cli/commands/cmd_project_spec.rb +1 -1
  114. data/spec/unit/cli/commands/cmd_role_spec.rb +13 -2
  115. data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +1 -1
  116. data/spec/unit/cli/commands/cmd_scaffold_spec.rb +1 -1
  117. data/spec/unit/cli/commands/cmd_user_spec.rb +1 -1
  118. data/spec/unit/commands/command_api_spec.rb +0 -19
  119. data/spec/unit/commands/command_auth_spec.rb +20 -13
  120. data/spec/unit/commands/command_dataset_spec.rb +2 -2
  121. data/spec/unit/commands/command_process_spec.rb +24 -21
  122. data/spec/unit/commands/command_projects_spec.rb +2 -2
  123. data/spec/unit/commands/command_scaffold_spec.rb +2 -2
  124. data/spec/unit/commands/command_user_spec.rb +3 -3
  125. data/spec/unit/core/connection_spec.rb +9 -10
  126. data/spec/unit/core/project_spec.rb +8 -4
  127. data/spec/unit/core/rest_spec.rb +6 -6
  128. data/spec/unit/models/domain_spec.rb +14 -7
  129. data/spec/unit/models/invitation_spec.rb +2 -2
  130. data/spec/unit/models/membership_spec.rb +5 -5
  131. data/spec/unit/models/metric_spec.rb +92 -0
  132. data/spec/unit/models/profile_spec.rb +25 -21
  133. data/spec/unit/models/project_blueprint_spec.rb +6 -6
  134. data/spec/unit/models/project_role_spec.rb +3 -5
  135. data/spec/unit/models/project_spec.rb +43 -37
  136. data/spec/unit/models/schedule_spec.rb +58 -107
  137. data/spec/unit/rest/resource_spec.rb +6 -0
  138. metadata +87 -10
  139. data/lib/gooddata/cli/commands/role_cmd.rb +0 -28
  140. data/lib/gooddata/core/connection.rb +0 -392
  141. data/lib/gooddata/core/threaded.rb +0 -14
  142. data/lib/gooddata/models/md_object.rb +0 -25
  143. data/lib/gooddata/models/metadata/folder.rb +0 -24
  144. data/spec/unit/models/md_object_spec.rb +0 -55
  145. data/spec/unit/models/metric.rb +0 -92
@@ -1,14 +1,16 @@
1
1
  require 'gooddata/commands/process'
2
2
 
3
3
  describe GoodData::Command::Process do
4
- deploy_dir = './'
4
+ deploy_dir = File.join(File.dirname(__FILE__), '..', '..', 'data/cc')
5
+ graph_path = 'graph/graph.grf'
5
6
 
6
7
  before(:each) do
7
- ConnectionHelper.create_default_connection
8
+ @client = ConnectionHelper.create_default_connection
9
+ @project = ProjectHelper.get_default_project(:client => @client)
8
10
  end
9
11
 
10
12
  after(:each) do
11
- GoodData.disconnect
13
+ @client.disconnect
12
14
  end
13
15
 
14
16
  it "Is Possible to create GoodData::Command::Process instance" do
@@ -17,13 +19,20 @@ describe GoodData::Command::Process do
17
19
  end
18
20
 
19
21
  describe "#get" do
20
- it "Should throw exception if no project specified" do
22
+ it "Should throw exception if no Project ID specified" do
21
23
  expect { GoodData::Command::Process.get }.to raise_error
22
24
  end
23
25
 
24
- it "Returns processes" do
25
- pending('Project ID needed')
26
- GoodData::Command::Process.get
26
+ it "Should throw exception if no Process ID specified" do
27
+ expect { GoodData::Command::Process.get(:project_id => ProjectHelper::PROJECT_ID) }.to raise_error
28
+ end
29
+
30
+ it "Gets process by process ID" do
31
+ pending "SystemStackError: stack level too deep"
32
+
33
+ res = GoodData::Command::Process.get(:project_id => ProjectHelper::PROJECT_ID, :process_id => ProcessHelper::PROCESS_ID)
34
+ expect(res).to_not be_nil
35
+ expect(res).to be_an_instance_of(GoodData::Process)
27
36
  end
28
37
  end
29
38
 
@@ -34,8 +43,7 @@ describe GoodData::Command::Process do
34
43
  end
35
44
 
36
45
  it "Deploys graph" do
37
- pending('Project ID needed')
38
- GoodData::Command::Process.deploy(deploy_dir)
46
+ GoodData::Command::Process.deploy(deploy_dir, :name => ProcessHelper::DEPLOY_NAME, :project_id => ProjectHelper::PROJECT_ID, :client => @client, :project => @project)
39
47
  end
40
48
  end
41
49
 
@@ -49,31 +57,26 @@ describe GoodData::Command::Process do
49
57
  end
50
58
 
51
59
  describe "#list" do
52
- it "Should throw exception if no project specified" do
53
- expect { GoodData::Command::Process.list }.to raise_error
54
- end
55
-
56
60
  it "Returns processes" do
57
- pending('Project ID needed')
58
- GoodData::Command::Process.list
61
+ res = GoodData::Command::Process.list(:project_id => ProjectHelper::PROJECT_ID, :client => @client, :project => @project)
62
+ expect(res).to be_an_instance_of(Array)
59
63
  end
60
64
  end
61
65
 
62
66
  describe "#run" do
63
67
  it "Throws exception if no project specified" do
64
- expect { GoodData::Command::Process.run(deploy_dir, './main.grf') }.to raise_error
68
+ expect { GoodData::Command::Process.run(deploy_dir, graph_path) }.to raise_error
65
69
  end
66
70
 
67
71
  it "Runs process" do
68
- pending('Project ID needed')
69
- GoodData::Command::Process.run(deploy_dir, './main.grf')
72
+ # GoodData::Command::Process.run(deploy_dir, graph_path)
70
73
  end
71
74
  end
72
75
 
73
76
  describe "#with_deploy" do
74
77
  it "Should throw exception if no project specified" do
75
78
  expect do
76
- GoodData::Command::Process.with_deploy(deploy_dir) do
79
+ GoodData::Process.with_deploy(deploy_dir) do
77
80
  msg = "Hello World!"
78
81
  end
79
82
 
@@ -81,8 +84,8 @@ describe GoodData::Command::Process do
81
84
  end
82
85
 
83
86
  it "Executes block when deploying" do
84
- pending('Project ID needed')
85
- GoodData::Command::Process.with_deploy(deploy_dir) do
87
+ # pending('Project ID needed')
88
+ GoodData::Process.with_deploy(deploy_dir, :name => ProcessHelper::DEPLOY_NAME, :project_id => ProjectHelper::PROJECT_ID, :client => @client, :project => @project) do
86
89
  msg = "Hello World!"
87
90
  end
88
91
  end
@@ -2,11 +2,11 @@ require 'gooddata/commands/project'
2
2
 
3
3
  describe GoodData::Command::Project do
4
4
  before(:each) do
5
- ConnectionHelper.create_default_connection
5
+ @client = ConnectionHelper.create_default_connection
6
6
  end
7
7
 
8
8
  after(:each) do
9
- GoodData.disconnect
9
+ @client.disconnect
10
10
  end
11
11
 
12
12
  it "Is Possible to create GoodData::Command::Project instance" do
@@ -6,11 +6,11 @@ describe GoodData::Command::Scaffold do
6
6
  end
7
7
 
8
8
  before(:each) do
9
- ConnectionHelper.create_default_connection
9
+ @client = ConnectionHelper.create_default_connection
10
10
  end
11
11
 
12
12
  after(:each) do
13
- GoodData.disconnect
13
+ @client.disconnect
14
14
  end
15
15
 
16
16
  it "Is Possible to create GoodData::Command::Scaffold instance" do
@@ -2,11 +2,11 @@ require 'gooddata/commands/user'
2
2
 
3
3
  describe GoodData::Command::User do
4
4
  before(:each) do
5
- ConnectionHelper.create_default_connection
5
+ @client = ConnectionHelper.create_default_connection
6
6
  end
7
7
 
8
8
  after(:each) do
9
- GoodData.disconnect
9
+ @client.disconnect
10
10
  end
11
11
 
12
12
  it "Is Possible to create GoodData::Command::Membership instance" do
@@ -16,7 +16,7 @@ describe GoodData::Command::User do
16
16
 
17
17
  describe "#show" do
18
18
  it "Shows profile" do
19
- GoodData::Command::User.show
19
+ GoodData::Command::User.show(:client => @client)
20
20
  end
21
21
  end
22
22
  end
@@ -1,36 +1,35 @@
1
1
  require 'gooddata/connection'
2
- require 'gooddata/core/connection'
3
2
 
4
- describe GoodData::Connection do
3
+ describe GoodData::Rest::Connection do
5
4
  before(:all) do
6
5
  USERNAME = ConnectionHelper::DEFAULT_USERNAME
7
6
  PASSWORD = ConnectionHelper::DEFAULT_PASSWORD
8
7
  end
9
8
 
10
9
  it "Has DEFAULT_URL defined" do
11
- GoodData::Connection::DEFAULT_URL.should be_a(String)
10
+ GoodData::Rest::Connection::DEFAULT_URL.should be_a(String)
12
11
  end
13
12
 
14
13
  it "Has LOGIN_PATH defined" do
15
- GoodData::Connection::LOGIN_PATH.should be_a(String)
14
+ GoodData::Rest::Connection::LOGIN_PATH.should be_a(String)
16
15
  end
17
16
 
18
17
  it "Has TOKEN_PATH defined" do
19
- GoodData::Connection::TOKEN_PATH.should be_a(String)
18
+ GoodData::Rest::Connection::TOKEN_PATH.should be_a(String)
20
19
  end
21
20
 
22
21
  describe '#connect' do
23
22
  it "Connects using username and password" do
24
23
  c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD)
25
- c.should be_a(GoodData::Connection)
26
- GoodData.disconnect
24
+ c.should be_a(GoodData::Rest::Client)
25
+ c.disconnect
27
26
  end
28
27
  end
29
28
 
30
29
  describe '#disconnect' do
31
30
  it "Connects using username and password" do
32
- GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD)
33
- GoodData.disconnect
31
+ c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD)
32
+ c.disconnect
34
33
  end
35
34
  end
36
35
 
@@ -49,7 +48,7 @@ describe GoodData::Connection do
49
48
  :password => ConnectionHelper::DEFAULT_PASSWORD
50
49
  }
51
50
  GoodData.create_authenticated_connection(opts)
52
- GoodData.disconnect
51
+ ConnectionHelper.disconnect
53
52
  end
54
53
  end
55
54
  end
@@ -1,17 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'gooddata/connection'
4
- require 'gooddata/core/connection'
5
4
  require 'gooddata/core/project'
6
5
  require 'gooddata/models/project'
7
6
 
8
7
  describe 'GoodData - project' do
9
8
  before(:each) do
10
- ConnectionHelper.create_default_connection
9
+ @client = ConnectionHelper.create_default_connection
11
10
  end
12
11
 
13
12
  after(:each) do
14
- GoodData.disconnect
13
+ @client.disconnect
15
14
  end
16
15
 
17
16
  describe '#project=' do
@@ -20,20 +19,25 @@ describe 'GoodData - project' do
20
19
  end
21
20
 
22
21
  it 'Assigns project using project ID' do
22
+ pending 'GoodData::project= is disabled for now'
23
23
  GoodData.project = ProjectHelper::PROJECT_ID
24
24
  end
25
25
 
26
26
  it 'Assigns project using project URL' do
27
+ pending 'GoodData::project= is disabled for now'
27
28
  GoodData.project = ProjectHelper::PROJECT_URL
28
29
  end
29
30
 
30
31
  it 'Assigns project directly' do
32
+ pending 'GoodData::project= is disabled for now'
31
33
  GoodData.project = GoodData::Project[ProjectHelper::PROJECT_ID]
32
34
  end
33
35
  end
34
36
 
35
37
  describe '#project' do
36
38
  it 'Returns project assigned' do
39
+ pending 'GoodData.project= is disabled for now'
40
+
37
41
  GoodData.project = nil
38
42
  GoodData.project.should == nil
39
43
 
@@ -44,7 +48,7 @@ describe 'GoodData - project' do
44
48
 
45
49
  describe '#with_project' do
46
50
  it 'Uses project specified' do
47
- GoodData.with_project GoodData::Project[ProjectHelper::PROJECT_ID] do
51
+ GoodData.with_project GoodData::Project[ProjectHelper::PROJECT_ID, :client => @client] do
48
52
  end
49
53
  end
50
54
  end
@@ -1,33 +1,33 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'gooddata/core/connection'
4
3
  require 'gooddata/core/rest'
5
4
 
6
5
  describe GoodData do
7
6
  before(:each) do
8
- ConnectionHelper.create_default_connection
7
+ @client = ConnectionHelper.create_default_connection
8
+ @project = ProjectHelper.get_default_project(:client => @client)
9
9
  end
10
10
 
11
11
  after(:each) do
12
- GoodData.disconnect
12
+ @client.disconnect
13
13
  end
14
14
 
15
15
  describe '#get_project_webdav_path' do
16
16
  it 'Returns path' do
17
- GoodData.get_project_webdav_path('test-file.csv')
17
+ @client.get_project_webdav_path('test-file.csv', :project => @project)
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#upload_to_project_webdav' do
22
22
  it 'Uploads file' do
23
23
  pending('Research how to properly upload file')
24
- GoodData.upload_to_project_webdav('spec/data/test-ci-data.csv')
24
+ @client.upload_to_project_webdav('spec/data/test-ci-data.csv', :project => @project)
25
25
  end
26
26
  end
27
27
 
28
28
  describe '#get_user_webdav_path' do
29
29
  it 'Gets the path' do
30
- GoodData.get_user_webdav_path('test.csv')
30
+ @client.get_user_webdav_path('test.csv', :project => @project)
31
31
  end
32
32
  end
33
33
  end
@@ -4,16 +4,23 @@ require 'gooddata/models/domain'
4
4
 
5
5
  describe GoodData::Domain do
6
6
  before(:each) do
7
- ConnectionHelper.create_default_connection
7
+ @client = ConnectionHelper.create_default_connection
8
8
  end
9
9
 
10
10
  after(:each) do
11
- GoodData.disconnect
11
+ @client.disconnect
12
12
  end
13
13
 
14
14
  describe '#add_user' do
15
15
  it 'Should add user' do
16
- user = GoodData::Domain.add_user(:domain => ConnectionHelper::DEFAULT_DOMAIN, :login => "gemtest#{rand(1e6)}@gooddata.com", :password => CryptoHelper.generate_password)
16
+ args = {
17
+ :domain => ConnectionHelper::DEFAULT_DOMAIN,
18
+ :login => "gemtest#{rand(1e6)}@gooddata.com",
19
+ :password => CryptoHelper.generate_password,
20
+ :client => @client
21
+ }
22
+
23
+ user = GoodData::Domain.add_user(args)
17
24
  expect(user).to be_an_instance_of(GoodData::Profile)
18
25
  user.delete
19
26
  end
@@ -21,7 +28,7 @@ describe GoodData::Domain do
21
28
 
22
29
  describe '#users' do
23
30
  it 'Should list users' do
24
- users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN)
31
+ users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, :client => @client)
25
32
  expect(users).to be_instance_of(Array)
26
33
  users.each do |user|
27
34
  expect(user).to be_an_instance_of(GoodData::Profile)
@@ -29,7 +36,7 @@ describe GoodData::Domain do
29
36
  end
30
37
 
31
38
  it 'Accepts pagination options - limit' do
32
- users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, {:limit =>1})
39
+ users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, {:client => @client, :limit =>1})
33
40
  expect(users).to be_instance_of(Array)
34
41
  users.each do |user|
35
42
  expect(user).to be_an_instance_of(GoodData::Profile)
@@ -37,7 +44,7 @@ describe GoodData::Domain do
37
44
  end
38
45
 
39
46
  it 'Accepts pagination options - offset' do
40
- users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, {:offset => 1})
47
+ users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, {:client => @client, :offset => 1})
41
48
  expect(users).to be_instance_of(Array)
42
49
  users.each do |user|
43
50
  expect(user).to be_an_instance_of(GoodData::Profile)
@@ -76,7 +83,7 @@ describe GoodData::Domain do
76
83
  list << user
77
84
  end
78
85
 
79
- res = GoodData::Domain.users_create(list, ConnectionHelper::DEFAULT_DOMAIN)
86
+ res = GoodData::Domain.users_create(list, ConnectionHelper::DEFAULT_DOMAIN, :client => @client)
80
87
 
81
88
  expect(res).to be_an_instance_of(Array)
82
89
  res.each do |r|
@@ -4,10 +4,10 @@ require 'gooddata/models/invitation'
4
4
 
5
5
  describe GoodData::Invitation do
6
6
  before(:each) do
7
- ConnectionHelper.create_default_connection
7
+ @client = ConnectionHelper.create_default_connection
8
8
  end
9
9
 
10
10
  after(:each) do
11
- GoodData.disconnect
11
+ @client.disconnect
12
12
  end
13
13
  end
@@ -6,10 +6,10 @@ require 'gooddata/models/project_role'
6
6
 
7
7
  describe GoodData::Membership do
8
8
  before(:all) do
9
- ConnectionHelper.create_default_connection
9
+ @client = ConnectionHelper.create_default_connection
10
10
 
11
11
  @users = [
12
- GoodData::Membership.new(
12
+ @client.create(GoodData::Membership,
13
13
  {
14
14
  'user' => {
15
15
  'content' => {
@@ -35,7 +35,7 @@ describe GoodData::Membership do
35
35
  }
36
36
  ),
37
37
 
38
- GoodData::Membership.new(
38
+ @client.create(GoodData::Membership,
39
39
  {
40
40
  'user' => {
41
41
  'content' => {
@@ -48,7 +48,7 @@ describe GoodData::Membership do
48
48
  }
49
49
  ),
50
50
 
51
- GoodData::Membership.new(
51
+ @client.create(GoodData::Membership,
52
52
  {
53
53
  'user' => {
54
54
  'content' => {
@@ -64,7 +64,7 @@ describe GoodData::Membership do
64
64
  end
65
65
 
66
66
  after(:all) do
67
- GoodData.disconnect
67
+ @client.disconnect
68
68
  end
69
69
 
70
70
  describe '#diff_list' do
@@ -0,0 +1,92 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/metadata/metric'
4
+
5
+ describe GoodData::Metric do
6
+
7
+
8
+ RAW_DATA2 = {'metric' =>
9
+ {'content' =>
10
+ {'format' => '#,##0',
11
+ 'expression' => 'SELECT SUM([/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/700])'},
12
+ 'meta' =>
13
+ {'author' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
14
+ 'uri' => '/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/70',
15
+ 'tags' => 'a b cg r t',
16
+ 'created' => '2014-04-30 22:47:57',
17
+ 'identifier' => 'afo7bx1VakCz',
18
+ 'deprecated' => '0',
19
+ 'summary' => '',
20
+ 'title' => 'sum of Lines changed',
21
+ 'category' => 'metric',
22
+ 'updated' => '2014-05-05 20:00:42',
23
+ 'contributor' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}}
24
+
25
+ RAW_DATA3 = {'metric' =>
26
+ {'content' =>
27
+ {'format' => '#,##0',
28
+ 'expression' => 'SELECT SUM([/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/710])'},
29
+ 'meta' =>
30
+ {'author' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
31
+ 'uri' => '/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/71',
32
+ 'tags' => 'a b cg r t',
33
+ 'created' => '2014-04-30 22:47:57',
34
+ 'identifier' => 'afo7bx1VakCz',
35
+ 'deprecated' => '0',
36
+ 'summary' => '',
37
+ 'title' => 'sum of Lines changed',
38
+ 'category' => 'metric',
39
+ 'updated' => '2014-05-05 20:00:42',
40
+ 'contributor' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}}
41
+
42
+ USED_METRIC = GoodData::Metric.new(RAW_DATA2)
43
+ UNUSED_METRIC = GoodData::Metric.new(RAW_DATA3)
44
+
45
+ RAW_DATA = {'metric' =>
46
+ {'content' =>
47
+ {'format' => '#,##0',
48
+ 'expression' =>
49
+ "SELECT SUM([#{USED_METRIC.uri})"},
50
+ 'meta' =>
51
+ {'author' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
52
+ 'uri' => '/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/252',
53
+ 'tags' => 'a b cg r t',
54
+ 'created' => '2014-04-30 22:47:57',
55
+ 'identifier' => 'afo7bx1VakCz',
56
+ 'deprecated' => '0',
57
+ 'summary' => '',
58
+ 'title' => 'sum of Lines changed',
59
+ 'category' => 'metric',
60
+ 'updated' => '2014-05-05 20:00:42',
61
+ 'contributor' => '/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}}
62
+
63
+ before(:each) do
64
+ @instance = GoodData::Metric.new(RAW_DATA)
65
+ end
66
+
67
+ describe '#contain?' do
68
+ it 'should say it contains a depending metric if it does' do
69
+ @instance.contain?(USED_METRIC).should == true
70
+ end
71
+
72
+ it 'should say it contains a depending object which is given as a string if it does' do
73
+ @instance.contain?(USED_METRIC).should == true
74
+ end
75
+
76
+ it 'should be able to replace an object if the object is used in the expression' do
77
+ pending('resolve mutating constant if I init from it')
78
+ end
79
+
80
+ it 'should be able to return an expression of the metric' do
81
+ @instance.expression.should == "SELECT SUM([#{USED_METRIC.uri})"
82
+ end
83
+
84
+ it 'should be able to replace an object if the object is used in the expression' do
85
+ @instance.contain?(USED_METRIC).should == true
86
+ @instance.contain?(UNUSED_METRIC).should == false
87
+ @instance.replace(USED_METRIC, UNUSED_METRIC)
88
+ @instance.contain?(USED_METRIC).should == false
89
+ @instance.contain?(UNUSED_METRIC).should == true
90
+ end
91
+ end
92
+ end