Skip to content

Commit

Permalink
Change submit button on block edit page when can only revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Aug 22, 2024
1 parent 11a7bf7 commit 76736ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions app/views/user_blocks/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<%= f.form_group :needs_view do %>
<%= f.check_box :needs_view %>
<% end %>
<%= f.primary %>
<% else %>
<div class="alert alert-info">
<% if @user_block.active? %>
Expand All @@ -32,7 +34,11 @@

<%= hidden_field_tag "user_block_period", 0 %>
<%= hidden_field_tag "user_block[needs_view]", false %>
<% end %>
<%= f.primary %>
<% if @user_block.active? %>
<%= f.submit t(".revoke"), :class => "btn btn-danger" %>
<% else %>
<%= f.primary %>
<% end %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,7 @@ en:
title: "Editing block on %{name}"
heading_html: "Editing block on %{name}"
period: "How long, starting now, the user will be blocked from the API for."
revoke: "Revoke block"
filter:
block_period: "The blocking period must be one of the values selectable in the drop-down list."
create:
Expand Down
6 changes: 4 additions & 2 deletions test/controllers/user_blocks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ def test_edit
assert_select "textarea#user_block_reason", :count => 1
assert_select "select#user_block_period", :count => 0
assert_select "input#user_block_needs_view[type='checkbox']", :count => 0
assert_select "input[type='submit'][value='Update block']", :count => 0
assert_select "input#user_block_period[type='hidden']", :count => 1
assert_select "input#user_block_needs_view[type='hidden']", :count => 1
assert_select "input[type='submit'][value='Update block']", :count => 1
assert_select "input[type='submit'][value='Revoke block']", :count => 1
end

# Login as the block creator
Expand All @@ -294,9 +295,10 @@ def test_edit
assert_select "textarea#user_block_reason", :count => 1
assert_select "select#user_block_period", :count => 1
assert_select "input#user_block_needs_view[type='checkbox']", :count => 1
assert_select "input[type='submit'][value='Update block']", :count => 1
assert_select "input#user_block_period[type='hidden']", :count => 0
assert_select "input#user_block_needs_view[type='hidden']", :count => 0
assert_select "input[type='submit'][value='Update block']", :count => 1
assert_select "input[type='submit'][value='Revoke block']", :count => 0
end

# We should get an error if the user doesn't exist
Expand Down
2 changes: 1 addition & 1 deletion test/system/user_blocks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class UserBlocksSystemTest < ApplicationSystemTestCase
assert_no_field "Needs view"

fill_in "Reason", :with => "Revoking 0-hour blocks works"
click_on "Update block"
click_on "Revoke block"
assert_text(/Revoker:\s+#{Regexp.escape other_moderator_user.display_name}/)
assert_text(/Status:\s+Ended/)
assert_text(/Reason for block:\s+Revoking 0-hour blocks works/)
Expand Down

0 comments on commit 76736ba

Please sign in to comment.