Merge remote-tracking branch 'upstream/pull/5189'
This commit is contained in:
commit
17bea98e19
2 changed files with 34 additions and 1 deletions
|
@ -18,7 +18,7 @@
|
|||
<%= link_to t(".edit"), edit_redaction_path(@redaction), :class => "btn btn-outline-primary" %>
|
||||
<% end %>
|
||||
<% if can?(:destroy, Redaction) %>
|
||||
<%= link_to t(".destroy"), @redaction, :method => "delete", :class => "btn btn-outline-danger", :remote => true, :data => { :confirm => t(".confirm") } %>
|
||||
<%= link_to t(".destroy"), @redaction, :class => "btn btn-outline-danger", :data => { :turbo => true, :turbo_method => "DELETE", :turbo_confirm => t(".confirm") } %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
33
test/system/redaction_destroy_test.rb
Normal file
33
test/system/redaction_destroy_test.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require "application_system_test_case"
|
||||
|
||||
class RedactionDestroyTest < ApplicationSystemTestCase
|
||||
test "fails to delete nonempty redaction" do
|
||||
redaction = create(:redaction, :title => "Some-unwanted-data-redaction")
|
||||
create(:old_node, :redaction => redaction)
|
||||
|
||||
sign_in_as create(:moderator_user)
|
||||
visit redaction_path(redaction)
|
||||
assert_text "Some-unwanted-data-redaction"
|
||||
|
||||
accept_alert do
|
||||
click_on "Remove this redaction"
|
||||
end
|
||||
assert_text "Redaction is not empty"
|
||||
assert_text "Some-unwanted-data-redaction"
|
||||
end
|
||||
|
||||
test "deletes empty redaction" do
|
||||
redaction = create(:redaction, :title => "No-unwanted-data-redaction")
|
||||
|
||||
sign_in_as create(:moderator_user)
|
||||
visit redaction_path(redaction)
|
||||
assert_text "No-unwanted-data-redaction"
|
||||
|
||||
accept_alert do
|
||||
click_on "Remove this redaction"
|
||||
end
|
||||
assert_text "Redaction destroyed"
|
||||
assert_text "List of Redactions"
|
||||
assert_no_text "No-unwanted-data-redaction"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue