Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
083d64c646
commit
996f700997
9 changed files with 113 additions and 11 deletions
|
@ -59,6 +59,14 @@ module Subscribable
|
|||
.update(subscribed: false)
|
||||
end
|
||||
|
||||
def set_subscription(user, desired_state, project = nil)
|
||||
if desired_state
|
||||
subscribe(user, project)
|
||||
else
|
||||
unsubscribe(user, project)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def unsubscribe_from_other_levels(user, project)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Graphql mutation for (un)subscribing to an epic
|
||||
merge_request: 19083
|
||||
author:
|
||||
type: added
|
|
@ -271,6 +271,14 @@ The API can be explored interactively using the [GraphiQL IDE](../index.md#graph
|
|||
| `createNote` | Boolean! | Whether or not a user can perform `create_note` on this resource |
|
||||
| `awardEmoji` | Boolean! | Whether or not a user can perform `award_emoji` on this resource |
|
||||
|
||||
### EpicSetSubscriptionPayload
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | ---- | ---------- |
|
||||
| `clientMutationId` | String | A unique identifier for the client performing the mutation. |
|
||||
| `errors` | String! => Array | Reasons why the mutation failed. |
|
||||
| `epic` | Epic | The epic after mutation |
|
||||
|
||||
### EpicTreeReorderPayload
|
||||
|
||||
| Name | Type | Description |
|
||||
|
|
|
@ -128,6 +128,10 @@ module Gitlab
|
|||
def aws_arn_regex_message
|
||||
"must be a valid Amazon Resource Name"
|
||||
end
|
||||
|
||||
def utc_date_regex
|
||||
@utc_date_regex ||= /\A[0-9]{4}-[0-9]{2}-[0-9]{2}\z/.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4801,6 +4801,12 @@ msgstr ""
|
|||
msgid "Created a branch and a merge request to resolve this issue."
|
||||
msgstr ""
|
||||
|
||||
msgid "Created after"
|
||||
msgstr ""
|
||||
|
||||
msgid "Created before"
|
||||
msgstr ""
|
||||
|
||||
msgid "Created branch '%{branch_name}' and a merge request to resolve this issue."
|
||||
msgstr ""
|
||||
|
||||
|
@ -9153,6 +9159,9 @@ msgstr ""
|
|||
msgid "Invalid date"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid date format. Please use UTC format as YYYY-MM-DD"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid feature"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -41,6 +41,12 @@ class CustomEnvironment extends JSDOMEnvironment {
|
|||
this.global.fixturesBasePath = `${ROOT_PATH}/tmp/tests/frontend/fixtures${IS_EE ? '-ee' : ''}`;
|
||||
this.global.staticFixturesBasePath = `${ROOT_PATH}/spec/frontend/fixtures`;
|
||||
|
||||
/**
|
||||
* window.fetch() is required by the apollo-upload-client library otherwise
|
||||
* a ReferenceError is generated: https://github.com/jaydenseric/apollo-upload-client/issues/100
|
||||
*/
|
||||
this.global.fetch = () => {};
|
||||
|
||||
// Not yet supported by JSDOM: https://github.com/jsdom/jsdom/issues/317
|
||||
this.global.document.createRange = () => ({
|
||||
setStart: () => {},
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
/* eslint-disable no-unused-expressions, no-return-assign, no-param-reassign */
|
||||
/* eslint-disable no-unused-expressions */
|
||||
|
||||
export default class MockU2FDevice {
|
||||
constructor() {
|
||||
this.respondToAuthenticateRequest = this.respondToAuthenticateRequest.bind(this);
|
||||
this.respondToRegisterRequest = this.respondToRegisterRequest.bind(this);
|
||||
window.u2f || (window.u2f = {});
|
||||
window.u2f.register = (function(_this) {
|
||||
return function(appId, registerRequests, signRequests, callback) {
|
||||
return (_this.registerCallback = callback);
|
||||
};
|
||||
})(this);
|
||||
window.u2f.sign = (function(_this) {
|
||||
return function(appId, challenges, signRequests, callback) {
|
||||
return (_this.authenticateCallback = callback);
|
||||
};
|
||||
})(this);
|
||||
window.u2f.register = (appId, registerRequests, signRequests, callback) => {
|
||||
this.registerCallback = callback;
|
||||
};
|
||||
window.u2f.sign = (appId, challenges, signRequests, callback) => {
|
||||
this.authenticateCallback = callback;
|
||||
};
|
||||
}
|
||||
|
||||
respondToRegisterRequest(params) {
|
||||
|
|
|
@ -75,4 +75,14 @@ describe Gitlab::Regex do
|
|||
it { is_expected.not_to match('123456789012') }
|
||||
it { is_expected.not_to match('role/role-name') }
|
||||
end
|
||||
|
||||
describe '.utc_date_regex' do
|
||||
subject { described_class.utc_date_regex }
|
||||
|
||||
it { is_expected.to match('2019-10-20') }
|
||||
it { is_expected.to match('1990-01-01') }
|
||||
it { is_expected.not_to match('11-1234-90') }
|
||||
it { is_expected.not_to match('aa-1234-cc') }
|
||||
it { is_expected.not_to match('9/9/2018') }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -133,4 +133,60 @@ describe Subscribable, 'Subscribable' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#set_subscription' do
|
||||
shared_examples 'setting subscriptions' do
|
||||
context 'when desired_state is set to true' do
|
||||
context 'when a user is subscribed to the resource' do
|
||||
it 'keeps the user subscribed' do
|
||||
resource.subscriptions.create(user: user_1, subscribed: true, project: resource_project)
|
||||
|
||||
resource.set_subscription(user_1, true, resource_project)
|
||||
|
||||
expect(resource.subscribed?(user_1, resource_project)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a user is not subscribed to the resource' do
|
||||
it 'subscribes the user to the resource' do
|
||||
expect { resource.set_subscription(user_1, true, resource_project) }
|
||||
.to change { resource.subscribed?(user_1, resource_project) }
|
||||
.from(false).to(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when desired_state is set to false' do
|
||||
context 'when a user is subscribed to the resource' do
|
||||
it 'unsubscribes the user from the resource' do
|
||||
resource.subscriptions.create(user: user_1, subscribed: true, project: resource_project)
|
||||
|
||||
expect { resource.set_subscription(user_1, false, resource_project) }
|
||||
.to change { resource.subscribed?(user_1, resource_project) }
|
||||
.from(true).to(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a user is not subscribed to the resource' do
|
||||
it 'keeps the user unsubscribed' do
|
||||
resource.set_subscription(user_1, false, resource_project)
|
||||
|
||||
expect(resource.subscribed?(user_1, resource_project)).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'without project' do
|
||||
let(:resource_project) { nil }
|
||||
|
||||
it_behaves_like 'setting subscriptions'
|
||||
end
|
||||
|
||||
context 'with project' do
|
||||
let(:resource_project) { project }
|
||||
|
||||
it_behaves_like 'setting subscriptions'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue