• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sleede / fab-manager / #106

pending completion
#106

push

coveralls-ruby

sylvainbx
Merge branch 'dev' for release 6.0.0

704 of 704 new or added lines in 168 files covered. (100.0%)

7919 of 13474 relevant lines covered (58.77%)

15.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/controllers/api/reservations_controller.rb
1
# frozen_string_literal: true
2

3
# API Controller for resources of type Reservation
4
# Reservations are used for Training, Machine, Space and Event
5
class API::ReservationsController < API::APIController
×
6
  before_action :authenticate_user!
×
7
  before_action :set_reservation, only: %i[show update]
×
8
  respond_to :json
×
9

10
  def index
×
11
    if params[:user_id]
×
12
      params[:user_id] = current_user.id unless current_user.admin? || current_user.manager?
×
13

14
      where_clause = { statistic_profile_id: StatisticProfile.find_by!(user_id: params[:user_id]) }
×
15
      where_clause[:reservable_type] = params[:reservable_type] if params[:reservable_type]
×
16
      where_clause[:reservable_id] = params[:reservable_id] if params[:reservable_id]
×
17

18
      @reservations = Reservation.where(where_clause)
×
19
    elsif params[:reservable_id] && params[:reservable_type] && (current_user.admin? || current_user.manager?)
×
20
      @reservations = Reservation.where(params.permit(:reservable_id, :reservable_type))
×
21
    else
×
22
      @reservations = []
×
23
    end
×
24
  end
×
25

26
  def show; end
×
27

28
  def update
×
29
    authorize @reservation
×
30
    if @reservation.update(reservation_params)
×
31
      render :show, status: :ok, location: @reservation
×
32
    else
×
33
      render json: @reservation.errors, status: :unprocessable_entity
×
34
    end
×
35
  end
×
36

37
  private
×
38

39
  def set_reservation
×
40
    @reservation = Reservation.find(params[:id])
×
41
  end
×
42

43
  def reservation_params
×
44
    params.require(:reservation).permit(:message, :reservable_id, :reservable_type, :nb_reserve_places,
×
45
                                        tickets_attributes: %i[event_price_category_id booked],
×
46
                                        slots_reservations_attributes: %i[id slot_id offered])
×
47
  end
×
48
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc