Skip to content

Commit

Permalink
fix: index destroy (#2466)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Feb 8, 2024
1 parent 6345d48 commit 2dc21f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/components/avo/index/resource_controls_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ def hidden_params
hidden[:referrer] = referrer_path
end

hidden
hidden.compact
end
end
4 changes: 2 additions & 2 deletions app/controllers/avo/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def set_related_resource_name
def set_resource
raise ActionController::RoutingError.new "No route matches" if resource.nil?

@resource = resource.new(view: params[:view] || action_name.to_s, user: _current_user, params: params)
@resource = resource.new(view: params[:view].presence || action_name.to_s, user: _current_user, params: params)

set_authorization
end
Expand All @@ -130,7 +130,7 @@ def set_related_resource
view = if action_view.in?([:index, :show, :new, :edit, :create])
action_view
else
params[:view] || action_view
params[:view].presence || action_view
end

@related_resource = related_resource.new(
Expand Down
10 changes: 10 additions & 0 deletions spec/system/avo/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,15 @@

expect(page).to have_text("Record destroyed").once
end

it "destroy from index page" do
visit "/admin/resources/projects"

expect {
find("[data-resource-id='#{project.id}'] [data-control='destroy']").click
confirm_alert
wait_for_loaded
}.to change(Project, :count).by(-1)
end
end
end

0 comments on commit 2dc21f3

Please sign in to comment.