Class: RemoteIssueFetch::Create

Inherits:
Base
  • Object
show all
Defined in:
app/models/remote_issue_fetch/create.rb,
app/models/remote_issue_fetch/create/_local_issue.rb,
app/models/remote_issue_fetch/create/_remote_issue.rb

Instance Method Summary collapse

Methods inherited from Base

#author_present, #provider_issue_present

Instance Method Details

#default_error_columnObject



20
21
22
# File 'app/models/remote_issue_fetch/create.rb', line 20

def default_error_column
  :issue_remote_code
end

#saveObject



24
25
26
# File 'app/models/remote_issue_fetch/create.rb', line 24

def save
  remote_issue_by_remote_code.present? ? update : super
end

#tracker_in_projectObject



28
29
30
31
32
33
# File 'app/models/remote_issue_fetch/create.rb', line 28

def tracker_in_project
  return unless local_tracker.present? && project.present?
  return if project.trackers.include?(local_tracker)

  errors.add(:local_tracker, 'is not a tracker of project')
end

#updateObject



35
36
37
38
39
40
41
42
# File 'app/models/remote_issue_fetch/create.rb', line 35

def update
  update_record = ::RemoteIssueFetch::Update
                  .new(remote_issue: remote_issue_by_remote_code)
  return true if update_record.save

  fetch_record_errors(update_record, default_column: default_error_column)
  false
end