Commit 940c89cc5fe68f837c6c9fcc75a8f7b0daedad69

Authored by Nick Recobra
2 parents 49468ce4 7e971d51
Exists in master and in 1 other branch production

Merge pull request #51 from crossroads/allow_none_for_issue_tracker

Allow user to select (None) for issue tracker.
app/models/app.rb
@@ -35,7 +35,7 @@ class App @@ -35,7 +35,7 @@ class App
35 accepts_nested_attributes_for :watchers, :allow_destroy => true, 35 accepts_nested_attributes_for :watchers, :allow_destroy => true,
36 :reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? } 36 :reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? }
37 accepts_nested_attributes_for :issue_tracker, :allow_destroy => true, 37 accepts_nested_attributes_for :issue_tracker, :allow_destroy => true,
38 - :reject_if => proc { |attrs| !%w(lighthouseapp redmine pivotal fogbugz).include?(attrs[:issue_tracker_type]) } 38 + :reject_if => proc { |attrs| !%w(none lighthouseapp redmine pivotal fogbugz).include?(attrs[:issue_tracker_type]) }
39 39
40 # Mongoid Bug: find(id) on association proxies returns an Enumerator 40 # Mongoid Bug: find(id) on association proxies returns an Enumerator
41 def self.find_by_id!(app_id) 41 def self.find_by_id!(app_id)
@@ -68,9 +68,9 @@ class App @@ -68,9 +68,9 @@ class App
68 def github_url_to_file(file) 68 def github_url_to_file(file)
69 "#{self.github_url}/blob/master#{file}" 69 "#{self.github_url}/blob/master#{file}"
70 end 70 end
71 - 71 +
72 def issue_tracker_configured? 72 def issue_tracker_configured?
73 - issue_tracker && !issue_tracker.project_id.blank? 73 + issue_tracker && issue_tracker.issue_tracker_type != "none" && !issue_tracker.project_id.blank?
74 end 74 end
75 75
76 protected 76 protected
@@ -96,3 +96,4 @@ class App @@ -96,3 +96,4 @@ class App
96 end 96 end
97 97
98 end 98 end
  99 +
app/models/issue_tracker.rb
@@ -14,7 +14,7 @@ class IssueTracker @@ -14,7 +14,7 @@ class IssueTracker
14 field :project_id, :type => String 14 field :project_id, :type => String
15 field :username, :type => String 15 field :username, :type => String
16 field :password, :type => String 16 field :password, :type => String
17 - field :issue_tracker_type, :type => String, :default => 'lighthouseapp' 17 + field :issue_tracker_type, :type => String, :default => 'none'
18 18
19 def create_issue err 19 def create_issue err
20 case issue_tracker_type 20 case issue_tracker_type
@@ -130,3 +130,4 @@ class IssueTracker @@ -130,3 +130,4 @@ class IssueTracker
130 end 130 end
131 end 131 end
132 end 132 end
  133 +
app/views/apps/_fields.html.haml
@@ -39,6 +39,8 @@ @@ -39,6 +39,8 @@
39 = f.fields_for :issue_tracker do |w| 39 = f.fields_for :issue_tracker do |w|
40 %div.issue_tracker.nested 40 %div.issue_tracker.nested
41 %div.choose 41 %div.choose
  42 + = w.radio_button :issue_tracker_type, :none
  43 + = label_tag :issue_tracker_type_lighthouseapp, '(None)', :for => label_for_attr(w, 'issue_tracker_type_none')
42 = w.radio_button :issue_tracker_type, :lighthouseapp 44 = w.radio_button :issue_tracker_type, :lighthouseapp
43 = label_tag :issue_tracker_type_lighthouseapp, 'Lighthouse', :for => label_for_attr(w, 'issue_tracker_type_lighthouseapp') 45 = label_tag :issue_tracker_type_lighthouseapp, 'Lighthouse', :for => label_for_attr(w, 'issue_tracker_type_lighthouseapp')
44 = w.radio_button :issue_tracker_type, :redmine 46 = w.radio_button :issue_tracker_type, :redmine
@@ -75,3 +77,4 @@ @@ -75,3 +77,4 @@
75 = w.text_field :username, :placeholder => 'Username/Email for your account' 77 = w.text_field :username, :placeholder => 'Username/Email for your account'
76 = w.label :password, 'account password' 78 = w.label :password, 'account password'
77 = w.password_field :password, :placeholder => 'Password for your account' 79 = w.password_field :password, :placeholder => 'Password for your account'
  80 +