Commit 80ab7ea5b440d6b28b591bec11e2622b2f8ed7d6
1 parent
2bd7dbf1
Exists in
master
and in
1 other branch
Remove allow_comments_with_issue_tracker config
Showing
10 changed files
with
33 additions
and
97 deletions
Show diff stats
app/models/app.rb
@@ -175,13 +175,6 @@ class App | @@ -175,13 +175,6 @@ class App | ||
175 | update_attribute(:api_key, SecureRandom.hex) | 175 | update_attribute(:api_key, SecureRandom.hex) |
176 | end | 176 | end |
177 | 177 | ||
178 | - ## | ||
179 | - # Check if comments can be allowed on this application | ||
180 | - # | ||
181 | - def comments_allowed? | ||
182 | - !issue_tracker || issue_tracker.comments_allowed? | ||
183 | - end | ||
184 | - | ||
185 | protected | 178 | protected |
186 | 179 | ||
187 | def store_cached_attributes_on_problems | 180 | def store_cached_attributes_on_problems |
app/models/issue_tracker.rb
@@ -41,6 +41,5 @@ class IssueTracker | @@ -41,6 +41,5 @@ class IssueTracker | ||
41 | 41 | ||
42 | delegate :configured?, :to => :tracker | 42 | delegate :configured?, :to => :tracker |
43 | delegate :create_issue, :to => :tracker | 43 | delegate :create_issue, :to => :tracker |
44 | - delegate :comments_allowed?, :to => :tracker | ||
45 | delegate :url, :to => :tracker | 44 | delegate :url, :to => :tracker |
46 | end | 45 | end |
app/models/problem.rb
@@ -73,10 +73,6 @@ class Problem | @@ -73,10 +73,6 @@ class Problem | ||
73 | Notice.for_errs(errs).ordered | 73 | Notice.for_errs(errs).ordered |
74 | end | 74 | end |
75 | 75 | ||
76 | - def comments_allowed? | ||
77 | - Errbit::Config.allow_comments_with_issue_tracker || app.comments_allowed? | ||
78 | - end | ||
79 | - | ||
80 | def resolve! | 76 | def resolve! |
81 | self.update_attributes!(:resolved => true, :resolved_at => Time.now) | 77 | self.update_attributes!(:resolved => true, :resolved_at => Time.now) |
82 | end | 78 | end |
app/views/problems/show.html.haml
@@ -22,32 +22,30 @@ | @@ -22,32 +22,30 @@ | ||
22 | %br | 22 | %br |
23 | = render "issue_tracker_links" | 23 | = render "issue_tracker_links" |
24 | 24 | ||
25 | -- if problem.comments_allowed? || problem.comments.any? | ||
26 | - - content_for :comments do | ||
27 | - %h3 Comments | ||
28 | - - problem.comments.each do |comment| | ||
29 | - .window | ||
30 | - %table.comment | ||
31 | - %tr | ||
32 | - %th | ||
33 | - - if comment.user | ||
34 | - - if Errbit::Config.use_gravatar | ||
35 | - = gravatar_tag comment.user.email, :s => 24 | ||
36 | - %span.comment-info | ||
37 | - = time_ago_in_words(comment.created_at, include_seconds: true) << " ago by " | ||
38 | - = link_to comment.user.email, comment.user | ||
39 | - - else | ||
40 | - %span.comment-info | ||
41 | - = time_ago_in_words(comment.created_at, true) << " ago by [Unknown User]" | ||
42 | - %span.delete= link_to '✘'.html_safe, [app, problem, comment], :method => :delete, | ||
43 | - :data => { :confirm => t("comments.confirm_delete") }, :class => "destroy-comment" | ||
44 | - %tr | ||
45 | - %td= simple_format comment.body | ||
46 | - - if problem.comments_allowed? | ||
47 | - = form_for [app, problem, @comment] do |comment_form| | ||
48 | - %p Add a comment | ||
49 | - = comment_form.text_area :body | ||
50 | - = comment_form.submit "Save Comment" | 25 | +- content_for :comments do |
26 | + %h3 Comments | ||
27 | + - problem.comments.each do |comment| | ||
28 | + .window | ||
29 | + %table.comment | ||
30 | + %tr | ||
31 | + %th | ||
32 | + - if comment.user | ||
33 | + - if Errbit::Config.use_gravatar | ||
34 | + = gravatar_tag comment.user.email, :s => 24 | ||
35 | + %span.comment-info | ||
36 | + = time_ago_in_words(comment.created_at, include_seconds: true) << " ago by " | ||
37 | + = link_to comment.user.email, comment.user | ||
38 | + - else | ||
39 | + %span.comment-info | ||
40 | + = time_ago_in_words(comment.created_at, true) << " ago by [Unknown User]" | ||
41 | + %span.delete= link_to '✘'.html_safe, [app, problem, comment], :method => :delete, | ||
42 | + :data => { :confirm => t("comments.confirm_delete") }, :class => "destroy-comment" | ||
43 | + %tr | ||
44 | + %td= simple_format comment.body | ||
45 | + = form_for [app, problem, @comment] do |comment_form| | ||
46 | + %p Add a comment | ||
47 | + = comment_form.text_area :body | ||
48 | + = comment_form.submit "Save Comment" | ||
51 | 49 | ||
52 | %h4= @notice.try(:message) | 50 | %h4= @notice.try(:message) |
53 | 51 |
config/cloud/cloud66/files/_load_config.rb
@@ -11,7 +11,6 @@ unless defined?(Errbit::Config) | @@ -11,7 +11,6 @@ unless defined?(Errbit::Config) | ||
11 | # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES'] | 11 | # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES'] |
12 | Errbit::Config.confirm_resolve_err = ENV['ERRBIT_CONFIRM_RESOLVE_ERR'].to_i == 0 | 12 | Errbit::Config.confirm_resolve_err = ENV['ERRBIT_CONFIRM_RESOLVE_ERR'].to_i == 0 |
13 | Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1 | 13 | Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1 |
14 | - Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER'].to_i == 0 | ||
15 | Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL'] | 14 | Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL'] |
16 | 15 | ||
17 | Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR'] | 16 | Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR'] |
config/cloud/cloud66/files/config.yml
@@ -32,11 +32,6 @@ confirm_resolve_err: true | @@ -32,11 +32,6 @@ confirm_resolve_err: true | ||
32 | # Helpful when you need to plug in a custom authentication strategy, such as LDAP. | 32 | # Helpful when you need to plug in a custom authentication strategy, such as LDAP. |
33 | user_has_username: false | 33 | user_has_username: false |
34 | 34 | ||
35 | -# Allow comments while an issue tracker is configured. | ||
36 | -# This is useful if the err is not critical enough to create a ticket, | ||
37 | -# but you want to leave a short comment. | ||
38 | -allow_comments_with_issue_tracker: true | ||
39 | - | ||
40 | # Display internal errors in production | 35 | # Display internal errors in production |
41 | # Since this is an internal application, you might like to see what caused Errbit to crash. | 36 | # Since this is an internal application, you might like to see what caused Errbit to crash. |
42 | # Pull requests are always welcome! | 37 | # Pull requests are always welcome! |
@@ -44,7 +39,6 @@ allow_comments_with_issue_tracker: true | @@ -44,7 +39,6 @@ allow_comments_with_issue_tracker: true | ||
44 | display_internal_errors: true | 39 | display_internal_errors: true |
45 | # The host of your errbit server | 40 | # The host of your errbit server |
46 | 41 | ||
47 | -allow_comments_with_issue_tracker: true | ||
48 | # Enable Gravatar. | 42 | # Enable Gravatar. |
49 | use_gravatar: true | 43 | use_gravatar: true |
50 | # Default Gravatar image, can be: mm, identicon, monsterid, wavatar, retro. | 44 | # Default Gravatar image, can be: mm, identicon, monsterid, wavatar, retro. |
config/config.example.yml
@@ -51,11 +51,6 @@ confirm_err_actions: true | @@ -51,11 +51,6 @@ confirm_err_actions: true | ||
51 | # Helpful when you need to plug in a custom authentication strategy, such as LDAP. | 51 | # Helpful when you need to plug in a custom authentication strategy, such as LDAP. |
52 | user_has_username: false | 52 | user_has_username: false |
53 | 53 | ||
54 | -# Allow comments while an issue tracker is configured. | ||
55 | -# This is useful if the err is not critical enough to create a ticket, | ||
56 | -# but you want to leave a short comment. | ||
57 | -allow_comments_with_issue_tracker: true | ||
58 | - | ||
59 | # Display internal errors in production | 54 | # Display internal errors in production |
60 | # Since this is an internal application, you might like to see what caused Errbit to crash. | 55 | # Since this is an internal application, you might like to see what caused Errbit to crash. |
61 | # Pull requests are always welcome! | 56 | # Pull requests are always welcome! |
config/initializers/_load_config.rb
@@ -18,9 +18,7 @@ unless defined?(Errbit::Config) | @@ -18,9 +18,7 @@ unless defined?(Errbit::Config) | ||
18 | # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES'] | 18 | # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES'] |
19 | Errbit::Config.confirm_err_actions = ENV['ERRBIT_CONFIRM_ERR_ACTIONS'].to_i == 0 | 19 | Errbit::Config.confirm_err_actions = ENV['ERRBIT_CONFIRM_ERR_ACTIONS'].to_i == 0 |
20 | Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1 | 20 | Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1 |
21 | - Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER'].to_i == 0 | ||
22 | Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL'] | 21 | Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL'] |
23 | - | ||
24 | Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR'] | 22 | Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR'] |
25 | Errbit::Config.gravatar_default = ENV['ERRBIT_GRAVATAR_DEFAULT'] | 23 | Errbit::Config.gravatar_default = ENV['ERRBIT_GRAVATAR_DEFAULT'] |
26 | 24 |
spec/models/app_spec.rb
@@ -220,26 +220,4 @@ describe App do | @@ -220,26 +220,4 @@ describe App do | ||
220 | }.to raise_error(Mongoid::Errors::DocumentNotFound) | 220 | }.to raise_error(Mongoid::Errors::DocumentNotFound) |
221 | end | 221 | end |
222 | end | 222 | end |
223 | - | ||
224 | - describe "#comments_allowed?" do | ||
225 | - context "without issue_tracker" do | ||
226 | - it 'return true' do | ||
227 | - expect(App.new.comments_allowed?).to be_true | ||
228 | - end | ||
229 | - end | ||
230 | - | ||
231 | - context "with issue_tracker" do | ||
232 | - let(:issue_tracker) do | ||
233 | - ist = IssueTracker.new | ||
234 | - ist.stub(:comments_allowed?).and_return('foo') | ||
235 | - ist | ||
236 | - end | ||
237 | - it 'delegate to issue_tracker' do | ||
238 | - expect(App.new( | ||
239 | - :issue_tracker => issue_tracker | ||
240 | - ).comments_allowed?).to eql 'foo' | ||
241 | - end | ||
242 | - end | ||
243 | - end | ||
244 | - | ||
245 | end | 223 | end |
spec/views/problems/show.html.haml_spec.rb
@@ -8,7 +8,6 @@ describe "problems/show.html.haml" do | @@ -8,7 +8,6 @@ describe "problems/show.html.haml" do | ||
8 | def self.label; 'pivotal'; end | 8 | def self.label; 'pivotal'; end |
9 | def initialize(app, params); end | 9 | def initialize(app, params); end |
10 | def configured?; true; end | 10 | def configured?; true; end |
11 | - def comments_allowed?; false; end | ||
12 | end | 11 | end |
13 | } | 12 | } |
14 | let(:github_tracker) { | 13 | let(:github_tracker) { |
@@ -16,7 +15,6 @@ describe "problems/show.html.haml" do | @@ -16,7 +15,6 @@ describe "problems/show.html.haml" do | ||
16 | def initialize(app, params); end | 15 | def initialize(app, params); end |
17 | def label; 'github'; end | 16 | def label; 'github'; end |
18 | def configured?; true; end | 17 | def configured?; true; end |
19 | - def comments_allowed?; false; end | ||
20 | end | 18 | end |
21 | } | 19 | } |
22 | let(:trackers) { | 20 | let(:trackers) { |
@@ -168,18 +166,16 @@ describe "problems/show.html.haml" do | @@ -168,18 +166,16 @@ describe "problems/show.html.haml" do | ||
168 | end | 166 | end |
169 | end | 167 | end |
170 | end | 168 | end |
171 | - | ||
172 | end | 169 | end |
173 | end | 170 | end |
174 | end | 171 | end |
175 | 172 | ||
176 | - describe "content_for :comments with comments disabled for configured issue tracker" do | 173 | + describe "content_for :comments" do |
177 | before do | 174 | before do |
178 | - Errbit::Config.stub(:allow_comments_with_issue_tracker).and_return(false) | ||
179 | Errbit::Config.stub(:use_gravatar).and_return(true) | 175 | Errbit::Config.stub(:use_gravatar).and_return(true) |
180 | end | 176 | end |
181 | 177 | ||
182 | - it 'should display comments and new comment form when no issue tracker' do | 178 | + it 'should display comments and new comment form' do |
183 | problem = Fabricate(:problem_with_comments) | 179 | problem = Fabricate(:problem_with_comments) |
184 | view.stub(:problem).and_return(problem) | 180 | view.stub(:problem).and_return(problem) |
185 | view.stub(:app).and_return(problem.app) | 181 | view.stub(:app).and_return(problem.app) |
@@ -190,24 +186,14 @@ describe "problems/show.html.haml" do | @@ -190,24 +186,14 @@ describe "problems/show.html.haml" do | ||
190 | expect(view.content_for(:comments)).to include('Add a comment') | 186 | expect(view.content_for(:comments)).to include('Add a comment') |
191 | end | 187 | end |
192 | 188 | ||
193 | - context "with issue tracker" do | ||
194 | - it 'should not display the comments section' do | ||
195 | - problem = Fabricate(:problem) | ||
196 | - with_issue_tracker("pivotal", problem) | ||
197 | - render | ||
198 | - expect(view.view_flow.get(:comments)).to be_blank | ||
199 | - end | ||
200 | - | ||
201 | - it 'should display existing comments' do | ||
202 | - problem = Fabricate(:problem_with_comments) | ||
203 | - problem.reload | ||
204 | - with_issue_tracker("pivotal", problem) | ||
205 | - render | 189 | + it 'should display existing comments' do |
190 | + problem = Fabricate(:problem_with_comments) | ||
191 | + problem.reload | ||
192 | + with_issue_tracker("pivotal", problem) | ||
193 | + render | ||
206 | 194 | ||
207 | - expect(view.content_for(:comments)).to include('Test comment') | ||
208 | - expect(view.content_for(:comments)).to have_selector('img[src^="http://www.gravatar.com/avatar"]') | ||
209 | - expect(view.content_for(:comments)).to_not include('Add a comment') | ||
210 | - end | 195 | + expect(view.content_for(:comments)).to include('Test comment') |
196 | + expect(view.content_for(:comments)).to have_selector('img[src^="http://www.gravatar.com/avatar"]') | ||
211 | end | 197 | end |
212 | end | 198 | end |
213 | end | 199 | end |