Skip to content

Commit

Permalink
Fix hound errors
Browse files Browse the repository at this point in the history
Fix hound errors
  • Loading branch information
bhtabor committed May 13, 2023
1 parent f81d49c commit aab1325
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/controllers/concerns/administrate/punditize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ def policy_scope!(user, scope)
begin
policy_scope = policy_scope_class.new(user, pundit_model(scope))
rescue ArgumentError
raise Pundit::InvalidConstructorError, "Invalid #<#{policy_scope_class}> constructor is called"
raise(Pundit::InvalidConstructorError,
"Invalid #<#{policy_scope_class}> constructor is called")
end

if policy_scope.respond_to? :resolve_admin
ActiveSupport::Deprecation.warn(
"The method `resolve_admin` on pundit policy scope is deprecated. " +
"Pundit policy scope `resolve_admin` method is deprecated. " +
"Please use a namespaced pundit policy instead.",
)
policy_scope.resolve_admin
Expand Down
12 changes: 7 additions & 5 deletions spec/controllers/admin/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
context "with namespaced Punditize concern" do
controller(Admin::OrdersController) do
include Administrate::Punditize

def policy_namespaces
[:own]
end

def pundit_user
Customer.find_by(name: "Current User")
end
Expand Down Expand Up @@ -129,7 +131,7 @@ def pundit_user

expect(locals[:resources]).to contain_exactly(order1, order3)
expect(ActiveSupport::Deprecation).to have_received(:warn).
with(/`resolve_admin` on pundit policy scope is deprecated/)
with(/`resolve_admin` method is deprecated/)
end
end

Expand All @@ -144,7 +146,7 @@ def pundit_user
order = create :order, customer: user
expect { get :edit, params: { id: order.id } }.not_to raise_error
expect(ActiveSupport::Deprecation).to have_received(:warn).
with(/`resolve_admin` on pundit policy scope is deprecated/)
with(/`resolve_admin` method is deprecated/)
end

it "does not allow me to see other users' records" do
Expand All @@ -153,7 +155,7 @@ def pundit_user
expect { get :show, params: { id: order.id } }.
to raise_error(ActiveRecord::RecordNotFound)
expect(ActiveSupport::Deprecation).to have_received(:warn).
with(/`resolve_admin` on pundit policy scope is deprecated/)
with(/`resolve_admin` method is deprecated/)
end
end

Expand All @@ -174,7 +176,7 @@ def send_request(order:)
expect(response).to redirect_to([:admin, order])
expect(order.reload.address_line_one).to eq("22 Acacia Avenue")
expect(ActiveSupport::Deprecation).to have_received(:warn).
with(/`resolve_admin` on pundit policy scope is deprecated/)
with(/`resolve_admin` method is deprecated/)
end

it "does not allow me to update other users' records" do
Expand All @@ -184,7 +186,7 @@ def send_request(order:)
send_request(order: order)
end.to raise_error(ActiveRecord::RecordNotFound)
expect(ActiveSupport::Deprecation).to have_received(:warn).
with(/`resolve_admin` on pundit policy scope is deprecated/)
with(/`resolve_admin` method is deprecated/)
end
end

Expand Down

0 comments on commit aab1325

Please sign in to comment.