Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 03:08:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 03:08:05 +0300
commit47b8f79a0896f406008d5a7eda2781f8da301e91 (patch)
tree1f15328719ca1215a2bd0ec6650ece0ca59de3f4 /spec
parent52fe64b740a4ddbd5b085386dfe40fea191174ea (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/merge_request/user_posts_notes_spec.rb18
-rw-r--r--spec/javascripts/diffs/store/actions_spec.js3
-rw-r--r--spec/javascripts/ide/stores/actions_spec.js25
-rw-r--r--spec/javascripts/notes/stores/actions_spec.js39
-rw-r--r--spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb53
-rw-r--r--spec/lib/gitlab/kubernetes/helm/install_command_spec.rb84
-rw-r--r--spec/services/notes/create_service_spec.rb13
-rw-r--r--spec/support/shared_examples/graphql/notes_creation_shared_examples.rb1
8 files changed, 185 insertions, 51 deletions
diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb
index 733d79127f7..c0655581b18 100644
--- a/spec/features/merge_request/user_posts_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_notes_spec.rb
@@ -95,6 +95,24 @@ describe 'Merge request > User posts notes', :js do
end
end
+ describe 'reply on a deleted conversation' do
+ before do
+ visit project_merge_request_path(project, merge_request)
+ end
+
+ it 'shows an error message' do
+ find('.js-reply-button').click
+ note.delete
+
+ page.within('.discussion-reply-holder') do
+ fill_in 'note[note]', with: 'A reply'
+ click_button 'Comment'
+ wait_for_requests
+ expect(page).to have_content('Your comment could not be submitted because discussion to reply to cannot be found')
+ end
+ end
+ end
+
describe 'when previewing a note' do
it 'shows the toolbar buttons when editing a note' do
page.within('.js-main-target-form') do
diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js
index c716053b288..589bd0e649a 100644
--- a/spec/javascripts/diffs/store/actions_spec.js
+++ b/spec/javascripts/diffs/store/actions_spec.js
@@ -145,8 +145,7 @@ describe('DiffsStoreActions', () => {
});
describe('fetchDiffFilesBatch', () => {
- // eslint-disable-next-line jasmine/no-focused-tests
- fit('should fetch batch diff files', done => {
+ it('should fetch batch diff files', done => {
const endpointBatch = '/fetch/diffs_batch';
const batch1 = `${endpointBatch}?per_page=${DIFFS_PER_PAGE}`;
const batch2 = `${endpointBatch}?per_page=${DIFFS_PER_PAGE}&page=2`;
diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js
index 246b3995395..708c5ea75e0 100644
--- a/spec/javascripts/ide/stores/actions_spec.js
+++ b/spec/javascripts/ide/stores/actions_spec.js
@@ -12,6 +12,7 @@ import actions, {
renameEntry,
getBranchData,
createTempEntry,
+ discardAllChanges,
} from '~/ide/stores/actions';
import axios from '~/lib/utils/axios_utils';
import { createStore } from '~/ide/stores';
@@ -60,8 +61,9 @@ describe('Multi-file store actions', () => {
});
describe('discardAllChanges', () => {
+ let f;
beforeEach(() => {
- const f = file('discardAll');
+ f = file('discardAll');
f.changed = true;
store.state.openFiles.push(f);
@@ -89,6 +91,27 @@ describe('Multi-file store actions', () => {
.then(done)
.catch(done.fail);
});
+
+ it('closes the temp file if it was open', done => {
+ f.tempFile = true;
+
+ testAction(
+ discardAllChanges,
+ undefined,
+ store.state,
+ [
+ { type: types.DISCARD_FILE_CHANGES, payload: 'discardAll' },
+ { type: types.REMOVE_ALL_CHANGES_FILES },
+ ],
+ [
+ {
+ type: 'closeFile',
+ payload: jasmine.objectContaining({ path: 'discardAll' }),
+ },
+ ],
+ done,
+ );
+ });
});
describe('closeAllFiles', () => {
diff --git a/spec/javascripts/notes/stores/actions_spec.js b/spec/javascripts/notes/stores/actions_spec.js
index 3e0c90277ee..ec1f1392845 100644
--- a/spec/javascripts/notes/stores/actions_spec.js
+++ b/spec/javascripts/notes/stores/actions_spec.js
@@ -751,24 +751,54 @@ describe('Actions Notes Store', () => {
});
describe('saveNote', () => {
- const payload = { endpoint: TEST_HOST, data: { 'note[note]': 'some text' } };
+ const flashContainer = {};
+ const payload = { endpoint: TEST_HOST, data: { 'note[note]': 'some text' }, flashContainer };
describe('if response contains errors', () => {
const res = { errors: { something: ['went wrong'] } };
+ const error = { message: 'Unprocessable entity', response: { data: res } };
it('throws an error', done => {
actions
.saveNote(
{
commit() {},
- dispatch: () => Promise.resolve(res),
+ dispatch: () => Promise.reject(error),
},
payload,
)
.then(() => done.fail('Expected error to be thrown!'))
- .catch(error => {
- expect(error.message).toBe('Failed to save comment!');
+ .catch(err => {
+ expect(err).toBe(error);
+ expect(flashSpy).not.toHaveBeenCalled();
+ })
+ .then(done)
+ .catch(done.fail);
+ });
+ });
+
+ describe('if response contains errors.base', () => {
+ const res = { errors: { base: ['something went wrong'] } };
+ const error = { message: 'Unprocessable entity', response: { data: res } };
+
+ it('sets flash alert using errors.base message', done => {
+ actions
+ .saveNote(
+ {
+ commit() {},
+ dispatch: () => Promise.reject(error),
+ },
+ { ...payload, flashContainer },
+ )
+ .then(resp => {
+ expect(resp.hasFlash).toBe(true);
+ expect(flashSpy).toHaveBeenCalledWith(
+ 'Your comment could not be submitted because something went wrong',
+ 'alert',
+ flashContainer,
+ );
})
+ .catch(() => done.fail('Expected success response!'))
.then(done)
.catch(done.fail);
});
@@ -788,6 +818,7 @@ describe('Actions Notes Store', () => {
)
.then(data => {
expect(data).toBe(res);
+ expect(flashSpy).not.toHaveBeenCalled();
})
.then(done)
.catch(done.fail);
diff --git a/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb
index 7e9853cf9ea..82e15864687 100644
--- a/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb
@@ -13,40 +13,57 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
helm delete --purge app-name
EOS
end
end
- let(:tls_flags) do
- <<~EOS.squish
- --tls
- --tls-ca-cert /data/helm/app-name/config/ca.pem
- --tls-cert /data/helm/app-name/config/cert.pem
- --tls-key /data/helm/app-name/config/key.pem
- EOS
- end
-
- context 'when there is a ca.pem file' do
- let(:files) { { 'ca.pem': 'some file content' } }
+ context 'tillerless feature disabled' do
+ before do
+ stub_feature_flags(managed_apps_local_tiller: false)
+ end
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
helm init --upgrade
- for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
- #{helm_delete_command}
+ for i in $(seq 1 30); do helm version && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ helm delete --purge app-name
EOS
end
+ end
- let(:helm_delete_command) do
+ context 'when there is a ca.pem file' do
+ let(:files) { { 'ca.pem': 'some file content' } }
+
+ let(:tls_flags) do
<<~EOS.squish
- helm delete --purge app-name
- #{tls_flags}
+ --tls
+ --tls-ca-cert /data/helm/app-name/config/ca.pem
+ --tls-cert /data/helm/app-name/config/cert.pem
+ --tls-key /data/helm/app-name/config/key.pem
EOS
end
+
+ it_behaves_like 'helm commands' do
+ let(:commands) do
+ <<~EOS
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ #{helm_delete_command}
+ EOS
+ end
+
+ let(:helm_delete_command) do
+ <<~EOS.squish
+ helm delete --purge app-name
+ #{tls_flags}
+ EOS
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
index a25b6b9a398..9c04e101e78 100644
--- a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
@@ -23,22 +23,14 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
)
end
- let(:tls_flags) do
- <<~EOS.squish
- --tls
- --tls-ca-cert /data/helm/app-name/config/ca.pem
- --tls-cert /data/helm/app-name/config/cert.pem
- --tls-key /data/helm/app-name/config/key.pem
- EOS
- end
-
subject { install_command }
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
helm repo add app-name https://repository.example.com
helm repo update
#{helm_install_comand}
@@ -50,7 +42,6 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
helm upgrade app-name chart-name
--install
--reset-values
- #{tls_flags}
--version 1.2.3
--set rbac.create\\=false,rbac.enabled\\=false
--namespace gitlab-managed-apps
@@ -59,8 +50,19 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
end
end
- context 'when rbac is true' do
- let(:rbac) { true }
+ context 'tillerless feature disabled' do
+ before do
+ stub_feature_flags(managed_apps_local_tiller: false)
+ end
+
+ let(:tls_flags) do
+ <<~EOS.squish
+ --tls
+ --tls-ca-cert /data/helm/app-name/config/ca.pem
+ --tls-cert /data/helm/app-name/config/cert.pem
+ --tls-key /data/helm/app-name/config/key.pem
+ EOS
+ end
it_behaves_like 'helm commands' do
let(:commands) do
@@ -69,6 +71,36 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
helm repo add app-name https://repository.example.com
helm repo update
+ #{helm_install_comand}
+ EOS
+ end
+
+ let(:helm_install_comand) do
+ <<~EOS.squish
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --version 1.2.3
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
+ EOS
+ end
+ end
+ end
+
+ context 'when rbac is true' do
+ let(:rbac) { true }
+
+ it_behaves_like 'helm commands' do
+ let(:commands) do
+ <<~EOS
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
+ helm repo add app-name https://repository.example.com
+ helm repo update
#{helm_install_command}
EOS
end
@@ -78,7 +110,6 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
helm upgrade app-name chart-name
--install
--reset-values
- #{tls_flags}
--version 1.2.3
--set rbac.create\\=true,rbac.enabled\\=true
--namespace gitlab-managed-apps
@@ -94,8 +125,9 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
helm repo add app-name https://repository.example.com
helm repo update
/bin/date
@@ -109,7 +141,6 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
helm upgrade app-name chart-name
--install
--reset-values
- #{tls_flags}
--version 1.2.3
--set rbac.create\\=false,rbac.enabled\\=false
--namespace gitlab-managed-apps
@@ -125,8 +156,9 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
helm repo add app-name https://repository.example.com
helm repo update
#{helm_install_command}
@@ -140,7 +172,6 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
helm upgrade app-name chart-name
--install
--reset-values
- #{tls_flags}
--version 1.2.3
--set rbac.create\\=false,rbac.enabled\\=false
--namespace gitlab-managed-apps
@@ -156,8 +187,9 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
helm repo add app-name https://repository.example.com
helm repo update
#{helm_install_command}
@@ -184,8 +216,9 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
it_behaves_like 'helm commands' do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version #{tls_flags} && s=0 && break || s=$?; sleep 1s; echo \"Retrying ($i)...\"; done; (exit $s)
+ export HELM_HOST="localhost:44134"
+ tiller -listen ${HELM_HOST} -alsologtostderr &
+ helm init --client-only
helm repo add app-name https://repository.example.com
helm repo update
#{helm_install_command}
@@ -197,7 +230,6 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
helm upgrade app-name chart-name
--install
--reset-values
- #{tls_flags}
--set rbac.create\\=false,rbac.enabled\\=false
--namespace gitlab-managed-apps
-f /data/helm/app-name/config/values.yaml
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index 79ea8f48a58..8fd03428eb2 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -382,6 +382,19 @@ describe Notes::CreateService do
end.to change { existing_note.type }.from(nil).to('DiscussionNote')
.and change { existing_note.updated_at }
end
+
+ context 'discussion to reply cannot be found' do
+ before do
+ existing_note.delete
+ end
+
+ it 'returns an note with errors' do
+ note = subject
+
+ expect(note.errors).not_to be_empty
+ expect(note.errors[:base]).to eq(['Discussion to reply to cannot be found'])
+ end
+ end
end
describe "usage counter" do
diff --git a/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb b/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb
index f2e1a95345b..522211340ea 100644
--- a/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb
+++ b/spec/support/shared_examples/graphql/notes_creation_shared_examples.rb
@@ -26,6 +26,7 @@ end
RSpec.shared_examples 'a Note mutation when there are active record validation errors' do |model: Note|
before do
expect_next_instance_of(model) do |note|
+ allow(note).to receive_message_chain(:errors, :empty?).and_return(true)
expect(note).to receive(:valid?).at_least(:once).and_return(false)
expect(note).to receive_message_chain(
:errors,