test/comment_test.rb in tracker_api-1.7.1 vs test/comment_test.rb in tracker_api-1.8.0

- old
+ new

@@ -19,17 +19,59 @@ comment.text.must_equal text comment.clean?.must_equal true end + it 'can create a comment with file attachment' do + text = "Test creating a comment" + comment = nil + files = [File.expand_path('../Gemfile', File.dirname(__FILE__))] + VCR.use_cassette('create comment with attachment', record: :new_episodes) do + comment = story.create_comment(text: text, files: files) + end + comment.text.must_equal text + comment.attachments.size.must_equal 1 + comment.clean?.must_equal true + end + it 'can update an existing comment' do new_text = "#{existing_comment.text}+" existing_comment.text = new_text VCR.use_cassette('save comment', record: :new_episodes) do existing_comment.save end existing_comment.text.must_equal new_text existing_comment.clean?.must_equal true + end + + it 'can create attachments in a comment' do + files = [File.expand_path('../Gemfile', File.dirname(__FILE__))] + VCR.use_cassette('create attachments', record: :new_episodes) do + existing_comment.create_attachments(files: files) + existing_comment.attachments.size.must_equal 1 + existing_comment.clean?.must_equal true + end + end + + it 'can delete attachments in a comment' do + files = [File.expand_path('../Gemfile', File.dirname(__FILE__))] + VCR.use_cassette('delete attachments', record: :new_episodes) do + existing_comment.create_attachments(files: files) + existing_comment.attachments.size.must_equal 1 + existing_comment.delete_attachments + existing_comment.attachments.size.must_equal 0 + end + end + + it 'can delete a comment' do + VCR.use_cassette('delete comment', record: :new_episodes) do + current_story = project.story(story_id) + new_comment_id = current_story.create_comment(text: "test comment").id + current_story.comments.last.id.must_equal new_comment_id + current_story.comments.last.delete + current_story = project.story(story_id) + current_story.comments.last.id.wont_equal new_comment_id + end end end