Sha256: 7dcede53b82aa3c3893e1e7fa2473792a42f6506e0f58578f05ff484cbfb853b

Contents?: true

Size: 2 KB

Versions: 21

Compression:

Stored size: 2 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe "spree/admin/shared/_navigation_footer", type: :view, partial_double_verification: false do
  let(:user) { FactoryBot.build_stubbed(:admin_user) }
  let(:ability) { Object.new.extend(CanCan::Ability) }
  before do
    allow(view).to receive(:try_spree_current_user).and_return(user)
    allow(controller).to receive(:current_ability).and_return(ability)
  end

  it "has a a login-nav section" do
    render
    expect(rendered).to have_selector("#login-nav")
  end

  context "authorized user" do
    before do
      ability.can :admin, user
    end

    it "has a user-account-link that links to edit_admin_user_path" do
      render
      expect(rendered).to have_link(user.email, href: Spree::Core::Engine.routes.url_helpers.edit_admin_user_path(user))
    end

    it "has not a user-account-link that links to admin_path" do
      render
      expect(rendered).to_not have_link(user.email, href: Spree::Core::Engine.routes.url_helpers.admin_path)
    end
  end

  context "unauthorized user" do
    it "has a user-account-link that links to admin_path" do
      render
      expect(rendered).to_not have_link(user.email, href: Spree::Core::Engine.routes.url_helpers.admin_path)
    end

    it "has not a user-account-link that links to edit_admin_user_path" do
      render
      expect(rendered).to_not have_link(user.email, href: Spree::Core::Engine.routes.url_helpers.edit_admin_user_path(user))
    end
  end

  context "with a required spree_logout_path helper" do
    before do
      allow(view).to receive(:spree_logout_path).and_return("/logout")
    end

    it "has user-logout-link" do
      render
      expect(rendered).to have_link(I18n.t('spree.logout'), href: "/logout")
    end
  end

  context "with a spree.root_path" do
    before do
      allow(view.spree).to receive("root_path").and_return("/")
    end

    it "has a back to store link" do
      render
      expect(rendered).to have_link(I18n.t('spree.back_to_store'), href: "/")
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
solidus_backend-2.10.5 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.10.3 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.10.2 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.6 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.8.6 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.10.1 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.5 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.10.0 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.4 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.8.5 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.3 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.2 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.10.0.beta1 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.1 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.0 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.9.0.rc.1 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.8.4 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.8.3 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.8.2 spec/views/spree/admin/shared/navigation_footer_spec.rb
solidus_backend-2.8.1 spec/views/spree/admin/shared/navigation_footer_spec.rb