chore(pipedrive): remove pipedrive
This commit is contained in:
parent
202e310d03
commit
ca4066939c
18 changed files with 0 additions and 470 deletions
|
@ -1,62 +0,0 @@
|
|||
module Manager
|
||||
class DemandesController < Manager::ApplicationController
|
||||
def index
|
||||
@pending_demandes = pending_demandes
|
||||
end
|
||||
|
||||
def create_administrateur
|
||||
administrateur = current_super_admin.invite_admin(create_administrateur_params[:email])
|
||||
|
||||
if administrateur.errors.empty?
|
||||
PipedriveAcceptsDealsJob.perform_later(
|
||||
create_administrateur_params[:person_id],
|
||||
current_super_admin.id,
|
||||
create_administrateur_params[:stage_id]
|
||||
)
|
||||
|
||||
flash.notice = "Administrateur créé"
|
||||
redirect_to manager_demandes_path
|
||||
else
|
||||
flash.now.alert = administrateur.errors.full_messages.to_sentence
|
||||
@pending_demandes = pending_demandes
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
def refuse_administrateur
|
||||
PipedriveRefusesDealsJob.perform_later(
|
||||
refuse_administrateur_params[:person_id],
|
||||
current_super_admin.id
|
||||
)
|
||||
|
||||
AdministrationMailer
|
||||
.refuse_admin(refuse_administrateur_params[:email])
|
||||
.deliver_later
|
||||
|
||||
flash.notice = "La demande de #{refuse_administrateur_params[:email]} va être refusée"
|
||||
redirect_to manager_demandes_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_administrateur_params
|
||||
params.permit(:email, :person_id, :stage_id)
|
||||
end
|
||||
|
||||
def refuse_administrateur_params
|
||||
params.permit(:email, :person_id)
|
||||
end
|
||||
|
||||
def pending_demandes
|
||||
already_approved_emails = Administrateur.eager_load(:user)
|
||||
.where(users: { email: demandes.map { |d| d[:email] } })
|
||||
.map(&:email)
|
||||
|
||||
demandes.reject { |demande| already_approved_emails.include?(demande[:email]) }
|
||||
end
|
||||
|
||||
def demandes
|
||||
@demandes ||= PipedriveService.get_demandes
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
require "administrate/base_dashboard"
|
||||
|
||||
class DemandeDashboard < Administrate::BaseDashboard
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
module DemandeHelper
|
||||
def nb_of_procedures_options
|
||||
{
|
||||
'je ne sais pas' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_DO_NOT_KNOW_VALUE,
|
||||
'1' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_1_VALUE,
|
||||
'1 à 10' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_1_TO_10_VALUE,
|
||||
'10 à 100 ' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_10_TO_100_VALUE,
|
||||
'plus de 100' => Pipedrive::DealAdapter::PIPEDRIVE_NB_OF_PROCEDURES_ABOVE_100_VALUE
|
||||
}
|
||||
end
|
||||
|
||||
def deadline_options
|
||||
{
|
||||
'le plus vite possible' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_ASAP_VALUE,
|
||||
'dans les 3 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_3_MONTHS_VALUE,
|
||||
'dans les 6 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_6_MONTHS_VALUE,
|
||||
'dans les 12 prochains mois' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NEXT_12_MONTHS_VALUE,
|
||||
'pas de date' => Pipedrive::DealAdapter::PIPEDRIVE_DEADLINE_NO_DATE_VALUE
|
||||
}
|
||||
end
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
class PipedriveAcceptsDealsJob < ApplicationJob
|
||||
def perform(person_id, administration_id, stage_id)
|
||||
PipedriveService.accept_demande_from_person(person_id, administration_id, stage_id)
|
||||
end
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
class PipedriveRefusesDealsJob < ApplicationJob
|
||||
def perform(person_id, administration_id)
|
||||
PipedriveService.refuse_demande_from_person(person_id, administration_id)
|
||||
end
|
||||
end
|
|
@ -5,8 +5,4 @@ module BizDev
|
|||
def self.full_name(administration_id)
|
||||
NAME
|
||||
end
|
||||
|
||||
def self.pipedrive_id(administration_id)
|
||||
PIPEDRIVE_ID
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
class Pipedrive::API
|
||||
PIPEDRIVE_ALL_NOT_DELETED_DEALS = 'all_not_deleted'
|
||||
PIPEDRIVE_DEALS_URL = [PIPEDRIVE_API_URL, 'deals'].join("/")
|
||||
PIPEDRIVE_PEOPLE_URL = [PIPEDRIVE_API_URL, 'persons'].join("/")
|
||||
PIPEDRIVE_ORGANIZATIONS_URL = [PIPEDRIVE_API_URL, 'organizations'].join("/")
|
||||
|
||||
def self.get_persons_owned_by_user(user_id)
|
||||
url = PIPEDRIVE_PEOPLE_URL
|
||||
params = { user_id: user_id }
|
||||
|
||||
self.get(url, params)
|
||||
end
|
||||
|
||||
def self.get_deals_for_person(person_id)
|
||||
url = [PIPEDRIVE_PEOPLE_URL, person_id, "deals"].join('/')
|
||||
params = { status: PIPEDRIVE_ALL_NOT_DELETED_DEALS }
|
||||
|
||||
self.get(url, params)
|
||||
end
|
||||
|
||||
def self.put_deal(deal_id, params)
|
||||
url = [PIPEDRIVE_DEALS_URL, deal_id].join("/")
|
||||
|
||||
self.put(url, params)
|
||||
end
|
||||
|
||||
def self.post_deal(params)
|
||||
self.post(PIPEDRIVE_DEALS_URL, params)
|
||||
end
|
||||
|
||||
def self.put_person(person_id, params)
|
||||
url = [PIPEDRIVE_PEOPLE_URL, person_id].join("/")
|
||||
|
||||
self.put(url, params)
|
||||
end
|
||||
|
||||
def self.post_person(params)
|
||||
self.post(PIPEDRIVE_PEOPLE_URL, params)
|
||||
end
|
||||
|
||||
def self.post_organization(params)
|
||||
self.post(PIPEDRIVE_ORGANIZATIONS_URL, params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.get(url, params)
|
||||
params.merge!({
|
||||
start: 0,
|
||||
limit: 500,
|
||||
api_token: token
|
||||
})
|
||||
|
||||
response = Typhoeus.get(url, params: params)
|
||||
|
||||
if response.success?
|
||||
JSON.parse(response.body)['data']
|
||||
end
|
||||
end
|
||||
|
||||
def self.put(url, params)
|
||||
Typhoeus.put(
|
||||
url,
|
||||
params: { api_token: token },
|
||||
body: params.to_json,
|
||||
headers: { 'content-type' => 'application/json' }
|
||||
)
|
||||
end
|
||||
|
||||
def self.post(url, params)
|
||||
Typhoeus.post(
|
||||
url,
|
||||
params: { api_token: token },
|
||||
body: params.to_json,
|
||||
headers: { 'content-type' => 'application/json' }
|
||||
)
|
||||
end
|
||||
|
||||
def self.token
|
||||
Rails.application.secrets.pipedrive[:key]
|
||||
end
|
||||
end
|
|
@ -1,63 +0,0 @@
|
|||
class Pipedrive::DealAdapter
|
||||
PIPEDRIVE_ADMIN_CENTRAL_STOCK_STAGE_ID = 35
|
||||
PIPEDRIVE_SERVICE_DECO_REGIONAL_STOCK_STAGE_ID = 24
|
||||
PIPEDRIVE_SERVICE_DECO_DEPARTEMENTAL_STOCK_STAGE_ID = 20
|
||||
PIPEDRIVE_COLLECTIVITE_DEP_OU_REG_STOCK_STAGE_ID = 30
|
||||
PIPEDRIVE_COLLECTIVITE_LOCALE_STOCK_STAGE_ID = 40
|
||||
PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID = 1
|
||||
PIPEDRIVE_ORGANISMES_REFUSES_STOCK_STAGE_ID = 45
|
||||
PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID = 48
|
||||
|
||||
PIPEDRIVE_LOST_STATUS = "lost"
|
||||
PIPEDRIVE_LOST_REASON = "refusé depuis DS"
|
||||
|
||||
PIPEDRIVE_NB_OF_PROCEDURES_ATTRIBUTE_ID = "b22f8710352a7fb548623c062bf82ed6d1b6b704"
|
||||
PIPEDRIVE_NB_OF_PROCEDURES_DO_NOT_KNOW_VALUE = "Je ne sais pas"
|
||||
PIPEDRIVE_NB_OF_PROCEDURES_1_VALUE = "juste 1"
|
||||
PIPEDRIVE_NB_OF_PROCEDURES_1_TO_10_VALUE = "de 1 a 10"
|
||||
PIPEDRIVE_NB_OF_PROCEDURES_10_TO_100_VALUE = "de 10 a 100"
|
||||
PIPEDRIVE_NB_OF_PROCEDURES_ABOVE_100_VALUE = "Plus de 100"
|
||||
|
||||
PIPEDRIVE_DEADLINE_ATTRIBUTE_ID = "36a72c82af9d9f0d476b041ede8876844a249bf2"
|
||||
PIPEDRIVE_DEADLINE_ASAP_VALUE = "Le plus vite possible"
|
||||
PIPEDRIVE_DEADLINE_NEXT_3_MONTHS_VALUE = "Dans les 3 prochain mois"
|
||||
PIPEDRIVE_DEADLINE_NEXT_6_MONTHS_VALUE = "Dans les 6 prochain mois"
|
||||
PIPEDRIVE_DEADLINE_NEXT_12_MONTHS_VALUE = "Dans les 12 prochain mois"
|
||||
PIPEDRIVE_DEADLINE_NO_DATE_VALUE = "Pas de date"
|
||||
|
||||
def self.refuse_deal(deal_id, owner_id)
|
||||
params = {
|
||||
user_id: owner_id,
|
||||
stage_id: PIPEDRIVE_ORGANISMES_REFUSES_STOCK_STAGE_ID,
|
||||
status: PIPEDRIVE_LOST_STATUS,
|
||||
lost_reason: PIPEDRIVE_LOST_REASON
|
||||
}
|
||||
|
||||
Pipedrive::API.put_deal(deal_id, params)
|
||||
end
|
||||
|
||||
def self.get_deals_ids_for_person(person_id)
|
||||
deals = Pipedrive::API.get_deals_for_person(person_id) || []
|
||||
deals.map { |datum| datum['id'] }
|
||||
end
|
||||
|
||||
def self.update_deal_owner_and_stage(deal_id, owner_id, stage_id)
|
||||
params = { user_id: owner_id, stage_id: stage_id }
|
||||
|
||||
Pipedrive::API.put_deal(deal_id, params)
|
||||
end
|
||||
|
||||
def self.add_deal(organisation_id, person_id, title, nb_of_procedures, nb_of_dossiers, deadline)
|
||||
params = {
|
||||
org_id: organisation_id,
|
||||
person_id: person_id,
|
||||
title: title,
|
||||
user_id: Pipedrive::PersonAdapter::PIPEDRIVE_ROBOT_ID,
|
||||
"#{PIPEDRIVE_NB_OF_PROCEDURES_ATTRIBUTE_ID}": nb_of_procedures,
|
||||
value: nb_of_dossiers,
|
||||
"#{PIPEDRIVE_DEADLINE_ATTRIBUTE_ID}": deadline
|
||||
}
|
||||
|
||||
Pipedrive::API.post_deal(params)
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
class Pipedrive::OrganizationAdapter
|
||||
def self.add_organization(name, address)
|
||||
params = {
|
||||
name: name,
|
||||
owner_id: Pipedrive::PersonAdapter::PIPEDRIVE_ROBOT_ID,
|
||||
address: address
|
||||
}
|
||||
|
||||
response = Pipedrive::API.post_organization(params)
|
||||
|
||||
JSON.parse(response.body)['data']['id']
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
class Pipedrive::PersonAdapter
|
||||
PIPEDRIVE_POSTE_ATTRIBUTE_ID = '33a790746f1713d712fe97bcce9ac1ca6374a4d6'
|
||||
PIPEDRIVE_SOURCE_ATTRIBUTE_ID = '2fa7864f467ffa97721cbcd08df5a3d591b15f50'
|
||||
PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID = '2734a3ff19f4b88bd0d7b4cf02c47c7545617207'
|
||||
PIPEDRIVE_DEADLINE_ATTRIBUTE_ID = 'ef766dd14de7da246fb5fc1704f45d1f1830f6c9'
|
||||
PIPEDRIVE_ROBOT_ID = '11381160'
|
||||
|
||||
def self.get_demandes_from_persons_owned_by_robot
|
||||
demandes = Pipedrive::API.get_persons_owned_by_user(PIPEDRIVE_ROBOT_ID)
|
||||
|
||||
if demandes.present?
|
||||
demandes.map do |datum|
|
||||
{
|
||||
person_id: datum['id'],
|
||||
nom: datum['name'],
|
||||
poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID],
|
||||
email: datum.dig('email', 0, 'value'),
|
||||
tel: datum.dig('phone', 0, 'value'),
|
||||
organisation: datum['org_name'],
|
||||
nb_dossiers: datum[PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID],
|
||||
deadline: datum[PIPEDRIVE_DEADLINE_ATTRIBUTE_ID]
|
||||
}
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def self.update_person_owner(person_id, owner_id)
|
||||
params = { owner_id: owner_id }
|
||||
|
||||
Pipedrive::API.put_person(person_id, params)
|
||||
end
|
||||
|
||||
def self.add_person(email, phone, name, organization_id, poste, source, nb_of_dossiers, deadline)
|
||||
params = {
|
||||
email: email,
|
||||
phone: phone,
|
||||
name: name,
|
||||
org_id: organization_id,
|
||||
owner_id: PIPEDRIVE_ROBOT_ID,
|
||||
"#{PIPEDRIVE_POSTE_ATTRIBUTE_ID}": poste,
|
||||
"#{PIPEDRIVE_SOURCE_ATTRIBUTE_ID}": source,
|
||||
"#{PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID}": nb_of_dossiers,
|
||||
"#{PIPEDRIVE_DEADLINE_ATTRIBUTE_ID}": deadline
|
||||
}
|
||||
|
||||
response = Pipedrive::API.post_person(params)
|
||||
|
||||
JSON.parse(response.body)['data']['id']
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
class PipedriveService
|
||||
def self.accept_demande_from_person(person_id, administration_id, stage_id)
|
||||
owner_id = BizDev.pipedrive_id(administration_id)
|
||||
person_deals_ids = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id)
|
||||
person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.update_deal_owner_and_stage(deal_id, owner_id, stage_id) }
|
||||
Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id)
|
||||
end
|
||||
|
||||
def self.refuse_demande_from_person(person_id, administration_id)
|
||||
owner_id = BizDev.pipedrive_id(administration_id)
|
||||
person_deals_ids = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id)
|
||||
person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.refuse_deal(deal_id, owner_id) }
|
||||
Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id)
|
||||
end
|
||||
|
||||
def self.get_demandes
|
||||
Pipedrive::PersonAdapter.get_demandes_from_persons_owned_by_robot
|
||||
end
|
||||
|
||||
def self.add_demande(email, phone, name, poste, source, organization_name, address, nb_of_procedures, nb_of_dossiers, deadline)
|
||||
organization_id = Pipedrive::OrganizationAdapter.add_organization(organization_name, address)
|
||||
person_id = Pipedrive::PersonAdapter.add_person(email, phone, name, organization_id, poste, source, nb_of_dossiers, deadline)
|
||||
Pipedrive::DealAdapter.add_deal(organization_id, person_id, organization_name, nb_of_procedures, nb_of_dossiers, deadline)
|
||||
end
|
||||
end
|
|
@ -1,63 +0,0 @@
|
|||
<% content_for(:title) do %>
|
||||
<%= display_resource_name('Demandes') %>
|
||||
<% end %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
</header>
|
||||
<p class="main-content__header">
|
||||
Plus de 1000 dossiers et "le plus vite possible" 👉 c'est un VIP ❤️. Appelez-le 📞 pour répondre à ses questions.
|
||||
</p>
|
||||
<% if @pending_demandes.present? %>
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<table>
|
||||
<thead>
|
||||
<% keys = @pending_demandes.first.keys %>
|
||||
<tr>
|
||||
<% keys.each do |key| %>
|
||||
<th class="cell-label cell-label--string cell-label--false" scope="col" role="columnheader" aria-sort="none">
|
||||
<%= key %>
|
||||
</th>
|
||||
<% end %>
|
||||
<th class="cell-label cell-label--string cell-label--false" scope="col" role="columnheader" aria-sort="none">
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @pending_demandes.each do |demande| %>
|
||||
<tr>
|
||||
<% keys.each do |key| %>
|
||||
<td class="cell-data cell-data--string">
|
||||
<%= demande[key] %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td class="cell-data cell-data--string" style="text-align: center;">
|
||||
<%= form_tag(manager_demandes_create_administrateur_path) do -%>
|
||||
<%= select_tag "stage_id",
|
||||
options_for_select({
|
||||
"suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID
|
||||
|
||||
}),
|
||||
style: 'margin-bottom: 20px; width: inherit;' %>
|
||||
|
||||
<%= hidden_field_tag 'email', demande[:email] %>
|
||||
<%= hidden_field_tag 'person_id', demande[:person_id] %>
|
||||
|
||||
<%= submit_tag 'Créer' %>
|
||||
<% end -%>
|
||||
</td>
|
||||
<td class="cell-data cell-data--string" style="text-align: center;">
|
||||
<%= button_to('Refuser',
|
||||
manager_demandes_refuse_administrateur_path,
|
||||
params: { person_id: demande[:person_id], email: demande[:email] },
|
||||
style: 'background-color: #FFFFFF; color: #293f54; border: 1px solid #dfe0e1') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<% else %>
|
||||
<h1>Aucune demande</h1>
|
||||
<% end %>
|
|
@ -8,7 +8,6 @@ API_PARTICULIER_URL = ENV.fetch("API_PARTICULIER_URL", "https://particulier.api.
|
|||
API_TCHAP_URL = ENV.fetch("API_TCHAP_URL", "https://matrix.agent.tchap.gouv.fr/_matrix/identity/api/v1")
|
||||
API_COJO_URL = ENV.fetch("API_COJO_URL", nil)
|
||||
HELPSCOUT_API_URL = ENV.fetch("HELPSCOUT_API_URL", "https://api.helpscout.net/v2")
|
||||
PIPEDRIVE_API_URL = ENV.fetch("PIPEDRIVE_API_URL", "https://api.pipedrive.com/v1")
|
||||
SENDINBLUE_API_URL = ENV.fetch("SENDINBLUE_API_URL", "https://in-automate.sendinblue.com/api/v2")
|
||||
SENDINBLUE_API_V3_URL = ENV.fetch("SENDINBLUE_API_V3_URL", "https://api.sendinblue.com/v3")
|
||||
UNIVERSIGN_API_URL = ENV.fetch("UNIVERSIGN_API_URL", "https://ws.universign.eu/tsa/post/")
|
||||
|
|
|
@ -56,8 +56,6 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :dossiers, only: [:show]
|
||||
|
||||
resources :demandes, only: [:index]
|
||||
|
||||
resources :bill_signatures, only: [:index]
|
||||
|
||||
resources :exports, only: [:index, :show]
|
||||
|
@ -80,9 +78,6 @@ Rails.application.routes.draw do
|
|||
end
|
||||
resources :safe_mailers, only: [:index, :edit, :update, :destroy, :new, :create, :show]
|
||||
|
||||
post 'demandes/create_administrateur'
|
||||
post 'demandes/refuse_administrateur'
|
||||
|
||||
authenticate :super_admin do
|
||||
mount Flipper::UI.app(-> { Flipper.instance }) => "/features", as: :flipper
|
||||
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
|
||||
|
|
|
@ -45,8 +45,6 @@ defaults: &defaults
|
|||
api_key: <%= ENV['DOLIST_API_KEY'] %>
|
||||
api_entreprise:
|
||||
key: <%= ENV['API_ENTREPRISE_KEY'] %>
|
||||
pipedrive:
|
||||
key: <%= ENV['PIPEDRIVE_KEY'] %>
|
||||
mailtrap:
|
||||
username: <%= ENV['MAILTRAP_USERNAME'] %>
|
||||
password: <%= ENV['MAILTRAP_PASSWORD'] %>
|
||||
|
@ -111,8 +109,6 @@ test:
|
|||
key_derivation_salt: test-yyMmzM9cTSD1rs3Fq3hwt3hMNg4 # ggignore
|
||||
api_entreprise:
|
||||
key: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ik9oIHllYWgiLCJpYXQiOjE1MTYyMzkwMjJ9.f06sBo3q2Yxnw_TYPFUEs0CozBmcV-XniH_DeKNWzKE" # ggignore
|
||||
pipedrive:
|
||||
key: pipedrive_test_key
|
||||
france_connect_particulier:
|
||||
identifier: france_connect_test_identifier
|
||||
secret: france_connect_test_secret
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
describe Manager::DemandesController, type: :controller do
|
||||
let(:super_admin) { create(:super_admin) }
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
sign_in super_admin
|
||||
end
|
||||
|
||||
it "display pending demandes" do
|
||||
approved_administrateur = create(:administrateur, email: "approved@example.com")
|
||||
pending_demande = { email: 'pending@example.com' }
|
||||
demandes = [{ email: approved_administrateur.email }, pending_demande]
|
||||
allow(PipedriveService).to receive(:get_demandes).and_return(demandes)
|
||||
|
||||
get :index
|
||||
|
||||
expect(assigns(:pending_demandes)).to eq([pending_demande])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -19,20 +19,4 @@ describe BizDev, lib: true do
|
|||
it { is_expected.not_to be_empty }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pipedrive_id' do
|
||||
subject { described_class.pipedrive_id(administration_id) }
|
||||
|
||||
context 'when administration is a business developer' do
|
||||
let(:administration_id) { first_biz_dev_id }
|
||||
|
||||
it { is_expected.to be > 0 }
|
||||
end
|
||||
|
||||
context 'when administration is not a business developer' do
|
||||
let(:administration_id) { non_biz_dev_id }
|
||||
|
||||
it { is_expected.to be > 0 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
describe Pipedrive::DealAdapter do
|
||||
let(:url) { PIPEDRIVE_API_URL }
|
||||
let(:status) { 200 }
|
||||
let(:body) { '{}' }
|
||||
|
||||
before do
|
||||
stub_request(:get, url)
|
||||
.to_return(status: status, body: body)
|
||||
end
|
||||
|
||||
describe ".get_deals_ids_for_person" do
|
||||
let(:url) { %r{/persons/1/deals\?*} }
|
||||
subject { Pipedrive::DealAdapter.get_deals_ids_for_person('1') }
|
||||
|
||||
context "with valid data" do
|
||||
let(:body) { '{ "success": true, "data": [ { "id": 34 }, { "id": 35 } ] }' }
|
||||
it { is_expected.to eq [34, 35] }
|
||||
end
|
||||
|
||||
context "when no data are returned" do
|
||||
let(:body) { '{ "success": true, "data": null }' }
|
||||
it { is_expected.to eq [] }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue