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
8d7e07d0
Commit
8d7e07d0
authored
Oct 04, 2017
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Gitlab::Database.readonly? to read_only?
parent
7746792a
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
52 additions
and
52 deletions
+52
-52
app/controllers/admin/application_controller.rb
app/controllers/admin/application_controller.rb
+6
-6
app/controllers/boards/issues_controller.rb
app/controllers/boards/issues_controller.rb
+1
-1
app/controllers/projects/lfs_api_controller.rb
app/controllers/projects/lfs_api_controller.rb
+3
-3
app/controllers/projects/merge_requests/application_controller.rb
...rollers/projects/merge_requests/application_controller.rb
+1
-1
app/models/concerns/routable.rb
app/models/concerns/routable.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-2
app/models/user.rb
app/models/user.rb
+3
-7
app/services/keys/last_used_service.rb
app/services/keys/last_used_service.rb
+1
-1
app/services/users/activity_service.rb
app/services/users/activity_service.rb
+1
-1
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+1
-1
doc/development/geo.md
doc/development/geo.md
+1
-1
ee/app/controllers/ee/admin/application_controller.rb
ee/app/controllers/ee/admin/application_controller.rb
+1
-1
ee/app/controllers/ee/projects/lfs_api_controller.rb
ee/app/controllers/ee/projects/lfs_api_controller.rb
+1
-1
ee/lib/ee/gitlab/database.rb
ee/lib/ee/gitlab/database.rb
+1
-1
lib/banzai/renderer.rb
lib/banzai/renderer.rb
+1
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+6
-1
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+1
-1
lib/gitlab/git_access_wiki.rb
lib/gitlab/git_access_wiki.rb
+3
-3
lib/gitlab/middleware/readonly.rb
lib/gitlab/middleware/readonly.rb
+1
-1
spec/ee/spec/models/ee/user_spec.rb
spec/ee/spec/models/ee/user_spec.rb
+2
-2
spec/ee/spec/services/ee/keys/last_used_service_spec.rb
spec/ee/spec/services/ee/keys/last_used_service_spec.rb
+1
-1
spec/lib/banzai/renderer_spec.rb
spec/lib/banzai/renderer_spec.rb
+1
-1
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+1
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+1
-1
spec/lib/gitlab/git_access_wiki_spec.rb
spec/lib/gitlab/git_access_wiki_spec.rb
+1
-1
spec/lib/gitlab/middleware/readonly_spec.rb
spec/lib/gitlab/middleware/readonly_spec.rb
+2
-2
spec/models/concerns/routable_spec.rb
spec/models/concerns/routable_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-2
spec/requests/lfs_http_spec.rb
spec/requests/lfs_http_spec.rb
+2
-3
spec/services/users/activity_service_spec.rb
spec/services/users/activity_service_spec.rb
+1
-1
No files found.
app/controllers/admin/application_controller.rb
View file @
8d7e07d0
...
@@ -3,23 +3,23 @@
...
@@ -3,23 +3,23 @@
# Automatically sets the layout and ensures an administrator is logged in
# Automatically sets the layout and ensures an administrator is logged in
class
Admin::ApplicationController
<
ApplicationController
class
Admin::ApplicationController
<
ApplicationController
before_action
:authenticate_admin!
before_action
:authenticate_admin!
before_action
:display_readonly_information
before_action
:display_read
_
only_information
layout
'admin'
layout
'admin'
def
authenticate_admin!
def
authenticate_admin!
render_404
unless
current_user
.
admin?
render_404
unless
current_user
.
admin?
end
end
def
display_readonly_information
def
display_read
_
only_information
return
unless
Gitlab
::
Database
.
readonly?
return
unless
Gitlab
::
Database
.
read
_
only?
flash
.
now
[
:notice
]
=
readonly_message
flash
.
now
[
:notice
]
=
read
_
only_message
end
end
private
private
# Overridden in EE
# Overridden in EE
def
readonly_message
def
read
_
only_message
_
(
'You are on a read-only GitLab instance.'
)
.
html_safe
_
(
'You are on a read-only GitLab instance.'
)
end
end
end
end
app/controllers/boards/issues_controller.rb
View file @
8d7e07d0
...
@@ -12,7 +12,7 @@ module Boards
...
@@ -12,7 +12,7 @@ module Boards
def
index
def
index
issues
=
Boards
::
Issues
::
ListService
.
new
(
board_parent
,
current_user
,
filter_params
).
execute
issues
=
Boards
::
Issues
::
ListService
.
new
(
board_parent
,
current_user
,
filter_params
).
execute
issues
=
issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
]
||
20
)
issues
=
issues
.
page
(
params
[
:page
]).
per
(
params
[
:per
]
||
20
)
make_sure_position_is_set
(
issues
)
unless
Gitlab
::
Database
.
readonly
?
make_sure_position_is_set
(
issues
)
if
Gitlab
::
Database
.
read_write
?
issues
=
issues
.
preload
(
:project
,
issues
=
issues
.
preload
(
:project
,
:milestone
,
:milestone
,
:assignees
,
:assignees
,
...
...
app/controllers/projects/lfs_api_controller.rb
View file @
8d7e07d0
...
@@ -98,10 +98,10 @@ class Projects::LfsApiController < Projects::GitHttpClientController
...
@@ -98,10 +98,10 @@ class Projects::LfsApiController < Projects::GitHttpClientController
end
end
def
lfs_check_batch_operation!
def
lfs_check_batch_operation!
if
upload_request?
&&
Gitlab
::
Database
.
readonly?
if
upload_request?
&&
Gitlab
::
Database
.
read
_
only?
render
(
render
(
json:
{
json:
{
message:
lfs_readonly_message
message:
lfs_read
_
only_message
},
},
content_type:
'application/vnd.git-lfs+json'
,
content_type:
'application/vnd.git-lfs+json'
,
status:
403
status:
403
...
@@ -110,7 +110,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController
...
@@ -110,7 +110,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController
end
end
# Overridden in EE
# Overridden in EE
def
lfs_readonly_message
def
lfs_read
_
only_message
_
(
'You cannot write to this read-only GitLab instance.'
)
_
(
'You cannot write to this read-only GitLab instance.'
)
end
end
end
end
app/controllers/projects/merge_requests/application_controller.rb
View file @
8d7e07d0
...
@@ -15,7 +15,7 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
...
@@ -15,7 +15,7 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
# Make sure merge requests created before 8.0
# Make sure merge requests created before 8.0
# have head file in refs/merge-requests/
# have head file in refs/merge-requests/
def
ensure_ref_fetched
def
ensure_ref_fetched
@merge_request
.
ensure_ref_fetched
unless
Gitlab
::
Database
.
readonly
?
@merge_request
.
ensure_ref_fetched
if
Gitlab
::
Database
.
read_write
?
end
end
def
merge_request_params
def
merge_request_params
...
...
app/models/concerns/routable.rb
View file @
8d7e07d0
...
@@ -152,7 +152,7 @@ module Routable
...
@@ -152,7 +152,7 @@ module Routable
end
end
def
update_route
def
update_route
return
if
Gitlab
::
Database
.
readonly?
return
if
Gitlab
::
Database
.
read
_
only?
prepare_route
prepare_route
route
.
save
route
.
save
...
...
app/models/merge_request.rb
View file @
8d7e07d0
...
@@ -498,7 +498,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -498,7 +498,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
check_if_can_be_merged
def
check_if_can_be_merged
return
unless
unchecked?
&&
!
Gitlab
::
Database
.
readonly
?
return
unless
unchecked?
&&
Gitlab
::
Database
.
read_write
?
can_be_merged
=
can_be_merged
=
!
broken?
&&
project
.
repository
.
can_be_merged?
(
diff_head_sha
,
target_branch
)
!
broken?
&&
project
.
repository
.
can_be_merged?
(
diff_head_sha
,
target_branch
)
...
...
app/models/project.rb
View file @
8d7e07d0
...
@@ -811,7 +811,7 @@ class Project < ActiveRecord::Base
...
@@ -811,7 +811,7 @@ class Project < ActiveRecord::Base
end
end
def
cache_has_external_issue_tracker
def
cache_has_external_issue_tracker
update_column
(
:has_external_issue_tracker
,
services
.
external_issue_trackers
.
any?
)
unless
Gitlab
::
Database
.
readonly
?
update_column
(
:has_external_issue_tracker
,
services
.
external_issue_trackers
.
any?
)
if
Gitlab
::
Database
.
read_write
?
end
end
def
has_wiki?
def
has_wiki?
...
@@ -831,7 +831,7 @@ class Project < ActiveRecord::Base
...
@@ -831,7 +831,7 @@ class Project < ActiveRecord::Base
end
end
def
cache_has_external_wiki
def
cache_has_external_wiki
update_column
(
:has_external_wiki
,
services
.
external_wikis
.
any?
)
unless
Gitlab
::
Database
.
readonly
?
update_column
(
:has_external_wiki
,
services
.
external_wikis
.
any?
)
if
Gitlab
::
Database
.
read_write
?
end
end
def
find_or_initialize_services
(
exceptions:
[])
def
find_or_initialize_services
(
exceptions:
[])
...
...
app/models/user.rb
View file @
8d7e07d0
...
@@ -478,15 +478,11 @@ class User < ActiveRecord::Base
...
@@ -478,15 +478,11 @@ class User < ActiveRecord::Base
end
end
def
remember_me!
def
remember_me!
raise
NotImplementedError
unless
defined?
(
super
)
super
if
::
Gitlab
::
Database
.
read_write?
super
unless
::
Gitlab
::
Database
.
readonly?
end
end
def
forget_me!
def
forget_me!
raise
NotImplementedError
unless
defined?
(
super
)
super
if
::
Gitlab
::
Database
.
read_write?
super
unless
::
Gitlab
::
Database
.
readonly?
end
end
def
disable_two_factor!
def
disable_two_factor!
...
@@ -1079,7 +1075,7 @@ class User < ActiveRecord::Base
...
@@ -1079,7 +1075,7 @@ class User < ActiveRecord::Base
# we do this on read since migrating all existing users is not a feasible
# we do this on read since migrating all existing users is not a feasible
# solution.
# solution.
def
rss_token
def
rss_token
return
read_attribute
(
:rss_token
)
if
Gitlab
::
Database
.
readonly?
return
read_attribute
(
:rss_token
)
if
Gitlab
::
Database
.
read
_
only?
ensure_rss_token!
ensure_rss_token!
end
end
...
...
app/services/keys/last_used_service.rb
View file @
8d7e07d0
...
@@ -16,7 +16,7 @@ module Keys
...
@@ -16,7 +16,7 @@ module Keys
end
end
def
update?
def
update?
return
false
if
::
Gitlab
::
Database
.
readonly?
return
false
if
::
Gitlab
::
Database
.
read
_
only?
last_used
=
key
.
last_used_at
last_used
=
key
.
last_used_at
...
...
app/services/users/activity_service.rb
View file @
8d7e07d0
...
@@ -14,7 +14,7 @@ module Users
...
@@ -14,7 +14,7 @@ module Users
private
private
def
record_activity
def
record_activity
Gitlab
::
UserActivities
.
record
(
@author
.
id
)
unless
Gitlab
::
Database
.
readonly
?
Gitlab
::
UserActivities
.
record
(
@author
.
id
)
if
Gitlab
::
Database
.
read_write
?
Rails
.
logger
.
debug
(
"Recorded activity:
#{
@activity
}
for User ID:
#{
@author
.
id
}
(username:
#{
@author
.
username
}
)"
)
Rails
.
logger
.
debug
(
"Recorded activity:
#{
@activity
}
for User ID:
#{
@author
.
id
}
(username:
#{
@author
.
username
}
)"
)
end
end
...
...
app/views/admin/geo_nodes/index.html.haml
View file @
8d7e07d0
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
%p
%p
.js-health
.js-health
-
unless
Gitlab
::
Database
.
readonly
?
-
if
Gitlab
::
Database
.
read_write
?
.node-actions
.node-actions
-
if
Gitlab
::
Geo
.
license_allows?
-
if
Gitlab
::
Geo
.
license_allows?
-
if
node
.
missing_oauth_application?
-
if
node
.
missing_oauth_application?
...
...
doc/development/geo.md
View file @
8d7e07d0
...
@@ -89,7 +89,7 @@ and prevent user from trying to update the database and getting a 500 error
...
@@ -89,7 +89,7 @@ and prevent user from trying to update the database and getting a 500 error
Database will already be read-only in a replicated setup, so we don't need to
Database will already be read-only in a replicated setup, so we don't need to
take any extra step for that.
take any extra step for that.
We do use our feature toggle
`Gitlab::Database.readonly?`
to deny write operations
We do use our feature toggle
`Gitlab::Database.read
_
only?`
to deny write operations
on a node that is in read-only mode. This toggle is also available in CE.
on a node that is in read-only mode. This toggle is also available in CE.
## File Transfers
## File Transfers
...
...
ee/app/controllers/application_controller.rb
→
ee/app/controllers/
ee/admin/
application_controller.rb
View file @
8d7e07d0
module
EE
module
EE
module
Admin
module
Admin
module
ApplicationController
module
ApplicationController
def
readonly_message
def
read
_
only_message
raise
NotImplementedError
unless
defined?
(
super
)
raise
NotImplementedError
unless
defined?
(
super
)
return
super
unless
Gitlab
::
Geo
.
secondary_with_primary?
return
super
unless
Gitlab
::
Geo
.
secondary_with_primary?
...
...
ee/app/controllers/ee/projects/lfs_api_controller.rb
View file @
8d7e07d0
module
EE
module
EE
module
Projects
module
Projects
module
LfsApiController
module
LfsApiController
def
lfs_readonly_message
def
lfs_read
_
only_message
raise
NotImplementedError
unless
defined?
(
super
)
raise
NotImplementedError
unless
defined?
(
super
)
return
super
unless
::
Gitlab
::
Geo
.
secondary_with_primary?
return
super
unless
::
Gitlab
::
Geo
.
secondary_with_primary?
...
...
ee/lib/ee/gitlab/database.rb
View file @
8d7e07d0
module
EE
module
EE
module
Gitlab
module
Gitlab
module
Database
module
Database
def
self
.
readonly?
def
self
.
read
_
only?
raise
NotImplementedError
unless
defined?
(
super
)
raise
NotImplementedError
unless
defined?
(
super
)
Gitlab
::
Geo
.
secondary?
||
super
Gitlab
::
Geo
.
secondary?
||
super
...
...
lib/banzai/renderer.rb
View file @
8d7e07d0
...
@@ -165,7 +165,7 @@ module Banzai
...
@@ -165,7 +165,7 @@ module Banzai
# GitLab needs to disable updates on GET requests if database is readonly
# GitLab needs to disable updates on GET requests if database is readonly
def
self
.
update_object?
(
object
)
def
self
.
update_object?
(
object
)
!
Gitlab
::
Database
.
readonly
?
Gitlab
::
Database
.
read_write
?
end
end
end
end
end
end
lib/gitlab/database.rb
View file @
8d7e07d0
...
@@ -31,10 +31,15 @@ module Gitlab
...
@@ -31,10 +31,15 @@ module Gitlab
adapter_name
.
casecmp
(
'postgresql'
).
zero?
adapter_name
.
casecmp
(
'postgresql'
).
zero?
end
end
def
self
.
readonly?
# Overridden in EE
def
self
.
read_only?
false
false
end
end
def
self
.
read_write?
!
self
.
read_only?
end
def
self
.
version
def
self
.
version
database_version
.
match
(
/\A(?:PostgreSQL |)([^\s]+).*\z/
)[
1
]
database_version
.
match
(
/\A(?:PostgreSQL |)([^\s]+).*\z/
)[
1
]
end
end
...
...
lib/gitlab/git_access.rb
View file @
8d7e07d0
...
@@ -176,7 +176,7 @@ module Gitlab
...
@@ -176,7 +176,7 @@ module Gitlab
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:readonly
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:readonly
]
end
end
if
Gitlab
::
Database
.
readonly?
if
Gitlab
::
Database
.
read
_
only?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:cannot_push_to_readonly
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:cannot_push_to_readonly
]
end
end
...
...
lib/gitlab/git_access_wiki.rb
View file @
8d7e07d0
module
Gitlab
module
Gitlab
class
GitAccessWiki
<
GitAccess
class
GitAccessWiki
<
GitAccess
ERROR_MESSAGES
=
{
ERROR_MESSAGES
=
{
read
only:
"You can't push code to this
read-only GitLab instance."
,
read
_only:
"You can't push code to a
read-only GitLab instance."
,
write_to_wiki:
"You are not allowed to write to this project's wiki."
write_to_wiki:
"You are not allowed to write to this project's wiki."
}.
freeze
}.
freeze
...
@@ -18,8 +18,8 @@ module Gitlab
...
@@ -18,8 +18,8 @@ module Gitlab
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:write_to_wiki
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:write_to_wiki
]
end
end
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Database
.
read
only?
if
Gitlab
::
Database
.
read_
only?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:readonly
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:read
_
only
]
end
end
true
true
...
...
lib/gitlab/middleware/readonly.rb
View file @
8d7e07d0
...
@@ -13,7 +13,7 @@ module Gitlab
...
@@ -13,7 +13,7 @@ module Gitlab
def
call
(
env
)
def
call
(
env
)
@env
=
env
@env
=
env
if
disallowed_request?
&&
Gitlab
::
Database
.
readonly?
if
disallowed_request?
&&
Gitlab
::
Database
.
read
_
only?
Rails
.
logger
.
debug
(
'GitLab Readonly: preventing possible non readonly operation'
)
Rails
.
logger
.
debug
(
'GitLab Readonly: preventing possible non readonly operation'
)
error_message
=
'You cannot do writing operations on a read-only GitLab instance'
error_message
=
'You cannot do writing operations on a read-only GitLab instance'
...
...
spec/ee/spec/models/ee/user_spec.rb
View file @
8d7e07d0
...
@@ -84,7 +84,7 @@ describe EE::User do
...
@@ -84,7 +84,7 @@ describe EE::User do
end
end
it
'does not clear remember_created_at when in a GitLab readonly instance'
do
it
'does not clear remember_created_at when in a GitLab readonly instance'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
expect
{
subject
.
forget_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
expect
{
subject
.
forget_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
end
end
...
@@ -100,7 +100,7 @@ describe EE::User do
...
@@ -100,7 +100,7 @@ describe EE::User do
end
end
it
'does not update remember_created_at when in a Geo readonly instance'
do
it
'does not update remember_created_at when in a Geo readonly instance'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
expect
{
subject
.
remember_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
expect
{
subject
.
remember_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
end
end
...
...
spec/ee/spec/services/ee/keys/last_used_service_spec.rb
View file @
8d7e07d0
...
@@ -5,7 +5,7 @@ describe Keys::LastUsedService do
...
@@ -5,7 +5,7 @@ describe Keys::LastUsedService do
key
=
create
(
:key
,
last_used_at:
1
.
year
.
ago
)
key
=
create
(
:key
,
last_used_at:
1
.
year
.
ago
)
original_time
=
key
.
last_used_at
original_time
=
key
.
last_used_at
allow
(
::
Gitlab
::
Database
).
to
receive
(
:readonly?
).
and_return
(
true
)
allow
(
::
Gitlab
::
Database
).
to
receive
(
:read
_
only?
).
and_return
(
true
)
described_class
.
new
(
key
).
execute
described_class
.
new
(
key
).
execute
expect
(
key
.
reload
.
last_used_at
).
to
be_like_time
(
original_time
)
expect
(
key
.
reload
.
last_used_at
).
to
be_like_time
(
original_time
)
...
...
spec/lib/banzai/renderer_spec.rb
View file @
8d7e07d0
...
@@ -37,7 +37,7 @@ describe Banzai::Renderer do
...
@@ -37,7 +37,7 @@ describe Banzai::Renderer do
end
end
it
"skips database caching on a GitLab readonly instance"
do
it
"skips database caching on a GitLab readonly instance"
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
).
and_return
(
true
)
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
).
and_return
(
true
)
expect
(
object
).
to
receive
(
:refresh_markdown_cache!
).
with
(
do_update:
false
)
expect
(
object
).
to
receive
(
:refresh_markdown_cache!
).
with
(
do_update:
false
)
is_expected
.
to
eq
(
'field_html'
)
is_expected
.
to
eq
(
'field_html'
)
...
...
spec/lib/gitlab/geo_spec.rb
View file @
8d7e07d0
...
@@ -110,7 +110,7 @@ describe Gitlab::Geo do
...
@@ -110,7 +110,7 @@ describe Gitlab::Geo do
end
end
end
end
describe
'
readonl
y?'
do
describe
'
secondar
y?'
do
context
'when current node is secondary'
do
context
'when current node is secondary'
do
it
'returns true'
do
it
'returns true'
do
stub_current_geo_node
(
secondary_node
)
stub_current_geo_node
(
secondary_node
)
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
8d7e07d0
...
@@ -747,7 +747,7 @@ describe Gitlab::GitAccess do
...
@@ -747,7 +747,7 @@ describe Gitlab::GitAccess do
context
"when in a read-only GitLab instance"
do
context
"when in a read-only GitLab instance"
do
before
do
before
do
create
(
:protected_branch
,
name:
'feature'
,
project:
project
)
create
(
:protected_branch
,
name:
'feature'
,
project:
project
)
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
end
end
# Only check admin; if an admin can't do it, other roles can't either
# Only check admin; if an admin can't do it, other roles can't either
...
...
spec/lib/gitlab/git_access_wiki_spec.rb
View file @
8d7e07d0
...
@@ -27,7 +27,7 @@ describe Gitlab::GitAccessWiki do
...
@@ -27,7 +27,7 @@ describe Gitlab::GitAccessWiki do
context
'when in a read-only GitLab instance'
do
context
'when in a read-only GitLab instance'
do
before
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
end
end
it
'does not give access to upload wiki code'
do
it
'does not give access to upload wiki code'
do
...
...
spec/lib/gitlab/middleware/readonly_spec.rb
View file @
8d7e07d0
...
@@ -42,7 +42,7 @@ describe Gitlab::Middleware::Readonly do
...
@@ -42,7 +42,7 @@ describe Gitlab::Middleware::Readonly do
let
(
:fake_app
)
{
lambda
{
|
env
|
[
200
,
{
'Content-Type'
=>
'text/plain'
},
[
'OK'
]]
}
}
let
(
:fake_app
)
{
lambda
{
|
env
|
[
200
,
{
'Content-Type'
=>
'text/plain'
},
[
'OK'
]]
}
}
before
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
end
end
it
'expects PATCH requests to be disallowed'
do
it
'expects PATCH requests to be disallowed'
do
...
@@ -112,7 +112,7 @@ describe Gitlab::Middleware::Readonly do
...
@@ -112,7 +112,7 @@ describe Gitlab::Middleware::Readonly do
let
(
:content_json
)
{
{
'CONTENT_TYPE'
=>
'application/json'
}
}
let
(
:content_json
)
{
{
'CONTENT_TYPE'
=>
'application/json'
}
}
before
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
end
end
it
'expects PATCH requests to be disallowed'
do
it
'expects PATCH requests to be disallowed'
do
...
...
spec/models/concerns/routable_spec.rb
View file @
8d7e07d0
...
@@ -15,7 +15,7 @@ describe Group, 'Routable' do
...
@@ -15,7 +15,7 @@ describe Group, 'Routable' do
describe
'GitLab read-only instance'
do
describe
'GitLab read-only instance'
do
it
'does not save route if route is not present'
do
it
'does not save route if route is not present'
do
group
.
route
.
path
=
''
group
.
route
.
path
=
''
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
).
and_return
(
true
)
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
).
and_return
(
true
)
expect
(
group
).
to
receive
(
:update_route
).
and_call_original
expect
(
group
).
to
receive
(
:update_route
).
and_call_original
expect
{
group
.
full_path
}.
to
change
{
Route
.
count
}.
by
(
0
)
expect
{
group
.
full_path
}.
to
change
{
Route
.
count
}.
by
(
0
)
...
...
spec/models/project_spec.rb
View file @
8d7e07d0
...
@@ -823,7 +823,7 @@ describe Project do
...
@@ -823,7 +823,7 @@ describe Project do
end
end
it
'does not cache data when in a read-only GitLab instance'
do
it
'does not cache data when in a read-only GitLab instance'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
expect
do
expect
do
project
.
cache_has_external_issue_tracker
project
.
cache_has_external_issue_tracker
...
@@ -853,7 +853,7 @@ describe Project do
...
@@ -853,7 +853,7 @@ describe Project do
end
end
it
'does not cache data when in a read-only GitLab instance'
do
it
'does not cache data when in a read-only GitLab instance'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
expect
do
expect
do
project
.
cache_has_external_wiki
project
.
cache_has_external_wiki
...
...
spec/requests/lfs_http_spec.rb
View file @
8d7e07d0
...
@@ -877,8 +877,7 @@ describe 'Git LFS API and storage' do
...
@@ -877,8 +877,7 @@ describe 'Git LFS API and storage' do
end
end
end
end
describe
'when handling lfs batch request on a secondary Geo node'
do
describe
'when handling lfs batch request on a read-only GitLab instance'
do
let!
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let
(
:authorization
)
{
authorize_user
}
let
(
:authorization
)
{
authorize_user
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:path
)
{
"
#{
project
.
http_url_to_repo
}
/info/lfs/objects/batch"
}
let
(
:path
)
{
"
#{
project
.
http_url_to_repo
}
/info/lfs/objects/batch"
}
...
@@ -887,7 +886,7 @@ describe 'Git LFS API and storage' do
...
@@ -887,7 +886,7 @@ describe 'Git LFS API and storage' do
end
end
before
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
)
{
true
}
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
enable_lfs
enable_lfs
end
end
...
...
spec/services/users/activity_service_spec.rb
View file @
8d7e07d0
...
@@ -41,7 +41,7 @@ describe Users::ActivityService do
...
@@ -41,7 +41,7 @@ describe Users::ActivityService do
context
'when in GitLab read-only instance'
do
context
'when in GitLab read-only instance'
do
before
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:readonly?
).
and_return
(
true
)
allow
(
Gitlab
::
Database
).
to
receive
(
:read
_
only?
).
and_return
(
true
)
end
end
it
'does not update last_activity_at'
do
it
'does not update last_activity_at'
do
...
...
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