require 'rails_helper'

RSpec.describe "settings/menu_items/index", type: :view do
  before(:each) do
    assign(:settings_menu_items, [
      Settings::MenuItem.create!(
        :item_code => "Item Code",
        :name => "Name",
        :alt_name => "Alt Name",
        :type => "Type",
        :menu_category => nil,
        :menu_item => nil,
        :min_qty => 2,
        :min_selectable_item => 3,
        :max_selectable_item => 4,
        :created_by => "Created By"
      ),
      Settings::MenuItem.create!(
        :item_code => "Item Code",
        :name => "Name",
        :alt_name => "Alt Name",
        :type => "Type",
        :menu_category => nil,
        :menu_item => nil,
        :min_qty => 2,
        :min_selectable_item => 3,
        :max_selectable_item => 4,
        :created_by => "Created By"
      )
    ])
  end

  it "renders a list of settings/menu_items" do
    render
    assert_select "tr>td", :text => "Item Code".to_s, :count => 2
    assert_select "tr>td", :text => "Name".to_s, :count => 2
    assert_select "tr>td", :text => "Alt Name".to_s, :count => 2
    assert_select "tr>td", :text => "Type".to_s, :count => 2
    assert_select "tr>td", :text => nil.to_s, :count => 2
    assert_select "tr>td", :text => nil.to_s, :count => 2
    assert_select "tr>td", :text => 2.to_s, :count => 2
    assert_select "tr>td", :text => 3.to_s, :count => 2
    assert_select "tr>td", :text => 4.to_s, :count => 2
    assert_select "tr>td", :text => "Created By".to_s, :count => 2
  end
end
