diff options
author | Angus MacArthur <amacarthur@blackberry.com> | 2013-10-04 15:11:50 -0400 |
---|---|---|
committer | Angus MacArthur <amacarthur@blackberry.com> | 2013-10-16 01:20:53 -0400 |
commit | aefe2e952f33267ce38fb9270400f4f6f194d37b (patch) | |
tree | 3546807c2b7942585a41cfb1163dc5e6a69e40e0 /db | |
parent | a8eb525e72f6883a07539af9429ccd41dbc8698b (diff) | |
download | gitlab-ce-aefe2e952f33267ce38fb9270400f4f6f194d37b.tar.gz |
Fixing unsafe use of Thread.current variable :current_user
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/09_issues.rb | 25 | ||||
-rw-r--r-- | db/fixtures/development/10_merge_requests.rb | 30 |
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 |