Commit 0ac9ab7c authored by Stan Hu's avatar Stan Hu

Fix JIRA client spec failing due to time differences

Jobs such as https://gitlab.com/gitlab-org/gitlab-foss/-/jobs/1686583500
were intermittently failing because the Authorization header would have
slightly different JWTs. It turns out the `iat` and `exp` fields were
off by a second since the test might generate the field before the test
made the HTTP request.

We fix this issue by freezing the time whenever we need to make an HTTP
request.
parent 0c9dbf79
......@@ -18,7 +18,15 @@ RSpec.describe Atlassian::JiraConnect::Client do
end
end
describe '.generate_update_sequence_id' do
around do |example|
if example.metadata[:skip_freeze_time]
example.run
else
freeze_time { example.run }
end
end
describe '.generate_update_sequence_id', :skip_freeze_time do
it 'returns unix time in microseconds as integer', :aggregate_failures do
travel_to(Time.utc(1970, 1, 1, 0, 0, 1)) do
expect(described_class.generate_update_sequence_id).to eq(1000)
......
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