2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-10-07 12:05:07 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2020-11-12 10:54:29 +00:00
|
|
|
RSpec.describe RoleSignupColumnFix, type: :db_migration, db_strategy: :reset do
|
2020-10-07 12:05:07 +00:00
|
|
|
context 'when a role contains signup permissions' do
|
|
|
|
let!(:role) do
|
|
|
|
role = create(:role)
|
|
|
|
role.permission_grant('user_preferences.password')
|
|
|
|
role.permission_grant('ticket.agent')
|
|
|
|
role.update_column(:default_at_signup, true)
|
|
|
|
role
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
without_column(:permissions, column: :allow_signup)
|
|
|
|
migrate
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has password permission' do
|
|
|
|
expect(role.reload.permissions.map(&:name)).to include('user_preferences.password')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no agent permission' do
|
|
|
|
expect(role.reload.permissions.map(&:name)).not_to include('ticket.agent')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permission with allow_signup set correctly' do
|
|
|
|
expect(Permission.find_by(name: 'user_preferences.password').allow_signup).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|