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
c3879358
Commit
c3879358
authored
Oct 09, 2019
by
allison.browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract zoom meeting validators to Validator class
parent
af7cd095
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
app/models/zoom_meeting.rb
app/models/zoom_meeting.rb
+1
-16
app/validators/zoom_meeting_validator.rb
app/validators/zoom_meeting_validator.rb
+17
-0
No files found.
app/models/zoom_meeting.rb
View file @
c3879358
...
...
@@ -5,9 +5,7 @@ class ZoomMeeting < ApplicationRecord
belongs_to
:issue
,
optional:
false
validates
:url
,
presence:
true
,
length:
{
maximum:
255
}
validate
:check_zoom_url
validate
:check_issue_association
validates_with
ZoomMeetingValidator
enum
issue_status:
{
added:
1
,
...
...
@@ -17,17 +15,4 @@ class ZoomMeeting < ApplicationRecord
scope
:added_to_issue
,
->
{
where
(
issue_status: :added
)
}
scope
:removed_from_issue
,
->
{
where
(
issue_status: :removed
)
}
private
def
check_zoom_url
return
if
Gitlab
::
ZoomLinkExtractor
.
new
(
url
).
links
.
size
==
1
errors
.
add
(
:url
,
'must contain one valid Zoom URL'
)
end
def
check_issue_association
return
if
project
==
issue
&
.
project
errors
.
add
(
:issue
,
'must associate the same project'
)
end
end
app/validators/zoom_meeting_validator.rb
0 → 100644
View file @
c3879358
# frozen_string_literal: true
# ZoomMeetingValidator
#
# Custom validator to TODO
#
class
ZoomMeetingValidator
<
ActiveModel
::
Validator
def
validate
(
zoom_meeting
)
unless
Gitlab
::
ZoomLinkExtractor
.
new
(
zoom_meeting
.
url
).
links
.
size
==
1
zoom_meeting
.
errors
.
add
(
:url
,
'must contain one valid Zoom URL'
)
end
unless
zoom_meeting
.
project
==
zoom_meeting
.
issue
&
.
project
zoom_meeting
.
errors
.
add
(
:issue
,
'must associate the same project'
)
end
true
end
end
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