mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
30 lines
923 B
Ruby
30 lines
923 B
Ruby
# frozen_string_literal: true
|
|
|
|
# test a single endpoint to make sure the redirects are working as intended.
|
|
require 'spec_helper'
|
|
|
|
RSpec.describe 'Orders Cycles endpoint' do
|
|
let(:distributor) { create(:distributor_enterprise) }
|
|
let(:order_cycle) { create(:order_cycle, distributors: [distributor]) }
|
|
|
|
context "requesting the latest version" do
|
|
let(:path) { "/api/order_cycles/#{order_cycle.id}/products?distributor=#{distributor.id}" }
|
|
|
|
it "redirects to v0, preserving URL params" do
|
|
get path
|
|
expect(response).to redirect_to(
|
|
"/api/v0/order_cycles/#{order_cycle.id}/products?distributor=#{distributor.id}"
|
|
)
|
|
end
|
|
end
|
|
|
|
context "requesting a specific API version" do
|
|
let(:path) { "/api/v0/order_cycles/#{order_cycle.id}/products?distributor=#{distributor.id}" }
|
|
|
|
it "does not redirect" do
|
|
get path
|
|
expect(response).to have_http_status(:ok)
|
|
end
|
|
end
|
|
end
|