Welcome to mirror list, hosted at ThFree Co, Russian Federation.

zoom_url_validator_spec.rb « gitlab « validators « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 308a6be78eb97f4e29a997120e1c617dbe829640 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::ZoomUrlValidator do
  let(:zoom_meeting) { build(:zoom_meeting) }

  describe 'validations' do
    context 'when zoom link starts with https' do
      it 'passes validation' do
        zoom_meeting.url = 'https://zoom.us/j/123456789'

        expect(zoom_meeting.valid?).to eq(true)
        expect(zoom_meeting.errors).to be_empty
      end
    end

    shared_examples 'zoom link does not start with https' do |url|
      it 'fails validation' do
        zoom_meeting.url = url
        expect(zoom_meeting.valid?).to eq(false)

        expect(zoom_meeting.errors).to be_present
        expect(zoom_meeting.errors.added?(:url, 'must contain one valid Zoom URL')).to be true
      end
    end

    context 'when zoom link does not start with https' do
      include_examples 'zoom link does not start with https', 'http://zoom.us/j/123456789'

      context 'when zoom link does not start with a scheme' do
        include_examples 'zoom link does not start with https', 'testinghttp://zoom.us/j/123456789'
      end
    end
  end
end