Skip to content

Commit 4947fe0

Browse files
authored
Merge pull request solidusio#3701 from filippoliverani/filippoliverani/remove_cancancan_customizations_cont
Remove CanCanCan custom actions aliases (cont.)
2 parents f36e61f + c92e13a commit 4947fe0

File tree

87 files changed

+395
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+395
-314
lines changed

api/app/controllers/spree/api/addresses_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class AddressesController < Spree::Api::BaseController
66
before_action :find_order
77

88
def show
9-
authorize! :read, @order, order_token
9+
authorize! :show, @order, order_token
1010
find_address
1111
respond_with(@address)
1212
end

api/app/controllers/spree/api/base_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ def find_product(id)
135135

136136
def product_scope
137137
if can?(:admin, Spree::Product)
138-
scope = Spree::Product.with_discarded.accessible_by(current_ability, :read).includes(*product_includes)
138+
scope = Spree::Product.with_discarded.accessible_by(current_ability).includes(*product_includes)
139139

140140
unless params[:show_deleted]
141141
scope = scope.not_deleted
142142
end
143143
else
144-
scope = Spree::Product.accessible_by(current_ability, :read).available.includes(*product_includes)
144+
scope = Spree::Product.accessible_by(current_ability).available.includes(*product_includes)
145145
end
146146

147147
scope
@@ -161,7 +161,7 @@ def order_id
161161

162162
def authorize_for_order
163163
@order = Spree::Order.find_by(number: order_id)
164-
authorize! :read, @order, order_token
164+
authorize! :show, @order, order_token
165165
end
166166

167167
def lock_order

api/app/controllers/spree/api/countries_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class CountriesController < Spree::Api::BaseController
77

88
def index
99
@countries = Spree::Country.
10-
accessible_by(current_ability, :read).
10+
accessible_by(current_ability).
1111
ransack(params[:q]).
1212
result.
1313
order('name ASC')
@@ -21,7 +21,7 @@ def index
2121
end
2222

2323
def show
24-
@country = Spree::Country.accessible_by(current_ability, :read).find(params[:id])
24+
@country = Spree::Country.accessible_by(current_ability, :show).find(params[:id])
2525
respond_with(@country)
2626
end
2727
end

api/app/controllers/spree/api/credit_cards_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CreditCardsController < Spree::Api::BaseController
99
def index
1010
@credit_cards = user
1111
.credit_cards
12-
.accessible_by(current_ability, :read)
12+
.accessible_by(current_ability)
1313
.with_payment_profile
1414
.ransack(params[:q]).result
1515

@@ -29,7 +29,7 @@ def update
2929

3030
def user
3131
if params[:user_id].present?
32-
@user ||= Spree.user_class.accessible_by(current_ability, :read).find(params[:user_id])
32+
@user ||= Spree.user_class.accessible_by(current_ability, :show).find(params[:user_id])
3333
end
3434
end
3535

api/app/controllers/spree/api/customer_returns_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def index
2323

2424
@customer_returns = @order.
2525
customer_returns.
26-
accessible_by(current_ability, :read).
26+
accessible_by(current_ability).
2727
ransack(params[:q]).
2828
result
2929

@@ -38,7 +38,7 @@ def new
3838

3939
def show
4040
authorize! :show, CustomerReturn
41-
@customer_return = @order.customer_returns.accessible_by(current_ability, :read).find(params[:id])
41+
@customer_return = @order.customer_returns.accessible_by(current_ability, :show).find(params[:id])
4242
respond_with(@customer_return)
4343
end
4444

@@ -56,7 +56,7 @@ def update
5656

5757
def load_order
5858
@order ||= Spree::Order.find_by!(number: order_id)
59-
authorize! :read, @order
59+
authorize! :show, @order
6060
end
6161

6262
def customer_return_params

api/app/controllers/spree/api/images_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ module Spree
44
module Api
55
class ImagesController < Spree::Api::BaseController
66
def index
7-
@images = scope.images.accessible_by(current_ability, :read)
7+
@images = scope.images.accessible_by(current_ability)
88
respond_with(@images)
99
end
1010

1111
def show
12-
@image = scope.images.accessible_by(current_ability, :read).find(params[:id])
12+
@image = scope.images.accessible_by(current_ability, :show).find(params[:id])
1313
respond_with(@image)
1414
end
1515

api/app/controllers/spree/api/inventory_units_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def update
2626
private
2727

2828
def inventory_unit
29-
@inventory_unit ||= Spree::InventoryUnit.accessible_by(current_ability, :read).find(params[:id])
29+
@inventory_unit ||= Spree::InventoryUnit.accessible_by(current_ability, :show).find(params[:id])
3030
end
3131

3232
def prepare_event

api/app/controllers/spree/api/option_types_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ module Api
55
class OptionTypesController < Spree::Api::BaseController
66
def index
77
if params[:ids]
8-
@option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability, :read).where(id: params[:ids].split(','))
8+
@option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability).where(id: params[:ids].split(','))
99
else
10-
@option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability, :read).load.ransack(params[:q]).result
10+
@option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability).load.ransack(params[:q]).result
1111
end
1212
respond_with(@option_types)
1313
end
1414

1515
def show
16-
@option_type = Spree::OptionType.accessible_by(current_ability, :read).find(params[:id])
16+
@option_type = Spree::OptionType.accessible_by(current_ability, :show).find(params[:id])
1717
respond_with(@option_type)
1818
end
1919

api/app/controllers/spree/api/option_values_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def destroy
4646

4747
def scope
4848
if params[:option_type_id]
49-
@scope ||= Spree::OptionType.find(params[:option_type_id]).option_values.accessible_by(current_ability, :read)
49+
@scope ||= Spree::OptionType.find(params[:option_type_id]).option_values.accessible_by(current_ability)
5050
else
51-
@scope ||= Spree::OptionValue.accessible_by(current_ability, :read).load
51+
@scope ||= Spree::OptionValue.accessible_by(current_ability).load
5252
end
5353
end
5454

api/app/controllers/spree/api/orders_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def empty
5353
end
5454

5555
def index
56-
authorize! :index, Order
56+
authorize! :admin, Order
5757
orders_includes = [
5858
{ user: :store_credits },
5959
:line_items,

0 commit comments

Comments
 (0)