Commit 96d8c7ff authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '37571-replace-wikipage-createservice-with-factory' into 'master'

Replaces 'WikiPage::CreateService' calls with 'wiki_page' factory

Closes #37571

See merge request gitlab-org/gitlab-ce!14850
parents d7326003 c30f9246
---
title: Replace WikiPage::CreateService calls with wiki_page factory in specs
merge_request: 14850
author: Jacopo Beschi @jacopo-beschi
type: changed
...@@ -14,7 +14,6 @@ feature 'Projects > Wiki > User previews markdown changes', :js do ...@@ -14,7 +14,6 @@ feature 'Projects > Wiki > User previews markdown changes', :js do
background do background do
project.team << [user, :master] project.team << [user, :master]
WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute
sign_in(user) sign_in(user)
......
...@@ -3,9 +3,7 @@ require 'spec_helper' ...@@ -3,9 +3,7 @@ require 'spec_helper'
feature 'Wiki shortcuts', :js do feature 'Wiki shortcuts', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
let(:wiki_page) do let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: 'Home page' }) }
WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute
end
before do before do
sign_in(user) sign_in(user)
......
...@@ -3,14 +3,7 @@ require 'spec_helper' ...@@ -3,14 +3,7 @@ require 'spec_helper'
describe 'Projects > Wiki > User views Git access wiki page' do describe 'Projects > Wiki > User views Git access wiki page' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:wiki_page) do let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' }) }
WikiPages::CreateService.new(
project,
user,
title: 'home',
content: '[some link](other-page)'
).execute
end
before do before do
sign_in(user) sign_in(user)
......
...@@ -18,12 +18,7 @@ describe 'Projects > Wiki > User views wiki in project page' do ...@@ -18,12 +18,7 @@ describe 'Projects > Wiki > User views wiki in project page' do
context 'when wiki homepage contains a link' do context 'when wiki homepage contains a link' do
before do before do
WikiPages::CreateService.new( create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' })
project,
user,
title: 'home',
content: '[some link](other-page)'
).execute
end end
it 'displays the correct URL for the link' do it 'displays the correct URL for the link' do
......
...@@ -37,7 +37,7 @@ describe BlobViewer::Readme do ...@@ -37,7 +37,7 @@ describe BlobViewer::Readme do
context 'when the wiki is not empty' do context 'when the wiki is not empty' do
before 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 end
it 'returns nil' do it 'returns nil' do
......
...@@ -108,12 +108,8 @@ describe MicrosoftTeamsService do ...@@ -108,12 +108,8 @@ describe MicrosoftTeamsService do
message: "user created page: Awesome wiki_page" message: "user created page: Awesome wiki_page"
} }
end end
let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: opts) }
let(:wiki_page_sample_data) do let(:wiki_page_sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') }
service = WikiPages::CreateService.new(project, user, opts)
wiki_page = service.execute
Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create')
end
it "calls Microsoft Teams API" do it "calls Microsoft Teams API" do
chat_service.execute(wiki_page_sample_data) chat_service.execute(wiki_page_sample_data)
......
...@@ -76,8 +76,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do ...@@ -76,8 +76,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
message: "user created page: Awesome wiki_page" message: "user created page: Awesome wiki_page"
} }
wiki_page_service = WikiPages::CreateService.new(project, user, opts) @wiki_page = create(:wiki_page, wiki: project.wiki, attrs: opts)
@wiki_page = wiki_page_service.execute
@wiki_page_sample_data = Gitlab::DataBuilder::WikiPage.build(@wiki_page, user, 'create') @wiki_page_sample_data = Gitlab::DataBuilder::WikiPage.build(@wiki_page, user, 'create')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment