This commit is contained in:
Philipp Rothmann 2022-12-20 16:26:37 +01:00
commit 135b14c868
35 changed files with 1363 additions and 0 deletions

View file

@ -0,0 +1,39 @@
require 'spec_helper'
describe :event_external_application do
subject { page }
let(:event) { Fabricate(:event, application_opening_at: 5.days.ago,
external_applications: true, groups: [group]) }
let(:group) { groups(:root) }
it 'creates an external event participation' do
visit group_public_event_path(group_id: group, id: event)
find_all('#new_person input#person_email').first.fill_in(with: 'max.muster@hitobito.example.com')
click_button('Weiter')
fill_in 'Vorname', with: 'Max'
fill_in 'Nachname', with: 'Muster'
fill_in 'Haupt-E-Mail', with: 'max.muster@hitobito.example.com'
expect do
find_all('.btn-toolbar.bottom .btn-group button[type="submit"]').first.click # submit
end.to change { Person.count }.by(1)
fill_in('Bemerkungen', with: 'Wichtige Bemerkungen über meine Teilnahme')
expect do
click_button('Anmelden')
end.to change { Event::Participation.count }.by(1)
person = Person.find_by(email: 'max.muster@hitobito.example.com')
expect(person).to be_present
is_expected.to have_text("Teilnahme von #{person.full_name} in #{event.name} wurde erfolgreich erstellt. Bitte überprüfe die Kontaktdaten und passe diese gegebenenfalls an.")
is_expected.to have_text('Wichtige Bemerkungen über meine Teilnahme')
end
end

View file

@ -0,0 +1,36 @@
require 'spec_helper'
describe :event_participation do
subject { page }
let(:person) { people(:leader) }
let(:event) { Fabricate(:event, application_opening_at: 5.days.ago, groups: [group]) }
let(:group) { person.roles.first.group }
before do
sign_in(person)
end
it 'creates an event participation' do
visit group_event_path(group_id: group, id: event)
click_link('Anmelden')
find_all('.btn-toolbar.bottom .btn-group button[type="submit"]').first.click # "Weiter"
fill_in('Bemerkungen', with: 'Wichtige Bemerkungen über meine Teilnahme')
expect do
click_button('Anmelden')
end.to change { Event::Participation.count }.by(1)
is_expected.to have_text("Teilnahme von #{person.full_name} in #{event.name} wurde erfolgreich erstellt. Bitte überprüfe die Kontaktdaten und passe diese gegebenenfalls an.")
is_expected.to have_text('Wichtige Bemerkungen über meine Teilnahme')
participation = Event::Participation.find_by(event: event, person: person)
expect(participation).to be_present
end
end

View file

@ -0,0 +1,62 @@
require 'spec_helper'
describe :self_registration do
subject { page }
class Group::SelfRegistrationGroup < Group
self.layer = true
class ReadOnly < ::Role
self.permissions = [:group_read]
end
roles ReadOnly
end
let(:group) do
Group::SelfRegistrationGroup.create!(name: 'Self-Registration Group')
end
let(:self_registration_role) { group.decorate.allowed_roles_for_self_registration.first }
before do
group.self_registration_role_type = self_registration_role
group.save!
allow(Settings.groups.self_registration).to receive(:enabled).and_return(true)
end
it 'self registers and creates new person' do
visit group_self_registration_path(group_id: group)
fill_in 'Vorname', with: 'Max'
fill_in 'Nachname', with: 'Muster'
fill_in 'Haupt-E-Mail', with: 'max.muster@hitobito.example.com'
expect do
find_all('.btn-toolbar.bottom .btn-group button[type="submit"]').first.click # submit
end.to change { Person.count }.by(1)
.and change { ActionMailer::Base.deliveries.count }.by(1)
is_expected.to have_text('Du hast Dich erfolgreich registriert. Du erhältst in Kürze eine E-Mail mit der Anleitung, wie Du Deinen Account freischalten kannst.')
person = Person.find_by(email: 'max.muster@hitobito.example.com')
expect(person).to be_present
person.confirm # confirm email
person.password = person.password_confirmation = 'really_b4dPassw0rD'
person.save!
fill_in 'Haupt-E-Mail', with: 'max.muster@hitobito.example.com'
fill_in 'Passwort', with: 'really_b4dPassw0rD'
click_button 'Anmelden'
expect(person.roles.map(&:type)).to eq([self_registration_role.to_s])
expect(current_path).to eq("/de#{group_person_path(group_id: group, id: person)}.html")
end
end