File obs-server-2.9-0105-frontend-Rails-5.2-Update-callback-in-bs-request-mod.patch of Package obs-server

From aa10f5613eafecc606d635615540349eda611722 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= <bgeuken@suse.de>
Date: Thu, 24 May 2018 11:22:46 +0200
Subject: [PATCH] [frontend] Rails 5.2: Update callback in bs request model

We were using a combination of after_update callback and
ActiveModel::Dirty to track changes of bs request states.

After upgrading to Rails 5.2 this stopped to work and we saw
some test failures.

The reason for that was that the ActiveModel::Dirty helper
stopped registering attribute changes after the update was
made (but before the save).
Which seems to make a lot of sense, but it caused this code
to always match:

`
  return if state_was.to_s == state.to_s
`

Using the before_update callback instead solved this.
---
 src/api/app/models/bs_request.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/api/app/models/bs_request.rb b/src/api/app/models/bs_request.rb
index d196207059..2045ea513e 100644
--- a/src/api/app/models/bs_request.rb
+++ b/src/api/app/models/bs_request.rb
@@ -89,7 +89,7 @@ class BsRequest < ApplicationRecord
   validates :comment, length: { maximum: 65_535 }
   validates :description, length: { maximum: 65_535 }
 
-  after_update :send_state_change
+  before_update :send_state_change
   after_commit :update_cache
 
   def self.delayed_auto_accept
-- 
2.25.3