spec/integration/segments_spec.rb in gooddata-0.6.53 vs spec/integration/segments_spec.rb in gooddata-0.6.54
- old
+ new
@@ -9,17 +9,10 @@
describe GoodData::Segment do
before(:all) do
@client = ConnectionHelper.create_default_connection
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
- GoodData::Segment.all(domain: @domain).each do |segment|
- begin
- segment.delete(force: true)
- rescue StandardError => e
- GoodData.logger.warn "Failed to delete segment: #{e}"
- end
- end
end
before(:each) do
@uuid = SecureRandom.uuid
@master_project = @client.create_project(title: "Test MASTER project for #{@uuid}", auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
@@ -60,21 +53,22 @@
@segment = nil
end
end
describe '#save' do
+ after do
+ @different_master.delete if @different_master
+ @different_data_product.delete if @different_data_product
+ end
+
it 'can update a segment master project' do
- begin
- different_master = @client.create_project(title: 'Test project', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
- @segment.master_project = different_master
- @segment.save
- @segment = @domain.segments(@segment_name)
- expect(@segment.master_project_uri).not_to eq @master_project.uri
- expect(@segment.master_project_uri).to eq different_master.uri
- ensure
- different_master.delete if different_master
- end
+ @different_master = @client.create_project(title: 'Test project', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
+ @segment.master_project = @different_master
+ @segment.save
+ @segment = @domain.segments(@segment_name)
+ expect(@segment.master_project_uri).not_to eq @master_project.uri
+ expect(@segment.master_project_uri).to eq @different_master.uri
end
it 'cannot update a segment id' do
@segment.segment_id = 'different_id'
expect do
@@ -82,18 +76,25 @@
end.to raise_error RestClient::BadRequest
end
end
describe '#create_client' do
+ after do
+ @client_project && @client_project.delete
+ @segment_client && @segment_client.delete
+ end
+
it 'can create a new client in a segment' do
- begin
- client_project = @client.create_project(title: 'client_1 project', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
- segment_client = @segment.create_client(id: 'tenant_1', project: client_project)
- expect(segment_client).to be_an_instance_of(GoodData::Client)
- expect(@segment.clients.count).to eq 1
- ensure
- client_project.delete if client_project
- segment_client && segment_client.delete
- end
+ @client_project = @client.create_project(title: 'client_1 project', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
+ @segment_client = @segment.create_client(id: 'tenant_1', project: @client_project)
+ expect(@segment_client).to be_an_instance_of(GoodData::Client)
+ expect(@segment.clients.count).to eq 1
+ end
+ end
+
+ describe '#provision_client_projects' do
+ it 'returns an enumerable result' do
+ result = @segment.provision_client_projects
+ expect(result).to be_an_instance_of(Enumerator)
end
end
end