summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-06-28 10:42:59 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-06-28 10:42:59 -0300
commit26f3731021e8c5c6417fe874c53a5bf2065b8888 (patch)
tree3b95b3573af0680b8f35a7c6b5ce9f50c2f3b731
parent2a64607b987add8747c4b9601aa01fe40064d15d (diff)
downloadgitlab-ce-26f3731021e8c5c6417fe874c53a5bf2065b8888.tar.gz
Add ProjectWiki#ensure_repositoryport-changes-ee-2467
-rw-r--r--app/models/project_wiki.rb4
-rw-r--r--spec/models/project_wiki_spec.rb18
2 files changed, 22 insertions, 0 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index f38fbda7839..f26ee57510c 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -149,6 +149,10 @@ class ProjectWiki
wiki
end
+ def ensure_repository
+ create_repo! unless repository_exists?
+ end
+
def hook_attrs
{
web_url: web_url,
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index bf74ac5ea25..1f314791479 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -278,6 +278,24 @@ describe ProjectWiki, models: true do
end
end
+ describe '#ensure_repository' do
+ it 'creates the repository if it not exist' do
+ allow(subject).to receive(:repository_exists?).and_return(false)
+
+ expect(subject).to receive(:create_repo!)
+
+ subject.ensure_repository
+ end
+
+ it 'does not create the repository if it exists' do
+ allow(subject).to receive(:repository_exists?).and_return(true)
+
+ expect(subject).not_to receive(:create_repo!)
+
+ subject.ensure_repository
+ end
+ end
+
describe '#hook_attrs' do
it 'returns a hash with values' do
expect(subject.hook_attrs).to be_a Hash