effective_resources 1.12.1 → 1.12.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3db298e3e7c154dc1aa2dbec87f22bcd2fe0c20b9ab565bea13a8305f6ba04f3
4
- data.tar.gz: 6b79e28b6b7f8f7335313d769725e16f9f6deb799bdfa29fb0b1de6c5b459b3c
3
+ metadata.gz: 78a62dc6fc911b14bbf9972a75a5a4efcb8c1be89f049c67698a8eef4d3c4c65
4
+ data.tar.gz: 236d6cd2e737b360d0678ca861804f7a07f841b88bf6180befef3f55e2a5194d
5
5
  SHA512:
6
- metadata.gz: 82f53749182dc5a0f9b86c92171c0dc36eebf49fbeb874789a466143354fe28143c4d83e8caefae4b4e42f7157608ec58400f5ce4322b3609616ccf115d2235c
7
- data.tar.gz: c388f8c66074503b1d04874419b71a5d5054ececd383d33a45087f0a17f65007fbd3f9aeb7c457c5d61ac3c36d1931a6b734756ea55ef807bd54c827e5143884
6
+ metadata.gz: 0f3030caa00296cc2aa2af8c33eeaf77ad6a7b3a08bd601a563c422e605f75f0d8ce8070f5c389c2267aca25d62fba94f391404ca8d6b2de9ce8182f0ce005cb
7
+ data.tar.gz: 0ceda0d79b3f8a0c9783c997c3ca40b05e00e046f4f22917560bf983b021a4b963fe7d8fc37ffcd8e996e671bdc67a9b31d0390a2fa6b074f221a7c3a17d500d
@@ -24,10 +24,13 @@ module Effective
24
24
  def update
25
25
  Rails.logger.info 'Processed by Effective::WizardController#update'
26
26
 
27
+ action = (commit_action[:action] == :save ? :update : commit_action[:action])
28
+ EffectiveResources.authorize!(self, action, resource)
29
+
27
30
  resource.assign_attributes(send(resource_params_method_name))
28
31
  assign_current_step
29
32
 
30
- save_wizard_resource(resource)
33
+ save_wizard_resource(resource, action)
31
34
  end
32
35
 
33
36
  end
@@ -4,12 +4,17 @@ module Effective
4
4
 
5
5
  def save_wizard_resource(resource, action = nil, options = {})
6
6
  was_new_record = resource.new_record?
7
- action ||= resource.respond_to?("#{step}!") ? step : :save
7
+
8
+ if action.blank? || action == :update
9
+ action = resource.respond_to?("#{step}!") ? step : :save
10
+ end
8
11
 
9
12
  if save_resource(resource, action)
10
13
  flash[:success] ||= options.delete(:success) || resource_flash(:success, resource, action)
11
14
 
12
15
  @skip_to ||= skip_to_step(resource)
16
+
17
+ @redirect_to ||= resource_redirect_path(resource, action) if specific_redirect_path?(action)
13
18
  @redirect_to ||= resource_wizard_path(resource, @skip_to) if was_new_record
14
19
 
15
20
  if @redirect_to
@@ -62,7 +62,7 @@ module ActsAsPurchasableWizard
62
62
  end
63
63
 
64
64
  # From Billing Step
65
- order.billing_address = owner.billing_address if owner.billing_address.present?
65
+ order.billing_address = owner.billing_address if owner.try(:billing_address).present?
66
66
 
67
67
  # Important to add/remove anything
68
68
  order.save!
@@ -141,6 +141,10 @@ module ActsAsWizard
141
141
  module ClassMethods
142
142
  def acts_as_wizard?; true; end
143
143
 
144
+ def wizard_steps_hash
145
+ const_get(:WIZARD_STEPS)
146
+ end
147
+
144
148
  def all_wizard_steps
145
149
  const_get(:WIZARD_STEPS).keys
146
150
  end
@@ -95,8 +95,6 @@ module Effective
95
95
  relation.where(is_null("#{sql_column}_id")).where(is_null("#{sql_column}_type"))
96
96
  elsif type.present? && id.present? # This was from a polymorphic select
97
97
  relation.where("#{sql_column}_id = ?", id).where("#{sql_column}_type = ?", type)
98
- elsif name == :user # Polymorphic user
99
- relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
100
98
  else # Maybe from a string field
101
99
  collection = relation.none
102
100
 
@@ -106,7 +104,7 @@ module Effective
106
104
  resource = Effective::Resource.new(klass_name)
107
105
  next unless resource.klass.present?
108
106
 
109
- collection = collection.or(relation.where("#{name}_id": resource.search_any(term), "#{name}_type": klass_name))
107
+ collection = collection.or(relation.where("#{name}_id": resource.search_any(term, fuzzy: fuzzy), "#{name}_type": klass_name))
110
108
  end
111
109
 
112
110
  collection
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.12.1'.freeze
2
+ VERSION = '1.12.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails