Sha256: 5d6383b46ef9e4c3055b76654e7552d026f7b75ee4c7bdfa861f159202ceb263

Contents?: true

Size: 1013 Bytes

Versions: 6

Compression:

Stored size: 1013 Bytes

Contents

RSpec.describe Spree::ProductsController, type: :controller do

  let!(:product) { create(:product, available_on: 1.year.from_now) }
  let!(:user)    { build(:user) }

  it 'allows admins to view non-active products' do
    allow(controller).to receive(:before_save_new_order)
    allow(controller).to receive(:spree_current_user) { user }
    allow(user).to receive(:has_spree_role?) { true }
    get :show, params: { id: product.to_param }
    expect(response.status).to eq(200)
  end

  it 'cannot view non-active products' do
    allow(controller).to receive(:before_save_new_order)
    allow(controller).to receive(:spree_current_user) { user }
    allow(user).to receive(:has_spree_role?) { false }
    if SolidusSupport.solidus_gem_version < Gem::Version.new('2.5.x')
      get :show, params: { id: product.to_param }
      expect(response.status).to eq(404)
    else
      expect {
        get :show, params: { id: product.to_param }
      }.to raise_error(ActiveRecord::RecordNotFound)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_auth_devise_devise_token_auth-2.1.0.5 spec/controllers/spree/products_controller_spec.rb
solidus_auth_devise_devise_token_auth-2.1.0.4 spec/controllers/spree/products_controller_spec.rb
solidus_auth_devise_devise_token_auth-2.1.0.3 spec/controllers/spree/products_controller_spec.rb
solidus_auth_devise_devise_token_auth-2.1.0.2 spec/controllers/spree/products_controller_spec.rb
solidus_auth_devise_devise_token_auth-2.1.0.1 spec/controllers/spree/products_controller_spec.rb
solidus_auth_devise_devise_token_auth-2.1.0 spec/controllers/spree/products_controller_spec.rb