Skip to content

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Feb 28, 2025
1 parent 9a62410 commit dba5c07
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/controllers/reservations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,38 @@
expect(assigns[:instrument]).to eq(instrument)
end

context "when discriminate=true" do
before do
@params[:discriminate] = true
end

it "does not allow non admin user" do
sign_in create(:user)

expect(CalendarEventsPresenter).to receive(:new).with(
anything,
anything,
anything,
a_hash_including(discriminate: false)
)

do_request
end

it "allow admin user" do
sign_in create(:user, :administrator)

expect(CalendarEventsPresenter).to receive(:new).with(
anything,
anything,
anything,
a_hash_including(discriminate: true)
)

do_request
end
end

describe "start/stop parameters" do
let(:start_range) { Time.zone.local(2018, 5, 15, 12, 13) }
let(:end_range) { start_range + 1.week }
Expand Down
57 changes: 57 additions & 0 deletions spec/system/admin/instrument_reservations_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "instrument reservations" do
describe "shared schedule", :js do
let(:admin) { create(:user, :administrator) }
let!(:instrument) { create(:setup_instrument, :always_available) }
let!(:instrument2) do
create(
:setup_instrument,
:always_available,
facility:,
schedule: instrument.schedule
)
end
let(:facility) { instrument.facility }
let!(:reservation2) do
end

before do
# Use actual current time so
# loaded reservations are correct
travel_back

login_as admin
create(
:purchased_reservation,
reserve_start_at: 1.hour.from_now,
reserve_end_at: 2.hours.from_now,
product: instrument
)
end

it "show current instrument reservation with default color" do
visit facility_instrument_schedule_path(facility, instrument)

expect(page).to have_css(".fc-event")
expect(page).not_to have_css(".fc-event.other-instrument")
end

it "shows other instrument reservations with different color", :js do
create(
:purchased_reservation,
reserve_start_at: Time.zone.now,
reserve_end_at: 1.hour.from_now,
product: instrument2
)

visit facility_instrument_schedule_path(facility, instrument)

save_and_open_screenshot

expect(page).to have_css(".fc-event.other-instrument")
end
end
end

0 comments on commit dba5c07

Please sign in to comment.