Commit 22cdb0b1 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'fix_flaky_tests_for_historical_vulnerability_statistics' into 'master'

Fix flaky tests on historical vulnerability statistic specs

See merge request gitlab-org/gitlab!38377
parents 2d8b8494 4e1f2606
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :vulnerability_historical_statistic, class: 'Vulnerabilities::HistoricalStatistic' do factory :vulnerability_historical_statistic, class: 'Vulnerabilities::HistoricalStatistic' do
project project
letter_grade { 'a' } letter_grade { 'a' }
date { Date.today } date { Date.current }
end end
end end
...@@ -5,6 +5,10 @@ require 'spec_helper' ...@@ -5,6 +5,10 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::HistoricalStatistics::AdjustmentService do RSpec.describe Vulnerabilities::HistoricalStatistics::AdjustmentService do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
around do |example|
travel_to(Date.current) { example.run }
end
describe '.execute' do describe '.execute' do
let(:project_ids) { [1, 2, 3] } let(:project_ids) { [1, 2, 3] }
let(:mock_service_object) { instance_double(described_class, execute: true) } let(:mock_service_object) { instance_double(described_class, execute: true) }
...@@ -37,7 +41,7 @@ RSpec.describe Vulnerabilities::HistoricalStatistics::AdjustmentService do ...@@ -37,7 +41,7 @@ RSpec.describe Vulnerabilities::HistoricalStatistics::AdjustmentService do
'info' => 0, 'info' => 0,
'unknown' => 0, 'unknown' => 0,
'letter_grade' => 'f', 'letter_grade' => 'f',
'date' => Date.today.to_s 'date' => Date.current.to_s
} }
end end
......
...@@ -30,6 +30,10 @@ RSpec.describe Vulnerabilities::HistoricalStatistics::UpdateService do ...@@ -30,6 +30,10 @@ RSpec.describe Vulnerabilities::HistoricalStatistics::UpdateService do
end end
context 'when there is already a record in the database' do context 'when there is already a record in the database' do
around do |example|
travel_to(Date.current) { example.run }
end
it 'changes the existing historical statistic entity' do it 'changes the existing historical statistic entity' do
historical_statistic = create(:vulnerability_historical_statistic, project: project, letter_grade: 'c') historical_statistic = create(:vulnerability_historical_statistic, project: project, letter_grade: 'c')
......
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