bloom_remit 0.2.1 → 0.3.0

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
  SHA1:
3
- metadata.gz: 719f89bbf5856431f18ebe7c3950dd10f68f0a76
4
- data.tar.gz: 98a247d1cde20c61b91751b41673c5c9a18267a0
3
+ metadata.gz: 531182e14ce01cc26b8d22289c39e93b166e1e86
4
+ data.tar.gz: 8d1888fe7681b257dd8db0660241a4dd7cd513ce
5
5
  SHA512:
6
- metadata.gz: 628c4dfa4f89d444be0670ac3a5cb0465549b9dd0ce413c2043a607c92afdba3af4c960127851b6a0ee225cdcd7af7b5d5b09d07ff334abc4c0ab08223d4fb60
7
- data.tar.gz: 9ef5f0d779febd3e6318a9e35155145b7d620b2b397401619f6788f39a906314c45da16b38c39ef8d745b6f4430e671af5e5e540e1a7e05ba9d1aad092ac134c
6
+ metadata.gz: f68751ada937788bda344ab7e7ee27f08442b87f056cc2621db0163f4631041c719140ca08bacd5fba2da3f6c989d68e800baa80fc0c97e9c2c6164f2fec4440
7
+ data.tar.gz: 375a3ccba4528c9f026377c0aa9ad32abff5b88c46f93b2bd6e4e6f66a81111677f7fb46da2484b3f2daaa1728d787c38e1ad58cb679439975dba09f40c80614
@@ -12,6 +12,9 @@ module BloomRemit
12
12
  property :target_slug
13
13
  property :owner_id
14
14
  property :owner_type
15
+ property :external_id
16
+
17
+ validates :external_id, presence: true
15
18
 
16
19
  end
17
20
  end
@@ -1,7 +1,15 @@
1
1
  module BloomRemit
2
2
  class CreateTxn
3
3
 
4
- def self.call(target_slug:, sender:, owner:, amount:, account_name:, account_id:)
4
+ def self.call(
5
+ target_slug:,
6
+ sender:,
7
+ owner:,
8
+ amount:,
9
+ account_name:,
10
+ account_id:,
11
+ external_id:
12
+ )
5
13
  Txns::Operations::Create.(txn: {
6
14
  sender_id: sender.id,
7
15
  sender_type: sender.class.base_class.name,
@@ -11,6 +19,7 @@ module BloomRemit
11
19
  target_slug: target_slug,
12
20
  owner_id: owner.id,
13
21
  owner_type: owner.class.base_class.name,
22
+ external_id: external_id,
14
23
  })
15
24
  end
16
25
 
@@ -21,6 +21,7 @@ module BloomRemit
21
21
  payout_method: txn.target_slug,
22
22
  paid_in_orig_currency: txn.amount,
23
23
  receivable_in_dest_currency: txn.amount,
24
+ external_id: txn.external_id,
24
25
  )
25
26
  end
26
27
 
@@ -0,0 +1,6 @@
1
+ class AddExternalIdToTxns < ActiveRecord::Migration
2
+ def change
3
+ add_column :bloom_remit_txns, :external_id, :string, null: false
4
+ add_index :bloom_remit_txns, :external_id
5
+ end
6
+ end
@@ -4,6 +4,7 @@ FactoryGirl.define do
4
4
  target_slug "TARGET_SLUG"
5
5
  amount 2500
6
6
  secret { SecureRandom.uuid }
7
+ external_id { SecureRandom.hex(12) }
7
8
  end
8
9
 
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module BloomRemit
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ module BloomRemit
4
+ module Txns
5
+ module Contracts
6
+ RSpec.describe Create, type: %i[model] do
7
+
8
+ describe "validations" do
9
+ subject { described_class.new(Txn.new) }
10
+ it { is_expected.to validate_presence_of(:external_id) }
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -8,6 +8,7 @@ module BloomRemit
8
8
  let(:user) { create(:bloom_remit_dummy_sub_user) }
9
9
  let(:biller) { create(:bloom_remit_dummy_biller, slug: "PLDT") }
10
10
  let(:payment) { create(:bloom_remit_dummy_sub_payment) }
11
+ let(:external_id) { SecureRandom.hex(12) }
11
12
 
12
13
  it "creates a txn with a secret and enqueues the PayoutJob" do
13
14
  op = described_class.(txn: {
@@ -19,6 +20,7 @@ module BloomRemit
19
20
  account_id: "Hooli X",
20
21
  owner_id: payment.id,
21
22
  owner_type: payment.class.base_class.name,
23
+ external_id: external_id,
22
24
  })
23
25
  txn = op.model
24
26
  expect(txn.target_slug).to eq biller.slug
@@ -27,6 +29,7 @@ module BloomRemit
27
29
  expect(txn.account_name).to eq "028109090"
28
30
  expect(txn.account_id).to eq "Hooli X"
29
31
  expect(txn.owner).to eq payment
32
+ expect(txn.external_id).to eq external_id
30
33
  expect(PayoutJob).to have_enqueued_job(txn.id)
31
34
  end
32
35
 
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20160806054012) do
14
+ ActiveRecord::Schema.define(version: 20160808081300) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
@@ -40,8 +40,10 @@ ActiveRecord::Schema.define(version: 20160806054012) do
40
40
  t.string "target_slug", null: false
41
41
  t.string "owner_id"
42
42
  t.string "owner_type"
43
+ t.string "external_id", null: false
43
44
  end
44
45
 
46
+ add_index "bloom_remit_txns", ["external_id"], name: "index_bloom_remit_txns_on_external_id", using: :btree
45
47
  add_index "bloom_remit_txns", ["owner_id", "owner_type"], name: "index_bloom_remit_txns_on_owner_id_and_owner_type", using: :btree
46
48
 
47
49
  create_table "payments", force: :cascade do |t|
@@ -1630,4 +1630,84 @@ WHERE c.contype = 'f'
1630
1630
  AND t1.relname = 'users'
1631
1631
  AND t3.nspname = ANY (current_schemas(false))
1632
1632
  ORDER BY c.conname
1633
+ 
1634
+ ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
1635
+ Migrating to AddExternalIdToTxns (20160808081300)
1636
+  (0.1ms) BEGIN
1637
+  (14.0ms) ALTER TABLE "bloom_remit_txns" ADD "external_id" character varying NOT NULL
1638
+  (8.8ms) CREATE INDEX "index_bloom_remit_txns_on_external_id" ON "bloom_remit_txns" ("external_id")
1639
+ SQL (1.7ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160808081300"]]
1640
+  (0.6ms) COMMIT
1641
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1642
+  (2.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1643
+ FROM pg_constraint c
1644
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1645
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1646
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1647
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1648
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1649
+ WHERE c.contype = 'f'
1650
+ AND t1.relname = 'billers'
1651
+ AND t3.nspname = ANY (current_schemas(false))
1652
+ ORDER BY c.conname
1653
+
1654
+  (1.9ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1655
+ FROM pg_constraint c
1656
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1657
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1658
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1659
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1660
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1661
+ WHERE c.contype = 'f'
1662
+ AND t1.relname = 'bloom_remit_billers'
1663
+ AND t3.nspname = ANY (current_schemas(false))
1664
+ ORDER BY c.conname
1665
+ 
1666
+  (2.0ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1667
+ FROM pg_constraint c
1668
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1669
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1670
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1671
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1672
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1673
+ WHERE c.contype = 'f'
1674
+ AND t1.relname = 'bloom_remit_responses'
1675
+ AND t3.nspname = ANY (current_schemas(false))
1676
+ ORDER BY c.conname
1677
+
1678
+  (2.5ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1679
+ FROM pg_constraint c
1680
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1681
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1682
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1683
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1684
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1685
+ WHERE c.contype = 'f'
1686
+ AND t1.relname = 'bloom_remit_txns'
1687
+ AND t3.nspname = ANY (current_schemas(false))
1688
+ ORDER BY c.conname
1689
+ 
1690
+  (1.9ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1691
+ FROM pg_constraint c
1692
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1693
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1694
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1695
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1696
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1697
+ WHERE c.contype = 'f'
1698
+ AND t1.relname = 'payments'
1699
+ AND t3.nspname = ANY (current_schemas(false))
1700
+ ORDER BY c.conname
1701
+
1702
+  (2.3ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1703
+ FROM pg_constraint c
1704
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1705
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1706
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1707
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1708
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1709
+ WHERE c.contype = 'f'
1710
+ AND t1.relname = 'users'
1711
+ AND t3.nspname = ANY (current_schemas(false))
1712
+ ORDER BY c.conname
1633
1713