aboutsummaryrefslogtreecommitdiffstats
path: root/models/action_test.go
diff options
context:
space:
mode:
authorLanre Adelowo <adelowomailbox@gmail.com>2019-02-10 20:27:19 +0100
committerLauris BH <lauris@nix.lv>2019-02-10 21:27:19 +0200
commit9d8178b3ac5f86a64f67ab7b5dea99347a5afe72 (patch)
treeed560142815927211f7d52db859728b88f0d9734 /models/action_test.go
parentc0adb5ea8bd0b2551a8c414b54ef5bc67882de55 (diff)
downloadgitea-9d8178b3ac5f86a64f67ab7b5dea99347a5afe72.tar.gz
gitea-9d8178b3ac5f86a64f67ab7b5dea99347a5afe72.zip
Add option to close issues via commit on a non master branch (#5992)
* fixes #5957 * add tests to make sure config option is respected * use already defined struct * - use migration to make the flag repo wide not for the entire gitea instance Also note that the config value can still be set so as to be able to control the value for new repositories that are to be created - fix copy/paste error in copyright header year and rearrange import - use repo config instead of server config value to determine if a commit should close an issue - update testsuite * use global config only when creating a new repository * allow repo admin toggle feature via UI * fix typo and improve testcase * fix fixtures * add DEFAULT prefix to config value * fix test
Diffstat (limited to 'models/action_test.go')
-rw-r--r--models/action_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/models/action_test.go b/models/action_test.go
index 0310b0ad5d..96d6ddb6dd 100644
--- a/models/action_test.go
+++ b/models/action_test.go
@@ -260,6 +260,40 @@ func TestUpdateIssuesCommit(t *testing.T) {
CheckConsistencyFor(t, &Action{})
}
+func TestUpdateIssuesCommit_Issue5957(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+ user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+
+ // Test that push to a non-default branch closes an issue.
+ pushCommits := []*PushCommit{
+ {
+ Sha1: "abcdef1",
+ CommitterEmail: "user2@example.com",
+ CommitterName: "User Two",
+ AuthorEmail: "user4@example.com",
+ AuthorName: "User Four",
+ Message: "close #2",
+ },
+ }
+
+ repo := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
+ commentBean := &Comment{
+ Type: CommentTypeCommitRef,
+ CommitSHA: "abcdef1",
+ PosterID: user.ID,
+ IssueID: 7,
+ }
+
+ issueBean := &Issue{RepoID: repo.ID, Index: 2, ID: 7}
+
+ AssertNotExistsBean(t, commentBean)
+ AssertNotExistsBean(t, issueBean, "is_closed=1")
+ assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, "non-existing-branch"))
+ AssertExistsAndLoadBean(t, commentBean)
+ AssertExistsAndLoadBean(t, issueBean, "is_closed=1")
+ CheckConsistencyFor(t, &Action{})
+}
+
func testCorrectRepoAction(t *testing.T, opts CommitRepoActionOptions, actionBean *Action) {
AssertNotExistsBean(t, actionBean)
assert.NoError(t, CommitRepoAction(opts))
option> Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/apps/testing/locking/fakedblockingprovider.php
blob: fd090e0e07564bcd956b7861484e6d73faa71765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
 * @author Joas Schilling <nickvergessen@owncloud.com>
 *
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

namespace OCA\Testing\Locking;

use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IDBConnection;
use OCP\ILogger;

class FakeDBLockingProvider extends \OC\Lock\DBLockingProvider {
	// Lock for 10 hours just to be sure
	const TTL = 36000;

	/**
	 * Need a new child, because parent::connection is private instead of protected...
	 * @var IDBConnection
	 */
	protected $db;

	/**
	 * @param \OCP\IDBConnection $connection
	 * @param \OCP\ILogger $logger
	 * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory
	 */
	public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory) {
		parent::__construct($connection, $logger, $timeFactory);
		$this->db = $connection;
	}


	/**
	 * @param string $path
	 * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
	 */
	public function releaseLock($path, $type) {
		// we DONT keep shared locks till the end of the request
		if ($type === self::LOCK_SHARED) {
			$this->db->executeUpdate(
				'UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `key` = ? AND `lock` = 1',
				[$path]
			);
		}

		parent::releaseLock($path, $type);
	}

	public function __destruct() {
		// Prevent cleaning up at the end of the live time.
		// parent::__destruct();
	}
}