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

Avoid changing method visibility when deprecating a method #2449

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def collection
end

def load_providers
Spree::Deprecation.warn('load_providers is deprecated. Please use load_payment_method_types instead.', caller)
load_payment_method_types
end
deprecate load_providers: :load_payment_method_types, deprecator: Spree::Deprecation

def load_payment_method_types
@payment_method_types = Rails.application.config.spree.payment_methods.sort_by(&:name)
Expand All @@ -60,10 +60,9 @@ def load_payment_method_types
end

def validate_payment_provider
Spree::Deprecation.warn('validate_payment_provider is deprecated. Please use validate_payment_method_type instead.', caller)
validate_payment_method_type
end
deprecate validate_payment_provider: :validate_payment_method_type,
deprecator: Spree::Deprecation

def validate_payment_method_type
requested_type = params[:payment_method].delete(:type)
Expand Down
8 changes: 5 additions & 3 deletions backend/app/controllers/spree/admin/resource_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ def parent_model_name
self.class.parent_data[:model_name].gsub('spree/', '')
end

alias_method :model_name, :parent_model_name
deprecate model_name: :parent_model_name, deprecator: Spree::Deprecation
def model_name
Spree::Deprecation.warn('model_name is deprecated. Please use parent_model_name instead.', caller)
parent_model_name
end

def object_name
controller_name.singularize
Expand Down Expand Up @@ -170,9 +172,9 @@ def load_resource_instance
end

def parent_data
Spree::Deprecation.warn('parent_data is deprecated without replacement.', caller)
self.class.parent_data
end
deprecate :parent_data, deprecator: Spree::Deprecation

def parent
if parent?
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,12 @@ def process_payments_before_complete
# }
#
def update_params_payment_source
Spree::Deprecation.warn('update_params_payment_source is deprecated. Please use set_payment_parameters_amount instead.', caller)
if @updating_params[:order] && (@updating_params[:order][:payments_attributes] || @updating_params[:order][:existing_card])
@updating_params[:order][:payments_attributes] ||= [{}]
@updating_params[:order][:payments_attributes].first[:amount] = total
end
end
deprecate update_params_payment_source: :set_payment_parameters_amount, deprecator: Spree::Deprecation

def associate_store
self.store ||= Spree::Store.default
Expand Down
1 change: 0 additions & 1 deletion core/app/models/spree/payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,5 @@ def gateway_class
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
end
end
deprecate provider_class: :gateway_class, deprecator: Spree::Deprecation
end
end
2 changes: 1 addition & 1 deletion core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ def generate
it 'is deprecated' do
subject.instance_variable_set('@updating_params', {})
expect(Spree::Deprecation).to receive(:warn)
subject.update_params_payment_source
subject.send(:update_params_payment_source)
end
end

Expand Down