Skip to content

Commit

Permalink
#1209 test for owner=
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 31, 2024
1 parent f686d24 commit b5dd2c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions objects/guests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def initialize(pgsql, human, bout)
@bout = bout
end

# Invite another user to this bout, where `guest` is the identity of the guest,
# not an object.
def invite(guest)
raise Nb::Urror, "#{@human} can't invite guests to bout ##{@id}" unless @bout.mine?
raise Nb::Urror, "@#{guest} is not a user" if @pgsql.exec(
Expand Down
11 changes: 11 additions & 0 deletions test/test_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,15 @@ def test_finds_by_date_intervals
assert_equal(1, human.search(Nb::Query.new("(posted<#{(DateTime.now + 1).iso8601(3)})"), 0, 10).to_a.size)
assert_equal(0, human.search(Nb::Query.new("(posted>#{(DateTime.now + 1).iso8601(3)})"), 0, 10).to_a.size)
end

def test_finds_by_bout_owner
human = Nb::Humans.new(test_pgsql).take(test_name).create
friend = Nb::Humans.new(test_pgsql).take(test_name).create
bouts = human.bouts
bout = bouts.start(test_name)
bout.post(test_name)
bout.guests.invite(friend.identity)
assert_equal(1, friend.search(Nb::Query.new("(owner=#{human.identity})"), 0, 10).to_a.size)
assert_equal(0, friend.search(Nb::Query.new("(owner=#{friend.identity})"), 0, 10).to_a.size)
end
end

0 comments on commit b5dd2c7

Please sign in to comment.