Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix actions spec #2068

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 Avo::Actions::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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def actions
action Avo::Actions::ToggleAdmin
action Avo::Actions::Sub::DummyAction
action Avo::Actions::DownloadFile
action Avo::Actions::Test::NoConfirmationRedirect
end

def filters
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 @@ -151,27 +151,12 @@

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

Avo::Actions::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"

Avo::Actions::Sub.send(:remove_const, "DummyAction")
Avo::Actions::Sub.const_set("DummyAction", original_dummy_action)
end
end

Expand Down
Loading