mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix failing spec
This commit is contained in:
parent
d23e118645
commit
e1ee39ec52
1 changed files with 11 additions and 6 deletions
|
|
@ -6,7 +6,9 @@ RSpec.describe 'Users::Registrations', type: :request do
|
||||||
let(:family_owner) { create(:user) }
|
let(:family_owner) { create(:user) }
|
||||||
let(:family) { create(:family, creator: family_owner) }
|
let(:family) { create(:family, creator: family_owner) }
|
||||||
let!(:owner_membership) { create(:family_membership, user: family_owner, family: family, role: :owner) }
|
let!(:owner_membership) { create(:family_membership, user: family_owner, family: family, role: :owner) }
|
||||||
let(:invitation) { create(:family_invitation, family: family, invited_by: family_owner, email: 'invited@example.com') }
|
let(:invitation) do
|
||||||
|
create(:family_invitation, family: family, invited_by: family_owner, email: 'invited@example.com')
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:any, 'https://api.github.com/repos/Freika/dawarich/tags')
|
stub_request(:any, 'https://api.github.com/repos/Freika/dawarich/tags')
|
||||||
|
|
@ -76,7 +78,7 @@ RSpec.describe 'Users::Registrations', type: :request do
|
||||||
expect do
|
expect do
|
||||||
post user_registration_path, params: request_params
|
post user_registration_path, params: request_params
|
||||||
end.to change(User, :count).by(1)
|
end.to change(User, :count).by(1)
|
||||||
.and change { invitation.reload.status }.from('pending').to('accepted')
|
.and change { invitation.reload.status }.from('pending').to('accepted')
|
||||||
|
|
||||||
new_user = User.find_by(email: invitation.email)
|
new_user = User.find_by(email: invitation.email)
|
||||||
expect(new_user).to be_present
|
expect(new_user).to be_present
|
||||||
|
|
@ -95,7 +97,7 @@ RSpec.describe 'Users::Registrations', type: :request do
|
||||||
|
|
||||||
# Check that user got the default registration success message
|
# Check that user got the default registration success message
|
||||||
# (family welcome message is set but may be overridden by Devise)
|
# (family welcome message is set but may be overridden by Devise)
|
||||||
expect(flash[:notice]).to include("signed up successfully")
|
expect(flash[:notice]).to include('signed up successfully')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -216,8 +218,8 @@ RSpec.describe 'Users::Registrations', type: :request do
|
||||||
|
|
||||||
describe 'Non-Self-Hosted Mode' do
|
describe 'Non-Self-Hosted Mode' do
|
||||||
before do
|
before do
|
||||||
allow(ENV).to receive(:[]).and_call_original
|
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
||||||
allow(ENV).to receive(:[]).with('SELF_HOSTED').and_return('false')
|
allow(DawarichSettings).to receive(:family_feature_enabled?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when accessing registration without invitation token' do
|
context 'when accessing registration without invitation token' do
|
||||||
|
|
@ -229,10 +231,12 @@ RSpec.describe 'Users::Registrations', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows account creation' do
|
it 'allows account creation' do
|
||||||
|
unique_email = "newuser-#{Time.current.to_i}@example.com"
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
post user_registration_path, params: {
|
post user_registration_path, params: {
|
||||||
user: {
|
user: {
|
||||||
email: 'test@example.com',
|
email: unique_email,
|
||||||
password: 'password123',
|
password: 'password123',
|
||||||
password_confirmation: 'password123'
|
password_confirmation: 'password123'
|
||||||
}
|
}
|
||||||
|
|
@ -240,6 +244,7 @@ RSpec.describe 'Users::Registrations', type: :request do
|
||||||
end.to change(User, :count).by(1)
|
end.to change(User, :count).by(1)
|
||||||
|
|
||||||
expect(response).to redirect_to(root_path)
|
expect(response).to redirect_to(root_path)
|
||||||
|
expect(User.find_by(email: unique_email)).to be_present
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue