Skip to content

Commit

Permalink
chore: fix actions spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Nov 28, 2023
1 parent 5dcb795 commit 4b849c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
9 changes: 9 additions & 0 deletions spec/dummy/app/avo/actions/test/no_confirmation_redirect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Test::NoConfirmationRedirect < Avo::BaseAction
self.name = "Test No Confirmation Redirect"
self.no_confirmation = true
self.standalone = true

def handle(**args)
redirect_to main_app.hey_path
end
end
1 change: 1 addition & 0 deletions spec/dummy/app/avo/resources/user_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class UserResource < Avo::BaseResource
action DownloadFile
action PreUpdate
action Update
action Test::NoConfirmationRedirect

filter UserNamesFilter
filter IsAdmin
Expand Down
17 changes: 1 addition & 16 deletions spec/system/avo/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,12 @@

describe "redirects when no confirmation" do
it "redirects to hey page" do
original_dummy_action = Sub::DummyAction.dup

Sub::DummyAction.class_eval do
self.no_confirmation = true

define_method(:redirect_handle) do |**args|
redirect_to main_app.hey_path
end

alias_method :handle, :redirect_handle
end

visit "/admin/resources/users"

click_on "Actions"
click_on "Dummy action"
click_on "Test No Confirmation Redirect"

expect(page).to have_text "hey en"

Sub.send(:remove_const, "DummyAction")
Sub.const_set("DummyAction", original_dummy_action)
end
end
# let!(:roles) { { admin: false, manager: false, writer: false } }
Expand Down

0 comments on commit 4b849c7

Please sign in to comment.