Skip to content

Commit

Permalink
Revert "Configure special course leader role for events api (#1265)"
Browse files Browse the repository at this point in the history
This reverts commit bcd910e.
  • Loading branch information
amaierhofer committed Nov 22, 2024
1 parent 3633d11 commit 303164d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
1 change: 0 additions & 1 deletion lib/hitobito_sac_cas/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class Wagon < Rails::Engine
EventResource.include SacCas::EventResource
Event::CourseResource.include SacCas::Event::CourseResource
Event::KindResource.include SacCas::Event::KindResource
Person::NameResource.course_leader_role = Event::Course::Role::Leader

## Helpers
EventKindsHelper.prepend SacCas::EventKindsHelper
Expand Down
20 changes: 0 additions & 20 deletions spec/api/events/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,5 @@
expect(d.map(&:id)).not_to be_empty
end
end

context "with include leaders" do
it "includes only leaders" do
course = events(:top_course)
leader = people(:tourenchef)
participation = course.participations.create!(person: leader, active: true)
Event::Course::Role::Leader.create!(participation: participation)
assistant = course.participations.create!(person: people(:familienmitglied), active: true)
Event::Course::Role::AssistantLeader.create!(participation: assistant)

jsonapi_get "/api/events", params: {include: "leaders"}

expect(response.status).to eq(200), response.body

expect(json["data"].first["id"]).to eq(course.id.to_s)
expect(json["data"].first["relationships"]["leaders"]["data"].size).to eq(1)
expect(json["data"].first["relationships"]["leaders"]["data"].first["id"]).to eq(leader.id.to_s)
expect(json["included"].first["id"]).to eq(leader.id.to_s)
end
end
end
end
17 changes: 1 addition & 16 deletions spec/resources/sac_cas/event/course_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "spec_helper"

describe Event::CourseResource, type: :resource do
let(:event) { events(:top_course) }
let(:event) { events(:closed) }
let(:person) { people(:admin) }
let(:additional_attrs) do
[
Expand Down Expand Up @@ -41,19 +41,4 @@
expect(attrs).to have_key(attr)
end
end

it "includes leaders" do
leader = people(:tourenchef)
participation = event.participations.create!(person: leader, active: true)
Event::Course::Role::Leader.create!(participation: participation)

params[:include] = "leaders"
render
data = jsonapi_data[0]
leaders = data.sideload(:leaders)
expect(leaders.size).to eq(1)
expect(leaders.first.id).to eq(leader.id)
expect(leaders.first.first_name).to eq(leader.first_name)
expect(leaders.first.last_name).to eq(leader.last_name)
end
end

0 comments on commit 303164d

Please sign in to comment.