diff options
8 files changed, 12 insertions, 27 deletions
diff --git a/changelogs/unreleased/37571-replace-wikipage-createservice-with-factory.yml b/changelogs/unreleased/37571-replace-wikipage-createservice-with-factory.yml new file mode 100644 index 00000000000..bc93aa1fca4 --- /dev/null +++ b/changelogs/unreleased/37571-replace-wikipage-createservice-with-factory.yml @@ -0,0 +1,5 @@ +--- +title: Replace WikiPage::CreateService calls with wiki_page factory in specs +merge_request: 14850 +author: Jacopo Beschi @jacopo-beschi +type: changed diff --git a/spec/features/projects/wiki/markdown_preview_spec.rb b/spec/features/projects/wiki/markdown_preview_spec.rb index 78c350c8ee4..d63cbe578d8 100644 --- a/spec/features/projects/wiki/markdown_preview_spec.rb +++ b/spec/features/projects/wiki/markdown_preview_spec.rb @@ -14,7 +14,6 @@ feature 'Projects > Wiki > User previews markdown changes', :js do background do project.team << [user, :master] - WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute sign_in(user) diff --git a/spec/features/projects/wiki/shortcuts_spec.rb b/spec/features/projects/wiki/shortcuts_spec.rb index eaff5f876b6..f70d1e710dd 100644 --- a/spec/features/projects/wiki/shortcuts_spec.rb +++ b/spec/features/projects/wiki/shortcuts_spec.rb @@ -3,9 +3,7 @@ require 'spec_helper' feature 'Wiki shortcuts', :js do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } - let(:wiki_page) do - WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute - end + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: 'Home page' }) } before do sign_in(user) diff --git a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb index 9a92622ba2b..37a118c34ab 100644 --- a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb @@ -3,14 +3,7 @@ require 'spec_helper' describe 'Projects > Wiki > User views Git access wiki page' do let(:user) { create(:user) } let(:project) { create(:project, :public) } - let(:wiki_page) do - WikiPages::CreateService.new( - project, - user, - title: 'home', - content: '[some link](other-page)' - ).execute - end + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' }) } before do sign_in(user) diff --git a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb index cf9fe4c1ad1..ebb3bd044c1 100644 --- a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb @@ -18,12 +18,7 @@ describe 'Projects > Wiki > User views wiki in project page' do context 'when wiki homepage contains a link' do before do - WikiPages::CreateService.new( - project, - user, - title: 'home', - content: '[some link](other-page)' - ).execute + create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' }) end it 'displays the correct URL for the link' do diff --git a/spec/models/blob_viewer/readme_spec.rb b/spec/models/blob_viewer/readme_spec.rb index 926df21ffda..b9946c0315a 100644 --- a/spec/models/blob_viewer/readme_spec.rb +++ b/spec/models/blob_viewer/readme_spec.rb @@ -37,7 +37,7 @@ describe BlobViewer::Readme do context 'when the wiki is not empty' do before do - WikiPages::CreateService.new(project, project.owner, title: 'home', content: 'Home page').execute + create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: 'Home page' }) end it 'returns nil' do diff --git a/spec/models/project_services/microsoft_teams_service_spec.rb b/spec/models/project_services/microsoft_teams_service_spec.rb index f89be20ad78..6a5d0decfec 100644 --- a/spec/models/project_services/microsoft_teams_service_spec.rb +++ b/spec/models/project_services/microsoft_teams_service_spec.rb @@ -108,12 +108,8 @@ describe MicrosoftTeamsService do message: "user created page: Awesome wiki_page" } end - - let(:wiki_page_sample_data) do - service = WikiPages::CreateService.new(project, user, opts) - wiki_page = service.execute - Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') - end + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: opts) } + let(:wiki_page_sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') } it "calls Microsoft Teams API" do chat_service.execute(wiki_page_sample_data) diff --git a/spec/support/slack_mattermost_notifications_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb index 6accf16bea4..17f3a861ba8 100644 --- a/spec/support/slack_mattermost_notifications_shared_examples.rb +++ b/spec/support/slack_mattermost_notifications_shared_examples.rb @@ -76,8 +76,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do message: "user created page: Awesome wiki_page" } - wiki_page_service = WikiPages::CreateService.new(project, user, opts) - @wiki_page = wiki_page_service.execute + @wiki_page = create(:wiki_page, wiki: project.wiki, attrs: opts) @wiki_page_sample_data = Gitlab::DataBuilder::WikiPage.build(@wiki_page, user, 'create') end |