Skip to content

Commit

Permalink
Merge pull request #6284 from DavidKang/staging_workflow/sprint51/mov…
Browse files Browse the repository at this point in the history
…e-to-correct-model

Move callback into the correct model
  • Loading branch information
ChrisBr committed Nov 19, 2018
2 parents f0c26ce + bb92227 commit af11087
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class Project < ApplicationRecord
@commit_opts = {}
end

after_save :update_staging_workflow_on_backend
after_destroy :update_staging_workflow_on_backend

has_many :relationships, dependent: :destroy, inverse_of: :project
has_many :packages, inverse_of: :project do
def autocomplete(search)
Expand Down Expand Up @@ -1747,13 +1744,6 @@ def has_local_distribution(project_name, repository)
linked_repository.name == repository
end
end

def update_staging_workflow_on_backend
return unless staging_workflow_id

staging_workflow.reload
staging_workflow.write_to_backend
end
end
# rubocop:enable Metrics/ClassLength

Expand Down
10 changes: 10 additions & 0 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class StagingProject < Project

default_scope { where.not(staging_workflow: nil) }

after_save :update_staging_workflow_on_backend
after_destroy :update_staging_workflow_on_backend

def staging_identifier
name[/.*:Staging:(.*)/, 1]
end
Expand Down Expand Up @@ -160,5 +163,12 @@ def set_buildinfo

@broken_packages.reject! { |package| package['state'] == 'unresolvable' } if @building_repositories.present?
end

def update_staging_workflow_on_backend
return unless staging_workflow_id

staging_workflow.reload
staging_workflow.write_to_backend
end
end
end

0 comments on commit af11087

Please sign in to comment.