mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-25 07:06:48 +09:00
Hello world
First open source release of Campfire 🎉
This commit is contained in:
commit
df76a227dc
664 files changed
+36235
No files matched your search
@@ -0,0 +1,45 @@
|
||||
require "test_helper"
|
||||
|
||||
class RoomsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in :david
|
||||
end
|
||||
|
||||
test "index redirects to the user's last room" do
|
||||
get rooms_url
|
||||
assert_redirected_to room_url(users(:david).rooms.last)
|
||||
end
|
||||
|
||||
test "show" do
|
||||
get room_url(users(:david).rooms.last)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "shows records the last room visited in a cookie" do
|
||||
get room_url(users(:david).rooms.last)
|
||||
assert response.cookies[:last_room] = users(:david).rooms.last.id
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
assert_turbo_stream_broadcasts :rooms, count: 1 do
|
||||
assert_difference -> { Room.count }, -1 do
|
||||
delete room_url(rooms(:designers))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "destroy only allowed for creators or those who can administer" do
|
||||
sign_in :jz
|
||||
|
||||
assert_no_difference -> { Room.count } do
|
||||
delete room_url(rooms(:designers))
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
rooms(:designers).update! creator: users(:jz)
|
||||
|
||||
assert_difference -> { Room.count }, -1 do
|
||||
delete room_url(rooms(:designers))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user