role_signup_column_fix_spec.rb 979 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe RoleSignupColumnFix, db_strategy: :reset, type: :db_migration do
  4. context 'when a role contains signup permissions' do
  5. let!(:role) do
  6. role = create(:role)
  7. role.permission_grant('user_preferences.password')
  8. role.permission_grant('ticket.agent')
  9. role.update_column(:default_at_signup, true)
  10. role
  11. end
  12. before do
  13. without_column(:permissions, column: :allow_signup)
  14. migrate
  15. end
  16. it 'has password permission' do
  17. expect(role.reload.permissions.map(&:name)).to include('user_preferences.password')
  18. end
  19. it 'has no agent permission' do
  20. expect(role.reload.permissions.map(&:name)).not_to include('ticket.agent')
  21. end
  22. it 'has permission with allow_signup set correctly' do
  23. expect(Permission.find_by(name: 'user_preferences.password').allow_signup).to be true
  24. end
  25. end
  26. end