Skip to content

Commit

Permalink
Support overriding or using the season status in batch (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Nov 22, 2024
1 parent 298d78f commit b58c0df
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/seatsio/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ def initialize(data)
class StatusChangeType
CHANGE_STATUS_TO = 'CHANGE_STATUS_TO'
RELEASE = 'RELEASE'
OVERRIDE_SEASON_STATUS = 'OVERRIDE_SEASON_STATUS'
USE_SEASON_STATUS = 'USE_SEASON_STATUS'
end

class EventObjectInfo
Expand Down
27 changes: 26 additions & 1 deletion test/events/change_object_status_in_batch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_rejected_previous_statuses
end
end

def release_in_batch
def test_release_in_batch
chart_key = create_test_chart
event = @seatsio.events.create chart_key: chart_key
@seatsio.events.book(event.key, ['A-1'])
Expand All @@ -94,4 +94,29 @@ def release_in_batch
assert_equal(Seatsio::EventObjectInfo::FREE, res[0].objects['A-1'].status)
assert_equal(Seatsio::EventObjectInfo::FREE, @seatsio.events.retrieve_object_info(key: event.key, label: 'A-1').status)
end

def test_override_season_status_in_batch
chart_key = create_test_chart
season = @seatsio.seasons.create chart_key: chart_key, event_keys: %w[event1]
@seatsio.events.book(season.key, ["A-1"])

res = @seatsio.events.change_object_status_in_batch([{ :type => Seatsio::StatusChangeType::OVERRIDE_SEASON_STATUS, :event => "event1", :objects => ['A-1'] }])

assert_equal(Seatsio::EventObjectInfo::FREE, res[0].objects['A-1'].status)
a1_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-1').status
assert_equal(Seatsio::EventObjectInfo::FREE, a1_status)
end

def test_use_season_status_in_batch
chart_key = create_test_chart
season = @seatsio.seasons.create chart_key: chart_key, event_keys: %w[event1]
@seatsio.events.book(season.key, ["A-1"])
@seatsio.events.override_season_object_status(key: "event1", objects: %w(A-1))

res = @seatsio.events.change_object_status_in_batch([{ :type => Seatsio::StatusChangeType::USE_SEASON_STATUS, :event => "event1", :objects => ['A-1'] }])

assert_equal(Seatsio::EventObjectInfo::BOOKED, res[0].objects['A-1'].status)
a1_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-1').status
assert_equal(Seatsio::EventObjectInfo::BOOKED, a1_status)
end
end

0 comments on commit b58c0df

Please sign in to comment.