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
f9b44e68
Commit
f9b44e68
authored
Aug 13, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
86571047
df35d772
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
4 deletions
+43
-4
app/controllers/projects/raw_controller.rb
app/controllers/projects/raw_controller.rb
+1
-1
spec/controllers/projects/raw_controller_spec.rb
spec/controllers/projects/raw_controller_spec.rb
+3
-3
spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb
...res/projects/raw/user_interacts_with_raw_endpoint_spec.rb
+39
-0
No files found.
app/controllers/projects/raw_controller.rb
View file @
f9b44e68
...
@@ -26,7 +26,7 @@ class Projects::RawController < Projects::ApplicationController
...
@@ -26,7 +26,7 @@ class Projects::RawController < Projects::ApplicationController
limiter
.
log_request
(
request
,
:raw_blob_request_limit
,
current_user
)
limiter
.
log_request
(
request
,
:raw_blob_request_limit
,
current_user
)
flash
[
:alert
]
=
_
(
'You cannot access the raw file. Please wait a minute.'
)
flash
[
:alert
]
=
_
(
'You cannot access the raw file. Please wait a minute.'
)
redirect_to
project_blob_path
(
@project
,
File
.
join
(
@ref
,
@path
))
redirect_to
project_blob_path
(
@project
,
File
.
join
(
@ref
,
@path
))
,
status: :too_many_requests
end
end
def
raw_blob_request_limit
def
raw_blob_request_limit
...
...
spec/controllers/projects/raw_controller_spec.rb
View file @
f9b44e68
...
@@ -60,7 +60,7 @@ describe Projects::RawController do
...
@@ -60,7 +60,7 @@ describe Projects::RawController do
execute_raw_requests
(
requests:
6
,
project:
project
,
file_path:
file_path
)
execute_raw_requests
(
requests:
6
,
project:
project
,
file_path:
file_path
)
expect
(
flash
[
:alert
]).
to
eq
(
'You cannot access the raw file. Please wait a minute.'
)
expect
(
flash
[
:alert
]).
to
eq
(
'You cannot access the raw file. Please wait a minute.'
)
expect
(
response
).
to
redirect_to
(
project_blob_path
(
project
,
file_path
)
)
expect
(
response
).
to
have_gitlab_http_status
(
429
)
end
end
it
'logs the event on auth.log'
do
it
'logs the event on auth.log'
do
...
@@ -92,7 +92,7 @@ describe Projects::RawController do
...
@@ -92,7 +92,7 @@ describe Projects::RawController do
execute_raw_requests
(
requests:
3
,
project:
project
,
file_path:
modified_path
)
execute_raw_requests
(
requests:
3
,
project:
project
,
file_path:
modified_path
)
expect
(
flash
[
:alert
]).
to
eq
(
'You cannot access the raw file. Please wait a minute.'
)
expect
(
flash
[
:alert
]).
to
eq
(
'You cannot access the raw file. Please wait a minute.'
)
expect
(
response
).
to
redirect_to
(
project_blob_path
(
project
,
modified_path
)
)
expect
(
response
).
to
have_gitlab_http_status
(
429
)
end
end
end
end
...
@@ -120,7 +120,7 @@ describe Projects::RawController do
...
@@ -120,7 +120,7 @@ describe Projects::RawController do
execute_raw_requests
(
requests:
6
,
project:
project
,
file_path:
file_path
)
execute_raw_requests
(
requests:
6
,
project:
project
,
file_path:
file_path
)
expect
(
flash
[
:alert
]).
to
eq
(
'You cannot access the raw file. Please wait a minute.'
)
expect
(
flash
[
:alert
]).
to
eq
(
'You cannot access the raw file. Please wait a minute.'
)
expect
(
response
).
to
redirect_to
(
project_blob_path
(
project
,
file_path
)
)
expect
(
response
).
to
have_gitlab_http_status
(
429
)
# Accessing upcase version of readme
# Accessing upcase version of readme
file_path
=
"
#{
commit_sha
}
/README.md"
file_path
=
"
#{
commit_sha
}
/README.md"
...
...
spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb
0 → 100644
View file @
f9b44e68
# frozen_string_literal: true
require
'spec_helper'
describe
'Projects > Raw > User interacts with raw endpoint'
do
include
RepoHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let
(
:file_path
)
{
'master/README.md'
}
before
do
stub_application_setting
(
raw_blob_request_limit:
3
)
project
.
add_developer
(
user
)
create_file_in_repo
(
project
,
'master'
,
'master'
,
'README.md'
,
'readme content'
)
sign_in
(
user
)
end
context
'when user access a raw file'
do
it
'renders the page successfully'
do
visit
project_raw_url
(
project
,
file_path
)
expect
(
source
).
to
eq
(
''
)
# Body is filled in by gitlab-workhorse
end
end
context
'when user goes over the rate requests limit'
do
it
'returns too many requests'
do
4
.
times
do
visit
project_raw_url
(
project
,
file_path
)
end
expect
(
source
).
to
have_content
(
'You are being redirected'
)
click_link
(
'redirected'
)
expect
(
page
).
to
have_content
(
'You cannot access the raw file. Please wait a minute.'
)
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