Sha256: cae4744e9b85276f5072c8e6be1beb6642042037ff11fb76d95b97cc1da536d2

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe Spree::Api::ProductsController do

  let!(:product) { FactoryGirl.create(:product) }

  let(:user)  { create(:user) }
  before { allow(controller).to receive(:current_spree_user) { user } }

  describe 'on :show to a product without any stores' do
    let!(:store) { FactoryGirl.create(:store) }

    it 'should return 404' do
      spree_get :show, :id => product.to_param, format: :json

      expect(response.response_code) == 404
    end
  end

  # Regression test for #75
  describe 'on :show to a product in the wrong store' do
    let!(:store_1) { FactoryGirl.create(:store) }
    let!(:store_2) { FactoryGirl.create(:store) }

    before(:each) do
      product.stores << store_1
    end

    it 'should return 404' do
      allow(controller).to receive_messages(:current_store => store_2)
      spree_get :show, :id => product.to_param, format: :json

      expect(response.response_code) == 404
    end
  end

  describe 'on :show to a product w/ store' do
    let!(:store) { FactoryGirl.create(:store) }

    before(:each) do
      product.stores << store
    end

    it 'should return 200' do
      allow(controller).to receive_messages(:current_store => store)
      spree_get :show, :id => product.to_param, format: :json

      expect(response.response_code) == 200
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solidus_multi_domain-1.5.0 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.4.3 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.4.2 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.4.1 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.4.0 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.3.0 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.2.0 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.1.3 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.1.2 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.1.1 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.0.3 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.1.0 spec/controllers/spree/api/products_controller_spec.rb
solidus_multi_domain-1.0.1 spec/controllers/spree/api/products_controller_spec.rb