Skip to content

Commit

Permalink
#1205 extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 30, 2024
1 parent 7c44366 commit c037b97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion objects/bout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def owner

def created
raise Nb::Urror, "#{@human} can't touch bout ##{@id}" unless mine?
@pgsql.exec('SELECT created FROM bout WHERE id = $1', [@id])[0]['created']
time = @pgsql.exec('SELECT created FROM bout WHERE id = $1', [@id])[0]['created']
Time.parse(time)
end

def title
raise Nb::Urror, "#{@human} can't touch bout ##{@id}" unless mine?
@pgsql.exec('SELECT title FROM bout WHERE id = $1', [@id])[0]['title']
end

def post(text)
Expand Down Expand Up @@ -93,6 +99,7 @@ def to_h
{
id: @id,
created: created,
title: title,
tags: tags.to_a,
guests: guests.to_a
}
Expand Down
9 changes: 9 additions & 0 deletions test/test_bout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,13 @@ def test_prohibits_existence_checking
assert(!bout.mine?)
assert(bout.exists?)
end

def test_turns_into_json
owner = Nb::Humans.new(test_pgsql).take(test_name).create
bouts = owner.bouts
bout = bouts.start('hi, друг!')
assert(bout.id.positive?)
assert(bout.title.include?('друг'))
assert(bout.created < Time.now)
end
end

0 comments on commit c037b97

Please sign in to comment.