summaryrefslogtreecommitdiffstats
path: root/l10n/nb_NO
diff options
context:
space:
mode:
authorJenkins for ownCloud <thomas.mueller@tmit.eu>2013-02-21 00:15:58 +0100
committerJenkins for ownCloud <thomas.mueller@tmit.eu>2013-02-21 00:15:58 +0100
commitdcd93a53e4f2d158cb67493ce94ff164bac8f0e8 (patch)
tree6dbd2faed1e6c62a919b425cc34da1576e855426 /l10n/nb_NO
parenteb3769e6d6e1b26d2c20c7b26c6a334a5d761f08 (diff)
downloadnextcloud-server-dcd93a53e4f2d158cb67493ce94ff164bac8f0e8.tar.gz
nextcloud-server-dcd93a53e4f2d158cb67493ce94ff164bac8f0e8.zip
[tx-robot] updated from transifex
Diffstat (limited to 'l10n/nb_NO')
-rw-r--r--l10n/nb_NO/files_trashbin.po30
1 files changed, 19 insertions, 11 deletions
diff --git a/l10n/nb_NO/files_trashbin.po b/l10n/nb_NO/files_trashbin.po
index d745e979401..81d8126f331 100644
--- a/l10n/nb_NO/files_trashbin.po
+++ b/l10n/nb_NO/files_trashbin.po
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: ownCloud\n"
"Report-Msgid-Bugs-To: http://bugs.owncloud.org/\n"
-"POT-Creation-Date: 2013-02-12 15:10+0100\n"
-"PO-Revision-Date: 2013-02-12 10:07+0000\n"
+"POT-Creation-Date: 2013-02-21 00:14+0100\n"
+"PO-Revision-Date: 2013-02-20 23:14+0000\n"
"Last-Translator: I Robot <owncloud-bot@tmit.eu>\n"
"Language-Team: Norwegian Bokmål (Norway) (http://www.transifex.com/projects/p/owncloud/language/nb_NO/)\n"
"MIME-Version: 1.0\n"
@@ -17,7 +17,7 @@ msgstr ""
"Language: nb_NO\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: ajax/delete.php:22
+#: ajax/delete.php:40
#, php-format
msgid "Couldn't delete %s permanently"
msgstr ""
@@ -27,35 +27,39 @@ msgstr ""
msgid "Couldn't restore %s"
msgstr ""
-#: js/trash.js:7 js/trash.js:94
+#: js/trash.js:7 js/trash.js:96
msgid "perform restore operation"
msgstr ""
-#: js/trash.js:33
+#: js/trash.js:34
msgid "delete file permanently"
msgstr ""
-#: js/trash.js:125 templates/index.php:17
+#: js/trash.js:121
+msgid "Delete permanently"
+msgstr ""
+
+#: js/trash.js:151 templates/index.php:17
msgid "Name"
msgstr "Navn"
-#: js/trash.js:126 templates/index.php:27
+#: js/trash.js:152 templates/index.php:27
msgid "Deleted"
msgstr ""
-#: js/trash.js:135
+#: js/trash.js:161
msgid "1 folder"
msgstr "1 mappe"
-#: js/trash.js:137
+#: js/trash.js:163
msgid "{count} folders"
msgstr "{count} mapper"
-#: js/trash.js:145
+#: js/trash.js:171
msgid "1 file"
msgstr "1 fil"
-#: js/trash.js:147
+#: js/trash.js:173
msgid "{count} files"
msgstr "{count} filer"
@@ -66,3 +70,7 @@ msgstr ""
#: templates/index.php:20 templates/index.php:22
msgid "Restore"
msgstr ""
+
+#: templates/index.php:30 templates/index.php:31
+msgid "Delete"
+msgstr ""
='n244' href='#n244'>244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
/**
* ownCloud
*
* @author Vincent Petry
* @copyright 2016 Vincent Petry <pvince81@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* comment 3 of the License, or any later comment.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/

describe('OCA.Comments.CommentsTabView tests', function() {
	var view, fileInfoModel;
	var fetchStub;
	var avatarStub;
	var testComments;
	var clock;

	/**
	 * Creates a dummy message with the given length
	 *
	 * @param {int} len length
	 * @return {string} message
	 */
	function createMessageWithLength(len) {
		var bigMessage = '';
		for (var i = 0; i < len; i++) {
			bigMessage += 'a';
		}
		return bigMessage;
	}

	beforeEach(function() {
		clock = sinon.useFakeTimers(Date.UTC(2016, 1, 3, 10, 5, 9));
		fetchStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'fetchNext');
		avatarStub = sinon.stub($.fn, 'avatar');
		view = new OCA.Comments.CommentsTabView();
		fileInfoModel = new OCA.Files.FileInfoModel({
			id: 5,
			name: 'One.txt',
			mimetype: 'text/plain',
			permissions: 31,
			path: '/subdir',
			size: 123456789,
			etag: 'abcdefg',
			mtime: Date.UTC(2016, 1, 0, 0, 0, 0)
		});
		view.render();
		var comment1 = new OCA.Comments.CommentModel({
			id: 1,
			actorType: 'users',
			actorId: 'user1',
			actorDisplayName: 'User One',
			objectType: 'files',
			objectId: 5,
			message: 'First',
			creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 0)).toUTCString()
		});
		var comment2 = new OCA.Comments.CommentModel({
			id: 2,
			actorType: 'users',
			actorId: 'user2',
			actorDisplayName: 'User Two',
			objectType: 'files',
			objectId: 5,
			message: 'Second\nNewline',
			creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 0, 0)).toUTCString()
		});
		var comment3 = new OCA.Comments.CommentModel({
			id: 3,
			actorId: 'anotheruser',
			actorDisplayName: 'Another User',
			actorType: 'users',
			verb: 'comment',
			message: 'Hail to thee, @macbeth. Yours faithfully, @banquo',
			creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString(),
			mentions: {
				0: {
					mentionDisplayName: "Thane of Cawdor",
					mentionId: "macbeth",
					mentionTye: "user"
				},
				1: {
					mentionDisplayName: "Lord Banquo",
					mentionId: "banquo",
					mentionTye: "user"
				}
			}
		});

		testComments = [comment1, comment2, comment3];
	});
	afterEach(function() {
		view.remove();
		view = undefined;
		fetchStub.restore();
		avatarStub.restore();
		clock.restore();
	});
	describe('rendering', function() {
		it('reloads matching comments when setting file info model', function() {
			view.setFileInfo(fileInfoModel);
			expect(fetchStub.calledOnce).toEqual(true);
		});

		it('renders loading icon while fetching comments', function() {
			view.setFileInfo(fileInfoModel);
			view.collection.trigger('request');

			expect(view.$el.find('.loading').length).toEqual(1);
			expect(view.$el.find('.comments li').length).toEqual(0);
		});

		it('renders comments', function() {
			view.setFileInfo(fileInfoModel);
			view.collection.set(testComments);

			var $comments = view.$el.find('.comments>li');
			expect($comments.length).toEqual(3);
			var $item = $comments.eq(0);
			expect($item.find('.author').text()).toEqual('User One');
			expect($item.find('.date').text()).toEqual('seconds ago');
			expect($item.find('.message').text()).toEqual('First');

			$item = $comments.eq(1);
			expect($item.find('.author').text()).toEqual('User Two');
			expect($item.find('.date').text()).toEqual('5 minutes ago');
			expect($item.find('.message').html()).toEqual('Second<br>Newline');
		});

		it('renders comments from deleted user differently', function() {
			testComments[0].set('actorType', 'deleted_users', {silent: true});
			view.collection.set(testComments);

			var $item = view.$el.find('.comment[data-id=1]');
			expect($item.find('.author').text()).toEqual('[Deleted user]');
			expect($item.find('.avatar').attr('data-username')).not.toBeDefined();
		});

		it('renders mentioned user id to avatar and displayname', function() {
			view.collection.set(testComments);

			var $comment = view.$el.find('.comment[data-id=3] .message');
			expect($comment.length).toEqual(1);
			expect($comment.find('.avatar[data-user=macbeth]').length).toEqual(1);
			expect($comment.find('strong:first').text()).toEqual('Thane of Cawdor');
			expect($comment.find('.avatar[data-user=macbeth] ~ .contactsmenu-popover').length).toEqual(1);

			expect($comment.find('.avatar[data-user=banquo]').length).toEqual(1);
			expect($comment.find('.avatar[data-user=banquo] ~ strong').text()).toEqual('Lord Banquo');
			expect($comment.find('.avatar[data-user=banquo] ~ .contactsmenu-popover').length).toEqual(1);
		});

	});
	describe('more comments', function() {
		var hasMoreResultsStub;

		beforeEach(function() {
			view.collection.set(testComments);
			hasMoreResultsStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'hasMoreResults');
		});
		afterEach(function() {
			hasMoreResultsStub.restore();
		});

		it('shows "More comments" button when more comments are available', function() {
			hasMoreResultsStub.returns(true);
			view.collection.trigger('sync');

			expect(view.$el.find('.showMore').hasClass('hidden')).toEqual(false);
		});
		it('does not show "More comments" button when more comments are available', function() {
			hasMoreResultsStub.returns(false);
			view.collection.trigger('sync');

			expect(view.$el.find('.showMore').hasClass('hidden')).toEqual(true);
		});
		it('fetches and appends the next page when clicking the "More" button', function() {
			hasMoreResultsStub.returns(true);

			expect(fetchStub.notCalled).toEqual(true);

			view.$el.find('.showMore').trigger('click');

			expect(fetchStub.calledOnce).toEqual(true);
		});
		it('appends comment to the list when added to collection', function() {
			var comment4 = new OCA.Comments.CommentModel({
				id: 4,
				actorType: 'users',
				actorId: 'user3',
				actorDisplayName: 'User Three',
				objectType: 'files',
				objectId: 5,
				message: 'Third',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 5, 0, 0)).toUTCString()
			});

			view.collection.add(comment4);

			expect(view.$el.find('.comments>li').length).toEqual(4);

			var $item = view.$el.find('.comments>li').eq(3);
			expect($item.find('.author').text()).toEqual('User Three');
			expect($item.find('.date').text()).toEqual('5 hours ago');
			expect($item.find('.message').html()).toEqual('Third');
		});
	});
	describe('posting comments', function() {
		var createStub;
		var currentUserStub;
		var $newCommentForm;

		beforeEach(function() {
			view.collection.set(testComments);
			createStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'create');
			currentUserStub = sinon.stub(OC, 'getCurrentUser');
			currentUserStub.returns({
				uid: 'testuser',
				displayName: 'Test User'
			});

			$newCommentForm = view.$el.find('.newCommentForm');

			// Required for the absolute selector used to find the new comment
			// after a successful creation in _onSubmitSuccess.
			$('#testArea').append(view.$el);
		});
		afterEach(function() {
			createStub.restore();
			currentUserStub.restore();
		});

		it('creates a new comment when clicking post button', function() {
			$newCommentForm.find('.message').text('New message');
			$newCommentForm.submit();

			expect(createStub.calledOnce).toEqual(true);
			expect(createStub.lastCall.args[0]).toEqual({
				actorId: 'testuser',
				actorDisplayName: 'Test User',
				actorType: 'users',
				verb: 'comment',
				message: 'New message',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
			});
		});
		it('creates a new comment when typing enter', function() {
			$newCommentForm.find('.message').text('New message');
			var keydownEvent = new $.Event('keydown', {keyCode: 13});
			$newCommentForm.find('.message').trigger(keydownEvent);

			expect(createStub.calledOnce).toEqual(true);
			expect(createStub.lastCall.args[0]).toEqual({
				actorId: 'testuser',
				actorDisplayName: 'Test User',
				actorType: 'users',
				verb: 'comment',
				message: 'New message',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
			});
			expect(keydownEvent.isDefaultPrevented()).toEqual(true);
		});
		it('creates a new mention when typing enter in the autocomplete popover', function() {
			var autoCompleteStub = sinon.stub(view, '_onAutoComplete');
			autoCompleteStub.callsArgWith(1, [{"id":"userId", "label":"User Name", "source":"users"}]);

			// Force the autocomplete to be initialized
			view._initAutoComplete($newCommentForm.find('.message'));

			// PhantomJS does not seem to handle typing in a contenteditable, so
			// some tricks are needed to show the autocomplete popover.
			//
			// Instead of sending key events to type "@u" the characters are
			// programatically set in the input field.
			$newCommentForm.find('.message').text('Mention to @u');

			// When focusing on the input field the caret is not guaranteed to
			// be at the end; instead of calling "focus()" on the input field
			// the caret is explicitly set at the end of the input field, that
			// is, after "@u".
			var range = document.createRange();
			range.selectNodeContents($newCommentForm.find('.message')[0]);
			range.collapse(false);
			var selection = window.getSelection();
			selection.removeAllRanges();
			selection.addRange(range);

			// As PhantomJS does not handle typing in a contenteditable the key
			// typed here is in practice ignored by At.js, but despite that it
			// will cause the popover to be shown.
			$newCommentForm.find('.message').trigger(new $.Event('keydown', {keyCode: 's'}));
			$newCommentForm.find('.message').trigger(new $.Event('keyup', {keyCode: 's'}));

			expect(autoCompleteStub.calledOnce).toEqual(true);

			var keydownEvent = new $.Event('keydown', {keyCode: 13});
			$newCommentForm.find('.message').trigger(keydownEvent);

			expect(createStub.calledOnce).toEqual(false);
			expect($newCommentForm.find('.message').html()).toContain('Mention to <span');
			expect($newCommentForm.find('.message').html()).toContain('<span class="avatar"');
			expect($newCommentForm.find('.message').html()).toContain('<strong>User Name</strong>');
			expect($newCommentForm.find('.message').text()).not.toContain('@');
			// In this case the default behaviour is prevented by the
			// "onKeydown" event handler of At.js.
			expect(keydownEvent.isDefaultPrevented()).toEqual(true);
		});
		it('creates a new line when typing shift+enter', function() {
			$newCommentForm.find('.message').text('New message');
			var keydownEvent = new $.Event('keydown', {keyCode: 13, shiftKey: true});
			$newCommentForm.find('.message').trigger(keydownEvent);

			expect(createStub.calledOnce).toEqual(false);
			// PhantomJS does not seem to handle typing in a contenteditable, so
			// instead of looking for a new line the best that can be done is
			// checking that the default behaviour would have been executed.
			expect($newCommentForm.find('.message').text()).toContain('New message');
			expect(keydownEvent.isDefaultPrevented()).toEqual(false);
		});
		it('creates a new comment with mentions when clicking post button', function() {
			$newCommentForm.find('.message').text('New message @anotheruser');
			$newCommentForm.submit();

			var createStubExpectedData = {
				actorId: 'testuser',
				actorDisplayName: 'Test User',
				actorType: 'users',
				verb: 'comment',
				message: 'New message @anotheruser',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
			};

			expect(createStub.calledOnce).toEqual(true);
			expect(createStub.lastCall.args[0]).toEqual(createStubExpectedData);

			var model = new OCA.Comments.CommentModel(_.extend({id: 4}, createStubExpectedData));
			var fetchStub = sinon.stub(model, 'fetch');
			// simulate the fact that create adds the model to the collection
			view.collection.add(model, {at: 0});
			createStub.yieldTo('success', model);

			expect(fetchStub.calledOnce).toEqual(true);

			// simulate the fact that fetch sets the attribute
			model.set('mentions', {
				0: {
					mentionDisplayName: "Another User",
					mentionId: "anotheruser",
					mentionTye: "user"
				}
			});
			fetchStub.yieldTo('success', model);

			// comment was added to the list
			var $comment = view.$el.find('.comment[data-id=4]');
			expect($comment.length).toEqual(1);
			var $message = $comment.find('.message');
			expect($message.html()).toContain('New message');
			expect($message.find('.avatar').length).toEqual(1);
			expect($message.find('.avatar[data-user=anotheruser]').length).toEqual(1);
			expect($message.find('.avatar[data-user=anotheruser] ~ strong').text()).toEqual('Another User');
			expect($message.find('.avatar[data-user=anotheruser] ~ .contactsmenu-popover').length).toEqual(1);
		});
		it('does not create a comment if the field is empty', function() {
			$newCommentForm.find('.message').val('   ');
			$newCommentForm.submit();

			expect(createStub.notCalled).toEqual(true);
		});
		it('does not create a comment if the field length is too large', function() {
			var bigMessage = '';
			for (var i = 0; i < view._commentMaxLength * 2; i++) {
				bigMessage += 'a';
			}
			$newCommentForm.find('.message').val(bigMessage);
			$newCommentForm.submit();

			expect(createStub.notCalled).toEqual(true);
		});
		describe('limit indicator', function() {
			var tooltipStub;
			var $message;
			var $submitButton;

			beforeEach(function() {
				tooltipStub = sinon.stub($.fn, 'tooltip');
				$message = $newCommentForm.find('.message');
				$submitButton = $newCommentForm.find('.submit');
			});
			afterEach(function() {
				tooltipStub.restore();
			});

			it('does not displays tooltip when limit is far away', function() {
				$message.val(createMessageWithLength(3));
				$message.trigger('change');

				expect(tooltipStub.calledWith('show')).toEqual(false);
				expect($submitButton.prop('disabled')).toEqual(false);
				expect($message.hasClass('error')).toEqual(false);
			});
			it('displays tooltip when limit is almost reached', function() {
				$message.text(createMessageWithLength(view._commentMaxLength - 2));
				$message.trigger('change');

				expect(tooltipStub.calledWith('show')).toEqual(true);
				expect($submitButton.prop('disabled')).toEqual(false);
				expect($message.hasClass('error')).toEqual(false);
			});
			it('displays tooltip and disabled button when limit is exceeded', function() {
				$message.text(createMessageWithLength(view._commentMaxLength + 2));
				$message.trigger('change');

				expect(tooltipStub.calledWith('show')).toEqual(true);
				expect($submitButton.prop('disabled')).toEqual(true);
				expect($message.hasClass('error')).toEqual(true);
			});
		});
	});
	describe('editing comments', function() {
		var saveStub;
		var fetchStub;
		var currentUserStub;

		beforeEach(function() {
			saveStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'save');
			fetchStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'fetch');
			currentUserStub = sinon.stub(OC, 'getCurrentUser');
			currentUserStub.returns({
				uid: 'testuser',
				displayName: 'Test User'
			});
			view.collection.add({
				id: 1,
				actorId: 'testuser',
				actorDisplayName: 'Test User',
				actorType: 'users',
				verb: 'comment',
				message: 'New message',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
			});
			view.collection.add({
				id: 2,
				actorId: 'anotheruser',
				actorDisplayName: 'Another User',
				actorType: 'users',
				verb: 'comment',
				message: 'New message from another user',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString(),
			});
			view.collection.add({
				id: 3,
				actorId: 'testuser',
				actorDisplayName: 'Test User',
				actorType: 'users',
				verb: 'comment',
				message: 'Hail to thee, @macbeth. Yours faithfully, @banquo',
				creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString(),
				mentions: {
					0: {
						mentionDisplayName: "Thane of Cawdor",
						mentionId: "macbeth",
						mentionTye: "user"
					},
					1: {
						mentionDisplayName: "Lord Banquo",
						mentionId: "banquo",
						mentionTye: "user"
					}
				}
			});
		});
		afterEach(function() {
			saveStub.restore();
			fetchStub.restore();
			currentUserStub.restore();
		});

		it('shows edit link for owner comments', function() {
			var $comment = view.$el.find('.comment[data-id=1]');
			expect($comment.length).toEqual(1);
			$comment.find('.action.more').trigger('click');
			expect($comment.find('.action.edit').length).toEqual(1);
		});

		it('does not show edit link for other user\'s comments', function() {
			var $comment = view.$el.find('.comment[data-id=2]');
			expect($comment.length).toEqual(1);
			$comment.find('.action.more').trigger('click');
			expect($comment.find('.action.edit').length).toEqual(0);
		});

		it('shows edit form when clicking edit', function() {
			var $comment = view.$el.find('.comment[data-id=1]');
			$comment.find('.action.more').trigger('click');
			$comment.find('.action.edit').trigger('click');

			expect($comment.hasClass('hidden')).toEqual(true);
			var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
			expect($formRow.length).toEqual(1);
		});

		it('saves message and updates comment item when clicking save', function() {
			var $comment = view.$el.find('.comment[data-id=1]');
			$comment.find('.action.more').trigger('click');
			$comment.find('.action.edit').trigger('click');

			var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
			expect($formRow.length).toEqual(1);

			$formRow.find('div.message').text('modified message');
			$formRow.find('form').submit();

			expect(saveStub.calledOnce).toEqual(true);
			expect(saveStub.lastCall.args[0]).toEqual({
				message: 'modified message'
			});

			var model = view.collection.get(1);
			// simulate the fact that save sets the attribute
			model.set('message', 'modified\nmessage');
			saveStub.yieldTo('success', model);
			view.collection.get(model);

			expect(fetchStub.called).toEqual(true);
			fetchStub.yieldTo('success', model);

			// original comment element is visible again
			expect($comment.hasClass('hidden')).toEqual(false);
			// and its message was updated
			expect($comment.find('.message').html()).toEqual('modified<br>message');

			// form row is gone
			$formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
			expect($formRow.length).toEqual(0);
		});

		it('saves message and updates comment item with mentions when clicking save', function() {
			var $comment = view.$el.find('.comment[data-id=3]');
			$comment.find('.action.more').trigger('click');
			$comment.find('.action.edit').trigger('click');

			var $formRow = view.$el.find('.newCommentRow.comment[data-id=3]');
			expect($formRow.length).toEqual(1);

			$formRow.find('div.message').text('modified\nmessage @anotheruser');
			$formRow.find('form').submit();

			expect(saveStub.calledOnce).toEqual(true);
			expect(saveStub.lastCall.args[0]).toEqual({
				message: 'modified\nmessage @anotheruser'
			});

			var model = view.collection.get(3);
			// simulate the fact that save sets the attribute
			model.set('message', 'modified\nmessage @anotheruser');
			saveStub.yieldTo('success', model);

			expect(fetchStub.called).toEqual(true);

			// simulate the fact that fetch sets the attribute
			model.set('mentions', {
				0: {
					mentionDisplayName: "Another User",
					mentionId: "anotheruser",
					mentionTye: "user"
				}
			});
			fetchStub.yieldTo('success', model);

			// original comment element is visible again
			expect($comment.hasClass('hidden')).toEqual(false);
			// and its message was updated
			var $message = $comment.find('.message');
			expect($message.html()).toContain('modified<br>message');
			expect($message.find('.avatar').length).toEqual(1);
			expect($message.find('.avatar[data-user=anotheruser]').length).toEqual(1);
			expect($message.find('.avatar[data-user=anotheruser] ~ strong').text()).toEqual('Another User');
			expect($message.find('.avatar[data-user=anotheruser] ~ .contactsmenu-popover').length).toEqual(1);

			// form row is gone
			$formRow = view.$el.find('.newCommentRow.comment[data-id=3]');
			expect($formRow.length).toEqual(0);
		});

		it('restores original comment when cancelling', function() {
			var $comment = view.$el.find('.comment[data-id=1]');
			$comment.find('.action.more').trigger('click');
			$comment.find('.action.edit').trigger('click');

			var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
			expect($formRow.length).toEqual(1);

			$formRow.find('textarea').val('modified\nmessage');
			$formRow.find('.cancel').trigger('click');

			expect(saveStub.notCalled).toEqual(true);

			// original comment element is visible again
			expect($comment.hasClass('hidden')).toEqual(false);
			// and its message was not updated
			expect($comment.find('.message').html()).toEqual('New message');

			// form row is gone
			$formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
			expect($formRow.length).toEqual(0);
		});

		it('destroys model when clicking delete', function() {
			var destroyStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'destroy');
			var $comment = view.$el.find('.comment[data-id=1]');
			$comment.find('.action.more').trigger('click');
			$comment.find('.action.delete').trigger('click');

			expect(destroyStub.calledOnce).toEqual(true);
			expect(destroyStub.thisValues[0].id).toEqual(1);

			destroyStub.yieldTo('success');

			// original comment element is gone
			$comment = view.$el.find('.comment[data-id=1]');
			expect($comment.length).toEqual(0);

			destroyStub.restore();
		});
		it('does not submit comment if the field is empty', function() {
			var $comment = view.$el.find('.comment[data-id=1]');
			$comment.find('.action.edit').trigger('click');
			$comment.find('.message').val('   ');
			$comment.find('form').submit();

			expect(saveStub.notCalled).toEqual(true);
		});
		it('does not submit comment if the field length is too large', function() {
			var $comment = view.$el.find('.comment[data-id=1]');
			$comment.find('.action.edit').trigger('click');
			$comment.find('.message').val(createMessageWithLength(view._commentMaxLength * 2));
			$comment.find('form').submit();

			expect(saveStub.notCalled).toEqual(true);
		});
	});
	describe('read marker', function() {
		var updateMarkerStub;

		beforeEach(function() {
			updateMarkerStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'updateReadMarker');
		});
		afterEach(function() {
			updateMarkerStub.restore();
		});

		it('resets the read marker after REPORT', function() {
			testComments[0].set('isUnread', true, {silent: true});
			testComments[1].set('isUnread', true, {silent: true});
			view.collection.set(testComments);
			view.collection.trigger('sync', 'REPORT');

			expect(updateMarkerStub.calledOnce).toEqual(true);
			expect(updateMarkerStub.lastCall.args[0]).toBeFalsy();
		});
		it('does not reset the read marker if there was no unread comments', function() {
			view.collection.set(testComments);
			view.collection.trigger('sync', 'REPORT');

			expect(updateMarkerStub.notCalled).toEqual(true);
		});
		it('does not reset the read marker when posting comments', function() {
			testComments[0].set('isUnread', true, {silent: true});
			testComments[1].set('isUnread', true, {silent: true});
			view.collection.set(testComments);
			view.collection.trigger('sync', 'POST');

			expect(updateMarkerStub.notCalled).toEqual(true);
		});
	});
});