# Copyright (c) 2015 Perforce Software, Inc. All rights reserved. require_relative '../test_config' require 'helix_versioning_engine' RSpec.describe 'HelixVersioningEngine triggers' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end entry = 'cscheck change-submit //depot/... "cmd %changelist%"' it 'should add a triggers entry' do authorize 'super', ticket_for_super get('/p4/v78/triggers') expect(last_response.status).to eq(200) obj = JSON.parse(last_response.body) obj['Triggers'] = [] unless obj.key?('Triggers') obj['Triggers'] << entry put('/p4/v78/triggers', obj) expect(last_response.status).to eq(200) get('/p4/v78/triggers') expect(last_response.status).to eq(200) updated = JSON.parse(last_response.body) expect(updated['Triggers']).to include(entry) end it 'should remove the triggers entry' do authorize 'super', ticket_for_super get('/p4/v78/triggers') expect(last_response.status).to eq(200) obj = JSON.parse(last_response.body) obj['Triggers'].delete(entry) put('/p4/v78/triggers', obj) expect(last_response.status).to eq(200) get('/p4/v78/triggers') expect(last_response.status).to eq(200) updated = JSON.parse(last_response.body) updated['Triggers'] = [] unless updated.key?('Triggers') expect(updated['Triggers']).to_not include(entry) end end