Commit 05e56cd31341a2c42a4d1fda2cd1a4f2c94c5f1a
1 parent
a7ef8536
Exists in
master
and in
29 other branches
Append logged-in class in body when user is logged in
Showing
2 changed files
with
18 additions
and
0 deletions
Show diff stats
app/helpers/layout_helper.rb
... | ... | @@ -2,6 +2,7 @@ module LayoutHelper |
2 | 2 | |
3 | 3 | def body_classes |
4 | 4 | # Identify the current controller and action for the CSS: |
5 | + (logged_in? ? " logged-in" : "") + | |
5 | 6 | " controller-#{controller.controller_name}" + |
6 | 7 | " action-#{controller.controller_name}-#{controller.action_name}" + |
7 | 8 | " template-#{@layout_template || if profile.blank? then 'default' else profile.layout_template end}" + | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | + | |
3 | +class LayoutHelperTest < ActionView::TestCase | |
4 | + | |
5 | + should 'append logged-in class in body when user is logged-in' do | |
6 | + expects(:logged_in?).returns(true) | |
7 | + expects(:profile).returns(nil).at_least_once | |
8 | + assert_includes body_classes.split, 'logged-in' | |
9 | + end | |
10 | + | |
11 | + should 'not append logged-in class when user is not logged-in' do | |
12 | + expects(:logged_in?).returns(false) | |
13 | + expects(:profile).returns(nil).at_least_once | |
14 | + assert_not_includes body_classes.split, 'logged-in' | |
15 | + end | |
16 | + | |
17 | +end | ... | ... |