Fix tests and remove unused policy files

This commit is contained in:
Eugene Burmakin 2025-11-07 11:34:34 +01:00
parent 19f6715218
commit adcf6aceca
5 changed files with 5 additions and 48 deletions

View file

@ -1,22 +0,0 @@
# frozen_string_literal: true
class FamilyInvitationPolicy < ApplicationPolicy
def show?
# Public endpoint for invitation acceptance - no authentication required
true
end
def create?
user.family == record.family && user.family_owner?
end
def accept?
# Users can accept invitations sent to their email
user.email == record.email
end
def destroy?
# Only family owners can cancel invitations
user.family == record.family && user.family_owner?
end
end

View file

@ -1,23 +0,0 @@
# frozen_string_literal: true
class FamilyMembershipPolicy < ApplicationPolicy
def show?
user.family == record.family
end
def update?
# Users can update their own settings
return true if user == record.user
# Family owners can update any member's settings
user.family == record.family && user.family_owner?
end
def destroy?
# Users can remove themselves (handled by family leave logic)
return true if user == record.user
# Family owners can remove other members
user.family == record.family && user.family_owner?
end
end

View file

@ -51,8 +51,8 @@ RSpec.describe 'Users::Registrations', type: :request do
get new_user_registration_path get new_user_registration_path
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(response.body).to include('Register now!') expect(response.body).to include('Almost there!')
expect(response.body).to include('take control over your location data') expect(response.body).to include('control over your location data')
expect(response.body).not_to include('Join') expect(response.body).not_to include('Join')
expect(response.body).to include('Sign up') expect(response.body).to include('Sign up')
end end
@ -227,7 +227,7 @@ RSpec.describe 'Users::Registrations', type: :request do
get new_user_registration_path get new_user_registration_path
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(response.body).to include('Register now!') expect(response.body).to include('Almost there!')
end end
it 'allows account creation' do it 'allows account creation' do

View file

@ -99,6 +99,7 @@ RSpec.describe Families::AcceptInvitation do
context 'when family is at max capacity' do context 'when family is at max capacity' do
before do before do
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
# Fill family to max capacity # Fill family to max capacity
create_list(:family_membership, Family::MAX_MEMBERS, family: family, role: :member) create_list(:family_membership, Family::MAX_MEMBERS, family: family, role: :member)
end end

View file

@ -57,6 +57,7 @@ RSpec.describe Families::Invite do
context 'when family is at max capacity' do context 'when family is at max capacity' do
before do before do
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
# Create max members (5 total including owner) # Create max members (5 total including owner)
create_list(:family_membership, Family::MAX_MEMBERS - 1, family: family, role: :member) create_list(:family_membership, Family::MAX_MEMBERS - 1, family: family, role: :member)
end end