Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(bookings): returns query for current user when no user or zone is specified #144

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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