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
c9c1f76e
Commit
c9c1f76e
authored
Aug 28, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All specs and features currently passing with FactoryGirl
parent
4805c64f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
262 additions
and
31 deletions
+262
-31
features/support/env.rb
features/support/env.rb
+4
-2
spec/factories.rb
spec/factories.rb
+107
-0
spec/factories_spec.rb
spec/factories_spec.rb
+83
-0
spec/helpers/gitlab_flavored_markdown_spec.rb
spec/helpers/gitlab_flavored_markdown_spec.rb
+2
-2
spec/models/system_hook_spec.rb
spec/models/system_hook_spec.rb
+5
-6
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
spec/support/monkeypatch.rb
spec/support/monkeypatch.rb
+0
-21
spec/support/stubbed_repository.rb
spec/support/stubbed_repository.rb
+60
-0
No files found.
features/support/env.rb
View file @
c9c1f76e
...
...
@@ -8,8 +8,8 @@ require 'webmock/cucumber'
WebMock
.
allow_net_connect!
require
Rails
.
root
.
join
'spec/support/monkeypatch'
require
Rails
.
root
.
join
'spec/support/gitolite_stub'
require
Rails
.
root
.
join
'spec/support/stubbed_repository'
require
Rails
.
root
.
join
'spec/support/login_helpers'
require
Rails
.
root
.
join
'spec/support/valid_commit'
...
...
@@ -55,3 +55,5 @@ include GitoliteStub
Before
do
stub_gitolite!
end
World
(
FactoryGirl
::
Syntax
::
Methods
)
spec/factories.rb
0 → 100644
View file @
c9c1f76e
# Backwards compatibility with the old method
def
Factory
(
type
,
*
args
)
FactoryGirl
.
create
(
type
,
*
args
)
end
module
Factory
def
self
.
create
(
type
,
*
args
)
FactoryGirl
.
create
(
type
,
*
args
)
end
def
self
.
new
(
type
,
*
args
)
FactoryGirl
.
build
(
type
,
*
args
)
end
end
FactoryGirl
.
define
do
sequence
:sentence
,
aliases:
[
:title
,
:content
]
do
Faker
::
Lorem
.
sentence
end
sequence
(
:url
)
{
Faker
::
Internet
.
uri
(
'http'
)
}
factory
:user
,
aliases:
[
:author
,
:assignee
,
:owner
]
do
email
{
Faker
::
Internet
.
email
}
name
{
Faker
::
Name
.
name
}
password
"123456"
password_confirmation
"123456"
trait
:admin
do
admin
true
end
factory
:admin
,
traits:
[
:admin
]
end
factory
:project
do
sequence
(
:name
)
{
|
n
|
"project
#{
n
}
"
}
path
{
name
}
code
{
name
}
owner
end
factory
:users_project
do
user
project
end
factory
:issue
do
title
author
project
trait
:closed
do
closed
true
end
factory
:closed_issue
,
traits:
[
:closed
]
end
factory
:merge_request
do
title
author
project
source_branch
"master"
target_branch
"stable"
end
factory
:note
do
project
note
"Note"
end
factory
:event
do
end
factory
:key
do
title
key
{
File
.
read
(
File
.
join
(
Rails
.
root
,
"db"
,
"pkey.example"
))
}
end
factory
:milestone
do
title
project
end
factory
:system_hook
do
url
end
factory
:project_hook
do
url
end
factory
:wiki
do
title
content
user
end
factory
:snippet
do
project
author
title
content
file_name
{
Faker
::
Lorem
.
sentence
}
end
end
spec/factories_spec.rb
0 → 100644
View file @
c9c1f76e
require
'spec_helper'
describe
"Factories"
do
describe
'User'
do
it
"builds a valid instance"
do
build
(
:user
).
should
be_valid
end
it
"builds a valid admin instance"
do
build
(
:admin
).
should
be_valid
end
end
describe
'Project'
do
it
"builds a valid instance"
do
build
(
:project
).
should
be_valid
end
end
describe
'Issue'
do
it
"builds a valid instance"
do
build
(
:issue
).
should
be_valid
end
it
"builds a valid closed instance"
do
build
(
:closed_issue
).
should
be_valid
end
end
describe
'MergeRequest'
do
it
"builds a valid instance"
do
build
(
:merge_request
).
should
be_valid
end
end
describe
'Note'
do
it
"builds a valid instance"
do
build
(
:note
).
should
be_valid
end
end
describe
'Event'
do
it
"builds a valid instance"
do
build
(
:event
).
should
be_valid
end
end
describe
'Key'
do
it
"builds a valid instance"
do
build
(
:key
).
should
be_valid
end
end
describe
'Milestone'
do
it
"builds a valid instance"
do
build
(
:milestone
).
should
be_valid
end
end
describe
'SystemHook'
do
it
"builds a valid instance"
do
build
(
:system_hook
).
should
be_valid
end
end
describe
'ProjectHook'
do
it
"builds a valid instance"
do
build
(
:project_hook
).
should
be_valid
end
end
describe
'Wiki'
do
it
"builds a valid instance"
do
build
(
:wiki
).
should
be_valid
end
end
describe
'Snippet'
do
it
"builds a valid instance"
do
build
(
:snippet
).
should
be_valid
end
end
end
spec/helpers/gitlab_flavored_markdown_spec.rb
View file @
c9c1f76e
...
...
@@ -2,7 +2,7 @@ require "spec_helper"
describe
GitlabMarkdownHelper
do
before
do
@project
=
Project
.
find_by_path
(
"gitlabhq"
)
||
Factory
(
:project
)
@project
=
Factory
(
:project
)
@commit
=
@project
.
repo
.
commits
.
first
.
parents
.
first
@commit
=
CommitDecorator
.
decorate
(
Commit
.
new
(
@commit
))
@other_project
=
Factory
:project
,
path:
"OtherPath"
,
code:
"OtherCode"
...
...
@@ -157,7 +157,7 @@ describe GitlabMarkdownHelper do
gfm
(
"Let @
#{
user
.
name
}
fix the *mess* in
#{
@commit
.
id
}
"
).
should
==
"Let
#{
link_to
"@
#{
user
.
name
}
"
,
project_team_member_path
(
@project
,
member
),
class:
"gfm gfm-team_member "
}
fix the *mess* in
#{
link_to
@commit
.
id
,
project_commit_path
(
@project
,
id:
@commit
.
id
),
title:
"Commit:
#{
@commit
.
author_name
}
-
#{
@commit
.
title
}
"
,
class:
"gfm gfm-commit "
}
"
end
it
"should not trip over other stuff"
,
focus:
true
do
it
"should not trip over other stuff"
do
gfm
(
"_Please_ *stop* 'helping' and all the other b*$#%' you do."
).
should
==
"_Please_ *stop* 'helping' and all the other b*$#%' you do."
end
...
...
spec/models/system_hook_spec.rb
View file @
c9c1f76e
...
...
@@ -10,9 +10,8 @@ describe SystemHook do
end
it
"project_create hook"
do
user
=
Factory
:user
with_resque
do
project
=
Factory
:project
_without_owner
,
owner:
user
project
=
Factory
:project
end
WebMock
.
should
have_requested
(
:post
,
@system_hook
.
url
).
with
(
body:
/project_create/
).
once
end
...
...
spec/spec_helper.rb
View file @
c9c1f76e
...
...
@@ -27,6 +27,7 @@ RSpec.configure do |config|
config
.
include
LoginHelpers
,
type: :request
config
.
include
GitoliteStub
config
.
include
FactoryGirl
::
Syntax
::
Methods
# 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
...
...
spec/support/monkeypatch.rb
deleted
100644 → 0
View file @
4805c64f
# Stubbing Project <-> git host path
# create project using Factory only
class
Project
def
path_to_repo
File
.
join
(
Rails
.
root
,
"tmp"
,
"tests"
,
path
)
end
def
satellite
@satellite
||=
FakeSatellite
.
new
end
end
class
FakeSatellite
def
exists?
true
end
def
create
true
end
end
spec/support/stubbed_repository.rb
0 → 100644
View file @
c9c1f76e
# Stubs out all Git repository access done by models so that specs can run
# against fake repositories without Grit complaining that they don't exist.
module
StubbedRepository
extend
ActiveSupport
::
Concern
included
do
# If a class defines the method we want to stub directly, rather than
# inheriting it from a module (as is the case in UsersProject), that method
# will overwrite our stub, so use alias_method to ensure it's our stub
# getting called.
alias_method
:update_repository
,
:fake_update_repository
alias_method
:destroy_repository
,
:fake_destroy_repository
alias_method
:repository_delete_key
,
:fake_repository_delete_key
alias_method
:path_to_repo
,
:fake_path_to_repo
alias_method
:satellite
,
:fake_satellite
end
def
fake_update_repository
true
end
def
fake_destroy_repository
true
end
def
fake_repository_delete_key
true
end
def
fake_path_to_repo
if
new_record?
# There are a couple Project specs that expect the Project's path to be
# in the returned path, so let's patronize them.
File
.
join
(
Rails
.
root
,
'tmp'
,
'tests'
,
path
)
else
# For everything else, just give it the path to one of our real seeded
# repos.
File
.
join
(
Rails
.
root
,
'tmp'
,
'tests'
,
'gitlabhq_1'
)
end
end
def
fake_satellite
FakeSatellite
.
new
end
class
FakeSatellite
def
exists?
true
end
def
create
true
end
end
end
[
Project
,
Key
,
ProtectedBranch
,
UsersProject
].
each
do
|
c
|
c
.
send
(
:include
,
StubbedRepository
)
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