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
b2f99c46
Commit
b2f99c46
authored
Feb 21, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
aeb4e34a
3de4c8d0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
3 deletions
+80
-3
app/finders/concerns/finder_methods.rb
app/finders/concerns/finder_methods.rb
+2
-2
babel.config.js
babel.config.js
+2
-0
jest.config.js
jest.config.js
+1
-0
spec/finders/concerns/finder_methods_spec.rb
spec/finders/concerns/finder_methods_spec.rb
+21
-1
spec/frontend/notes/components/__snapshots__/discussion_jump_to_next_button_spec.js.snap
...__snapshots__/discussion_jump_to_next_button_spec.js.snap
+20
-0
spec/frontend/notes/components/discussion_jump_to_next_button_spec.js
...d/notes/components/discussion_jump_to_next_button_spec.js
+30
-0
spec/frontend/test_setup.js
spec/frontend/test_setup.js
+4
-0
No files found.
app/finders/concerns/finder_methods.rb
View file @
b2f99c46
...
...
@@ -3,13 +3,13 @@
module
FinderMethods
# rubocop: disable CodeReuse/ActiveRecord
def
find_by!
(
*
args
)
raise_not_found_unless_authorized
execute
.
find_by!
(
*
args
)
raise_not_found_unless_authorized
execute
.
reorder
(
nil
).
find_by!
(
*
args
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
find_by
(
*
args
)
if_authorized
execute
.
find_by
(
*
args
)
if_authorized
execute
.
reorder
(
nil
).
find_by
(
*
args
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
.babelrc
.js
→
babel.config
.js
View file @
b2f99c46
/* eslint-disable import/no-commonjs, filenames/match-regex */
const
BABEL_ENV
=
process
.
env
.
BABEL_ENV
||
process
.
env
.
NODE_ENV
||
null
;
const
presets
=
[
...
...
jest.config.js
View file @
b2f99c46
...
...
@@ -31,4 +31,5 @@ module.exports = {
'
^.+
\\
.js$
'
:
'
babel-jest
'
,
'
^.+
\\
.vue$
'
:
'
vue-jest
'
,
},
transformIgnorePatterns
:
[
'
node_modules/(?!(@gitlab/ui)/)
'
],
};
spec/finders/concerns/finder_methods_spec.rb
View file @
b2f99c46
...
...
@@ -12,7 +12,7 @@ describe FinderMethods do
end
def
execute
Project
.
all
Project
.
all
.
order
(
id: :desc
)
end
end
end
...
...
@@ -38,6 +38,16 @@ describe FinderMethods do
it
'raises not found the user does not have access'
do
expect
{
finder
.
find_by!
(
id:
unauthorized_project
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'ignores ordering'
do
# Memoise the finder result so we can add message expectations to it
relation
=
finder
.
execute
allow
(
finder
).
to
receive
(
:execute
).
and_return
(
relation
)
expect
(
relation
).
to
receive
(
:reorder
).
with
(
nil
).
and_call_original
finder
.
find_by!
(
id:
authorized_project
.
id
)
end
end
describe
'#find'
do
...
...
@@ -66,5 +76,15 @@ describe FinderMethods do
it
'returns nil when the user does not have access'
do
expect
(
finder
.
find_by
(
id:
unauthorized_project
.
id
)).
to
be_nil
end
it
'ignores ordering'
do
# Memoise the finder result so we can add message expectations to it
relation
=
finder
.
execute
allow
(
finder
).
to
receive
(
:execute
).
and_return
(
relation
)
expect
(
relation
).
to
receive
(
:reorder
).
with
(
nil
).
and_call_original
finder
.
find_by
(
id:
authorized_project
.
id
)
end
end
end
spec/frontend/notes/components/__snapshots__/discussion_jump_to_next_button_spec.js.snap
0 → 100644
View file @
b2f99c46
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`JumpToNextDiscussionButton matches the snapshot 1`] = `
<div
class="btn-group"
role="group"
>
<button
class="btn btn-default discussion-next-btn"
data-original-title="Jump to next unresolved discussion"
title=""
>
<icon-stub
cssclasses=""
name="comment-next"
size="16"
/>
</button>
</div>
`;
spec/
javascripts
/notes/components/discussion_jump_to_next_button_spec.js
→
spec/
frontend
/notes/components/discussion_jump_to_next_button_spec.js
View file @
b2f99c46
import
j
umpToNextDiscussionButton
from
'
~/notes/components/discussion_jump_to_next_button.vue
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
J
umpToNextDiscussionButton
from
'
~/notes/components/discussion_jump_to_next_button.vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
const
localVue
=
createLocalVue
();
describe
(
'
jumpToNextDiscussionButton
'
,
()
=>
{
describe
(
'
JumpToNextDiscussionButton
'
,
()
=>
{
let
wrapper
;
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
jumpToNextDiscussionButton
,
{
localVue
,
wrapper
=
shallowMount
(
JumpToNextDiscussionButton
,
{
sync
:
false
,
});
});
...
...
@@ -17,17 +14,17 @@ describe('jumpToNextDiscussionButton', () => {
wrapper
.
destroy
();
});
it
(
'
emits onClick event on button click
'
,
done
=>
{
it
(
'
matches the snapshot
'
,
()
=>
{
expect
(
wrapper
.
vm
.
$el
).
toMatchSnapshot
();
});
it
(
'
emits onClick event on button click
'
,
()
=>
{
const
button
=
wrapper
.
find
({
ref
:
'
button
'
});
button
.
trigger
(
'
click
'
);
localVue
.
nextTick
(()
=>
{
expect
(
wrapper
.
emitted
()).
toEqual
({
onClick
:
[[]],
});
done
();
expect
(
wrapper
.
emitted
()).
toEqual
({
onClick
:
[[]],
});
});
});
spec/frontend/test_setup.js
View file @
b2f99c46
import
Vue
from
'
vue
'
;
import
Translate
from
'
~/vue_shared/translate
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
const
testTimeoutInMs
=
300
;
...
...
@@ -28,3 +30,5 @@ beforeEach(done => {
done
();
});
Vue
.
use
(
Translate
);
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