Commit 05e56cd31341a2c42a4d1fda2cd1a4f2c94c5f1a

Authored by Victor Costa
1 parent a7ef8536

Append logged-in class in body when user is logged in

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}" +
... ...
test/unit/layout_helper_test.rb 0 → 100644
... ... @@ -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
... ...