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
Boxiang Sun
gitlab-ce
Commits
964f7a11
Commit
964f7a11
authored
Jun 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/threadsafe' of /home/git/repositories/gitlab/gitlabhq
parents
159eee8d
993af5d0
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
18 additions
and
15 deletions
+18
-15
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+3
-4
app/observers/base_observer.rb
app/observers/base_observer.rb
+4
-0
app/observers/issue_observer.rb
app/observers/issue_observer.rb
+0
-2
app/observers/merge_request_observer.rb
app/observers/merge_request_observer.rb
+0
-2
config/database.yml.mysql
config/database.yml.mysql
+1
-1
config/database.yml.postgresql
config/database.yml.postgresql
+1
-1
config/environments/production.rb
config/environments/production.rb
+1
-1
config/initializers/2_app.rb
config/initializers/2_app.rb
+5
-0
lib/api/issues.rb
lib/api/issues.rb
+2
-1
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-2
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+0
-1
No files found.
app/controllers/application_controller.rb
View file @
964f7a11
class
ApplicationController
<
ActionController
::
Base
before_filter
:authenticate_user!
before_filter
:reject_blocked!
before_filter
:set_current_user_for_
observers
before_filter
:set_current_user_for_
thread
before_filter
:add_abilities
before_filter
:dev_tools
if
Rails
.
env
==
'development'
before_filter
:default_headers
...
...
@@ -47,9 +47,8 @@ class ApplicationController < ActionController::Base
end
end
def
set_current_user_for_observers
MergeRequestObserver
.
current_user
=
current_user
IssueObserver
.
current_user
=
current_user
def
set_current_user_for_thread
Thread
.
current
[
:current_user
]
=
current_user
end
def
abilities
...
...
app/observers/base_observer.rb
View file @
964f7a11
...
...
@@ -6,4 +6,8 @@ class BaseObserver < ActiveRecord::Observer
def
log_info
message
Gitlab
::
AppLogger
.
info
message
end
def
current_user
Thread
.
current
[
:current_user
]
end
end
app/observers/issue_observer.rb
View file @
964f7a11
class
IssueObserver
<
BaseObserver
cattr_accessor
:current_user
def
after_create
(
issue
)
notification
.
new_issue
(
issue
,
current_user
)
end
...
...
app/observers/merge_request_observer.rb
View file @
964f7a11
class
MergeRequestObserver
<
BaseObserver
cattr_accessor
:current_user
def
after_create
(
merge_request
)
notification
.
new_merge_request
(
merge_request
,
current_user
)
end
...
...
config/database.yml.mysql
View file @
964f7a11
...
...
@@ -6,7 +6,7 @@ production:
encoding: utf8
reconnect: false
database: gitlabhq_production
pool:
5
pool:
10
username: root
password: "secure password"
# host: localhost
...
...
config/database.yml.postgresql
View file @
964f7a11
...
...
@@ -5,7 +5,7 @@ production:
adapter: postgresql
encoding: unicode
database: gitlabhq_production
pool:
5
pool:
10
username: git
password:
# host: localhost
...
...
config/environments/production.rb
View file @
964f7a11
...
...
@@ -52,7 +52,7 @@ Gitlab::Application.configure do
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
#
config.threadsafe!
config
.
threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
...
...
config/initializers/2_app.rb
View file @
964f7a11
...
...
@@ -6,3 +6,8 @@ module Gitlab
Settings
end
end
#
# Load all libs for threadsafety
#
Dir
[
"
#{
Rails
.
root
}
/lib/**/*.rb"
].
each
{
|
file
|
require
file
}
lib/api/issues.rb
View file @
964f7a11
...
...
@@ -2,6 +2,7 @@ module API
# Issues API
class
Issues
<
Grape
::
API
before
{
authenticate!
}
before
{
Thread
.
current
[
:current_user
]
=
current_user
}
resource
:issues
do
# Get currently authenticated user's issues
...
...
@@ -79,7 +80,7 @@ module API
attrs
=
attributes_for_keys
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:state_event
]
attrs
[
:label_list
]
=
params
[
:labels
]
if
params
[
:labels
].
present?
IssueObserver
.
current_user
=
current_user
if
@issue
.
update_attributes
attrs
present
@issue
,
with:
Entities
::
Issue
else
...
...
lib/api/merge_requests.rb
View file @
964f7a11
...
...
@@ -2,6 +2,7 @@ module API
# MergeRequest API
class
MergeRequests
<
Grape
::
API
before
{
authenticate!
}
before
{
Thread
.
current
[
:current_user
]
=
current_user
}
resource
:projects
do
helpers
do
...
...
@@ -94,8 +95,6 @@ module API
authorize!
:modify_merge_request
,
merge_request
MergeRequestObserver
.
current_user
=
current_user
if
merge_request
.
update_attributes
attrs
merge_request
.
reload_code
merge_request
.
mark_as_unchecked
...
...
spec/models/milestone_spec.rb
View file @
964f7a11
...
...
@@ -39,7 +39,6 @@ describe Milestone do
end
it
"should count closed issues"
do
IssueObserver
.
current_user
=
issue
.
author
issue
.
close
milestone
.
issues
<<
issue
milestone
.
percent_complete
.
should
==
100
...
...
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