mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix tests and remove unused policy files
This commit is contained in:
parent
19f6715218
commit
adcf6aceca
5 changed files with 5 additions and 48 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -51,8 +51,8 @@ RSpec.describe 'Users::Registrations', type: :request do
|
|||
get new_user_registration_path
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include('Register now!')
|
||||
expect(response.body).to include('take control over your location data')
|
||||
expect(response.body).to include('Almost there!')
|
||||
expect(response.body).to include('control over your location data')
|
||||
expect(response.body).not_to include('Join')
|
||||
expect(response.body).to include('Sign up')
|
||||
end
|
||||
|
|
@ -227,7 +227,7 @@ RSpec.describe 'Users::Registrations', type: :request do
|
|||
get new_user_registration_path
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include('Register now!')
|
||||
expect(response.body).to include('Almost there!')
|
||||
end
|
||||
|
||||
it 'allows account creation' do
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ RSpec.describe Families::AcceptInvitation do
|
|||
|
||||
context 'when family is at max capacity' do
|
||||
before do
|
||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
||||
# Fill family to max capacity
|
||||
create_list(:family_membership, Family::MAX_MEMBERS, family: family, role: :member)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ RSpec.describe Families::Invite do
|
|||
|
||||
context 'when family is at max capacity' do
|
||||
before do
|
||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
||||
# Create max members (5 total including owner)
|
||||
create_list(:family_membership, Family::MAX_MEMBERS - 1, family: family, role: :member)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue