cable_ready 5.0.0.pre8 → 5.0.0.pre9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -542
- data/Gemfile.lock +16 -78
- data/IMPLEMENTATION.md +93 -0
- data/README.md +35 -6
- data/Rakefile +0 -8
- data/app/assets/javascripts/cable_ready.js +959 -0
- data/app/assets/javascripts/cable_ready.min.js +2 -0
- data/app/assets/javascripts/cable_ready.min.js.map +1 -0
- data/app/assets/javascripts/cable_ready.umd.js +910 -0
- data/app/assets/javascripts/cable_ready.umd.min.js +2 -0
- data/app/assets/javascripts/cable_ready.umd.min.js.map +1 -0
- data/app/helpers/cable_ready_helper.rb +2 -1
- data/app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb +3 -3
- data/app/models/concerns/cable_ready/updatable.rb +55 -10
- data/cable_ready.gemspec +42 -0
- data/lib/cable_ready/engine.rb +40 -0
- data/lib/cable_ready/importmap.rb +2 -0
- data/lib/cable_ready/version.rb +1 -1
- data/lib/cable_ready.rb +1 -18
- data/package.json +51 -0
- data/rollup.config.js +75 -0
- data/test/dummy/app/models/dugong.rb +4 -0
- data/test/dummy/db/migrate/20220329222959_create_dugongs.rb +8 -0
- data/test/dummy/db/migrate/20220329230221_create_active_storage_tables.active_storage.rb +36 -0
- data/test/dummy/db/schema.rb +36 -1
- data/test/dummy/test/models/dugong_test.rb +7 -0
- data/test/lib/cable_ready/updatable_test.rb +23 -0
- data/yarn.lock +2817 -0
- metadata +145 -54
data/test/dummy/db/schema.rb
CHANGED
@@ -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:
|
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
|
@@ -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
|