cable_ready 5.0.0.pre8 → 5.0.0.pre9

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,40 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2021_09_13_191759) do
13
+ ActiveRecord::Schema.define(version: 2022_03_29_230221) do
14
+
15
+ create_table "active_storage_attachments", force: :cascade do |t|
16
+ t.string "name", null: false
17
+ t.string "record_type", null: false
18
+ t.integer "record_id", null: false
19
+ t.integer "blob_id", null: false
20
+ t.datetime "created_at", null: false
21
+ t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
22
+ t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
23
+ end
24
+
25
+ create_table "active_storage_blobs", force: :cascade do |t|
26
+ t.string "key", null: false
27
+ t.string "filename", null: false
28
+ t.string "content_type"
29
+ t.text "metadata"
30
+ t.string "service_name", null: false
31
+ t.bigint "byte_size", null: false
32
+ t.string "checksum", null: false
33
+ t.datetime "created_at", null: false
34
+ t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
35
+ end
36
+
37
+ create_table "active_storage_variant_records", force: :cascade do |t|
38
+ t.integer "blob_id", null: false
39
+ t.string "variation_digest", null: false
40
+ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
41
+ end
42
+
43
+ create_table "dugongs", force: :cascade do |t|
44
+ t.datetime "created_at", precision: 6, null: false
45
+ t.datetime "updated_at", precision: 6, null: false
46
+ end
14
47
 
15
48
  create_table "posts", force: :cascade do |t|
16
49
  t.string "title"
@@ -45,5 +78,7 @@ ActiveRecord::Schema.define(version: 2021_09_13_191759) do
45
78
  t.index ["team_id"], name: "index_users_on_team_id"
46
79
  end
47
80
 
81
+ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
82
+ add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
48
83
  add_foreign_key "posts", "users"
49
84
  end
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ class DugongTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -109,4 +109,27 @@ class CableReady::UpdatableTest < ActiveSupport::TestCase
109
109
 
110
110
  entity.fake_update
111
111
  end
112
+
113
+ test "updates the collection when a file is attached" do
114
+ mock_server = mock("server")
115
+ image = File.open(Rails.root.join("test", "fixtures", "files", "dugong.jpg"))
116
+ dugong = Dugong.create
117
+
118
+ mock_server.expects(:broadcast).with("gid://dummy/Dugong/1:images", {changed: ["id", "name", "record_type", "record_id", "blob_id", "created_at"]}).once
119
+ ActionCable.stubs(:server).returns(mock_server)
120
+
121
+ dugong.images.attach(io: image, filename: "dugong.jpg")
122
+ end
123
+
124
+ test "updates the collection when a file is destroyed" do
125
+ mock_server = mock("server")
126
+ image = File.open(Rails.root.join("test", "fixtures", "files", "dugong.jpg"))
127
+ dugong = Dugong.create
128
+ dugong.images.attach(io: image, filename: "dugong.jpg")
129
+
130
+ mock_server.expects(:broadcast).with("gid://dummy/Dugong/1:images", {changed: ["id", "name", "record_type", "record_id", "blob_id", "created_at"]}).once
131
+ ActionCable.stubs(:server).returns(mock_server)
132
+
133
+ dugong.images.first.destroy
134
+ end
112
135
  end