Sha256: c0a979fc07c01382b4800abd9ae79cf868de03bb0520339e12e2d83da4f20f1b

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'

module Components

  class ModuleSidebarTest < ActiveSupport::TestCase
   
    class MenuItem
      attr_accessor :title, :path, :items

      def initialize(title, path, items)
        @title = title
        @path = path
        @items = items
      end
    end

    def rendered_module_sidebar
      arbre {
        module_sidebar
      }
    end

    def assigns
      { current_menu: current_menu, 
        current_menu_name: current_menu_name,
        foo_path: 'foo',
        bar_path: 'bar',
        baz_path: 'baz'
      }
    end

    def current_menu
      MenuItem.new('Big Menu', 'menu_path', [
                      MenuItem.new('Foo', 'foo_path',[]),
                      MenuItem.new('Bar', 'bar_path', []),
                      MenuItem.new('Baz', 'baz_path', [])])
    end

    def current_menu_name
      current_menu.title
    end

    def helpers
      mock_action_view(assigns)
    end

    test "renders the correct current menu name as sidebar title" do
      assert_match /class="title">Big Menu/, rendered_module_sidebar
    end

    test "evals the correct path" do
      assert_equal "foo", helpers.instance_eval(current_menu.items.first.path)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
express_admin-1.4.8 test/dummy/test/components/module_sidebar_test.rb
express_admin-1.4.7 test/dummy/test/components/module_sidebar_test.rb
express_admin-1.4.6 test/dummy/test/components/module_sidebar_test.rb
express_admin-1.4.5 test/dummy/test/components/module_sidebar_test.rb