Commit ed6327ef authored by Philip Cunningham's avatar Philip Cunningham Committed by Dylan Griffith

Fix return type of DastSiteProfile#status

This was returning a symbol when it should have been returning a String.
parent b076da89
# frozen_string_literal: true # frozen_string_literal: true
class DastSiteValidation < ApplicationRecord class DastSiteValidation < ApplicationRecord
HEADER = 'Gitlab-On-Demand-DAST'.freeze HEADER = 'Gitlab-On-Demand-DAST'
belongs_to :dast_site_token belongs_to :dast_site_token
has_many :dast_sites has_many :dast_sites
...@@ -27,9 +27,9 @@ class DastSiteValidation < ApplicationRecord ...@@ -27,9 +27,9 @@ class DastSiteValidation < ApplicationRecord
"#{url_base}/#{url_path}" "#{url_base}/#{url_path}"
end end
INITIAL_STATE = :pending INITIAL_STATE = 'pending'
state_machine :state, initial: INITIAL_STATE do state_machine :state, initial: INITIAL_STATE.to_sym do
event :start do event :start do
transition pending: :inprogress transition pending: :inprogress
end end
......
...@@ -44,7 +44,7 @@ module DastSiteTokens ...@@ -44,7 +44,7 @@ module DastSiteTokens
end end
def calculate_status(dast_site_validation) def calculate_status(dast_site_validation)
dast_site_validation&.state || DastSiteValidation::INITIAL_STATE.to_s dast_site_validation&.state || DastSiteValidation::INITIAL_STATE
end end
end end
end end
---
title: Fix return type of DastSiteProfile#status
merge_request: 46180
author:
type: fixed
...@@ -79,7 +79,7 @@ RSpec.describe DastSiteProfile, type: :model do ...@@ -79,7 +79,7 @@ RSpec.describe DastSiteProfile, type: :model do
aggregate_failures do aggregate_failures do
expect(subject.dast_site_validation).to be_nil expect(subject.dast_site_validation).to be_nil
expect(subject.status).to eq(:pending) expect(subject.status).to eq('pending')
end end
end end
end end
......
...@@ -98,5 +98,13 @@ RSpec.describe 'Query.project(fullPath).dastSiteProfile' do ...@@ -98,5 +98,13 @@ RSpec.describe 'Query.project(fullPath).dastSiteProfile' do
expect(dast_site_profile_response).to be_nil expect(dast_site_profile_response).to be_nil
end end
end end
context 'when there is no associated dast_site_validation' do
it 'returns a pending validation status' do
dast_site_profile.dast_site_validation.destroy!
expect(dast_site_profile_response['validationStatus']).to eq('PENDING_VALIDATION')
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment