Skip to content

Commit

Permalink
Merge pull request #5151 from luisramos0/fix_order_perms
Browse files Browse the repository at this point in the history
Fix Permissions::Order spec in rails 4
  • Loading branch information
sauloperez committed Apr 6, 2020
2 parents ce45e7c + 55b3f4d commit 924e816
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/services/permissions/order_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 924e816

Please sign in to comment.