Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorAngus MacArthur <amacarthur@blackberry.com>2013-10-04 23:11:50 +0400
committerAngus MacArthur <amacarthur@blackberry.com>2013-10-16 09:20:53 +0400
commitaefe2e952f33267ce38fb9270400f4f6f194d37b (patch)
tree3546807c2b7942585a41cfb1163dc5e6a69e40e0 /db
parenta8eb525e72f6883a07539af9429ccd41dbc8698b (diff)
Fixing unsafe use of Thread.current variable :current_user
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/09_issues.rb25
-rw-r--r--db/fixtures/development/10_merge_requests.rb30
2 files changed, 32 insertions, 23 deletions
diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb
index 31ba77254a3..1535c16939c 100644
--- a/db/fixtures/development/09_issues.rb
+++ b/db/fixtures/development/09_issues.rb
@@ -11,17 +11,22 @@ Gitlab::Seeder.quiet do
next unless user
user_id = user.id
- Thread.current[:current_user] = user
- Issue.seed(:id, [{
- id: i,
- project_id: project.id,
- author_id: user_id,
- assignee_id: user_id,
- state: ['opened', 'closed'].sample,
- milestone: project.milestones.sample,
- title: Faker::Lorem.sentence(6)
- }])
+ begin
+ Thread.current[:current_user] = user
+
+ Issue.seed(:id, [{
+ id: i,
+ project_id: project.id,
+ author_id: user_id,
+ assignee_id: user_id,
+ state: ['opened', 'closed'].sample,
+ milestone: project.milestones.sample,
+ title: Faker::Lorem.sentence(6)
+ }])
+ ensure
+ Thread.current[:current_user] = nil
+ end
print('.')
end
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 1e61ea28636..75f6e56985d 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -17,19 +17,23 @@ Gitlab::Seeder.quiet do
next if branches.uniq.size < 2
user_id = user.id
- Thread.current[:current_user] = user
-
- MergeRequest.seed(:id, [{
- id: i,
- source_branch: branches.first,
- target_branch: branches.last,
- source_project_id: project.id,
- target_project_id: project.id,
- author_id: user_id,
- assignee_id: user_id,
- milestone: project.milestones.sample,
- title: Faker::Lorem.sentence(6)
- }])
+ begin
+ Thread.current[:current_user] = user
+
+ MergeRequest.seed(:id, [{
+ id: i,
+ source_branch: branches.first,
+ target_branch: branches.last,
+ source_project_id: project.id,
+ target_project_id: project.id,
+ author_id: user_id,
+ assignee_id: user_id,
+ milestone: project.milestones.sample,
+ title: Faker::Lorem.sentence(6)
+ }])
+ ensure
+ Thread.current[:current_user] = nil
+ end
print('.')
end
end