Skip to content

Commit

Permalink
Merge pull request #9100 from CitizenLabDotCo/TAN-2773-fix-master-tem…
Browse files Browse the repository at this point in the history
…plate

TAN-2773 - Stopped templates from allowing permitted_by verified
  • Loading branch information
jamesspeake authored Oct 14, 2024
2 parents 69e622a + d8c4020 commit e273f04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ module Templates
module Serializers
class Permission < Base
ref_attribute :permission_scope
attributes %i[action permitted_by global_custom_fields]
attributes %i[action global_custom_fields]

# Permitted by 'verified' is only allowed if verification turned on in settings, so should fallback to 'users' when written to templates
attribute(:permitted_by) { |permission| permission.permitted_by == 'verified' ? 'users' : permission.permitted_by }
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ namespace :templates do
lifecycle_stage: 'demo'
) }.with_indifferent_access

# Required for verified actions
config_attrs[:settings][:verification] = {
enabled: true,
allowed: true,
verification_methods: [{ name: 'fake_sso' }]
}

_success, tenant, _app_config = MultiTenancy::TenantService.new.initialize_tenant(
tenant_attrs, config_attrs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,14 @@
expect(template['models']['user'].last['email']).to be_nil
expect(template['models']['user'].last['unique_code']).not_to be_nil
end

it 'changes "verified" permissions to "user" permissions' do
SettingsService.new.activate_feature! 'verification', settings: { verification_methods: [{ name: 'fake_sso' }] }
create(:permission, :by_admins_moderators)
create(:permission, :by_verified)
template = tenant_serializer.run(deserializer_format: true)
expect(template['models']['permission'].first['permitted_by']).to eq 'admins_moderators' # Not changed
expect(template['models']['permission'].last['permitted_by']).to eq 'users' # Changed
end
end
end

0 comments on commit e273f04

Please sign in to comment.