From f480997754705f9dc820a0034e6907cc4f065036 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 11 Jan 2024 12:06:07 +1100 Subject: [PATCH] Spec admin enterprise menu helper There was no spec despite lots of logic. And I want to add more logic. --- spec/helpers/admin/enterprises_helper_spec.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/helpers/admin/enterprises_helper_spec.rb diff --git a/spec/helpers/admin/enterprises_helper_spec.rb b/spec/helpers/admin/enterprises_helper_spec.rb new file mode 100644 index 0000000000..400822ee19 --- /dev/null +++ b/spec/helpers/admin/enterprises_helper_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe Admin::EnterprisesHelper, type: :helper do + let(:user) { build(:user) } + + before do + # Enable helper to use `#can?` method. + # We could extract this when other helper specs need it. + allow_any_instance_of(CanCan::ControllerAdditions).to receive(:current_ability) do + Spree::Ability.new(user) + end + allow(helper).to receive(:spree_current_user) { user } + end + + describe "#enterprise_side_menu_items" do + let(:enterprise) { build(:enterprise) } + let(:menu_items) { helper.enterprise_side_menu_items(enterprise) } + let(:visible_items) { menu_items.select { |i| i[:show] } } + + it "lists default items" do + expect(visible_items.pluck(:name)).to eq %w[ + primary_details address contact social about business_details images + vouchers enterprise_permissions inventory_settings tag_rules + shop_preferences users white_label + ] + end + + it "lists enabled features", feature: :connected_apps do + expect(visible_items.pluck(:name)).to include "connected_apps" + end + end +end