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
Boxiang Sun
gitlab-ce
Commits
f7811b4b
Commit
f7811b4b
authored
Jan 29, 2018
by
Clement Ho
Committed by
Filipa Lacerda
Jan 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $.post in edit blob with axios
parent
44edd111
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
app/assets/javascripts/blob_edit/edit_blob.js
app/assets/javascripts/blob_edit/edit_blob.js
+10
-5
spec/features/projects/blobs/edit_spec.rb
spec/features/projects/blobs/edit_spec.rb
+19
-3
No files found.
app/assets/javascripts/blob_edit/edit_blob.js
View file @
f7811b4b
/* global ace */
/* global ace */
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
createFlash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
TemplateSelectorMediator
from
'
../blob/file_template_mediator
'
;
import
TemplateSelectorMediator
from
'
../blob/file_template_mediator
'
;
export
default
class
EditBlob
{
export
default
class
EditBlob
{
...
@@ -56,12 +59,14 @@ export default class EditBlob {
...
@@ -56,12 +59,14 @@ export default class EditBlob {
if
(
paneId
===
'
#preview
'
)
{
if
(
paneId
===
'
#preview
'
)
{
this
.
$toggleButton
.
hide
();
this
.
$toggleButton
.
hide
();
return
$
.
post
(
currentLink
.
data
(
'
preview-url
'
),
{
axios
.
post
(
currentLink
.
data
(
'
preview-url
'
),
{
content
:
this
.
editor
.
getValue
(),
content
:
this
.
editor
.
getValue
(),
},
(
response
)
=>
{
})
currentPane
.
empty
().
append
(
response
);
.
then
(({
data
})
=>
{
return
currentPane
.
renderGFM
();
currentPane
.
empty
().
append
(
data
);
});
currentPane
.
renderGFM
();
})
.
catch
(()
=>
createFlash
(
__
(
'
An error occurred previewing the blob
'
)));
}
}
this
.
$toggleButton
.
show
();
this
.
$toggleButton
.
show
();
...
...
spec/features/projects/blobs/edit_spec.rb
View file @
f7811b4b
...
@@ -17,13 +17,16 @@ feature 'Editing file blob', :js do
...
@@ -17,13 +17,16 @@ feature 'Editing file blob', :js do
sign_in
(
user
)
sign_in
(
user
)
end
end
def
edit_and_commit
def
edit_and_commit
(
commit_changes:
true
)
wait_for_requests
wait_for_requests
find
(
'.js-edit-blob'
).
click
find
(
'.js-edit-blob'
).
click
find
(
'#editor'
)
find
(
'#editor'
)
execute_script
(
'ace.edit("editor").setValue("class NextFeature\nend\n")'
)
execute_script
(
'ace.edit("editor").setValue("class NextFeature\nend\n")'
)
if
commit_changes
click_button
'Commit changes'
click_button
'Commit changes'
end
end
end
context
'from MR diff'
do
context
'from MR diff'
do
before
do
before
do
...
@@ -39,13 +42,26 @@ feature 'Editing file blob', :js do
...
@@ -39,13 +42,26 @@ feature 'Editing file blob', :js do
context
'from blob file path'
do
context
'from blob file path'
do
before
do
before
do
visit
project_blob_path
(
project
,
tree_join
(
branch
,
file_path
))
visit
project_blob_path
(
project
,
tree_join
(
branch
,
file_path
))
edit_and_commit
end
end
it
'updates content'
do
it
'updates content'
do
edit_and_commit
expect
(
page
).
to
have_content
'successfully committed'
expect
(
page
).
to
have_content
'successfully committed'
expect
(
page
).
to
have_content
'NextFeature'
expect
(
page
).
to
have_content
'NextFeature'
end
end
it
'previews content'
do
edit_and_commit
(
commit_changes:
false
)
click_link
'Preview changes'
wait_for_requests
old_line_count
=
page
.
all
(
'.line_holder.old'
).
size
new_line_count
=
page
.
all
(
'.line_holder.new'
).
size
expect
(
old_line_count
).
to
be
>
0
expect
(
new_line_count
).
to
be
>
0
end
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