Skip to content

Commit

Permalink
Added call that copies a chart from a workspace to another workspace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Oct 16, 2023
1 parent f9f3969 commit 02e6fe9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/seatsio/charts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions test/charts/copy_chart_from_workspace_to_test.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/seatsio_test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 02e6fe9

Please sign in to comment.