Move search params test case to a different context so that we dont have to set the producer of the products in the order

This is working in master by chance of the factories but breaks in rails 4 because the orders in this test dont have products supplied by the producer which is a necessary condition in the context where it was
This commit is contained in:
Luis Ramos
2020-04-03 19:47:33 +01:00
parent e64d573337
commit 55b3f4d54f

View File

@@ -47,6 +47,18 @@ module Permissions
it "should let me see the order" do
expect(permissions.visible_orders).to include order
end
context "with search params" do
let(:search_params) { { completed_at_gt: Time.zone.now.yesterday.strftime('%Y-%m-%d') } }
let(:permissions) { Permissions::Order.new(user, search_params) }
it "only returns completed, non-cancelled orders within search filter range" do
expect(permissions.visible_orders).to include order_completed
expect(permissions.visible_orders).to_not include order_cancelled
expect(permissions.visible_orders).to_not include order_cart
expect(permissions.visible_orders).to_not include order_from_last_year
end
end
end
context "as a producer which has granted P-OC to the distributor of an order" do
@@ -71,18 +83,6 @@ module Permissions
expect(permissions.visible_orders).to_not include order
end
end
context "with search params" do
let(:search_params) { { completed_at_gt: Time.zone.now.yesterday.strftime('%Y-%m-%d') } }
let(:permissions) { Permissions::Order.new(user, search_params) }
it "only returns completed, non-cancelled orders within search filter range" do
expect(permissions.visible_orders).to include order_completed
expect(permissions.visible_orders).to_not include order_cancelled
expect(permissions.visible_orders).to_not include order_cart
expect(permissions.visible_orders).to_not include order_from_last_year
end
end
end
context "as an enterprise that is a distributor in the order cycle, but not the distributor of the order" do