summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-07 06:08:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-07 06:08:23 +0000
commit7c33a59ac3b716b38baffbfe5c7f15e8104f3c6f (patch)
treedb23f9dfa479fdf0b06add2196617144c269166e /spec
parent0dce207848e4dd4425c116fb91a5cd2b41a8ec59 (diff)
downloadgitlab-ce-7c33a59ac3b716b38baffbfe5c7f15e8104f3c6f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/analytics/shared/components/daterange_spec.js2
-rw-r--r--spec/services/wiki_pages/create_service_spec.rb20
-rw-r--r--spec/services/wiki_pages/update_service_spec.rb22
3 files changed, 43 insertions, 1 deletions
diff --git a/spec/frontend/analytics/shared/components/daterange_spec.js b/spec/frontend/analytics/shared/components/daterange_spec.js
index 3b7574c1947..854582abb82 100644
--- a/spec/frontend/analytics/shared/components/daterange_spec.js
+++ b/spec/frontend/analytics/shared/components/daterange_spec.js
@@ -76,7 +76,7 @@ describe('Daterange component', () => {
});
it('displays the correct number of selected days in the indicator', () => {
- expect(findDateRangeIndicator().find('span').text()).toBe('10 days');
+ expect(findDateRangeIndicator().find('span').text()).toBe('10 days selected');
});
it('displays a tooltip', () => {
diff --git a/spec/services/wiki_pages/create_service_spec.rb b/spec/services/wiki_pages/create_service_spec.rb
index 44b57088319..fd3776f4207 100644
--- a/spec/services/wiki_pages/create_service_spec.rb
+++ b/spec/services/wiki_pages/create_service_spec.rb
@@ -4,4 +4,24 @@ require 'spec_helper'
RSpec.describe WikiPages::CreateService do
it_behaves_like 'WikiPages::CreateService#execute', :project
+
+ describe '#execute' do
+ let_it_be(:project) { create(:project) }
+
+ subject(:service) { described_class.new(container: project) }
+
+ context 'when wiki create fails due to git error' do
+ let(:wiki_git_error) { 'Could not create wiki page' }
+
+ it 'catches the thrown error and returns a ServiceResponse error' do
+ allow_next_instance_of(WikiPage) do |instance|
+ allow(instance).to receive(:create).and_raise(Gitlab::Git::CommandError.new(wiki_git_error))
+ end
+
+ result = service.execute
+ expect(result).to be_error
+ expect(result.message).to eq(wiki_git_error)
+ end
+ end
+ end
end
diff --git a/spec/services/wiki_pages/update_service_spec.rb b/spec/services/wiki_pages/update_service_spec.rb
index 33ac98e764d..62881817e32 100644
--- a/spec/services/wiki_pages/update_service_spec.rb
+++ b/spec/services/wiki_pages/update_service_spec.rb
@@ -4,4 +4,26 @@ require 'spec_helper'
RSpec.describe WikiPages::UpdateService do
it_behaves_like 'WikiPages::UpdateService#execute', :project
+
+ describe '#execute' do
+ let_it_be(:project) { create(:project) }
+
+ let(:page) { create(:wiki_page, project: project) }
+
+ subject(:service) { described_class.new(container: project) }
+
+ context 'when wiki create fails due to git error' do
+ let(:wiki_git_error) { 'Could not update wiki page' }
+
+ it 'catches the thrown error and returns a ServiceResponse error' do
+ allow_next_instance_of(WikiPage) do |instance|
+ allow(instance).to receive(:update).and_raise(Gitlab::Git::CommandError.new(wiki_git_error))
+ end
+
+ result = service.execute(page)
+ expect(result).to be_error
+ expect(result.message).to eq(wiki_git_error)
+ end
+ end
+ end
end