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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
b9df1a63
Commit
b9df1a63
authored
Nov 26, 2015
by
Jose Corcuera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip attributes for Milestone and Issuable. #3428
parent
68a45338
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
6 deletions
+62
-6
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-3
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-3
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+2
-0
app/models/concerns/strip_attribute.rb
app/models/concerns/strip_attribute.rb
+34
-0
app/models/milestone.rb
app/models/milestone.rb
+3
-0
spec/models/concerns/strip_attribute_spec.rb
spec/models/concerns/strip_attribute_spec.rb
+20
-0
No files found.
CHANGELOG
View file @
b9df1a63
...
@@ -4,6 +4,7 @@ v 8.3.0 (unreleased)
...
@@ -4,6 +4,7 @@ v 8.3.0 (unreleased)
- Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera)
- Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera)
- Fix 500 error when update group member permission
- Fix 500 error when update group member permission
- Fix: Raw private snippets access workflow
- Fix: Raw private snippets access workflow
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
v 8.2.1
v 8.2.1
- Forcefully update builds that didn't want to update with state machine
- Forcefully update builds that didn't want to update with state machine
...
...
app/controllers/projects/issues_controller.rb
View file @
b9df1a63
...
@@ -158,12 +158,10 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -158,12 +158,10 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
def
issue_params
def
issue_params
p
ermitted
=
p
arams
.
require
(
:issue
).
permit
(
params
.
require
(
:issue
).
permit
(
:title
,
:assignee_id
,
:position
,
:description
,
:title
,
:assignee_id
,
:position
,
:description
,
:milestone_id
,
:state_event
,
:task_num
,
label_ids:
[]
:milestone_id
,
:state_event
,
:task_num
,
label_ids:
[]
)
)
params
[
:issue
][
:title
].
strip!
if
params
[
:issue
][
:title
]
permitted
end
end
def
bulk_update_params
def
bulk_update_params
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
b9df1a63
...
@@ -276,13 +276,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -276,13 +276,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
merge_request_params
def
merge_request_params
p
ermitted
=
p
arams
.
require
(
:merge_request
).
permit
(
params
.
require
(
:merge_request
).
permit
(
:title
,
:assignee_id
,
:source_project_id
,
:source_branch
,
:title
,
:assignee_id
,
:source_project_id
,
:source_branch
,
:target_project_id
,
:target_branch
,
:milestone_id
,
:target_project_id
,
:target_branch
,
:milestone_id
,
:state_event
,
:description
,
:task_num
,
label_ids:
[]
:state_event
,
:description
,
:task_num
,
label_ids:
[]
)
)
params
[
:merge_request
][
:title
].
strip!
if
params
[
:merge_request
][
:title
]
permitted
end
end
# Make sure merge requests created before 8.0
# Make sure merge requests created before 8.0
...
...
app/models/concerns/issuable.rb
View file @
b9df1a63
...
@@ -8,6 +8,7 @@ module Issuable
...
@@ -8,6 +8,7 @@ module Issuable
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
include
Participable
include
Participable
include
Mentionable
include
Mentionable
include
StripAttribute
included
do
included
do
belongs_to
:author
,
class_name:
"User"
belongs_to
:author
,
class_name:
"User"
...
@@ -51,6 +52,7 @@ module Issuable
...
@@ -51,6 +52,7 @@ module Issuable
attr_mentionable
:title
,
:description
attr_mentionable
:title
,
:description
participant
:author
,
:assignee
,
:notes_with_associations
participant
:author
,
:assignee
,
:notes_with_associations
strip_attributes
:title
end
end
module
ClassMethods
module
ClassMethods
...
...
app/models/concerns/strip_attribute.rb
0 → 100644
View file @
b9df1a63
# == Strip Attribute module
#
# Contains functionality to clean attributes before validation
#
# Usage:
#
# class Milestone < ActiveRecord::Base
# strip_attributes :title
# end
#
#
module
StripAttribute
extend
ActiveSupport
::
Concern
module
ClassMethods
def
strip_attributes
(
*
attrs
)
strip_attrs
.
concat
(
attrs
)
end
def
strip_attrs
@strip_attrs
||=
[]
end
end
included
do
before_validation
:strip_attributes
end
def
strip_attributes
self
.
class
.
strip_attrs
.
each
do
|
attr
|
self
[
attr
].
strip!
if
self
[
attr
]
&&
self
[
attr
].
respond_to?
(
:strip!
)
end
end
end
app/models/milestone.rb
View file @
b9df1a63
...
@@ -22,6 +22,7 @@ class Milestone < ActiveRecord::Base
...
@@ -22,6 +22,7 @@ class Milestone < ActiveRecord::Base
include
InternalId
include
InternalId
include
Sortable
include
Sortable
include
StripAttribute
belongs_to
:project
belongs_to
:project
has_many
:issues
has_many
:issues
...
@@ -35,6 +36,8 @@ class Milestone < ActiveRecord::Base
...
@@ -35,6 +36,8 @@ class Milestone < ActiveRecord::Base
validates
:title
,
presence:
true
validates
:title
,
presence:
true
validates
:project
,
presence:
true
validates
:project
,
presence:
true
strip_attributes
:title
state_machine
:state
,
initial: :active
do
state_machine
:state
,
initial: :active
do
event
:close
do
event
:close
do
transition
active: :closed
transition
active: :closed
...
...
spec/models/concerns/strip_attribute_spec.rb
0 → 100644
View file @
b9df1a63
require
'spec_helper'
describe
Milestone
,
"StripAttribute"
do
let
(
:milestone
)
{
create
(
:milestone
)
}
describe
".strip_attributes"
do
it
{
expect
(
Milestone
).
to
respond_to
(
:strip_attributes
)
}
it
{
expect
(
Milestone
.
strip_attrs
).
to
include
(
:title
)
}
end
describe
"#strip_attributes"
do
before
do
milestone
.
title
=
' 8.3 '
milestone
.
valid?
end
it
{
expect
(
milestone
.
title
).
to
eq
(
'8.3'
)
}
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