diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-05-28 15:31:46 +0200 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-31 10:56:41 +0200 |
commit | 2ccbe4fd341254c1d3146c81888881ace5f997c4 (patch) | |
tree | 63c8b2f30b84998a0c30efb29dea02679ab2bb9f /app/models/ci/runner.rb | |
parent | bf74e69eeb3d7881fe46ee34a26ba03a1744e8d0 (diff) | |
download | gitlab-ce-2ccbe4fd341254c1d3146c81888881ace5f997c4.tar.gz |
Run `Ci::Runner#assign_to` in transaction
Diffstat (limited to 'app/models/ci/runner.rb')
-rw-r--r-- | app/models/ci/runner.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 3f0476fb7cf..57edd6a4956 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -120,8 +120,15 @@ module Ci raise ArgumentError, 'Transitioning a group runner to a project runner is not supported' end - self.projects << project - self.save + begin + transaction do + self.projects << project + self.save! + end + rescue ActiveRecord::RecordInvalid => e + self.errors.add(:assign_to, e.message) + false + end end def display_name |