Skip to content

Commit

Permalink
feat: add manager to participation view (hitobito_jubla#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Oct 10, 2024
1 parent 951b9a4 commit ee88bb5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 28 deletions.
25 changes: 0 additions & 25 deletions app/domain/youth/export/pdf/participation.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/event/participations/_people_managers.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- # frozen_string_literal: true
-

- # Copyright (c) 2024, Schweizer Alpen-Club. This file is part of
- # hitobito and licensed under the Affero General Public License version 3
- # or later. See the COPYING file at the top-level directory or at
Expand All @@ -8,5 +8,5 @@

- FeatureGate.if('people.people_managers') do
- if entry.person.people_managers.any?
%section
%section
= render 'person/managers/list', person: entry.person
2 changes: 1 addition & 1 deletion app/views/person/managers/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- person.people_managers.each do |item|
%tr
%td
%strong= link_to(item.manager, item.manager, data: { turbo_frame: :_top })
%strong= link_to_if(can?(:show, item.manager), item.manager, item.manager, data: { turbo_frame: :_top })
%div.d-flex.gap-2
= mail_to(item.email)
= phone_to(item.phone_number.number, item.phone_number) if item.phone_number.present?
Expand Down
57 changes: 57 additions & 0 deletions spec/views/event/participations/_attrs.html.haml_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright (c) 2012-2013, Jungwacht Blauring Schweiz. This file is part of
# hitobito 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.

require "spec_helper"

describe "event/participations/_attrs.html.haml" do
let(:event) { EventDecorator.decorate(Fabricate(:course, groups: [groups(:top_layer)])) }
let(:participation) { Fabricate(:event_participation, event: event) }
subject(:dom) do
render
Capybara::Node::Simple.new(@rendered)
end

let(:params) do
{"action" => "show",
"controller" => "event/participations",
"group_id" => "1",
"event_id" => "36"}
end

before do
assign(:event, event)
assign(:group, event.groups.first.decorate)
assign(:answers, [])
allow(view).to receive_messages(parent: event)
allow(view).to receive_messages(entry: participation.decorate)
allow(view).to receive_messages(params: params)
# allow(view).to receive_messages(current_person: people(:top_leader))
# Fabricate(event.participant_types.first.name, participation: participation)
# participation.reload
end

context "with PeopleManager assigned" do
let!(:manager) do
Fabricate(:person).tap do |manager|
manager.phone_numbers.create(number: "+41 44 123 45 57", label: "Privat")
participation.person.managers << manager
end
end

it "marks participations where required questions are unanswered" do
login_as(people(:top_leader))

expect(dom).to have_text PeopleManager.model_name.human(count: 2)
expect(dom).to have_text manager.to_s
expect(dom).to have_text manager.email
expect(dom).to have_text manager.phone_numbers.first
end
end

def login_as(user)
allow(controller).to receive_messages(current_user: user)
allow(view).to receive_messages(current_user: user)
end
end

0 comments on commit ee88bb5

Please sign in to comment.