Commit 44e49755adf9b7aeaa7d2068d9684244c31e8cf9

Authored by Sergey Nartimov
1 parent 2039747d
Exists in master and in 1 other branch production

extract IssueTracker#configured? and NotificationService#configured?

App is not responsible to know implementation details of issue trackers
and notification services.
app/models/app.rb
@@ -142,11 +142,11 @@ class App @@ -142,11 +142,11 @@ class App
142 142
143 143
144 def issue_tracker_configured? 144 def issue_tracker_configured?
145 - !!(issue_tracker && issue_tracker.class < IssueTracker && issue_tracker.project_id.present?) 145 + !!(issue_tracker && issue_tracker.class < IssueTracker && issue_tracker.configured?)
146 end 146 end
147 147
148 def notification_service_configured? 148 def notification_service_configured?
149 - !!(notification_service && notification_service.class < NotificationService && notification_service.api_token.present?) 149 + !!(notification_service && notification_service.class < NotificationService && notification_service.configured?)
150 end 150 end
151 151
152 152
app/models/issue_tracker.rb
@@ -35,5 +35,9 @@ class IssueTracker @@ -35,5 +35,9 @@ class IssueTracker
35 Label = '' 35 Label = ''
36 def self.label; self::Label; end 36 def self.label; self::Label; end
37 def label; self.class.label; end 37 def label; self.class.label; end
  38 +
  39 + def configured?
  40 + project_id.present?
  41 + end
38 end 42 end
39 43
app/models/notification_service.rb
@@ -30,4 +30,8 @@ class NotificationService @@ -30,4 +30,8 @@ class NotificationService
30 Label = '' 30 Label = ''
31 def self.label; self::Label; end 31 def self.label; self::Label; end
32 def label; self.class.label; end 32 def label; self.class.label; end
  33 +
  34 + def configured?
  35 + api_token.present?
  36 + end
33 end 37 end