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
Léo-Paul Géneau
gitlab-ce
Commits
3cc806ee
Commit
3cc806ee
authored
Apr 12, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for success and failure of deleting branch from MR page
parent
81c920f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletion
+54
-1
app/assets/javascripts/merged_buttons.js
app/assets/javascripts/merged_buttons.js
+3
-1
spec/javascripts/fixtures/merge_requests.rb
spec/javascripts/fixtures/merge_requests.rb
+7
-0
spec/javascripts/merged_buttons_spec.js
spec/javascripts/merged_buttons_spec.js
+44
-0
No files found.
app/assets/javascripts/merged_buttons.js
View file @
3cc806ee
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, max-len */
import
'
~/lib/utils/url_utility
'
;
(
function
()
{
this
.
MergedButtons
=
(
function
()
{
function
MergedButtons
()
{
...
...
@@ -31,7 +33,7 @@
};
MergedButtons
.
prototype
.
removeBranchSuccess
=
function
()
{
return
location
.
reload
();
gl
.
utils
.
refreshCurrentPage
();
};
MergedButtons
.
prototype
.
removeBranchError
=
function
()
{
...
...
spec/javascripts/fixtures/merge_requests.rb
View file @
3cc806ee
...
...
@@ -7,6 +7,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
let
(
:namespace
)
{
create
(
:namespace
,
name:
'frontend-fixtures'
)}
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
,
path:
'merge-requests-project'
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
project
,
target_project:
project
,
description:
'- [ ] Task List Item'
)
}
let
(
:merged_merge_request
)
{
create
(
:merge_request
,
:merged
,
source_project:
project
,
target_project:
project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
...
...
@@ -32,6 +33,12 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
render_merge_request
(
example
.
description
,
merge_request
)
end
it
'merge_requests/merged_merge_request.html.raw'
do
|
example
|
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:source_branch_exists?
).
and_return
(
true
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:can_remove_source_branch?
).
and_return
(
true
)
render_merge_request
(
example
.
description
,
merged_merge_request
)
end
private
def
render_merge_request
(
fixture_file_name
,
merge_request
)
...
...
spec/javascripts/merged_buttons_spec.js
0 → 100644
View file @
3cc806ee
/* global MergedButtons */
import
'
~/merged_buttons
'
;
describe
(
'
MergedButtons
'
,
()
=>
{
const
fixturesPath
=
'
merge_requests/merged_merge_request.html.raw
'
;
preloadFixtures
(
fixturesPath
);
beforeEach
(()
=>
{
loadFixtures
(
fixturesPath
);
this
.
mergedButtons
=
new
MergedButtons
();
this
.
$removeBranchWidget
=
$
(
'
.remove_source_branch_widget:not(.failed)
'
);
this
.
$removeBranchProgress
=
$
(
'
.remove_source_branch_in_progress
'
);
this
.
$removeBranchFailed
=
$
(
'
.remove_source_branch_widget.failed
'
);
this
.
$removeBranchButton
=
$
(
'
.remove_source_branch
'
);
});
describe
(
'
removeSourceBranch
'
,
()
=>
{
it
(
'
shows loader
'
,
()
=>
{
$
(
'
.remove_source_branch
'
).
trigger
(
'
click
'
);
expect
(
this
.
$removeBranchProgress
).
toBeVisible
();
expect
(
this
.
$removeBranchWidget
).
not
.
toBeVisible
();
});
});
describe
(
'
removeBranchSuccess
'
,
()
=>
{
it
(
'
refreshes page when branch removed
'
,
()
=>
{
spyOn
(
gl
.
utils
,
'
refreshCurrentPage
'
).
and
.
stub
();
const
response
=
{
status
:
200
};
this
.
$removeBranchButton
.
trigger
(
'
ajax:success
'
,
response
,
'
xhr
'
);
expect
(
gl
.
utils
.
refreshCurrentPage
).
toHaveBeenCalled
();
});
});
describe
(
'
removeBranchError
'
,
()
=>
{
it
(
'
shows error message
'
,
()
=>
{
const
response
=
{
status
:
500
};
this
.
$removeBranchButton
.
trigger
(
'
ajax:error
'
,
response
,
'
xhr
'
);
expect
(
this
.
$removeBranchFailed
).
toBeVisible
();
expect
(
this
.
$removeBranchProgress
).
not
.
toBeVisible
();
expect
(
this
.
$removeBranchWidget
).
not
.
toBeVisible
();
});
});
});
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