Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
06ec3ca
Hide removal button for personal ownerships
MaxSukhanov May 31, 2025
5b2e8f3
Ensure audit page is rendered before clicking.
simi Jun 1, 2025
73515af
Bump pghero from 3.6.2 to 3.7.0 (#5698)
dependabot[bot] Jun 2, 2025
c63921f
Bump rubocop-minitest from 0.38.0 to 0.38.1 in the rubocop group (#5712)
dependabot[bot] Jun 3, 2025
2b4f956
Bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#5711)
dependabot[bot] Jun 3, 2025
ae9eff6
Bump csv from 3.3.4 to 3.3.5 (#5713)
dependabot[bot] Jun 3, 2025
af3e8ab
set GOOD_JOB_QUEUE_SELECT_LIMIT env var (#5715)
colby-swandale Jun 3, 2025
4a31a03
notify users of new policy from last known good send (#5716)
colby-swandale Jun 3, 2025
de97ea0
Bump github/codeql-action from 3.28.18 to 3.28.19
dependabot[bot] Jun 3, 2025
dbfa01f
Bump groupdate from 6.6.0 to 6.7.0
dependabot[bot] Jun 3, 2025
589e058
Bump datadog from 2.16.0 to 2.17.0 (#5719)
dependabot[bot] Jun 4, 2025
528dfe8
Bump the aws group with 2 updates (#5718)
dependabot[bot] Jun 4, 2025
3c12560
Bump rack from 3.1.15 to 3.1.16 (#5723)
dependabot[bot] Jun 10, 2025
8602533
Bump rbtrace from 0.5.1 to 0.5.2 (#5725)
dependabot[bot] Jun 10, 2025
ec99331
Bump datadog-ci from 1.17.0 to 1.18.0 (#5724)
dependabot[bot] Jun 11, 2025
c670b4f
Bump aws-sdk-s3 from 1.189.0 to 1.189.1 in the aws group (#5728)
dependabot[bot] Jun 12, 2025
b41c3e7
remove email policy maintenance task (#5730)
colby-swandale Jun 12, 2025
9646455
Bump ruby/setup-ruby from 1.244.0 to 1.245.0 (#5732)
dependabot[bot] Jun 12, 2025
71b4947
Bump github/codeql-action from 3.28.19 to 3.29.0 (#5731)
dependabot[bot] Jun 12, 2025
bc87b17
Resolve FromAsCasing warnings
landongrindheim Jun 13, 2025
0b6e979
Bump factory_bot_rails from 6.4.4 to 6.5.0 (#5734)
dependabot[bot] Jun 13, 2025
57ce320
Update logic to allow removal of personal membership
MaxSukhanov Jun 13, 2025
1ec6044
Merge branch 'master' into MaxSukhanov/change-logic-displaying-remove…
MaxSukhanov Jun 13, 2025
57c0007
Merge branch 'master' into MaxSukhanov/change-logic-displaying-remove…
MaxSukhanov Jul 27, 2025
da3492f
Merge branch 'master' into MaxSukhanov/change-logic-displaying-remove…
MaxSukhanov Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/helpers/owners_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ def mfa_status(user)
image_tag("/images/check.svg")
end
end

def multiple_owners?(rubygem)
rubygem.owners.size > 1
end
end
14 changes: 8 additions & 6 deletions app/views/owners/_owners_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@
<%= ownership.confirmed_at.strftime("%Y-%m-%d %H:%M %Z") if ownership.confirmed? %>
</td>
<td class="owners__cell" data-title="Action">
<%= button_to t("remove"),
rubygem_owner_path(@rubygem.slug, ownership.user.display_id),
method: "delete",
data: { confirm: t("owners.index.confirm_remove") },
class: "form__submit form__submit--small" %>
<br>
<% if multiple_owners?(@rubygem) %>
<%= button_to t("remove"),
rubygem_owner_path(@rubygem.slug, ownership.user.display_id),
method: "delete",
data: { confirm: t("owners.index.confirm_remove") },
class: "form__submit form__submit--small" %>
<br>
<% end %>
<%= button_to t("edit"),
edit_rubygem_owner_path(@rubygem.name, ownership.user.display_id),
disabled: ownership.user == current_user,
Expand Down
37 changes: 22 additions & 15 deletions test/integration/owner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,6 @@ class OwnerTest < SystemTest
assert_equal [@other_user.email], last_email.to
end

test "removing last owner shows error message" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the delete action button has been disabled, i would still like to see a test, maybe just a unit/functional, that verifies that that we're not allowing this action to take place.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colby-swandale I believe that there are two tests verifying this:

I updated the logic responsible for hiding the button according to the issue description.

visit_ownerships_page

within_element owner_row(@user) do
click_button "Remove"
end

assert page.has_selector?("a[href='#{profile_path(@user.display_id)}']")
assert page.has_selector? "#flash_alert", text: "Can't remove the only owner of the gem"

perform_enqueued_jobs only: ActionMailer::MailDeliveryJob

assert_no_emails
end

test "verify using webauthn" do
create_webauthn_credential

Expand Down Expand Up @@ -224,6 +209,28 @@ class OwnerTest < SystemTest
assert page.has_selector?("a[href='#{rubygem_owners_path(@rubygem.slug)}']")
end

test "shows the remove button for all owners when there are multiple owners" do
create(:ownership, user: @other_user, rubygem: @rubygem)

visit_ownerships_page

within_element owner_row(@user) do
assert page.has_button?("Remove")
end

within_element owner_row(@other_user) do
assert page.has_button?("Remove")
end
end

test "hides the remove button if owner is single" do
visit_ownerships_page

within_element owner_row(@user) do
assert page.has_no_button?("Remove")
end
end

test "hides ownership link when not owner" do
page.click_link(nil, href: "/sign_out")
sign_in_as(@other_user)
Expand Down