From 2120c98dce67763f94fc527e3861234fec77c627 Mon Sep 17 00:00:00 2001 From: Aishwarya Kaneri Date: Wed, 20 Feb 2019 18:19:02 +0530 Subject: [PATCH] [Aishwarya|Jenson] add uuid in vpn creation using v1 api (cherry picked from commit e4783f1a376ebc98f39a19b388d1f856f2c397ee) --- app/controllers/api/v1/vpns_controller.rb | 1 + spec/controllers/api/v1/vpns_controller_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/api/v1/vpns_controller.rb b/app/controllers/api/v1/vpns_controller.rb index ea7fc29a..a12fb71c 100755 --- a/app/controllers/api/v1/vpns_controller.rb +++ b/app/controllers/api/v1/vpns_controller.rb @@ -4,6 +4,7 @@ class ::Api::V1::VpnsController < ::Api::V1::BaseController def create if current_user.admin? @vpn = Vpn.new(vpn_params) + @vpn.uuid = SecureRandom.uuid if @vpn.save render json: { id: @vpn.id, diff --git a/spec/controllers/api/v1/vpns_controller_spec.rb b/spec/controllers/api/v1/vpns_controller_spec.rb index c0c9f18a..88baa56d 100755 --- a/spec/controllers/api/v1/vpns_controller_spec.rb +++ b/spec/controllers/api/v1/vpns_controller_spec.rb @@ -20,6 +20,7 @@ vpn = Vpn.where(name: valid_attributes[:name]).first expect(vpn.blank?).to eq(false) expect(vpn.name).to eq(valid_attributes[:name]) + expect(UUID.validate(vpn.uuid)).to eq(true) end it 'should return proper response' do