Skip to content

Commit

Permalink
Add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
simfeld committed Apr 12, 2024
1 parent 8fa79ff commit 0a0c6d9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/resources/event/read_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

# Copyright (c) 2024, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_pbs.

require 'spec_helper'

describe EventResource, type: :resource do
let!(:camp) { events(:tsueri_supercamp) }
let!(:course) { events(:top_course) }

before do
params[:include] = 'advisor'
course.update!(advisor_id: person.id)
end

describe 'advisor' do
it 'is null for camps' do
params[:filter] = { id: { eq: camp.id } }
render

advisor_data = d[0].sideload(:advisor)

expect(jsonapi_data).to have(1).item
expect(jsonapi_data[0].id).to eq camp.id
expect(advisor_data).to be_nil
end

it 'works for courses' do
params[:filter] = { id: { eq: course.id } }
render

advisor_data = d[0].sideload(:advisor)

expect(jsonapi_data).to have(1).item
expect(jsonapi_data[0].id).to eq course.id
expect(advisor_data.id).to eq person.id
end
end
end

0 comments on commit 0a0c6d9

Please sign in to comment.