Skip to content

Commit

Permalink
Fixes #4831 - Invited colleagues during setup always get Agent role
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas committed Sep 25, 2023
1 parent c9418e2 commit 60d00c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Expand Up @@ -46,17 +46,11 @@ class GettingStartedAgent extends App.ControllerWizardFullScreen
submit: (e) =>
e.preventDefault()
@formDisable(e)
@params = @formParam(e.target)
@params.role_ids = []

@params = @formParam(e.target)
# set invite flag
@params.invite = true

# find agent role
role = App.Role.findByAttribute('name', 'Agent')
if role
@params.role_ids = role.id

user = new App.User
user.load(@params)

Expand Down
17 changes: 17 additions & 0 deletions spec/system/getting_started/agents_spec.rb
Expand Up @@ -17,4 +17,21 @@
.to have_text("Email address 'admin@example.com' is already used for another user.")
end
end

it 'adds roles correctly' do
visit 'getting_started/agents', skip_waiting: true

fill_in 'email', with: 'test@example.com'

click 'span', text: 'Admin'
click 'span', text: 'Agent' # unselect preselected role
click '.btn--success'

expect(User.last).to have_attributes(
email: 'test@example.com',
roles: contain_exactly(
Role.find_by(name: 'Admin')
)
)
end
end

0 comments on commit 60d00c0

Please sign in to comment.