Skip to content

Commit

Permalink
test(bookings): returns query for current user when no user or zone i…
Browse files Browse the repository at this point in the history
…s specified (#144)
  • Loading branch information
chillfox authored Jan 18, 2022
1 parent 51607d3 commit b4a584c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/controllers/bookings_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ describe Bookings do
booking_user_ids = body.map { |r| r["user_id"] }
booking_user_ids.should eq(["[email protected]"])
end

it "should return a list of bookings filtered current user when no zones or user is specified" do
tenant = Tenant.query.find! { domain == "toby.staff-api.dev" }
BookingsHelper.create_booking(tenant_id: tenant.id, user_id: "[email protected]")
BookingsHelper.create_booking(tenant.id)

starting = 5.minutes.from_now.to_unix
ending = 40.minutes.from_now.to_unix
# Since we are using Toby's token to login, user=current means Toby
route = "#{BOOKINGS_BASE}?period_start=#{starting}&period_end=#{ending}&type=desk"
body = Context(Bookings, JSON::Any).response("GET", route, headers: Mock::Headers.office365_guest, &.index)[1].as_a
booking_user_ids = body.map { |r| r["user_id"] }
booking_user_ids.should eq(["[email protected]"])
end
end

it "#show should find booking" do
Expand Down

0 comments on commit b4a584c

Please sign in to comment.