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
6264694d
Commit
6264694d
authored
Mar 20, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the hidden option to whitelisted
parent
69dc893d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
9 deletions
+10
-9
app/models/broadcast_message.rb
app/models/broadcast_message.rb
+1
-1
app/models/concerns/cache_markdown_field.rb
app/models/concerns/cache_markdown_field.rb
+7
-6
spec/models/concerns/cache_markdown_field_spec.rb
spec/models/concerns/cache_markdown_field_spec.rb
+2
-2
No files found.
app/models/broadcast_message.rb
View file @
6264694d
...
@@ -4,7 +4,7 @@ class BroadcastMessage < ActiveRecord::Base
...
@@ -4,7 +4,7 @@ class BroadcastMessage < ActiveRecord::Base
include
CacheMarkdownField
include
CacheMarkdownField
include
Sortable
include
Sortable
cache_markdown_field
:message
,
pipeline: :broadcast_message
,
hidden:
fals
e
cache_markdown_field
:message
,
pipeline: :broadcast_message
,
whitelisted:
tru
e
validates
:message
,
presence:
true
validates
:message
,
presence:
true
validates
:starts_at
,
presence:
true
validates
:starts_at
,
presence:
true
...
...
app/models/concerns/cache_markdown_field.rb
View file @
6264694d
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
# cache_markdown_field :foo
# cache_markdown_field :foo
# cache_markdown_field :bar
# cache_markdown_field :bar
# cache_markdown_field :baz, pipeline: :single_line
# cache_markdown_field :baz, pipeline: :single_line
# cache_markdown_field :baz,
hidden: fals
e
# cache_markdown_field :baz,
whitelisted: tru
e
#
#
# Corresponding foo_html, bar_html and baz_html fields should exist.
# Corresponding foo_html, bar_html and baz_html fields should exist.
module
CacheMarkdownField
module
CacheMarkdownField
...
@@ -41,9 +41,9 @@ module CacheMarkdownField
...
@@ -41,9 +41,9 @@ module CacheMarkdownField
markdown_fields
.
map
{
|
field
|
html_field
(
field
)
}
markdown_fields
.
map
{
|
field
|
html_field
(
field
)
}
end
end
def
h
idden_html_fields
def
h
tml_fields_whitelisted
markdown_fields
.
each_with_object
([])
do
|
field
,
fields
|
markdown_fields
.
each_with_object
([])
do
|
field
,
fields
|
if
@data
[
field
].
fetch
(
:
hidden
,
tru
e
)
if
@data
[
field
].
fetch
(
:
whitelisted
,
fals
e
)
fields
<<
html_field
(
field
)
fields
<<
html_field
(
field
)
end
end
end
end
...
@@ -159,13 +159,14 @@ module CacheMarkdownField
...
@@ -159,13 +159,14 @@ module CacheMarkdownField
def
attributes
def
attributes
attrs
=
attributes_before_markdown_cache
attrs
=
attributes_before_markdown_cache
html_fields
=
cached_markdown_fields
.
html_fields
html_fields
=
cached_markdown_fields
.
html_fields
hidden_html_fields
=
cached_markdown_fields
.
hidden_html_fields
whitelisted
=
cached_markdown_fields
.
html_fields_whitelisted
exclude_fields
=
html_fields
-
whitelisted
hidden_html
_fields
.
each
do
|
field
|
exclude
_fields
.
each
do
|
field
|
attrs
.
delete
(
field
)
attrs
.
delete
(
field
)
end
end
if
(
html_fields
-
hidden_html_fields
)
.
empty?
if
whitelisted
.
empty?
attrs
.
delete
(
'cached_markdown_version'
)
attrs
.
delete
(
'cached_markdown_version'
)
end
end
...
...
spec/models/concerns/cache_markdown_field_spec.rb
View file @
6264694d
...
@@ -23,7 +23,7 @@ describe CacheMarkdownField do
...
@@ -23,7 +23,7 @@ describe CacheMarkdownField do
include
CacheMarkdownField
include
CacheMarkdownField
cache_markdown_field
:foo
cache_markdown_field
:foo
cache_markdown_field
:baz
,
pipeline: :single_line
cache_markdown_field
:baz
,
pipeline: :single_line
cache_markdown_field
:zoo
,
hidden:
fals
e
cache_markdown_field
:zoo
,
whitelisted:
tru
e
def
self
.
add_attr
(
name
)
def
self
.
add_attr
(
name
)
self
.
attribute_names
+=
[
name
]
self
.
attribute_names
+=
[
name
]
...
@@ -85,7 +85,7 @@ describe CacheMarkdownField do
...
@@ -85,7 +85,7 @@ describe CacheMarkdownField do
end
end
describe
'.attributes'
do
describe
'.attributes'
do
it
'excludes cache attributes that is
hidden
by default'
do
it
'excludes cache attributes that is
blacklisted
by default'
do
expect
(
thing
.
attributes
.
keys
.
sort
).
to
eq
(
%w[bar baz cached_markdown_version foo zoo zoo_html]
)
expect
(
thing
.
attributes
.
keys
.
sort
).
to
eq
(
%w[bar baz cached_markdown_version foo zoo zoo_html]
)
end
end
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