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
c0845073
Commit
c0845073
authored
Aug 25, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow snippet move actions without an existing file name
parent
e7d96fd0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
4 deletions
+25
-4
app/models/snippet_input_action.rb
app/models/snippet_input_action.rb
+1
-1
changelogs/unreleased/239341-fj-allow-snippet-move-action-without-file-path.yml
...239341-fj-allow-snippet-move-action-without-file-path.yml
+5
-0
spec/models/snippet_input_action_spec.rb
spec/models/snippet_input_action_spec.rb
+3
-3
spec/services/snippets/update_service_spec.rb
spec/services/snippets/update_service_spec.rb
+16
-0
No files found.
app/models/snippet_input_action.rb
View file @
c0845073
...
...
@@ -15,7 +15,7 @@ class SnippetInputAction
validates
:action
,
inclusion:
{
in:
ACTIONS
,
message:
"%{value} is not a valid action"
}
validates
:previous_path
,
presence:
true
,
if: :move_action?
validates
:file_path
,
presence:
true
,
unless: :create_action?
validates
:file_path
,
presence:
true
,
if:
->
(
action
)
{
action
.
update_action?
||
action
.
delete_action?
}
validates
:content
,
presence:
true
,
if:
->
(
action
)
{
action
.
create_action?
||
action
.
update_action?
}
validate
:ensure_same_file_path_and_previous_path
,
if: :update_action?
validate
:ensure_different_file_path_and_previous_path
,
if: :move_action?
...
...
changelogs/unreleased/239341-fj-allow-snippet-move-action-without-file-path.yml
0 → 100644
View file @
c0845073
---
title
:
Allow snippet move action without an existing file name
merge_request
:
40343
author
:
type
:
fixed
spec/models/snippet_input_action_spec.rb
View file @
c0845073
...
...
@@ -22,9 +22,9 @@ RSpec.describe SnippetInputAction do
:move
|
'foobar'
|
'foobar'
|
nil
|
nil
|
false
|
:previous_path
:move
|
'foobar'
|
'foobar'
|
''
|
nil
|
false
|
:previous_path
:move
|
'foobar'
|
'foobar'
|
'foobar'
|
nil
|
false
|
:file_path
:move
|
nil
|
'foobar'
|
'foobar'
|
nil
|
false
|
:file_path
:move
|
''
|
'foobar'
|
'foobar'
|
nil
|
false
|
:file_path
:move
|
nil
|
'foobar'
|
'foo1'
|
nil
|
false
|
:file_path
:move
|
nil
|
'foobar'
|
'foobar'
|
nil
|
true
|
nil
:move
|
''
|
'foobar'
|
'foobar'
|
nil
|
true
|
nil
:move
|
nil
|
'foobar'
|
'foo1'
|
nil
|
true
|
nil
:move
|
'foobar'
|
nil
|
'foo1'
|
nil
|
true
|
nil
:move
|
'foobar'
|
''
|
'foo1'
|
nil
|
true
|
nil
:create
|
'foobar'
|
nil
|
'foobar'
|
nil
|
false
|
:content
...
...
spec/services/snippets/update_service_spec.rb
View file @
c0845073
...
...
@@ -479,6 +479,22 @@ RSpec.describe Snippets::UpdateService do
expect
(
blob
.
data
).
to
eq
content
end
end
context
'when the file_path is not present'
do
let
(
:snippet_actions
)
{
[{
action: :move
,
previous_path:
file_path
}]
}
it
'generates the name for the renamed file'
do
old_blob
=
blob
(
file_path
)
expect
(
blob
(
'snippetfile1.txt'
)).
to
be_nil
expect
(
subject
).
to
be_success
new_blob
=
blob
(
'snippetfile1.txt'
)
expect
(
new_blob
).
to
be_present
expect
(
new_blob
.
data
).
to
eq
old_blob
.
data
end
end
end
context
'delete action'
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