From 02e6fe98504a53d3b85db05f2b2a8a4705b783f6 Mon Sep 17 00:00:00 2001 From: mroloux Date: Mon, 16 Oct 2023 16:37:27 +0200 Subject: [PATCH] Added call that copies a chart from a workspace to another workspace (#90) --- lib/seatsio/charts.rb | 6 +++++ .../copy_chart_from_workspace_to_test.rb | 22 +++++++++++++++++++ test/seatsio_test_client.rb | 1 + 3 files changed, 29 insertions(+) create mode 100644 test/charts/copy_chart_from_workspace_to_test.rb diff --git a/lib/seatsio/charts.rb b/lib/seatsio/charts.rb index 4e5cbbf..2f26cfb 100644 --- a/lib/seatsio/charts.rb +++ b/lib/seatsio/charts.rb @@ -70,6 +70,12 @@ def copy_to_workspace(chart_key, to_workspace_key) Chart.new(response) end + def copy_from_workspace_to(chart_key, from_workspace_key, to_workspace_key) + url = "charts/#{chart_key}/version/published/actions/copy/from/#{from_workspace_key}/to/#{to_workspace_key}" + response = @http_client.post url + Chart.new(response) + end + def copy_draft_version(key) response = @http_client.post("charts/#{key}/version/draft/actions/copy") Chart.new(response) diff --git a/test/charts/copy_chart_from_workspace_to_test.rb b/test/charts/copy_chart_from_workspace_to_test.rb new file mode 100644 index 0000000..cbf6e93 --- /dev/null +++ b/test/charts/copy_chart_from_workspace_to_test.rb @@ -0,0 +1,22 @@ +require "test_helper" +require "util" + +class CopyChartToWorkspaceTest < SeatsioTestClient + def test_copy_to_workspace + chart = @seatsio.charts.create name: 'my chart', venue_type: 'BOOTHS' + to_workspace = @seatsio.workspaces.create name: 'my ws' + + copied_chart = @seatsio.charts.copy_from_workspace_to(chart.key, @workspace.key, to_workspace.key) + + workspace_client = test_client(to_workspace.secret_key, nil) + assert_equal("my chart", copied_chart.name) + + retrieved_chart = workspace_client.charts.retrieve(copied_chart.key) + assert_equal("my chart", retrieved_chart.name) + + drawing = workspace_client.charts.retrieve_published_version(copied_chart.key) + assert_equal("BOOTHS", drawing['venueType']) + + end + +end diff --git a/test/seatsio_test_client.rb b/test/seatsio_test_client.rb index 987e255..83c3e8b 100644 --- a/test/seatsio_test_client.rb +++ b/test/seatsio_test_client.rb @@ -5,6 +5,7 @@ class SeatsioTestClient < Minitest::Test def setup company = create_test_user @user = company['admin'] + @workspace = Seatsio::Workspace.new(company['workspace']) @seatsio = test_client(@user['secretKey'], nil) end