Commit 7f0137d2fa3334f61ed6b92823400222f053b6e1

Authored by Nathan Broadbent
1 parent b0b24717
Exists in master and in 1 other branch production

Use constants instead of methods in issue tracker models.

app/models/issue_trackers/fogbugz_tracker.rb
1 1 class FogbugzTracker < IssueTracker
2   - def self.label; "fogbugz"; end
  2 + Label = "fogbugz"
  3 + RequiredFields = %w(project_id account username password)
3 4  
4 5 def check_params
5   - if %w(project_id account username password).detect {|f| self[f].blank? }
  6 + if RequiredFields.detect {|f| self[f].blank? }
6 7 errors.add :base, 'You must specify your FogBugz Area Name, FogBugz URL, Username, and Password'
7 8 end
8 9 end
... ...
app/models/issue_trackers/github_tracker.rb
1 1 class GithubTracker < IssueTracker
2   - def self.label; "github"; end
  2 + Label = "github"
  3 + RequiredFields = %w(project_id username api_token)
3 4  
4 5 def check_params
5   - if %w(project_id username api_token ).detect {|f| self[f].blank? }
  6 + if RequiredFields.detect {|f| self[f].blank? }
6 7 errors.add :base, 'You must specify your Github repository, username and API token'
7 8 end
8 9 end
... ...
app/models/issue_trackers/lighthouse_tracker.rb
1 1 class LighthouseTracker < IssueTracker
2   - def self.label; "lighthouseapp"; end
  2 + Label = "lighthouseapp"
  3 + RequiredFields = %w(account api_token project_id)
3 4  
4 5 def check_params
5   - if %w(account api_token project_id).detect {|f| self[f].blank? }
  6 + if RequiredFields.detect {|f| self[f].blank? }
6 7 errors.add :base, 'You must specify your Lighthouseapp account, API token and Project ID'
7 8 end
8 9 end
... ...
app/models/issue_trackers/mingle_tracker.rb
1 1 class MingleTracker < IssueTracker
2   - def self.label; "mingle"; end
  2 + Label = "mingle"
  3 + RequiredFields = %w(account project_id username password)
3 4  
4 5 def check_params
5   - if %w(account project_id username password).detect {|f| self[f].blank? } or !ticket_properties_hash["card_type"]
  6 + if RequiredFields.detect {|f| self[f].blank? } or !ticket_properties_hash["card_type"]
6 7 errors.add :base, 'You must specify your Mingle URL, Project ID, Card Type (in default card properties), Sign-in name, and Password'
7 8 end
8 9 end
... ...
app/models/issue_trackers/pivotal_labs_tracker.rb
1 1 class PivotalLabsTracker < IssueTracker
2   - def self.label; "pivotal"; end
  2 + Label = "pivotal"
  3 + RequiredFields = %w(api_token project_id)
3 4  
4 5 def check_params
5   - if %w(api_token project_id).detect {|f| self[f].blank? }
  6 + if RequiredFields.detect {|f| self[f].blank? }
6 7 errors.add :base, 'You must specify your Pivotal Tracker API token and Project ID'
7 8 end
8 9 end
... ...
app/models/issue_trackers/redmine_tracker.rb
1 1 class RedmineTracker < IssueTracker
2   - def self.label; "redmine"; end
  2 + Label = "redmine"
  3 + RequiredFields = %w(account api_token project_id)
3 4  
4 5 def check_params
5   - if %w(account api_token project_id).detect {|f| self[f].blank? }
  6 + if RequiredFields.detect {|f| self[f].blank? }
6 7 errors.add :base, 'You must specify your Redmine URL, API token and Project ID'
7 8 end
8 9 end
... ...
app/views/errs/show.html.haml
... ... @@ -13,9 +13,9 @@
13 13 - content_for :action_bar do
14 14 - if @err.app.issue_tracker_configured?
15 15 - if @err.issue_link.blank?
16   - %span= link_to 'create issue', create_issue_app_err_path(@app, @err), :method => :post, :class => "#{@app.issue_tracker.class.label}_create create-issue"
  16 + %span= link_to 'create issue', create_issue_app_err_path(@app, @err), :method => :post, :class => "#{@app.issue_tracker.class::Label}_create create-issue"
17 17 - else
18   - %span= link_to 'go to issue', @err.issue_link, :class => "#{@app.issue_tracker.class.label}_goto goto-issue"
  18 + %span= link_to 'go to issue', @err.issue_link, :class => "#{@app.issue_tracker.class::Label}_goto goto-issue"
19 19 = link_to 'unlink issue', unlink_issue_app_err_path(@app, @err), :method => :delete, :confirm => "Unlink err issues?", :class => "unlink-issue"
20 20 - if @err.unresolved?
21 21 %span= link_to 'resolve', resolve_app_err_path(@app, @err), :method => :put, :confirm => err_confirm, :class => 'resolve'
... ...