From fde9bed7208f1127285f0c1241a5e1f3fd49d621 Mon Sep 17 00:00:00 2001 From: Andrew Bromwich Date: Tue, 30 Apr 2024 11:23:36 +1000 Subject: [PATCH] Update Applicants#advance_applicant to support funnel_id --- lib/fountain.rb | 1 + lib/fountain/api/applicants.rb | 2 +- spec/fountain/api/applicants_spec.rb | 21 +++++++++++++++++++++ spec/spec_helper.rb | 6 ++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/fountain.rb b/lib/fountain.rb index ee773c7..4ce9b75 100644 --- a/lib/fountain.rb +++ b/lib/fountain.rb @@ -3,6 +3,7 @@ require 'fountain/gem_version' require 'json' +require 'forwardable' require 'fountain/configuration' require 'fountain/util' diff --git a/lib/fountain/api/applicants.rb b/lib/fountain/api/applicants.rb index 942d182..a752c6d 100644 --- a/lib/fountain/api/applicants.rb +++ b/lib/fountain/api/applicants.rb @@ -130,7 +130,7 @@ def self.advance_applicant(applicant_id, advance_options = {}) method: :put, body: Util.slice_hash( advance_options, - :skip_automated_actions, :stage_id + :skip_automated_actions, :stage_id, :funnel_id ) ) check_response response, Net::HTTPNoContent diff --git a/spec/fountain/api/applicants_spec.rb b/spec/fountain/api/applicants_spec.rb index dc1580a..3fd1975 100644 --- a/spec/fountain/api/applicants_spec.rb +++ b/spec/fountain/api/applicants_spec.rb @@ -347,6 +347,16 @@ }.to_json ) .to_return(status: 204) + + stub_authed_request(:put, '/v2/applicants/01234567-0000-0000-0000-000000000002/advance') + .with( + body: { + skip_automated_actions: true, + stage_id: 'stage-id', + funnel_id: 'funnel-id' + }.to_json + ) + .to_return(status: 204) end it 'advances an applicant' do @@ -365,6 +375,17 @@ ) expect(result).to be true end + + it 'advances an applicant to a specific stage and funnel (ignoring non-standard arguments)' do + result = described_class.advance_applicant( + '01234567-0000-0000-0000-000000000002', + skip_automated_actions: true, + stage_id: 'stage-id', + funnel_id: 'funnel-id', + invalid_arg: 'should not be included' + ) + expect(result).to be true + end end describe '.advance_applicants' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 153897c..1a4c089 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -require 'simplecov' -SimpleCov.start +if ENV['CI'] == 'true' + require 'simplecov' + SimpleCov.start +end $LOAD_PATH.unshift File.expand_path('../lib', __dir__) require 'fountain'