cats_core 1.2.4 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2026abe247e382b33bd737605c3aeeb4c4a26c431e557fc98a94234314170074
4
- data.tar.gz: d154ca8293fdcf4cff3de77d33542838e759ba0b46df48e3572036f589e15486
3
+ metadata.gz: 410f6f43a8f38fee7dc6fa2b1bfa35d57e33f15e34f5a2449820fe969cd94afc
4
+ data.tar.gz: e9e309081d7c9e253bf5eb5e1d1bc0ae5d78aedbcfa51585d2cc2f897e3e8edb
5
5
  SHA512:
6
- metadata.gz: d92b1ea622c407e0a418a469bf6ed429e76d035b77d3a20184108fc96d0b89241ef5d54bcff3f6d8a0fc0e2158d9a70adb2bdd4a2eaaf20298ae88b758cb7097
7
- data.tar.gz: 486d2a372a236e91e17142859c90a5bbb0b80d577787ce4bc710f064176a26fafbc8caaf2030fc2d085112dc708ec89d763391d5ab9c48cea4509ab99c58447e
6
+ metadata.gz: e3945bba2c0198ca40dd78ffae146adebfa75a5404918e46e6c354098bbdd5b78e4febedc8557776f7713a660bd1bf1adb47d535b24e2697e751a1d4894054f9
7
+ data.tar.gz: 220b1eebc52a63d51bc9c3f21cdf603116ea9e74fa2adf4bd40b2732fdefb93276fcc8b64c964ba1912c3b232aa6a9d6ee1b84f2a7f7961b6623fde8d506b1a6
@@ -1,8 +1,19 @@
1
1
  module Cats
2
2
  module Core
3
3
  class TransportServiceRequest < ApplicationRecord
4
- validates :reference_no, :request_date, presence: true
4
+ DRAFT = 'Draft'.freeze
5
+ APPROVED = 'Approved'.freeze
6
+ STATUSES = [DRAFT, APPROVED].freeze
7
+
8
+ belongs_to :requested_by, class_name: 'Cats::Core::User'
9
+ belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
10
+
11
+ validates :reference_no, :request_date, :status, presence: true
5
12
  validates :reference_no, uniqueness: true
13
+ validates :status, inclusion: { in: STATUSES }
14
+
15
+ delegate(:full_name, to: :requested_by, prefix: true, allow_nil: true)
16
+ delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
6
17
  end
7
18
  end
8
19
  end
@@ -50,6 +50,10 @@ module Cats
50
50
 
51
51
  errors.add(:phone_number, 'must be 10 or 12 digits and should match with local phone pattern')
52
52
  end
53
+
54
+ def full_name
55
+ "#{first_name} #{last_name}"
56
+ end
53
57
  end
54
58
  end
55
59
  end
@@ -3,6 +3,15 @@ class CreateCatsCoreTransportServiceRequests < ActiveRecord::Migration[6.1]
3
3
  create_table :cats_core_transport_service_requests do |t|
4
4
  t.string :reference_no, unique: true
5
5
  t.date :request_date, null: false
6
+ t.string :status, null: false, default: 'Draft'
7
+ t.references :requested_by,
8
+ null: false,
9
+ index: { name: 'tsr_on_rb_indx' },
10
+ foreign_key: { to_table: :cats_core_users }
11
+ t.references :approved_by,
12
+ null: true,
13
+ index: { name: 'tsr_on_ab_indx' },
14
+ foreign_key: { to_table: :cats_core_users }
6
15
 
7
16
  t.timestamps
8
17
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.4'.freeze
3
+ VERSION = '1.2.8'.freeze
4
4
  end
5
5
  end
@@ -2,5 +2,7 @@ FactoryBot.define do
2
2
  factory :transport_service_request, class: 'Cats::Core::TransportServiceRequest' do
3
3
  reference_no { FFaker::Name.name }
4
4
  request_date { Date.today }
5
+ requested_by factory: :user
6
+ approved_by factory: :user
5
7
  end
6
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.