diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index e2db756..0eb9f60 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -2,6 +2,7 @@ module LayoutHelper def body_classes # Identify the current controller and action for the CSS: + (logged_in? ? " logged-in" : "") + " controller-#{controller.controller_name}" + " action-#{controller.controller_name}-#{controller.action_name}" + " template-#{@layout_template || if profile.blank? then 'default' else profile.layout_template end}" + diff --git a/test/unit/layout_helper_test.rb b/test/unit/layout_helper_test.rb new file mode 100644 index 0000000..4eedc67 --- /dev/null +++ b/test/unit/layout_helper_test.rb @@ -0,0 +1,17 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class LayoutHelperTest < ActionView::TestCase + + should 'append logged-in class in body when user is logged-in' do + expects(:logged_in?).returns(true) + expects(:profile).returns(nil).at_least_once + assert_includes body_classes.split, 'logged-in' + end + + should 'not append logged-in class when user is not logged-in' do + expects(:logged_in?).returns(false) + expects(:profile).returns(nil).at_least_once + assert_not_includes body_classes.split, 'logged-in' + end + +end -- libgit2 0.21.2