Sha256: 00c0eb84221f4a20d9adf02f2579cba3f29c89e1cb939aa0c370aaf4d72e162b

Contents?: true

Size: 1.24 KB

Versions: 59

Compression:

Stored size: 1.24 KB

Contents

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

59 entries across 59 versions & 1 rubygems

Version Path
solidus_backend-2.5.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.5.1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.5.0 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.5.0.rc1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.5.0.beta2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.5.0.beta1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.4.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.4.1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.3.1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.2.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.1.1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.0.3 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-1.4.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-1.3.2 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-1.2.3 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-1.1.4 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-1.0.7 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.4.0 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.4.0.rc1 spec/controllers/spree/admin/root_controller_spec.rb
solidus_backend-2.4.0.beta1 spec/controllers/spree/admin/root_controller_spec.rb