Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
b238b154
Commit
b238b154
authored
Jul 31, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recreate tmp/tests on each test run
parent
ee4643c7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
56 deletions
+52
-56
features/support/env.rb
features/support/env.rb
+1
-1
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+26
-23
spec/models/wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+19
-24
spec/spec_helper.rb
spec/spec_helper.rb
+1
-8
spec/support/test_env.rb
spec/support/test_env.rb
+5
-0
No files found.
features/support/env.rb
View file @
b238b154
...
@@ -47,7 +47,7 @@ Spinach.hooks.after_scenario do
...
@@ -47,7 +47,7 @@ Spinach.hooks.after_scenario do
end
end
Spinach
.
hooks
.
before_run
do
Spinach
.
hooks
.
before_run
do
TestEnv
.
init
(
mailer:
false
,
init_repos:
true
,
repos:
false
)
TestEnv
.
init
(
mailer:
false
)
RSpec
::
Mocks
::
setup
self
RSpec
::
Mocks
::
setup
self
include
FactoryGirl
::
Syntax
::
Methods
include
FactoryGirl
::
Syntax
::
Methods
...
...
spec/models/project_wiki_spec.rb
View file @
b238b154
require
"spec_helper"
require
"spec_helper"
describe
ProjectWiki
do
describe
ProjectWiki
do
let
(
:project
)
{
create
(
:empty_project
)
}
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
(
:repository
)
{
project
.
repository
}
let
(
:repository
)
{
project
.
repository
}
let
(
:user
)
{
project
.
owner
}
let
(
:user
)
{
project
.
owner
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let
(
:project_wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
subject
{
ProjectWiki
.
new
(
project
,
user
)
}
subject
{
project_wiki
}
before
{
project_wiki
.
wiki
}
before
do
create_temp_repo
(
subject
.
send
(
:path_to_repo
))
end
describe
"#path_with_namespace"
do
describe
"#path_with_namespace"
do
it
"returns the project path with namespace with the .wiki extension"
do
it
"returns the project path with namespace with the .wiki extension"
do
...
@@ -242,4 +223,26 @@ describe ProjectWiki do
...
@@ -242,4 +223,26 @@ describe ProjectWiki do
end
end
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
end
spec/models/wiki_page_spec.rb
View file @
b238b154
require
"spec_helper"
require
"spec_helper"
describe
WikiPage
do
describe
WikiPage
do
let
(
:project
)
{
create
(
:empty_project
)
}
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
)
wiki
.
wiki
.
write_page
(
name
,
:markdown
,
content
,
commit_details
)
end
def
destroy_page
(
title
)
page
=
wiki
.
wiki
.
paged
(
title
)
wiki
.
wiki
.
delete_page
(
page
,
commit_details
)
end
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:user
)
{
project
.
owner
}
let
(
:user
)
{
project
.
owner
}
let
(
:wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
let
(
:wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
subject
{
WikiPage
.
new
(
wiki
)
}
subject
{
WikiPage
.
new
(
wiki
)
}
before
do
create_temp_repo
(
wiki
.
send
(
:path_to_repo
))
end
describe
"#initialize"
do
describe
"#initialize"
do
context
"when initialized with an existing gollum page"
do
context
"when initialized with an existing gollum page"
do
before
do
before
do
...
@@ -171,4 +148,22 @@ describe WikiPage do
...
@@ -171,4 +148,22 @@ describe WikiPage do
end
end
end
end
private
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
)
wiki
.
wiki
.
write_page
(
name
,
:markdown
,
content
,
commit_details
)
end
def
destroy_page
(
title
)
page
=
wiki
.
wiki
.
paged
(
title
)
wiki
.
wiki
.
delete_page
(
page
,
commit_details
)
end
end
end
spec/spec_helper.rb
View file @
b238b154
...
@@ -38,14 +38,7 @@ RSpec.configure do |config|
...
@@ -38,14 +38,7 @@ RSpec.configure do |config|
config
.
include
TestEnv
config
.
include
TestEnv
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config
.
before
(
:suite
)
do
config
.
before
(
:suite
)
do
TestEnv
.
init
(
init_repos:
true
,
repos:
false
)
TestEnv
.
init
end
config
.
before
(
:each
)
do
TestEnv
.
setup_stubs
end
end
end
end
spec/support/test_env.rb
View file @
b238b154
...
@@ -16,6 +16,11 @@ module TestEnv
...
@@ -16,6 +16,11 @@ module TestEnv
# Setup GitLab shell for test instance
# Setup GitLab shell for test instance
setup_gitlab_shell
setup_gitlab_shell
# Clean /tmp/tests
tmp_test_path
=
Rails
.
root
.
join
(
'tmp'
,
'tests'
)
FileUtils
.
rm_r
(
tmp_test_path
)
FileUtils
.
mkdir
(
tmp_test_path
)
# Create repository for FactoryGirl.create(:project)
# Create repository for FactoryGirl.create(:project)
setup_factory_repo
setup_factory_repo
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment