Skip to content

Commit 7476660

Browse files
committed
test: Ensure idempotency in airline creation tests
Added a cleanup step to delete any existing airline before creating a new one in the airlines_spec. This change ensures that the tests are idempotent and do not interfere with each other, improving test reliability.
1 parent 9f14575 commit 7476660

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spec/requests/api/v1/airlines_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@
134134

135135
context 'when the airline is deleted successfully' do
136136
it 'returns a success message' do
137+
# Clean up any existing test data first to ensure idempotent test
138+
delete "/api/v1/airlines/#{airline_id}"
139+
137140
post "/api/v1/airlines/#{airline_id}", params: { airline: airline_params }
141+
expect(response).to have_http_status(:created)
138142

139143
delete "/api/v1/airlines/#{airline_id}"
140144

0 commit comments

Comments
 (0)