Skip to content

Commit

Permalink
Fixes error pinned posting info missing when editing as mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Sep 10, 2019
1 parent 11b739a commit 278b9b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Model/Behavior/PostingBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public function updatePosting(Entry $posting, array $data, CurrentUserInterface

/// must be set for validation
$data['locked'] = $posting->get('locked');
$data['fixed'] = $posting->get('fixed');

$data['pid'] = $posting->get('pid');
$data['time'] = $posting->get('time');
$data['user_id'] = $posting->get('user_id');
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixture/EntryFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ class EntryFixture extends TestFixture
'time' => '2000-01-01 10:59:00',
'last_answer' => '2000-01-01 10:59:00',
'category_id' => 4, // accession = 1
'user_id' => 7
'user_id' => 7,
'fixed' => true,
],
// thread 6
// -------------------------------------
Expand Down
33 changes: 33 additions & 0 deletions tests/TestCase/Model/Behavior/PostingBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,39 @@ public function testCreateNewThreadButNoCategoryProvided()
$this->assertArrayHasKey('_required', $errors['category_id']);
}

public function testUpdateSuccesModOnPinnedPosting()
{
$now = (string)time();
$edit = ['subject' => $now];

$entity = $this->table->findById(11)->first();

$user = ['id' => 7, 'user_type' => 'mod', 'username' => 'bar'];
$user = CurrentUserFactory::createLoggedIn($user);

$result = $this->table->updatePosting($entity, $edit, $user);

$this->assertEmpty($result->getErrors());
$this->assertEquals($now, $result->get('subject'));
}

public function testUpdateFailureModOnOwnPosting()
{
$now = (string)time();
$edit = ['subject' => $now];

$entity = $this->table->findById(11)->first();
$entity->set('fixed', false);

$user = ['id' => 7, 'user_type' => 'mod', 'username' => 'bar'];
$user = CurrentUserFactory::createLoggedIn($user);

$result = $this->table->updatePosting($entity, $edit, $user);

$errors = $result->getErrors();
$this->assertArrayHasKey('isEditingAllowed', $errors['edited_by']);
}

public function testPrepareChildPosting()
{
$parent = [
Expand Down

0 comments on commit 278b9b4

Please sign in to comment.