Commit e7bd852175c72fe9069b6d1f90e9af3492e18139
1 parent
11173e81
Exists in
master
and in
1 other branch
Add configuration option to suppress confirmation when resolving errors.
Showing
3 changed files
with
45 additions
and
2 deletions
Show diff stats
app/views/errs/show.html.haml
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | %strong Last Notice: | 8 | %strong Last Notice: |
9 | = last_notice_at(@err).to_s(:micro) | 9 | = last_notice_at(@err).to_s(:micro) |
10 | - content_for :action_bar do | 10 | - content_for :action_bar do |
11 | - %span= link_to 'resolve', resolve_app_err_path(@app, @err), :method => :put, :confirm => 'Seriously?', :class => 'resolve' if @err.unresolved? | 11 | + %span= link_to 'resolve', resolve_app_err_path(@app, @err), :method => :put, :confirm => (Errbit::Config.confirm_resolve_err === false ? nil : 'Seriously?'), :class => 'resolve' if @err.unresolved? |
12 | 12 | ||
13 | %h4= @notice.try(:message) | 13 | %h4= @notice.try(:message) |
14 | 14 |
config/config.example.yml
@@ -17,4 +17,8 @@ email_from: errbit@example.com | @@ -17,4 +17,8 @@ email_from: errbit@example.com | ||
17 | # Configure when emails are sent for an error. | 17 | # Configure when emails are sent for an error. |
18 | # [1,3,7] = 1st, 3rd, and 7th occurence triggers | 18 | # [1,3,7] = 1st, 3rd, and 7th occurence triggers |
19 | # an email notification. | 19 | # an email notification. |
20 | -email_at_notices: [1, 10, 100] | ||
21 | \ No newline at end of file | 20 | \ No newline at end of file |
21 | +email_at_notices: [1, 10, 100] | ||
22 | + | ||
23 | +# Set to false to suppress confirmation when | ||
24 | +# resolving errors. | ||
25 | +confirm_resolve_err: true |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe "errs/show.html.erb" do | ||
4 | + before do | ||
5 | + err = Factory(:err) | ||
6 | + assign :err, err | ||
7 | + assign :app, err.app | ||
8 | + assign :notices, err.notices.ordered.paginate(:page => 1, :per_page => 1) | ||
9 | + assign :notice, err.notices.first | ||
10 | + end | ||
11 | + | ||
12 | + describe "content_for :action_bar" do | ||
13 | + | ||
14 | + it "should confirm the 'resolve' link by default" do | ||
15 | + render | ||
16 | + action_bar = String.new(view.instance_variable_get(:@_content_for)[:action_bar]) | ||
17 | + resolve_link = action_bar.match(/(<a href.*?(class="resolve").*?>)/)[0] | ||
18 | + resolve_link.should =~ /data-confirm="Seriously\?"/ | ||
19 | + end | ||
20 | + | ||
21 | + it "should confirm the 'resolve' link if configuration is unset" do | ||
22 | + Errbit::Config.stub(:confirm_resolve_err).and_return(nil) | ||
23 | + render | ||
24 | + action_bar = String.new(view.instance_variable_get(:@_content_for)[:action_bar]) | ||
25 | + resolve_link = action_bar.match(/(<a href.*?(class="resolve").*?>)/)[0] | ||
26 | + resolve_link.should =~ /data-confirm="Seriously\?"/ | ||
27 | + end | ||
28 | + | ||
29 | + it "should not confirm the 'resolve' link if configured not to" do | ||
30 | + Errbit::Config.stub(:confirm_resolve_err).and_return(false) | ||
31 | + render | ||
32 | + action_bar = String.new(view.instance_variable_get(:@_content_for)[:action_bar]) | ||
33 | + resolve_link = action_bar.match(/(<a href.*?(class="resolve").*?>)/)[0] | ||
34 | + resolve_link.should_not =~ /data-confirm=/ | ||
35 | + end | ||
36 | + | ||
37 | + end | ||
38 | + | ||
39 | +end |