Sha256: 3e8f7059e96cbb947e45b1d666b14e178efcfd84b7447e92b4d407e03862b6df

Contents?: true

Size: 1003 Bytes

Versions: 16

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe "Rabl Cache", type: :request, caching: true do
  let(:user) { create(:user, :admin) }

  before do
    create(:variant)
    expect(Spree::Product.count).to eq(1)
  end

  it "doesn't create a cache key collision for models with different rabl templates" do
    get "/api/variants", headers: user.create_new_auth_token
    expect(response.status).to eq(200)

    # Make sure we get a non master variant
    variant_a = JSON.parse(response.body)['variants'].find do |v|
      !v['is_master']
    end

    expect(variant_a['is_master']).to be false
    expect(variant_a['stock_items']).not_to be_nil

    get "/api/products/#{Spree::Product.first.id}", headers: user.create_new_auth_token
    expect(response.status).to eq(200)
    variant_b = JSON.parse(response.body)['variants'].last
    expect(variant_b['is_master']).to be false

    expect(variant_a['id']).to eq(variant_b['id'])
    expect(variant_b['stock_items']).to be_nil
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
solidus_api_devise_token_auth-2.8.0.alpha.14 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.13 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.12 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.11 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.10 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.9 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.8 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.7 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.6 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.5 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.4 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.3 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.2 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.1 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha.0 spec/requests/rabl_cache_spec.rb
solidus_api_devise_token_auth-2.8.0.alpha spec/requests/rabl_cache_spec.rb