File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,6 +221,9 @@ def whitelist_params(params)
221221 invoice_custom_section = whitelist_invoice_custom_section_params ( params [ :invoice_custom_section ] )
222222 result [ :invoice_custom_section ] = invoice_custom_section if invoice_custom_section
223223
224+ activation_rules = whitelist_activation_rules_params ( params [ :activation_rules ] )
225+ result [ :activation_rules ] = activation_rules if activation_rules
226+
224227 { root_name => result }
225228 end
226229
@@ -287,6 +290,12 @@ def whitelist_payment_method_params(payment_method_param)
287290 payment_method_param &.slice ( :payment_method_type , :payment_method_id )
288291 end
289292
293+ def whitelist_activation_rules_params ( activation_rules_param )
294+ activation_rules_param &.map do |rule |
295+ ( rule || { } ) . slice ( :type , :timeout_hours )
296+ end
297+ end
298+
290299 def whitelist_invoice_custom_section_params ( invoice_custom_section_param )
291300 invoice_custom_section_param &.slice ( :skip_invoice_custom_sections , :invoice_custom_section_codes )
292301 end
Original file line number Diff line number Diff line change 164164 end
165165 end
166166
167+ context 'when activation_rules is provided' do
168+ let ( :params_with_activation_rules ) do
169+ params . merge (
170+ activation_rules : [
171+ { type : 'payment' , timeout_hours : 48 } ,
172+ ] ,
173+ )
174+ end
175+ let ( :body_with_activation_rules ) do
176+ {
177+ 'subscription' => params . merge (
178+ activation_rules : [
179+ { type : 'payment' , timeout_hours : 48 } ,
180+ ] ,
181+ ) ,
182+ }
183+ end
184+
185+ before do
186+ stub_request ( :post , 'https://api.getlago.com/api/v1/subscriptions' )
187+ . with ( body : body_with_activation_rules )
188+ . to_return ( body : response , status : 200 )
189+ end
190+
191+ it 'returns subscription' do
192+ subscription = resource . create ( params_with_activation_rules )
193+
194+ expect ( subscription . external_customer_id ) . to eq ( factory_subscription . external_customer_id )
195+ end
196+ end
197+
167198 context 'when payment_method_id is invalid' do
168199 let ( :params_with_invalid_pm ) do
169200 params . merge (
You can’t perform that action at this time.
0 commit comments