Sha256: 442b90dffc1d090dda083cd6f59ab93bfc1c2ed01a3cdf5afe004ecea31ac2b2

Contents?: true

Size: 953 Bytes

Versions: 13

Compression:

Stored size: 953 Bytes

Contents

require 'spec_helper'

describe "Rabl Cache", :caching => true do
  let!(:user)  { create(:admin_user) }

  before do
    create(:variant) 
    user.generate_spree_api_key!
    Spree::Product.count.should == 1
  end
  
  it "doesn't create a cache key collision for models with different rabl templates" do
    get "/api/variants", :token => user.spree_api_key
    response.status.should == 200

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

    variant_a['is_master'].should be false
    variant_a['stock_items'].should_not be_nil

    get "/api/products/#{Spree::Product.first.id}", :token => user.spree_api_key
    response.status.should == 200
    variant_b = JSON.parse(response.body)['variants'].last
    variant_b['is_master'].should be false

    variant_a['id'].should == variant_b['id']
    variant_b['stock_items'].should be_nil
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spree_api-2.2.14 spec/requests/rabl_cache_spec.rb
spree_api-2.2.13 spec/requests/rabl_cache_spec.rb
spree_api-2.2.12 spec/requests/rabl_cache_spec.rb
spree_api-2.2.11 spec/requests/rabl_cache_spec.rb
spree_api-2.2.10 spec/requests/rabl_cache_spec.rb
spree_api-2.2.9 spec/requests/rabl_cache_spec.rb
spree_api-2.2.8 spec/requests/rabl_cache_spec.rb
spree_api-2.2.7 spec/requests/rabl_cache_spec.rb
spree_api-2.4.0.rc2 spec/requests/rabl_cache_spec.rb
spree_api-2.4.0.rc1 spec/requests/rabl_cache_spec.rb
spree_api-2.3.4 spec/requests/rabl_cache_spec.rb
spree_api-2.2.6 spec/requests/rabl_cache_spec.rb
spree_api-2.3.3 spec/requests/rabl_cache_spec.rb