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

Feature: alias close_modal action response to do_nothing #2952

Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions lib/avo/base_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@
self
end

alias do_nothing close_modal

Check failure on line 241 in lib/avo/base_action.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/Alias: Use alias_method instead of alias. Raw Output: lib/avo/base_action.rb:241:5: C: [Corrected] Style/Alias: Use alias_method instead of alias. alias do_nothing close_modal ^^^^^
adrianthedev marked this conversation as resolved.
Show resolved Hide resolved

# Add a placeholder silent message from when a user wants to do a redirect action or something similar
def silent
add_message nil, :silent
Expand Down
13 changes: 13 additions & 0 deletions spec/dummy/app/avo/actions/test/do_nothing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Avo::Actions::Test::DoNothing < Avo::BaseAction
self.name = "Do Nothing"
self.standalone = true
self.visible = -> {
true
}

def handle(**args)
TestBuddy.hi "Hello from Avo::Actions::Test::DoNothing handle method"
succeed "Nothing Done!!"
do_nothing
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 @@ -73,6 +73,7 @@ def actions
divider
action Avo::Actions::Test::NoConfirmationRedirect
action Avo::Actions::Test::CloseModal
action Avo::Actions::Test::DoNothing
action Avo::Actions::DetachUser
end

Expand Down
24 changes: 23 additions & 1 deletion spec/system/avo/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,30 @@
end
end


Check failure on line 182 in spec/system/avo/actions_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/EmptyLines: Extra blank line detected. Raw Output: spec/system/avo/actions_spec.rb:182:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
describe "do_nothing" do
it "closes the modal and flashes messages" do
allow(TestBuddy).to receive(:hi).and_call_original
expect(TestBuddy).to receive(:hi).with("Hello from Avo::Actions::Test::DoNothing handle method").at_least :once

visit "/admin/resources/users/new"

fill_in "user_first_name", with: "First name should persist after action."


Check failure on line 192 in spec/system/avo/actions_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/EmptyLines: Extra blank line detected. Raw Output: spec/system/avo/actions_spec.rb:192:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
click_on "Actions"
click_on "Do Nothing"
expect(page).to have_css('turbo-frame#actions_show')

Check failure on line 195 in spec/system/avo/actions_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: spec/system/avo/actions_spec.rb:195:32: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. expect(page).to have_css('turbo-frame#actions_show') ^^^^^^^^^^^^^^^^^^^^^^^^^^
expect(page).to have_selector(modal = "[role='dialog']")
click_on "Run"
expect(page).not_to have_selector(modal)
expect(page).to have_text "Nothing Done!!"
expect(page).to have_field('user_first_name', with: 'First name should persist after action.')

Check failure on line 200 in spec/system/avo/actions_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: spec/system/avo/actions_spec.rb:200:34: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. expect(page).to have_field('user_first_name', with: 'First name should persist after action.') ^^^^^^^^^^^^^^^^^

Check failure on line 200 in spec/system/avo/actions_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: spec/system/avo/actions_spec.rb:200:59: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. expect(page).to have_field('user_first_name', with: 'First name should persist after action.') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
end
end

describe "close_modal" do
it "closes the modal and flahses messages" do
it "closes the modal and flashes messages" do
allow(TestBuddy).to receive(:hi).and_call_original
expect(TestBuddy).to receive(:hi).with("Hello from Avo::Actions::Test::CloseModal handle method").at_least :once

Expand Down
Loading