Skip to content

Commit

Permalink
Admin changing owner: Add explanation and more tests
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
  • Loading branch information
david-a-wheeler committed Sep 12, 2024
1 parent c7299d1 commit 8a6fc43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/views/projects/_form_0.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@
hide_label: true, class:"form-control",
placeholder: nil,
spellcheck: false,
disabled: is_disabled %>
disabled: is_disabled %><br>
If changed, consider adding the old owner to additional rights list.
</div>
</div>
<% end %>
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/projects_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ def only_correct_criteria_selectable(level)
log_in_as(@admin)
old_user = @project.user
assert_not_equal @admin.id, old_user.id
# We SHOULD see the option to change the owner id
get "/en/projects/#{@project.id}/edit"
assert_response :success
assert_includes @response.body, 'New owner id'
# Let's ensure we CAN change it.
# Admin will own this project after this instruction.
patch "/en/projects/#{@project.id}", params: {
project: { user_id: @admin.id }
Expand All @@ -608,6 +613,11 @@ def only_correct_criteria_selectable(level)
# Verify test setup - @project is owned by @user
assert_equal @project.user_id, @user.id
log_in_as(@user)
# We should NOT see the option to change the owner id
get "/en/projects/#{@project.id}/edit"
assert_response :success
assert_not_includes @response.body, 'New owner id'
# Let's ensure we can't change it.
patch "/en/projects/#{@project.id}", params: {
project: { user_id: @admin.id }
}
Expand Down

0 comments on commit 8a6fc43

Please sign in to comment.