add tests for controllers and ActionCable channels; improve main backend docs
This commit is contained in:
@@ -38,6 +38,27 @@ RSpec.describe User, type: :model do
|
||||
expect(duplicate).not_to be_valid
|
||||
expect(duplicate.errors[:nickname]).to be_present
|
||||
end
|
||||
|
||||
it "accepts valid image formats for avatar" do
|
||||
user = User.new(valid_attributes)
|
||||
user.avatar.attach(
|
||||
io: StringIO.new("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15c4"),
|
||||
filename: "avatar.png",
|
||||
content_type: "image/png"
|
||||
)
|
||||
expect(user).to be_valid
|
||||
end
|
||||
|
||||
it "rejects unsupported mime types for avatar" do
|
||||
user = User.new(valid_attributes)
|
||||
user.avatar.attach(
|
||||
io: StringIO.new("plain text"),
|
||||
filename: "test.txt",
|
||||
content_type: "text/plain"
|
||||
)
|
||||
expect(user).not_to be_valid
|
||||
expect(user.errors[:avatar]).to include("must be a PNG, JPEG, GIF or WebP image")
|
||||
end
|
||||
end
|
||||
|
||||
describe "rating" do
|
||||
|
||||
Reference in New Issue
Block a user