summaryrefslogtreecommitdiff
path: root/spec/frontend/fixtures/freeze_period.rb
blob: 09e4f969e1d921d8069e7e147c29150b18b83762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Freeze Periods (JavaScript fixtures)' do
  include JavaScriptFixturesHelpers
  include TimeZoneHelper

  let_it_be(:project) { create(:project, :repository, path: 'freeze-periods-project') }
  let_it_be(:user) { project.owner }

  before(:all) do
    clean_frontend_fixtures('api/freeze-periods/')
  end

  after(:all) do
    remove_repository(project)
  end

  around do |example|
    freeze_time do
      # Mock time to sept 19 (intl. talk like a pirate day)
      Timecop.travel(2020, 9, 19)

      example.run
    end
  end

  describe API::FreezePeriods, '(JavaScript fixtures)', type: :request do
    include ApiHelpers

    it 'api/freeze-periods/freeze_periods.json' do
      create(:ci_freeze_period, project: project, freeze_start: '5 4 * * *', freeze_end: '5 9 * 8 *', cron_timezone: 'America/New_York')
      create(:ci_freeze_period, project: project, freeze_start: '0 12 * * 1-5', freeze_end: '0 1 5 * *', cron_timezone: 'Etc/UTC')
      create(:ci_freeze_period, project: project, freeze_start: '0 12 * * 1-5', freeze_end: '0 16 * * 6', cron_timezone: 'Europe/Berlin')

      get api("/projects/#{project.id}/freeze_periods", user)

      expect(response).to be_successful
    end
  end

  describe TimeZoneHelper, '(JavaScript fixtures)' do
    let(:response) { timezone_data.to_json }

    it 'api/freeze-periods/timezone_data.json' do
      # Looks empty but does things
      # More info: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38525/diffs#note_391048415
    end
  end
end