tabletop-companion/test/models/table_invite_test.rb

40 lines
1013 B
Ruby
Raw Normal View History

2024-05-29 14:24:18 +00:00
# frozen_string_literal: true
require "test_helper"
class TableInviteTest < ActiveSupport::TestCase
test "accept! accepts the invite" do
invite = table_invites(:unaccepted)
user = User.find_by(email: invite.email)
assert_not_includes user.tables, invite.table
assert_nil invite.accepted_at
invite.accept!
assert_not_nil invite.accepted_at
assert_includes user.tables, invite.table
end
test "decline! declines the invite" do
invite = table_invites(:unaccepted)
assert_nil invite.declined_at
invite.decline!
assert_not_nil invite.declined_at
end
test "cannot accept a declined invitation" do
assert_raises do
table_invites(:declined).accept!
end
end
test "cannot decline an accepted invitation" do
assert_raises do
table_invites(:one).decline!
end
end
test "responded? is true for both accepted and declined invites" do
assert table_invites(:one).responded?
assert table_invites(:declined).responded?
end
end