Skip to content

Commit

Permalink
More tests work without avo pro
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Sep 4, 2024
1 parent 3c3ce6f commit 1d893de
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
52 changes: 30 additions & 22 deletions app/avo/resources/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,41 @@ class Avo::Resources::Audit < Avo::BaseResource
def fields
field :action, as: :text

panel do
sidebar do
field :admin_github_user, as: :belongs_to
field :created_at, as: :date_time
field :comment, as: :text
if defined?(Avo::Pro)
panel do
sidebar do
panel_sidebar_contents
end
end
else
panel_sidebar_contents
end

field :auditable, as: :belongs_to,
polymorphic_as: :auditable,
types: [::User, ::WebHook],
name: "Edited Record"
field :audited_changes, as: :audited_changes, except_on: :index
end

field :action_details, as: :heading
def panel_sidebar_contents
field :admin_github_user, as: :belongs_to
field :created_at, as: :date_time
field :comment, as: :text

field :audited_changes_arguments, as: :json_viewer, only_on: :show do |_model|
record.audited_changes["arguments"]
end
field :audited_changes_fields, as: :json_viewer, only_on: :show do |_model|
record.audited_changes["fields"]
end
field :audited_changes_models, as: :text, as_html: true, only_on: :show do
record.audited_changes["models"]
end
field :auditable, as: :belongs_to,
polymorphic_as: :auditable,
types: [::User, ::WebHook],
name: "Edited Record"

field :id, as: :id
end
field :action_details, as: :heading

field :audited_changes_arguments, as: :json_viewer, only_on: :show do |_model|
record.audited_changes["arguments"]
end
field :audited_changes_fields, as: :json_viewer, only_on: :show do |_model|
record.audited_changes["fields"]
end
field :audited_changes_models, as: :text, as_html: true, only_on: :show do
record.audited_changes["models"]
end

field :audited_changes, as: :audited_changes, except_on: :index
field :id, as: :id
end
end
2 changes: 1 addition & 1 deletion config/initializers/avo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
config.root_path = '/admin'

# Where should the user be redirected when visting the `/avo` url
config.home_path = "/admin/dashboards/dashy"
config.home_path = "/admin/dashboards/dashy" if defined?(Avo::Pro)

## == Licensing ==
config.license_key = ENV['AVO_LICENSE_KEY']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ class Avo::GemNameReservationsControllerTest < ActionDispatch::IntegrationTest
get avo.resources_gem_name_reservations_path

assert_response :success
end

test "resource search_query scope" do
skip "avo-pro needed to run this test" unless defined?(Avo::Pro)

admin_sign_in_as create(:admin_github_user, :is_admin)
create(:gem_name_reservation, name: "hello")

# test resource search_query scope
get avo.avo_api_search_path(q: "hello")

assert_response :success
Expand Down

0 comments on commit 1d893de

Please sign in to comment.