From 33bcc6a5f0a0a9637631a37dc904b0ed291f38dd Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Feldis <5403+jbfeldis@users.noreply.github.com> Date: Tue, 11 Jun 2024 17:59:07 +0200 Subject: [PATCH] Renomme le model en shipment parce que c'est mieux et beaucoup plus court --- .../create_quotient_familial_request.rb | 19 ------------------- app/interactors/create_shipment.rb | 19 +++++++++++++++++++ app/models/quotient_familial_request.rb | 2 -- app/models/shipment.rb | 2 ++ app/organizers/store_quotient_familial.rb | 2 +- ...84727_create_quotient_familial_requests.rb | 10 ---------- db/migrate/20240603084727_create_shipments.rb | 10 ++++++++++ db/schema.rb | 2 +- ...ient_familial_requests.rb => shipments.rb} | 2 +- ...equest_spec.rb => create_shipment_spec.rb} | 4 ++-- .../store_quotient_familial_spec.rb | 6 +++--- 11 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 app/interactors/create_quotient_familial_request.rb create mode 100644 app/interactors/create_shipment.rb delete mode 100644 app/models/quotient_familial_request.rb create mode 100644 app/models/shipment.rb delete mode 100644 db/migrate/20240603084727_create_quotient_familial_requests.rb create mode 100644 db/migrate/20240603084727_create_shipments.rb rename spec/factories/{quotient_familial_requests.rb => shipments.rb} (68%) rename spec/interactors/{create_quotient_familial_request_spec.rb => create_shipment_spec.rb} (77%) diff --git a/app/interactors/create_quotient_familial_request.rb b/app/interactors/create_quotient_familial_request.rb deleted file mode 100644 index 1b73caf3..00000000 --- a/app/interactors/create_quotient_familial_request.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateQuotientFamilialRequest < BaseInteractor - def call - quotient_familial_request = QuotientFamilialRequest.new(params) - if quotient_familial_request.save - context.quotient_familial_request = quotient_familial_request - else - context.fail!(message: quotient_familial_request.errors.full_messages) - end - end - - private - - def params - { - sub: context.identity.sub, - hubee_folder_id: context.folder.id, - } - end -end diff --git a/app/interactors/create_shipment.rb b/app/interactors/create_shipment.rb new file mode 100644 index 00000000..8c3ee83d --- /dev/null +++ b/app/interactors/create_shipment.rb @@ -0,0 +1,19 @@ +class CreateShipment < BaseInteractor + def call + shipment = Shipment.new(params) + if shipment.save + context.shipment = shipment + else + context.fail!(message: shipment.errors.full_messages) + end + end + + private + + def params + { + sub: context.identity.sub, + hubee_folder_id: context.folder.id, + } + end +end diff --git a/app/models/quotient_familial_request.rb b/app/models/quotient_familial_request.rb deleted file mode 100644 index fd21869a..00000000 --- a/app/models/quotient_familial_request.rb +++ /dev/null @@ -1,2 +0,0 @@ -class QuotientFamilialRequest < ApplicationRecord -end diff --git a/app/models/shipment.rb b/app/models/shipment.rb new file mode 100644 index 00000000..fcdecddd --- /dev/null +++ b/app/models/shipment.rb @@ -0,0 +1,2 @@ +class Shipment < ApplicationRecord +end diff --git a/app/organizers/store_quotient_familial.rb b/app/organizers/store_quotient_familial.rb index b84ffc2f..28059138 100644 --- a/app/organizers/store_quotient_familial.rb +++ b/app/organizers/store_quotient_familial.rb @@ -1,3 +1,3 @@ class StoreQuotientFamilial < BaseOrganizer - organize UploadQuotientFamilialToHubEE, CreateQuotientFamilialRequest + organize UploadQuotientFamilialToHubEE, CreateShipment end diff --git a/db/migrate/20240603084727_create_quotient_familial_requests.rb b/db/migrate/20240603084727_create_quotient_familial_requests.rb deleted file mode 100644 index 5ed6c06b..00000000 --- a/db/migrate/20240603084727_create_quotient_familial_requests.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateQuotientFamilialRequests < ActiveRecord::Migration[7.1] - def change - create_table :quotient_familial_requests do |t| - t.string :sub - t.string :hubee_folder_id - - t.timestamps - end - end -end diff --git a/db/migrate/20240603084727_create_shipments.rb b/db/migrate/20240603084727_create_shipments.rb new file mode 100644 index 00000000..97a4ca26 --- /dev/null +++ b/db/migrate/20240603084727_create_shipments.rb @@ -0,0 +1,10 @@ +class CreateShipments < ActiveRecord::Migration[7.1] + def change + create_table :shipments do |t| + t.string :sub + t.string :hubee_folder_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4f9a417c..0df84c73 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,7 +14,7 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "quotient_familial_requests", force: :cascade do |t| + create_table "shipments", force: :cascade do |t| t.string "sub" t.string "hubee_folder_id" t.datetime "created_at", null: false diff --git a/spec/factories/quotient_familial_requests.rb b/spec/factories/shipments.rb similarity index 68% rename from spec/factories/quotient_familial_requests.rb rename to spec/factories/shipments.rb index 4d291d28..664e1f47 100644 --- a/spec/factories/quotient_familial_requests.rb +++ b/spec/factories/shipments.rb @@ -1,5 +1,5 @@ FactoryBot.define do - factory :quotient_familial_request do + factory :shipment do sub { "uuid" } hubee_folder_id { "folder_uuid" } end diff --git a/spec/interactors/create_quotient_familial_request_spec.rb b/spec/interactors/create_shipment_spec.rb similarity index 77% rename from spec/interactors/create_quotient_familial_request_spec.rb rename to spec/interactors/create_shipment_spec.rb index 8333b1f9..4baeb192 100644 --- a/spec/interactors/create_quotient_familial_request_spec.rb +++ b/spec/interactors/create_shipment_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe CreateQuotientFamilialRequest, type: :interactor do +RSpec.describe CreateShipment, type: :interactor do describe ".call" do subject(:interactor) { described_class.call(**params) } @@ -17,7 +17,7 @@ it { is_expected.to be_a_success } it "creates a quotient familial request" do - expect { interactor }.to change(QuotientFamilialRequest, :count).by(1) + expect { interactor }.to change(Shipment, :count).by(1) end end end diff --git a/spec/organizers/store_quotient_familial_spec.rb b/spec/organizers/store_quotient_familial_spec.rb index 51083953..b6152444 100644 --- a/spec/organizers/store_quotient_familial_spec.rb +++ b/spec/organizers/store_quotient_familial_spec.rb @@ -4,7 +4,7 @@ let(:interactors) do [ UploadQuotientFamilialToHubEE, - CreateQuotientFamilialRequest, + CreateShipment, ] end @@ -37,8 +37,8 @@ it { is_expected.to be_a_success } - it "creates a quotient_familial_request" do - expect { organizer }.to change(QuotientFamilialRequest, :count).by(1) + it "creates a shipment" do + expect { organizer }.to change(Shipment, :count).by(1) end end end