diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-31 20:24:53 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-31 20:24:53 +0400 |
commit | b238b1544c391bbc60a7d38c30d98e05be786667 (patch) | |
tree | 8f94b6018882d2053000e719e671f7df46ae92e7 /spec/models/project_wiki_spec.rb | |
parent | ee4643c732c3d91437e50d0c8486dbb8ea5b51b5 (diff) |
Recreate tmp/tests on each test run
Diffstat (limited to 'spec/models/project_wiki_spec.rb')
-rw-r--r-- | spec/models/project_wiki_spec.rb | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index f06a5cd4ecc..56ec83e3e7d 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -1,33 +1,14 @@ require "spec_helper" describe ProjectWiki do - - def remove_temp_repo(path) - FileUtils.rm_rf path - end - - def commit_details - commit = {name: user.name, email: user.email, message: "test commit"} - end - - def create_page(name, content) - subject.wiki.write_page(name, :markdown, content, commit_details) - end - - def destroy_page(page) - subject.wiki.delete_page(page, commit_details) - end - - let(:project) { create(:project) } + let(:project) { create(:empty_project) } let(:repository) { project.repository } let(:user) { project.owner } let(:gitlab_shell) { Gitlab::Shell.new } + let(:project_wiki) { ProjectWiki.new(project, user) } - subject { ProjectWiki.new(project, user) } - - before do - create_temp_repo(subject.send(:path_to_repo)) - end + subject { project_wiki } + before { project_wiki.wiki } describe "#path_with_namespace" do it "returns the project path with namespace with the .wiki extension" do @@ -242,4 +223,26 @@ describe ProjectWiki do end end + private + + def create_temp_repo(path) + FileUtils.mkdir_p path + system(*%W(git init --quiet --bare -- #{path})) + end + + def remove_temp_repo(path) + FileUtils.rm_rf path + end + + def commit_details + commit = {name: user.name, email: user.email, message: "test commit"} + end + + def create_page(name, content) + subject.wiki.write_page(name, :markdown, content, commit_details) + end + + def destroy_page(page) + subject.wiki.delete_page(page, commit_details) + end end |