layout_helper_test.rb 1.23 KB
require_relative "../test_helper"

class LayoutHelperTest < ActionView::TestCase
  include ApplicationHelper

  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

  should 'add global.css to noosfero_stylesheets if env theme has it' do
    env = fast_create Environment
    env.theme = 'my-theme'
    @plugins = []
    expects(:profile).returns(nil).at_least_once
    expects(:environment).returns(env).at_least_once
    expects(:theme_option).with(:icon_theme).returns(['my-icons']).at_least_once
    expects(:jquery_theme).returns('jquery-nice').at_least_once
    global_css = Rails.root.join "public/designs/themes/#{env.theme}/global.css"
    File.stubs(:exists?).returns(false)
    File.expects(:exists?).with(global_css).returns(true).at_least_once
    css = noosfero_stylesheets
    assert_match /<link [^<]*href="\/designs\/themes\/my-theme\/global.css"/, css
  end

end