-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajoute un model claim pour gérer les demandes
- Loading branch information
Showing
9 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CreateClaim < BaseInteractor | ||
def call | ||
claim = Claim.new(claim_params) | ||
if claim.save | ||
context.claim = claim | ||
else | ||
context.fail!(message: claim.errors.full_messages) | ||
end | ||
end | ||
|
||
private | ||
|
||
def claim_params | ||
{ | ||
sub: context.identity.sub, | ||
hubee_folder_id: context.folder.id, | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Claim < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
class StoreQuotientFamilial < BaseOrganizer | ||
organize UploadQuotientFamilialToHubEE | ||
organize UploadQuotientFamilialToHubEE, CreateClaim | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateClaims < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :claims do |t| | ||
t.string :sub | ||
t.string :hubee_folder_id | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :claim do | ||
sub { "uuid" } | ||
hubee_folder_id { "folder_uuid" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe CreateClaim, type: :interactor do | ||
describe ".call" do | ||
subject(:interactor) { described_class.call(**params) } | ||
|
||
let(:folder) { instance_double("HubEE::Folder", id: "folder_uuid") } | ||
let(:identity) { instance_double("PivotIdentity", sub: "real_uuid") } | ||
let(:params) do | ||
{ | ||
identity:, | ||
folder:, | ||
} | ||
end | ||
|
||
context "when the claim is created" do | ||
it { is_expected.to be_a_success } | ||
|
||
it "creates a claim" do | ||
expect { interactor }.to change(Claim, :count).by(1) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters