Commit c1c364f50eae009527969e35fe675dd6fa9ebab6

Authored by Nick Recobra
1 parent 697bee6a
Exists in master and in 1 other branch production

Ability to clear err issue link.

app/controllers/errs_controller.rb
... ... @@ -40,6 +40,11 @@ class ErrsController < ApplicationController
40 40 flash[:error] = "There was an error during issue creation. Check your tracker settings or try again later."
41 41 redirect_to app_err_path(@app, @err)
42 42 end
  43 +
  44 + def clear_issue
  45 + @err.update_attribute :issue_link, nil
  46 + redirect_to app_err_path(@app, @err)
  47 + end
43 48  
44 49 def resolve
45 50 # Deal with bug in mogoid where find is returning an Enumberable obj
... ...
app/views/errs/show.html.haml
... ... @@ -10,12 +10,13 @@
10 10 %strong Last Notice:
11 11 = last_notice_at(@err).to_s(:micro)
12 12 - content_for :action_bar do
  13 + - if @err.app.issue_tracker
  14 + - if @err.issue_link.blank?
  15 + %span= link_to 'create issue', create_issue_app_err_path(@app, @err), :method => :post, :class => 'create-issue'
  16 + - else
  17 + %span= link_to 'go to issue', @err.issue_link, :class => 'goto-issue'
  18 + = link_to 'clear issue', clear_issue_app_err_path(@app, @err), :method => :delete, :confirm => "Clear err issues?", :class => 'clear-issue'
13 19 - if @err.unresolved?
14   - - if @err.app.issue_tracker
15   - - if @err.issue_link.blank?
16   - %span= link_to 'create issue', create_issue_app_err_path(@app, @err), :method => :post, :class => 'create-issue'
17   - - else
18   - %span= link_to 'go to issue', @err.issue_link, :class => 'goto-issue'
19 20 %span= link_to 'resolve', resolve_app_err_path(@app, @err), :method => :put, :confirm => err_confirm, :class => 'resolve'
20 21  
21 22 %h4= @notice.try(:message)
... ...
config/routes.rb
... ... @@ -21,6 +21,7 @@ Errbit::Application.routes.draw do
21 21 member do
22 22 put :resolve
23 23 post :create_issue
  24 + delete :clear_issue
24 25 end
25 26 end
26 27  
... ...
spec/controllers/errs_controller_spec.rb
... ... @@ -292,4 +292,40 @@ describe ErrsController do
292 292 end
293 293 end
294 294 end
  295 +
  296 + describe "DELETE /apps/:app_id/errs/:id/clear_issue" do
  297 + before(:each) do
  298 + sign_in Factory(:admin)
  299 + end
  300 +
  301 + context "err with issue" do
  302 + let(:err) { Factory :err, :issue_link => "http://some.host" }
  303 +
  304 + before(:each) do
  305 + delete :clear_issue, :app_id => err.app.id, :id => err.id
  306 + err.reload
  307 + end
  308 +
  309 + it "should redirect to err page" do
  310 + response.should redirect_to( app_err_path(err.app, err) )
  311 + end
  312 +
  313 + it "should clear issue link" do
  314 + err.issue_link.should be_nil
  315 + end
  316 + end
  317 +
  318 + context "err without issue" do
  319 + let(:err) { Factory :err }
  320 +
  321 + before(:each) do
  322 + delete :clear_issue, :app_id => err.app.id, :id => err.id
  323 + err.reload
  324 + end
  325 +
  326 + it "should redirect to err page" do
  327 + response.should redirect_to( app_err_path(err.app, err) )
  328 + end
  329 + end
  330 + end
295 331 end
... ...