File tree Expand file tree Collapse file tree 5 files changed +25
-20
lines changed Expand file tree Collapse file tree 5 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def show_error_messages!(resource)
41
41
messages = resource . errors .
42
42
full_messages . map { |msg | content_tag ( :li , msg ) } . join
43
43
html = <<-HTML
44
- < div class ="alert alert-error alert-block ">
44
+ < div class ="alert alert-danger ">
45
45
< button type ="button " class ="close " data-dismiss ="alert "> x</ button >
46
46
< ul >
47
47
#{ messages }
@@ -83,4 +83,15 @@ def get_body_css_class(controller)
83
83
84
84
"#{ classes [ controller ] } "
85
85
end
86
+
87
+ def alert_class ( alert )
88
+ case alert
89
+ when 'error' , 'alert'
90
+ 'alert-danger'
91
+ when 'notice'
92
+ 'alert-success'
93
+ else
94
+ 'alert-info'
95
+ end
96
+ end
86
97
end
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
4
4
<div class ="alert <%= alert_class ( key ) %> ">
5
5
< button type ="button " class ="close " data-dismiss ="alert "> x</ button >
6
- < ul >
7
- < li >
8
- <%= value %>
9
- </ li >
10
- </ ul >
6
+ < ul >
7
+ < li >
8
+ <%= value %>
9
+ </ li >
10
+ </ ul >
11
11
</ div >
12
12
<% end %>
Original file line number Diff line number Diff line change 66
66
config . error_notification_tag = :div
67
67
68
68
# CSS class to add for error notification helper.
69
- config . error_notification_class = 'alert alert-error '
69
+ config . error_notification_class = 'alert alert-danger '
70
70
71
71
# ID to add for error notification helper.
72
72
# config.error_notification_id = nil
Original file line number Diff line number Diff line change 19
19
expect ( helper . seconds_to_hm ( 3600 ) ) . to eq ( "1:00" )
20
20
end
21
21
end
22
+
23
+ it 'alert_class returns specific error classes' do
24
+ expect ( helper . alert_class ( 'error' ) ) . to eq ( 'alert-danger' )
25
+ expect ( helper . alert_class ( 'alert' ) ) . to eq ( 'alert-danger' )
26
+ expect ( helper . alert_class ( 'notice' ) ) . to eq ( 'alert-success' )
27
+ expect ( helper . alert_class ( 'foo' ) ) . to eq ( 'alert-info' )
28
+ end
22
29
end
You can’t perform that action at this time.
0 commit comments