Skip to content

Commit

Permalink
Adapt spec for changed self registration buttons (#2772)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaierhofer committed Aug 29, 2024
1 parent c0a3db9 commit 5ee0dd5
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions spec/features/self_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_jemk.


require 'spec_helper'
require "spec_helper"

describe :self_registration do
subject { page }
Expand All @@ -22,7 +21,7 @@ class ReadOnly < ::Role
end

let(:group) do
Group::SelfRegistrationGroup.create!(name: 'Self-Registration Group')
Group::SelfRegistrationGroup.create!(name: "Self-Registration Group")
end

let(:self_registration_role) { group.decorate.allowed_roles_for_self_registration.first }
Expand All @@ -34,35 +33,34 @@ class ReadOnly < ::Role
allow(Settings.groups.self_registration).to receive(:enabled).and_return(true)
end

it 'self registers and creates new person' do
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: '[email protected]'
fill_in "Vorname", with: "Max"
fill_in "Nachname", with: "Muster"
fill_in "Haupt-E-Mail", with: "[email protected]"

expect do
find_all('.btn-toolbar.bottom button[type="submit"]').first.click # submit
click_on "Registrieren"
expect(page).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.'
"Du hast Dich erfolgreich registriert. Du erhältst in Kürze eine E-Mail mit der Anleitung, " \
"wie Du Deinen Account freischalten kannst."
)

end.to change { Person.count }.by(1)
.and change { ActionMailer::Base.deliveries.count }.by(1)
.and change { ActionMailer::Base.deliveries.count }.by(1)

person = Person.find_by(email: '[email protected]')
person = Person.find_by(email: "[email protected]")
expect(person).to be_present

person.confirm # confirm email

person.password = person.password_confirmation = 'really_b4dPassw0rD'
person.password = person.password_confirmation = "really_b4dPassw0rD"
person.save!

fill_in 'Haupt-E-Mail', with: '[email protected]'
fill_in 'Passwort', with: 'really_b4dPassw0rD'
fill_in "Haupt-E-Mail", with: "[email protected]"
fill_in "Passwort", with: "really_b4dPassw0rD"

click_button 'Anmelden'
click_button "Anmelden"

expect(person.roles.map(&:type)).to eq([self_registration_role.to_s])
expect(current_path).to match(/#{group_person_path(group_id: group, id: person)}.html\z/)
Expand Down

0 comments on commit 5ee0dd5

Please sign in to comment.