#75: added checking "mass_build" field before creating ActivityFeed
This commit is contained in:
parent
69ffc52bf3
commit
aa3f8af0bf
|
@ -2,6 +2,15 @@
|
|||
class ActivityFeedObserver < ActiveRecord::Observer
|
||||
observe :issue, :comment, :user, :build_list
|
||||
|
||||
BUILD_LIST_STATUSES = [
|
||||
BuildList::BUILD_PUBLISHED,
|
||||
BuildList::SUCCESS,
|
||||
BuildList::BUILD_ERROR,
|
||||
BuildList::PROJECT_VERSION_NOT_FOUND,
|
||||
BuildList::FAILED_PUBLISH,
|
||||
BuildList::TESTS_FAILED
|
||||
].freeze
|
||||
|
||||
def after_create(record)
|
||||
case record.class.to_s
|
||||
when 'User'
|
||||
|
@ -136,15 +145,13 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
when 'BuildList'
|
||||
if ( record.status_changed? &&
|
||||
[BuildList::BUILD_PUBLISHED,
|
||||
BuildList::SUCCESS,
|
||||
BuildList::BUILD_ERROR,
|
||||
BuildList::PROJECT_VERSION_NOT_FOUND,
|
||||
BuildList::FAILED_PUBLISH,
|
||||
BuildList::TESTS_FAILED
|
||||
].include?(record.status)
|
||||
) or (record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
|
||||
# Do not show mass build activity in activity feeds
|
||||
return true if record.mass_build
|
||||
if record.mass_build.blank? && (
|
||||
record.status_changed? && BUILD_LIST_STATUSES.include?(record.status) ||
|
||||
record.status == BuildList::BUILD_PENDING && record.bs_id_changed?
|
||||
)
|
||||
|
||||
record.project.admins.each do |recipient|
|
||||
user = record.publisher || record.user
|
||||
ActivityFeed.create(
|
||||
|
|
|
@ -86,7 +86,7 @@ class BuildList < ActiveRecord::Base
|
|||
BUILD_ERROR,
|
||||
PROJECT_VERSION_NOT_FOUND,
|
||||
TESTS_FAILED
|
||||
]
|
||||
].freeze
|
||||
|
||||
HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response,
|
||||
BUILD_CANCELED => :build_canceled,
|
||||
|
@ -101,7 +101,7 @@ class BuildList < ActiveRecord::Base
|
|||
SUCCESS => :success,
|
||||
PROJECT_VERSION_NOT_FOUND => :project_version_not_found,
|
||||
TESTS_FAILED => :tests_failed
|
||||
}
|
||||
}.freeze
|
||||
|
||||
scope :recent, order("#{table_name}.updated_at DESC")
|
||||
scope :for_status, lambda {|status| where(:status => status) }
|
||||
|
|
Loading…
Reference in New Issue