debian-mirror-gitlab/spec/validators/gitlab/zoom_url_validator_spec.rb

37 lines
1.1 KiB
Ruby
Raw Normal View History

2020-12-08 15:28:05 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-11-11 11:23:49 +05:30
RSpec.describe Gitlab::ZoomUrlValidator do
2020-12-08 15:28:05 +05:30
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
2021-06-08 01:23:25 +05:30
expect(zoom_meeting.errors.added?(:url, 'must contain one valid Zoom URL')).to be true
2020-12-08 15:28:05 +05:30
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