err_merchant 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,5 +1,5 @@
1
1
  = err_merchant
2
- This is a very simple Rails Engine for replacing the standard (ugly) Rails exception pages, with pages which are rendered in your layout. There are several gems out there that do the same, but this one takes the approach proposed by AccUser[http://accuser.cc/posts/1-rails-3-0-exception-handling]. I just made a gem out of it because I use it in every project.
2
+ This is a very simple Rails Engine for replacing the standard (ugly) Rails exception pages with pages which are rendered in your layout. There are several gems out there that do the same, but this one takes the approach proposed by AccUser[http://accuser.cc/posts/1-rails-3-0-exception-handling]. I just made a gem out of it because I use it in every project. This solution works seamlessly with Airbrake[http://airbrake.io/].
3
3
 
4
4
  == Installation
5
5
  Add the gem to your Gemfile, run `bundle install` and restart your server:
@@ -8,6 +8,12 @@ Add the gem to your Gemfile, run `bundle install` and restart your server:
8
8
 
9
9
  This is it. If you want to check the error pages in development mode, make sure to set +config.consider_all_requests_local+ to +false+ and restart your development server.
10
10
 
11
+ === Should I keep the standard Rails error pages around?
12
+ Yes, these files are used as a fallback if +err_merchant+ itself raises an exception. This can happen if there is an error in your application layout.
13
+
14
+ == Configuration
15
+ * +ErrMerchant.layout+: Can be used to set the layout for the error pages. By default the application-layout is used.
16
+
11
17
  == I18n
12
18
  You can translate the error messages, by default they are the same as the standard Rails errors:
13
19
 
@@ -22,9 +28,12 @@ You can translate the error messages, by default they are the same as the standa
22
28
  title: "We're sorry, but something went wrong."
23
29
  description: "We've been notified about this issue and we'll take a look at it shortly."
24
30
 
25
- Please note that there are translations missing in development mode if you don't supply translations for your locale. In production however, +config.i18n.fallbacks+ is usually set to +true+, so the english error message will be shown if the lookup is unsuccessful.
31
+ Please note that there are translations missing in development mode if you don't supply translations for your locale. In production however, +config.i18n.fallbacks+ is usually set to +true+, so the error messages for the default locale will be shown if the lookup is not successful.
26
32
 
27
33
  == Changelog
34
+ === 0.1.2
35
+ * added configuration option for layout
36
+
28
37
  === 0.1.1
29
38
  * fix gemspec
30
39
  * add test for fallback to standard rails error pages
@@ -13,7 +13,7 @@ class ErrMerchant::ErrorsController < ApplicationController
13
13
  ERRORS.each do |e, status_code|
14
14
  define_method e do
15
15
  respond_to do |format|
16
- format.html { render 'template', :locals => {:status_code => status_code}, :status => e }
16
+ format.html { render 'template', :locals => {:status_code => status_code}, :layout => ErrMerchant.layout, :status => e }
17
17
  format.any { head e }
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module ErrMerchant
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/err_merchant.rb CHANGED
@@ -1 +1,8 @@
1
+ require 'active_support/core_ext/module/attribute_accessors'
2
+
3
+ module ErrMerchant
4
+ mattr_accessor :layout
5
+ @@layout = 'application'
6
+ end
7
+
1
8
  require 'err_merchant/engine'
@@ -34,23 +34,33 @@ describe 'ErrMerchant' do
34
34
  page.should have_content("This is a usual action.")
35
35
  page.status_code.should == 200
36
36
  end
37
+
38
+ it 'shows translated error messages if available' do
39
+ I18n.locale = :de
40
+ visit '/failures/where_is_it'
41
+
42
+ page.should have_content("Seite nicht gefunden")
43
+ end
37
44
 
38
45
  it 'shows english error message when no translation available' do
39
- I18n.locale = :de
46
+ I18n.locale = :fr
40
47
  visit '/failures/wild_error'
41
48
 
42
49
  page.should have_content("We're sorry, but something went wrong.")
43
50
  end
44
51
 
45
52
  it 'falls back to standard error pages if everything goes wrong' do
46
- ErrMerchant::ErrorsController.class_eval do
47
- layout "erroneous"
48
- end
53
+ ErrMerchant.layout = "erroneous"
49
54
 
50
55
  visit '/failures/wild_error'
51
56
  page.should have_content("We're sorry, but something went wrong.")
52
57
  page.status_code.should == 500
58
+ page.should_not have_css('div.err_merchant')
53
59
  page.should have_css('div.dialog h1')
54
60
  end
55
61
 
62
+ it 'should deliver airbrake notifications' do
63
+ Airbrake.should_receive(:notify_or_ignore)
64
+ visit '/failures/wild_error'
65
+ end
56
66
  end
@@ -0,0 +1,4 @@
1
+ de:
2
+ err_merchant:
3
+ '404':
4
+ title: "Seite nicht gefunden"