Sha256: 65540c83e0217d00e54571911c7b1317a2e7acd50259f7d286b7a7ab005d7c66

Contents?: true

Size: 1.27 KB

Versions: 47

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Spree::Admin::RootController do
  describe "GET index" do
    subject { get :index }

    let(:user) { build(:user) }
    let(:ability) { Spree::Ability.new(user) }

    before do
      allow_any_instance_of(Spree::Admin::RootController).to receive(:try_spree_current_user).and_return(user)
      allow_any_instance_of(Spree::Admin::RootController).to receive(:current_ability).and_return(ability)
    end

    context "when a user can admin and display spree orders" do
      before do
        ability.can :admin, Spree::Order
        ability.can :display, Spree::Order
      end

      it { is_expected.to redirect_to(spree.admin_orders_path) }
    end

    context "when a user cannot admin and display spree orders" do
      context "when a user can admin and home dashboards" do
        before do
          ability.can :admin, :dashboards
          ability.can :home, :dashboards
        end

        it { is_expected.to redirect_to(spree.home_admin_dashboards_path) }
      end

      context "when a user cannot admin and home dashboards" do
        # The default exception handler redirects to /unauthorized.
        # Extensions may change this.
        it { is_expected.to redirect_to('/unauthorized') }
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
solidus_backend-2.10.5 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.10.3 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.10.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.6 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.8.6 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.10.1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.5 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.10.0 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.4 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.6.6 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.7.4 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.8.5 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.3 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.10.0.beta1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.7.3 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.6.5 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.0 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.9.0.rc.1 spec/controllers/spree/admin/root_controller_spec.rb