Sha256: efded0063dc617109b7b47565a15c7af211df724e95c5d2c3040deaf5e20ea8c
Contents?: true
Size: 1.02 KB
Versions: 13
Compression:
Stored size: 1.02 KB
Contents
require 'spec_helper' module Spree describe Api::ClassificationsController, :type => :controller do let(:taxon) do taxon = create(:taxon) 3.times do product = create(:product) product.taxons << taxon end taxon end before do stub_authentication! end context "as a user" do it "cannot change the order of a product" do api_put :update, :taxon_id => taxon, :product_id => taxon.products.first, :position => 1 expect(response.status).to eq(401) end end context "as an admin" do sign_in_as_admin! it "can change the order a product" do last_product = taxon.products.last classification = taxon.classifications.find_by(:product_id => last_product.id) expect(classification.position).to eq(3) api_put :update, :taxon_id => taxon, :product_id => last_product, :position => 0 expect(response.status).to eq(200) expect(classification.reload.position).to eq(1) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems