Skip to content

Commit

Permalink
Fixed the bug (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea authored Dec 17, 2024
1 parent 8e24f2e commit 9de532d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/projects/_edit_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
function addUsersToForm() {
const userAlreadyAdded = usersInForm();
const users = $(".data_user_added_modal");
var totalUserCount = users.length;
var totalUserCount = userAlreadyAdded.length;
for(var i = 0; i < users.length; i += 1) {
var netIdToAdd = users[i].firstChild.textContent;
if (userAlreadyAdded.includes(netIdToAdd) === false) {
Expand Down
12 changes: 10 additions & 2 deletions spec/system/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,21 @@
click_on "Create new project"
expect(page.find("#non-editable-data-sponsor").text).to eq sponsor_user.uid
fill_in_and_out "data_manager", with: data_manager.uid
expect(page).to have_content "No Data User(s) added"

# Launch the modal, trigger the validation, and then add a valid user
click_on "+ Add User(s)"
fill_in_and_out "data-user-uid-to-add", with: "notuser"
# shows the error
expect(page.find("#data-user-uid-to-add_error").text).to eq "Invalid value entered"
# gets rid of the error
fill_in_and_out "data-user-uid-to-add", with: read_only.uid
expect(page.find("#data-user-uid-to-add_error", visible: false).text).to eq ""
click_on "Save changes"

# Launch the modal again and this time don't add any users
# (but we already had added some so we don't expect the "no data users" message)
click_on "+ Add User(s)"
click_on "Save changes"
expect(page).not_to have_content "No Data User(s) added"
end
end

Expand Down

0 comments on commit 9de532d

Please sign in to comment.