Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bd88c34c
Commit
bd88c34c
authored
Sep 06, 2021
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ZoomValidator to use `gitlab/zoom_url` namespace
parent
7261fde0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
24 deletions
+24
-24
app/models/zoom_meeting.rb
app/models/zoom_meeting.rb
+1
-1
app/validators/gitlab/utils/zoom_url_validator.rb
app/validators/gitlab/utils/zoom_url_validator.rb
+0
-22
app/validators/gitlab/zoom_url_validator.rb
app/validators/gitlab/zoom_url_validator.rb
+22
-0
spec/validators/gitlab/zoom_url_validator_spec.rb
spec/validators/gitlab/zoom_url_validator_spec.rb
+1
-1
No files found.
app/models/zoom_meeting.rb
View file @
bd88c34c
...
...
@@ -10,7 +10,7 @@ class ZoomMeeting < ApplicationRecord
validates
:project
,
presence:
true
,
unless: :importing?
validates
:issue
,
presence:
true
,
unless: :importing?
validates
:url
,
presence:
true
,
length:
{
maximum:
255
},
'gitlab/
utils/
zoom_url'
:
true
validates
:url
,
presence:
true
,
length:
{
maximum:
255
},
'gitlab/zoom_url'
:
true
validates
:issue
,
same_project_association:
true
,
unless: :importing?
enum
issue_status:
{
...
...
app/validators/gitlab/utils/zoom_url_validator.rb
deleted
100644 → 0
View file @
7261fde0
# frozen_string_literal: true
# Gitlab::Utils::ZoomUrlValidator
#
# Custom validator for zoom urls
#
module
Gitlab
module
Utils
class
ZoomUrlValidator
<
ActiveModel
::
EachValidator
ALLOWED_SCHEMES
=
%w(https)
.
freeze
def
validate_each
(
record
,
attribute
,
value
)
links_count
=
Gitlab
::
ZoomLinkExtractor
.
new
(
value
).
links
.
size
valid
=
Gitlab
::
UrlSanitizer
.
valid?
(
value
,
allowed_schemes:
ALLOWED_SCHEMES
)
return
if
links_count
==
1
&&
valid
record
.
errors
.
add
(
:url
,
'must contain one valid Zoom URL'
)
end
end
end
end
app/validators/gitlab/zoom_url_validator.rb
0 → 100644
View file @
bd88c34c
# frozen_string_literal: true
module
Gitlab
# Gitlab::Utils::ZoomUrlValidator
#
# Custom validator for zoom urls
#
# @example usage
# validates :url, 'gitlab/zoom_url': true
class
ZoomUrlValidator
<
ActiveModel
::
EachValidator
ALLOWED_SCHEMES
=
%w(https)
.
freeze
def
validate_each
(
record
,
attribute
,
value
)
links_count
=
Gitlab
::
ZoomLinkExtractor
.
new
(
value
).
links
.
size
valid
=
Gitlab
::
UrlSanitizer
.
valid?
(
value
,
allowed_schemes:
ALLOWED_SCHEMES
)
return
if
links_count
==
1
&&
valid
record
.
errors
.
add
(
:url
,
'must contain one valid Zoom URL'
)
end
end
end
spec/validators/gitlab/
utils/
zoom_url_validator_spec.rb
→
spec/validators/gitlab/zoom_url_validator_spec.rb
View file @
bd88c34c
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Utils
::
ZoomUrlValidator
do
RSpec
.
describe
Gitlab
::
ZoomUrlValidator
do
let
(
:zoom_meeting
)
{
build
(
:zoom_meeting
)
}
describe
'validations'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment