Fixes #3007 - Customer invitation doesn't work if "customer" role is name wise missing.
This commit is contained in:
parent
f09b82b427
commit
a2e3d8c7b4
3 changed files with 27 additions and 6 deletions
|
@ -48,7 +48,7 @@ class App.DashboardFirstSteps extends App.Controller
|
|||
#container: @el.closest('.content')
|
||||
head: 'Invite Customer'
|
||||
screen: 'invite_customer'
|
||||
role: 'Customer'
|
||||
signup: true
|
||||
)
|
||||
|
||||
testTicketLoading: =>
|
||||
|
|
|
@ -48,11 +48,13 @@ class App.InviteUser extends App.WizardModal
|
|||
# set invite flag
|
||||
@params.invite = true
|
||||
|
||||
# find agent role
|
||||
if @role
|
||||
role = App.Role.findByAttribute('name', @role)
|
||||
if role
|
||||
@params.role_ids = role.id
|
||||
# find signup roles
|
||||
if @signup
|
||||
@params.role_ids = App.Role.search(
|
||||
filter:
|
||||
active: true
|
||||
default_at_signup: true
|
||||
).map((role) -> role.id)
|
||||
|
||||
user = new App.User
|
||||
user.load(@params)
|
||||
|
|
|
@ -13,4 +13,23 @@ RSpec.describe 'Dashboard', type: :system, authenticated_as: true do
|
|||
expect(page).to have_css('.ticket_in_process > div > div.stat-title', text: /Your tickets in process/i)
|
||||
expect(page).to have_css('.ticket_reopen > div > div.stat-title', text: /Reopening rate/i)
|
||||
end
|
||||
|
||||
context 'when customer role is named different', authenticated_as: :authenticate do
|
||||
def authenticate
|
||||
Role.find_by(name: 'Customer').update(name: 'Public')
|
||||
true
|
||||
end
|
||||
|
||||
it 'invites a customer user' do
|
||||
visit 'dashboard'
|
||||
find('div.tab[data-area=first-steps-widgets]').click
|
||||
find('.js-inviteCustomer').click
|
||||
fill_in 'Firstname', with: 'Nick'
|
||||
fill_in 'Lastname', with: 'Braun'
|
||||
fill_in 'Email', with: 'nick.braun@zammad.org'
|
||||
click_on 'Invite'
|
||||
await_empty_ajax_queue
|
||||
expect(User.find_by(firstname: 'Nick').roles).to eq([Role.find_by(name: 'Public')])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue