summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-11 00:06:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-11 00:06:24 +0000
commit133924c6cc443f5f69e1ab08d43b363d77677cb0 (patch)
treee893a7d36105fc4acec7038feae5f03bd34cfc2c /spec
parentf607152a0802a68067343ad73f989033cb8e9a06 (diff)
downloadgitlab-ce-133924c6cc443f5f69e1ab08d43b363d77677cb0.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/boards/boards_spec.rb8
-rw-r--r--spec/features/boards/sidebar_spec.rb9
-rw-r--r--spec/frontend/lib/utils/url_utility_spec.js18
-rw-r--r--spec/javascripts/boards/issue_card_spec.js11
-rw-r--r--spec/javascripts/boards/mock_data.js4
-rw-r--r--spec/javascripts/notes/components/discussion_filter_spec.js23
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/access_spec.rb22
-rw-r--r--spec/policies/global_policy_spec.rb8
-rw-r--r--spec/support/shared_examples/chat_slash_commands_shared_examples.rb24
-rw-r--r--spec/workers/prune_old_events_worker_spec.rb10
10 files changed, 112 insertions, 25 deletions
diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb
index 25aa1c1fb7d..e26582d3444 100644
--- a/spec/features/boards/boards_spec.rb
+++ b/spec/features/boards/boards_spec.rb
@@ -251,7 +251,7 @@ describe 'Issue Boards', :js do
expect(page).to have_selector(selector, text: development.title, count: 1)
end
- it 'issue moves between lists' do
+ it 'issue moves between lists and does not show the "Development" label since the card is in the "Development" list label' do
drag(list_from_index: 1, from_index: 1, list_to_index: 2)
wait_for_board_cards(2, 7)
@@ -259,10 +259,10 @@ describe 'Issue Boards', :js do
wait_for_board_cards(4, 1)
expect(find('.board:nth-child(3)')).to have_content(issue6.title)
- expect(find('.board:nth-child(3)').all('.board-card').last).to have_content(development.title)
+ expect(find('.board:nth-child(3)').all('.board-card').last).not_to have_content(development.title)
end
- it 'issue moves between lists' do
+ it 'issue moves between lists and does not show the "Planning" label since the card is in the "Planning" list label' do
drag(list_from_index: 2, list_to_index: 1)
wait_for_board_cards(2, 9)
@@ -270,7 +270,7 @@ describe 'Issue Boards', :js do
wait_for_board_cards(4, 1)
expect(find('.board:nth-child(2)')).to have_content(issue7.title)
- expect(find('.board:nth-child(2)').all('.board-card').first).to have_content(planning.title)
+ expect(find('.board:nth-child(2)').all('.board-card').first).not_to have_content(planning.title)
end
it 'issue moves from closed' do
diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb
index 8497eaf102f..2b923df40c5 100644
--- a/spec/features/boards/sidebar_spec.rb
+++ b/spec/features/boards/sidebar_spec.rb
@@ -304,7 +304,8 @@ describe 'Issue Boards', :js do
end
end
- expect(card).to have_selector('.badge', count: 3)
+ # 'Development' label does not show since the card is in a 'Development' list label
+ expect(card).to have_selector('.badge', count: 2)
expect(card).to have_content(bug.title)
end
@@ -330,7 +331,8 @@ describe 'Issue Boards', :js do
end
end
- expect(card).to have_selector('.badge', count: 4)
+ # 'Development' label does not show since the card is in a 'Development' list label
+ expect(card).to have_selector('.badge', count: 3)
expect(card).to have_content(bug.title)
expect(card).to have_content(regression.title)
end
@@ -357,7 +359,8 @@ describe 'Issue Boards', :js do
end
end
- expect(card).to have_selector('.badge', count: 1)
+ # 'Development' label does not show since the card is in a 'Development' list label
+ expect(card).to have_selector('.badge', count: 0)
expect(card).not_to have_content(stretch.title)
end
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js
index 41df93c9a48..6edb2e2dce2 100644
--- a/spec/frontend/lib/utils/url_utility_spec.js
+++ b/spec/frontend/lib/utils/url_utility_spec.js
@@ -136,6 +136,24 @@ describe('URL utility', () => {
});
});
+ describe('doesHashExistInUrl', () => {
+ it('should return true when the given string exists in the URL hash', () => {
+ setWindowLocation({
+ href: 'https://gitlab.com/gitlab-org/gitlab-test/issues/1#note_1',
+ });
+
+ expect(urlUtils.doesHashExistInUrl('note_')).toBe(true);
+ });
+
+ it('should return false when the given string does not exist in the URL hash', () => {
+ setWindowLocation({
+ href: 'https://gitlab.com/gitlab-org/gitlab-test/issues/1#note_1',
+ });
+
+ expect(urlUtils.doesHashExistInUrl('doesnotexist')).toBe(false);
+ });
+ });
+
describe('setUrlFragment', () => {
it('should set fragment when url has no fragment', () => {
const url = urlUtils.setUrlFragment('/home/feature', 'usage');
diff --git a/spec/javascripts/boards/issue_card_spec.js b/spec/javascripts/boards/issue_card_spec.js
index 9e99f961797..314e051665e 100644
--- a/spec/javascripts/boards/issue_card_spec.js
+++ b/spec/javascripts/boards/issue_card_spec.js
@@ -32,7 +32,10 @@ describe('Issue card component', () => {
beforeEach(() => {
setFixtures('<div class="test-container"></div>');
- list = listObj;
+ list = {
+ ...listObj,
+ type: 'label',
+ };
issue = new ListIssue({
title: 'Testing',
id: 1,
@@ -241,8 +244,8 @@ describe('Issue card component', () => {
Vue.nextTick(() => done());
});
- it('renders list label', () => {
- expect(component.$el.querySelectorAll('.badge').length).toBe(2);
+ it('does not render list label but renders all other labels', () => {
+ expect(component.$el.querySelectorAll('.badge').length).toBe(1);
});
it('renders label', () => {
@@ -278,7 +281,7 @@ describe('Issue card component', () => {
Vue.nextTick()
.then(() => {
- expect(component.$el.querySelectorAll('.badge').length).toBe(2);
+ expect(component.$el.querySelectorAll('.badge').length).toBe(1);
expect(component.$el.textContent).not.toContain('closed');
done();
diff --git a/spec/javascripts/boards/mock_data.js b/spec/javascripts/boards/mock_data.js
index 50ad1442873..41b8f567e08 100644
--- a/spec/javascripts/boards/mock_data.js
+++ b/spec/javascripts/boards/mock_data.js
@@ -15,7 +15,7 @@ export const listObj = {
weight: 3,
label: {
id: 5000,
- title: 'Testing',
+ title: 'Test',
color: 'red',
description: 'testing;',
textColor: 'white',
@@ -30,7 +30,7 @@ export const listObjDuplicate = {
weight: 3,
label: {
id: listObj.label.id,
- title: 'Testing',
+ title: 'Test',
color: 'red',
description: 'testing;',
},
diff --git a/spec/javascripts/notes/components/discussion_filter_spec.js b/spec/javascripts/notes/components/discussion_filter_spec.js
index 1c366aee8e2..7524de36ac5 100644
--- a/spec/javascripts/notes/components/discussion_filter_spec.js
+++ b/spec/javascripts/notes/components/discussion_filter_spec.js
@@ -160,5 +160,28 @@ describe('DiscussionFilter component', () => {
done();
});
});
+
+ it('fetches discussions when there is a hash', done => {
+ window.location.hash = `note_${discussionMock.notes[0].id}`;
+ vm.currentValue = discussionFiltersMock[2].value;
+ spyOn(vm, 'selectFilter');
+ vm.handleLocationHash();
+
+ vm.$nextTick(() => {
+ expect(vm.selectFilter).toHaveBeenCalled();
+ done();
+ });
+ });
+
+ it('does not fetch discussions when there is no hash', done => {
+ window.location.hash = '';
+ spyOn(vm, 'selectFilter');
+ vm.handleLocationHash();
+
+ vm.$nextTick(() => {
+ expect(vm.selectFilter).not.toHaveBeenCalled();
+ done();
+ });
+ });
});
});
diff --git a/spec/lib/gitlab/slash_commands/presenters/access_spec.rb b/spec/lib/gitlab/slash_commands/presenters/access_spec.rb
index f00039c634f..c7b83467660 100644
--- a/spec/lib/gitlab/slash_commands/presenters/access_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/access_spec.rb
@@ -3,6 +3,13 @@
require 'spec_helper'
describe Gitlab::SlashCommands::Presenters::Access do
+ shared_examples_for 'displays an error message' do
+ it do
+ expect(subject[:text]).to match(error_message)
+ expect(subject[:response_type]).to be(:ephemeral)
+ end
+ end
+
describe '#access_denied' do
let(:project) { build(:project) }
@@ -10,9 +17,18 @@ describe Gitlab::SlashCommands::Presenters::Access do
it { is_expected.to be_a(Hash) }
- it 'displays an error message' do
- expect(subject[:text]).to match('are not allowed')
- expect(subject[:response_type]).to be(:ephemeral)
+ it_behaves_like 'displays an error message' do
+ let(:error_message) { 'you do not have access to the GitLab project' }
+ end
+ end
+
+ describe '#deactivated' do
+ subject { described_class.new.deactivated }
+
+ it { is_expected.to be_a(Hash) }
+
+ it_behaves_like 'displays an error message' do
+ let(:error_message) { 'your account has been deactivated by your administrator' }
end
end
diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb
index 48f3d485f4b..880f1bcbc05 100644
--- a/spec/policies/global_policy_spec.rb
+++ b/spec/policies/global_policy_spec.rb
@@ -288,6 +288,14 @@ describe GlobalPolicy do
it { is_expected.not_to be_allowed(:use_slash_commands) }
end
+ context 'when deactivated' do
+ before do
+ current_user.deactivate
+ end
+
+ it { is_expected.not_to be_allowed(:use_slash_commands) }
+ end
+
context 'when access locked' do
before do
current_user.lock_access!
diff --git a/spec/support/shared_examples/chat_slash_commands_shared_examples.rb b/spec/support/shared_examples/chat_slash_commands_shared_examples.rb
index a99068ab678..370f2072705 100644
--- a/spec/support/shared_examples/chat_slash_commands_shared_examples.rb
+++ b/spec/support/shared_examples/chat_slash_commands_shared_examples.rb
@@ -94,16 +94,32 @@ RSpec.shared_examples 'chat slash commands service' do
subject.trigger(params)
end
+ shared_examples_for 'blocks command execution' do
+ it do
+ expect_any_instance_of(Gitlab::SlashCommands::Command).not_to receive(:execute)
+
+ result = subject.trigger(params)
+ expect(result[:text]).to match(error_message)
+ end
+ end
+
context 'when user is blocked' do
before do
chat_name.user.block
end
- it 'blocks command execution' do
- expect_any_instance_of(Gitlab::SlashCommands::Command).not_to receive(:execute)
+ it_behaves_like 'blocks command execution' do
+ let(:error_message) { 'you do not have access to the GitLab project' }
+ end
+ end
- result = subject.trigger(params)
- expect(result).to include(text: /^You are not allowed/)
+ context 'when user is deactivated' do
+ before do
+ chat_name.user.deactivate
+ end
+
+ it_behaves_like 'blocks command execution' do
+ let(:error_message) { 'your account has been deactivated by your administrator' }
end
end
end
diff --git a/spec/workers/prune_old_events_worker_spec.rb b/spec/workers/prune_old_events_worker_spec.rb
index f1eef1923bf..14235bde070 100644
--- a/spec/workers/prune_old_events_worker_spec.rb
+++ b/spec/workers/prune_old_events_worker_spec.rb
@@ -6,12 +6,12 @@ describe PruneOldEventsWorker do
describe '#perform' do
let(:user) { create(:user) }
- let!(:expired_event) { create(:event, :closed, author: user, created_at: 25.months.ago) }
+ let!(:expired_event) { create(:event, :closed, author: user, created_at: 37.months.ago) }
let!(:not_expired_1_day_event) { create(:event, :closed, author: user, created_at: 1.day.ago) }
let!(:not_expired_13_month_event) { create(:event, :closed, author: user, created_at: 13.months.ago) }
- let!(:not_expired_2_years_event) { create(:event, :closed, author: user, created_at: 2.years.ago) }
+ let!(:not_expired_3_years_event) { create(:event, :closed, author: user, created_at: 3.years.ago) }
- it 'prunes events older than 2 years' do
+ it 'prunes events older than 3 years' do
expect { subject.perform }.to change { Event.count }.by(-1)
expect(Event.find_by(id: expired_event.id)).to be_nil
end
@@ -26,9 +26,9 @@ describe PruneOldEventsWorker do
expect(not_expired_13_month_event.reload).to be_present
end
- it 'leaves events from 2 years ago' do
+ it 'leaves events from 3 years ago' do
subject.perform
- expect(not_expired_2_years_event).to be_present
+ expect(not_expired_3_years_event).to be_present
end
end
end