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
f99d8786
Commit
f99d8786
authored
Sep 23, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix snippets pagination
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
fca610e5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
70 additions
and
20 deletions
+70
-20
CHANGELOG
CHANGELOG
+1
-0
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+1
-1
app/views/snippets/_snippets.html.haml
app/views/snippets/_snippets.html.haml
+3
-1
spec/features/dashboard/snippets_spec.rb
spec/features/dashboard/snippets_spec.rb
+15
-0
spec/features/projects/snippets_spec.rb
spec/features/projects/snippets_spec.rb
+14
-0
spec/features/snippets_spec.rb
spec/features/snippets_spec.rb
+14
-0
spec/features/users/snippets_spec.rb
spec/features/users/snippets_spec.rb
+4
-18
spec/support/snippets_shared_examples.rb
spec/support/snippets_shared_examples.rb
+18
-0
No files found.
CHANGELOG
View file @
f99d8786
...
@@ -5,6 +5,7 @@ v 8.13.0 (unreleased)
...
@@ -5,6 +5,7 @@ v 8.13.0 (unreleased)
v 8.12.2 (unreleased)
v 8.12.2 (unreleased)
- Fix Import/Export not recognising correctly the imported services.
- Fix Import/Export not recognising correctly the imported services.
- Fix snippets pagination
v 8.12.1
v 8.12.1
- Fix a memory leak in HTML::Pipeline::SanitizationFilter::WHITELIST
- Fix a memory leak in HTML::Pipeline::SanitizationFilter::WHITELIST
...
...
app/controllers/users_controller.rb
View file @
f99d8786
...
@@ -65,7 +65,7 @@ class UsersController < ApplicationController
...
@@ -65,7 +65,7 @@ class UsersController < ApplicationController
format
.
html
{
render
'show'
}
format
.
html
{
render
'show'
}
format
.
json
do
format
.
json
do
render
json:
{
render
json:
{
html:
view_to_html_string
(
"snippets/_snippets"
,
collection:
@snippets
)
html:
view_to_html_string
(
"snippets/_snippets"
,
collection:
@snippets
,
remote:
true
)
}
}
end
end
end
end
...
...
app/views/snippets/_snippets.html.haml
View file @
f99d8786
-
remote
=
local_assigns
.
fetch
(
:remote
,
false
)
.snippets-list-holder
.snippets-list-holder
%ul
.content-list
%ul
.content-list
=
render
partial:
'shared/snippets/snippet'
,
collection:
@snippets
=
render
partial:
'shared/snippets/snippet'
,
collection:
@snippets
...
@@ -5,7 +7,7 @@
...
@@ -5,7 +7,7 @@
%li
%li
.nothing-here-block
Nothing here.
.nothing-here-block
Nothing here.
=
paginate
@snippets
,
theme:
'gitlab'
,
remote:
tru
e
=
paginate
@snippets
,
theme:
'gitlab'
,
remote:
remot
e
:javascript
:javascript
gl
.
SnippetsList
();
gl
.
SnippetsList
();
spec/features/dashboard/snippets_spec.rb
0 → 100644
View file @
f99d8786
require
'spec_helper'
describe
'Dashboard snippets'
,
feature:
true
do
context
'when the project has snippets'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let!
(
:snippets
)
{
create_list
(
:project_snippet
,
2
,
:public
,
author:
project
.
owner
,
project:
project
)
}
before
do
allow
(
Snippet
).
to
receive
(
:default_per_page
).
and_return
(
1
)
login_as
(
project
.
owner
)
visit
dashboard_snippets_path
end
it_behaves_like
'paginated snippets'
end
end
spec/features/projects/snippets_spec.rb
0 → 100644
View file @
f99d8786
require
'spec_helper'
describe
'Project snippets'
,
feature:
true
do
context
'when the project has snippets'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let!
(
:snippets
)
{
create_list
(
:project_snippet
,
2
,
:public
,
author:
project
.
owner
,
project:
project
)
}
before
do
allow
(
Snippet
).
to
receive
(
:default_per_page
).
and_return
(
1
)
visit
namespace_project_snippets_path
(
project
.
namespace
,
project
)
end
it_behaves_like
'paginated snippets'
end
end
spec/features/snippets_spec.rb
0 → 100644
View file @
f99d8786
require
'spec_helper'
describe
'Snippets'
,
feature:
true
do
context
'when the project has snippets'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let!
(
:snippets
)
{
create_list
(
:project_snippet
,
2
,
:public
,
author:
project
.
owner
,
project:
project
)
}
before
do
allow
(
Snippet
).
to
receive
(
:default_per_page
).
and_return
(
1
)
visit
snippets_path
(
username:
project
.
owner
.
username
)
end
it_behaves_like
'paginated snippets'
end
end
spec/features/users/snippets_spec.rb
View file @
f99d8786
...
@@ -3,30 +3,16 @@ require 'spec_helper'
...
@@ -3,30 +3,16 @@ require 'spec_helper'
describe
'Snippets tab on a user profile'
,
feature:
true
,
js:
true
do
describe
'Snippets tab on a user profile'
,
feature:
true
,
js:
true
do
include
WaitForAjax
include
WaitForAjax
let
(
:user
)
{
create
(
:user
)
}
context
'when the user has snippets'
do
context
'when the user has snippets'
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:snippets
)
{
create_list
(
:snippet
,
2
,
:public
,
author:
user
)
}
before
do
before
do
create_list
(
:snippet
,
25
,
:public
,
author:
user
)
allow
(
Snippet
).
to
receive
(
:default_per_page
).
and_return
(
1
)
visit
user_path
(
user
)
visit
user_path
(
user
)
page
.
within
(
'.user-profile-nav'
)
{
click_link
'Snippets'
}
page
.
within
(
'.user-profile-nav'
)
{
click_link
'Snippets'
}
wait_for_ajax
wait_for_ajax
end
end
it
'is limited to 20 items per page'
do
it_behaves_like
'paginated snippets'
,
remote:
true
expect
(
page
.
all
(
'.snippets-list-holder .snippet-row'
).
count
).
to
eq
(
20
)
end
context
'clicking on the link to the second page'
do
before
do
click_link
(
'2'
)
wait_for_ajax
end
it
'shows the remaining snippets'
do
expect
(
page
.
all
(
'.snippets-list-holder .snippet-row'
).
count
).
to
eq
(
5
)
end
end
end
end
end
end
spec/support/snippets_shared_examples.rb
0 → 100644
View file @
f99d8786
# These shared examples expect a `snippets` array of snippets
RSpec
.
shared_examples
'paginated snippets'
do
|
remote:
false
|
it
"is limited to
#{
Snippet
.
default_per_page
}
items per page"
do
expect
(
page
.
all
(
'.snippets-list-holder .snippet-row'
).
count
).
to
eq
(
Snippet
.
default_per_page
)
end
context
'clicking on the link to the second page'
do
before
do
click_link
(
'2'
)
wait_for_ajax
if
remote
end
it
'shows the remaining snippets'
do
remaining_snippets_count
=
[
snippets
.
size
-
Snippet
.
default_per_page
,
Snippet
.
default_per_page
].
min
expect
(
page
).
to
have_selector
(
'.snippets-list-holder .snippet-row'
,
count:
remaining_snippets_count
)
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