BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
dc33f71b
Commit
dc33f71b
authored
Oct 09, 2012
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1656 from zzet/refactoring
Refactoring
parents
c348284f
a4cd7386
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
128 additions
and
116 deletions
+128
-116
commits_helper.rb
app/helpers/commits_helper.rb
+0
-0
merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+0
-0
ability.rb
app/models/ability.rb
+4
-5
event.rb
app/models/event.rb
+5
-2
group.rb
app/models/group.rb
+14
-14
key.rb
app/models/key.rb
+5
-6
merge_request.rb
app/models/merge_request.rb
+4
-3
milestone.rb
app/models/milestone.rb
+2
-1
note.rb
app/models/note.rb
+9
-7
project.rb
app/models/project.rb
+23
-21
protected_branch.rb
app/models/protected_branch.rb
+2
-1
snippet.rb
app/models/snippet.rb
+3
-1
system_hook.rb
app/models/system_hook.rb
+4
-4
user.rb
app/models/user.rb
+21
-18
users_project.rb
app/models/users_project.rb
+10
-8
web_hook.rb
app/models/web_hook.rb
+0
-0
wiki.rb
app/models/wiki.rb
+8
-8
account.rb
app/roles/account.rb
+1
-1
authority.rb
app/roles/authority.rb
+0
-0
issue_commonality.rb
app/roles/issue_commonality.rb
+3
-6
push_event.rb
app/roles/push_event.rb
+0
-0
group_spec.rb
spec/models/group_spec.rb
+1
-1
milestone_spec.rb
spec/models/milestone_spec.rb
+1
-1
protected_branch_spec.rb
spec/models/protected_branch_spec.rb
+1
-1
snippet_spec.rb
spec/models/snippet_spec.rb
+2
-2
users_project_spec.rb
spec/models/users_project_spec.rb
+2
-2
wiki_spec.rb
spec/models/wiki_spec.rb
+1
-1
issue_commonality_spec.rb
spec/roles/issue_commonality_spec.rb
+2
-2
No files found.
app/helpers/commits_helper.rb
View file @
dc33f71b
app/helpers/merge_requests_helper.rb
View file @
dc33f71b
app/models/ability.rb
View file @
dc33f71b
class
Ability
def
self
.
allowed
(
object
,
subject
)
class
<<
self
def
allowed
(
object
,
subject
)
case
subject
.
class
.
name
when
"Project"
then
project_abilities
(
object
,
subject
)
when
"Issue"
then
issue_abilities
(
object
,
subject
)
...
...
@@ -10,7 +11,7 @@ class Ability
end
end
def
self
.
project_abilities
(
user
,
project
)
def
project_abilities
(
user
,
project
)
rules
=
[]
rules
<<
[
...
...
@@ -55,7 +56,6 @@ class Ability
rules
.
flatten
end
class
<<
self
[
:issue
,
:note
,
:snippet
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
if
subject
.
author
==
user
...
...
@@ -72,8 +72,7 @@ class Ability
:"modify_
#{
name
}
"
,
]
else
subject
.
respond_to?
(
:project
)
?
project_abilities
(
user
,
subject
.
project
)
:
[]
subject
.
respond_to?
(
:project
)
?
project_abilities
(
user
,
subject
.
project
)
:
[]
end
end
end
...
...
app/models/event.rb
View file @
dc33f71b
...
...
@@ -27,10 +27,12 @@ class Event < ActiveRecord::Base
# For Hash only
serialize
:data
# Scopes
scope
:recent
,
order
(
"created_at DESC"
)
scope
:code_push
,
where
(
action:
Pushed
)
def
self
.
determine_action
(
record
)
class
<<
self
def
determine_action
(
record
)
if
[
Issue
,
MergeRequest
].
include?
record
.
class
Event
::
Created
elsif
record
.
kind_of?
Note
...
...
@@ -38,9 +40,10 @@ class Event < ActiveRecord::Base
end
end
def
self
.
recent_for_user
user
def
recent_for_user
user
where
(
project_id:
user
.
projects
.
map
(
&
:id
)).
recent
end
end
# Next events currently enabled for system
# - push
...
...
app/models/group.rb
View file @
dc33f71b
# == Schema Information
#
# Table name: groups
#
# id :integer not null, primary key
# name :string(255) not null
# code :string(255) not null
# owner_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class
Group
<
ActiveRecord
::
Base
attr_accessible
:code
,
:name
,
:owner_id
...
...
@@ -18,7 +6,7 @@ class Group < ActiveRecord::Base
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:code
,
presence:
true
,
uniqueness:
true
validates
:owner
_id
,
presence:
true
validates
:owner
,
presence:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
...
...
@@ -31,6 +19,18 @@ class Group < ActiveRecord::Base
end
def
users
User
.
joins
(
:users_projects
).
where
(
'users_projects.project_id'
=>
project_ids
).
uniq
User
.
joins
(
:users_projects
).
where
(
users_projects:
{
project_id:
project_ids
}
).
uniq
end
end
# == Schema Information
#
# Table name: groups
#
# id :integer not null, primary key
# name :string(255) not null
# code :string(255) not null
# owner_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
app/models/key.rb
View file @
dc33f71b
...
...
@@ -6,15 +6,14 @@ class Key < ActiveRecord::Base
attr_accessible
:key
,
:title
before_validation
:strip_white_space
before_save
:set_identifier
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:key
,
presence:
true
,
length:
{
within:
0
..
5000
},
format:
{
:with
=>
/ssh-.{3} /
}
validates
:key
,
presence:
true
,
length:
{
within:
0
..
5000
},
format:
{
:with
=>
/ssh-.{3} /
}
validate
:unique_key
,
:fingerprintable_key
before_save
:set_identifier
before_validation
:strip_white_space
delegate
:name
,
:email
,
to: :user
,
prefix:
true
validate
:unique_key
,
:fingerprintable_key
def
strip_white_space
self
.
key
=
self
.
key
.
strip
unless
self
.
key
.
blank?
...
...
app/models/merge_request.rb
View file @
dc33f71b
...
...
@@ -7,6 +7,8 @@ class MergeRequest < ActiveRecord::Base
attr_accessible
:title
,
:assignee_id
,
:closed
,
:target_branch
,
:source_branch
,
:author_id_of_changes
attr_accessor
:should_remove_source_branch
BROKEN_DIFF
=
"--broken-diff"
UNCHECKED
=
1
...
...
@@ -16,9 +18,8 @@ class MergeRequest < ActiveRecord::Base
serialize
:st_commits
serialize
:st_diffs
attr_accessor
:should_remove_source_branch
validates_presence_of
:source_branch
,
:target_branch
validates
:source_branch
,
presence:
true
validates
:target_branch
,
presence:
true
validate
:validate_branches
def
self
.
find_all_by_branch
(
branch_name
)
...
...
app/models/milestone.rb
View file @
dc33f71b
...
...
@@ -4,7 +4,8 @@ class Milestone < ActiveRecord::Base
belongs_to
:project
has_many
:issues
validates_presence_of
:title
,
:project_id
validates
:title
,
presence:
true
validates
:project
,
presence:
true
def
self
.
active
where
(
"due_date > ? OR due_date IS NULL"
,
Date
.
today
)
...
...
app/models/note.rb
View file @
dc33f71b
...
...
@@ -2,10 +2,13 @@ require 'carrierwave/orm/activerecord'
require
'file_size_validator'
class
Note
<
ActiveRecord
::
Base
mount_uploader
:attachment
,
AttachmentUploader
attr_accessible
:note
,
:noteable
,
:noteable_id
,
:noteable_type
,
:project_id
,
:attachment
,
:line_code
attr_accessor
:notify
attr_accessor
:notify_author
belongs_to
:project
belongs_to
:noteable
,
polymorphic:
true
belongs_to
:author
,
class_name:
"User"
...
...
@@ -13,18 +16,17 @@ class Note < ActiveRecord::Base
delegate
:name
,
to: :project
,
prefix:
true
delegate
:name
,
:email
,
to: :author
,
prefix:
true
attr_accessor
:notify
attr_accessor
:notify_author
validates_presence_of
:project
validates
:project
,
presence:
true
validates
:note
,
presence:
true
,
length:
{
within:
0
..
5000
}
validates
:attachment
,
file_size:
{
maximum:
10
.
megabytes
.
to_i
}
mount_uploader
:attachment
,
AttachmentUploader
# Scopes
scope
:common
,
where
(
noteable_id:
nil
)
scope
:today
,
where
(
"created_at >= :date"
,
date:
Date
.
today
)
scope
:last_week
,
where
(
"created_at >= :date"
,
date:
(
Date
.
today
-
7
.
days
))
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
date:
(
day
))
}
scope
:since
,
->
(
day
)
{
where
(
"created_at >= :date"
,
date:
(
day
))
}
scope
:fresh
,
order
(
"created_at ASC, id ASC"
)
scope
:inc_author_project
,
includes
(
:project
,
:author
)
scope
:inc_author
,
includes
(
:author
)
...
...
app/models/project.rb
View file @
dc33f71b
...
...
@@ -28,20 +28,35 @@ class Project < ActiveRecord::Base
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
# Validations
validates
:owner
,
presence:
true
validates
:description
,
length:
{
within:
0
..
2000
}
validates
:name
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:code
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
1
..
255
},
format:
{
with:
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validate
:check_limit
,
:repo_name
# Scopes
scope
:public_only
,
where
(
private_flag:
false
)
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
def
self
.
active
class
<<
self
def
active
joins
(
:issues
,
:notes
,
:merge_requests
).
order
(
"issues.created_at, notes.created_at, merge_requests.created_at DESC"
)
end
def
self
.
search
query
def
search
query
where
(
"name LIKE :query OR code LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
def
self
.
create_by_user
(
params
,
user
)
def
create_by_user
(
params
,
user
)
project
=
Project
.
new
params
Project
.
transaction
do
...
...
@@ -66,6 +81,11 @@ class Project < ActiveRecord::Base
project
end
def
access_options
UsersProject
.
access_roles
end
end
def
git_error?
error_code
==
:gitolite
end
...
...
@@ -74,20 +94,6 @@ class Project < ActiveRecord::Base
id
&&
valid?
end
# Validations
validates
:owner
,
presence:
true
validates
:description
,
length:
{
within:
0
..
2000
}
validates
:name
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:code
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
1
..
255
},
format:
{
with:
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validate
:check_limit
,
:repo_name
def
check_limit
unless
owner
.
can_create_project?
errors
[
:base
]
<<
(
"Your own projects limit is
#{
owner
.
projects_limit
}
! Please contact administrator to increase it"
)
...
...
@@ -102,10 +108,6 @@ class Project < ActiveRecord::Base
end
end
def
self
.
access_options
UsersProject
.
access_roles
end
def
to_param
code
end
...
...
app/models/protected_branch.rb
View file @
dc33f71b
...
...
@@ -4,7 +4,8 @@ class ProtectedBranch < ActiveRecord::Base
attr_accessible
:name
belongs_to
:project
validates_presence_of
:name
,
:project_id
validates
:name
,
presence:
true
validates
:project
,
presence:
true
after_save
:update_repository
after_destroy
:update_repository
...
...
app/models/snippet.rb
View file @
dc33f71b
...
...
@@ -9,11 +9,13 @@ class Snippet < ActiveRecord::Base
delegate
:name
,
:email
,
to: :author
,
prefix:
true
validates_presence_of
:author_id
,
:project_id
validates
:author
,
presence:
true
validates
:project
,
presence:
true
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:file_name
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:content
,
presence:
true
,
length:
{
within:
0
..
10000
}
# Scopes
scope
:fresh
,
order
(
"created_at DESC"
)
scope
:non_expired
,
where
([
"expires_at IS NULL OR expires_at > ?"
,
Time
.
current
])
scope
:expired
,
where
([
"expires_at IS NOT NULL AND expires_at < ?"
,
Time
.
current
])
...
...
app/models/system_hook.rb
View file @
dc33f71b
class
SystemHook
<
WebHook
def
async_execute
(
data
)
Resque
.
enqueue
(
SystemHookWorker
,
id
,
data
)
end
def
self
.
all_hooks_fire
(
data
)
SystemHook
.
all
.
each
do
|
sh
|
sh
.
async_execute
data
end
end
def
async_execute
(
data
)
Resque
.
enqueue
(
SystemHookWorker
,
id
,
data
)
end
end
# == Schema Information
...
...
app/models/user.rb
View file @
dc33f71b
...
...
@@ -27,22 +27,18 @@ class User < ActiveRecord::Base
validates
:extern_uid
,
:allow_blank
=>
true
,
:uniqueness
=>
{
:scope
=>
:provider
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
scope
:not_in_project
,
lambda
{
|
project
|
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
}
scope
:admins
,
where
(
admin:
true
)
scope
:blocked
,
where
(
blocked:
true
)
scope
:active
,
where
(
blocked:
false
)
before_validation
:generate_password
,
on: :create
before_save
:ensure_authentication_token
alias_attribute
:private_token
,
:authentication_token
def
generate_password
if
self
.
force_random_password
self
.
password
=
self
.
password_confirmation
=
Devise
.
friendly_token
.
first
(
8
)
end
end
# Scopes
scope
:not_in_project
,
->
(
project
)
{
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:id
)
)
}
scope
:admins
,
where
(
admin:
true
)
scope
:blocked
,
where
(
blocked:
true
)
scope
:active
,
where
(
blocked:
false
)
def
self
.
filter
filter_name
class
<<
self
def
filter
filter_name
case
filter_name
when
"admins"
;
self
.
admins
when
"blocked"
;
self
.
blocked
...
...
@@ -52,28 +48,35 @@ class User < ActiveRecord::Base
end
end
def
self
.
without_projects
def
without_projects
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)'
)
end
def
self
.
create_from_omniauth
(
auth
,
ldap
=
false
)
def
create_from_omniauth
(
auth
,
ldap
=
false
)
gitlab_auth
.
create_from_omniauth
(
auth
,
ldap
)
end
def
self
.
find_or_new_for_omniauth
(
auth
)
def
find_or_new_for_omniauth
(
auth
)
gitlab_auth
.
find_or_new_for_omniauth
(
auth
)
end
def
self
.
find_for_ldap_auth
(
auth
,
signed_in_resource
=
nil
)
def
find_for_ldap_auth
(
auth
,
signed_in_resource
=
nil
)
gitlab_auth
.
find_for_ldap_auth
(
auth
,
signed_in_resource
)
end
def
self
.
gitlab_auth
def
gitlab_auth
Gitlab
::
Auth
.
new
end
def
self
.
search
query
where
(
"name LIKE :query OR email LIKE :query"
,
query:
"%
#{
query
}
%"
)
def
search
query
where
(
"name LIKE :query or email LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
end
def
generate_password
if
self
.
force_random_password
self
.
password
=
self
.
password_confirmation
=
Devise
.
friendly_token
.
first
(
8
)
end
end
end
...
...
app/models/users_project.rb
View file @
dc33f71b
...
...
@@ -14,13 +14,14 @@ class UsersProject < ActiveRecord::Base
after_save
:update_repository
after_destroy
:update_repository
validates
_uniqueness_of
:user_id
,
scope:
[
:project_id
],
message:
"already exists in project"
validates
_presence_of
:user_id
validates
_presence_of
:project_id
validates
:user
,
presence:
true
validates
:user_id
,
uniqueness:
{
:scope
=>
[
:project_id
],
message:
"already exists in project"
}
validates
:project
,
presence:
true
delegate
:name
,
:email
,
to: :user
,
prefix:
true
def
self
.
bulk_delete
(
project
,
user_ids
)
class
<<
self
def
bulk_delete
(
project
,
user_ids
)
UsersProject
.
transaction
do
UsersProject
.
where
(
:user_id
=>
user_ids
,
:project_id
=>
project
.
id
).
each
do
|
users_project
|
users_project
.
destroy
...
...
@@ -28,7 +29,7 @@ class UsersProject < ActiveRecord::Base
end
end
def
self
.
bulk_update
(
project
,
user_ids
,
project_access
)
def
bulk_update
(
project
,
user_ids
,
project_access
)
UsersProject
.
transaction
do
UsersProject
.
where
(
:user_id
=>
user_ids
,
:project_id
=>
project
.
id
).
each
do
|
users_project
|
users_project
.
project_access
=
project_access
...
...
@@ -37,7 +38,7 @@ class UsersProject < ActiveRecord::Base
end
end
def
self
.
bulk_import
(
project
,
user_ids
,
project_access
)
def
bulk_import
(
project
,
user_ids
,
project_access
)
UsersProject
.
transaction
do
user_ids
.
each
do
|
user_id
|
users_project
=
UsersProject
.
new
(
...
...
@@ -50,7 +51,7 @@ class UsersProject < ActiveRecord::Base
end
end
def
self
.
user_bulk_import
(
user
,
project_ids
,
project_access
)
def
user_bulk_import
(
user
,
project_ids
,
project_access
)
UsersProject
.
transaction
do
project_ids
.
each
do
|
project_id
|
users_project
=
UsersProject
.
new
(
...
...
@@ -63,7 +64,7 @@ class UsersProject < ActiveRecord::Base
end
end
def
self
.
access_roles
def
access_roles
{
"Guest"
=>
GUEST
,
"Reporter"
=>
REPORTER
,
...
...
@@ -71,6 +72,7 @@ class UsersProject < ActiveRecord::Base
"Master"
=>
MASTER
}
end
end
def
role_access
project_access
...
...
app/models/web_hook.rb
View file @
dc33f71b
app/models/wiki.rb
View file @
dc33f71b
...
...
@@ -5,8 +5,9 @@ class Wiki < ActiveRecord::Base
belongs_to
:user
has_many
:notes
,
as: :noteable
,
dependent: :destroy
validates
:content
,
:title
,
:user_id
,
presence:
true
validates
:title
,
length:
1
..
250
validates
:content
,
presence:
true
validates
:user
,
presence:
true
validates
:title
,
presence:
true
,
length:
1
..
250
before_update
:set_slug
...
...
@@ -16,12 +17,7 @@ class Wiki < ActiveRecord::Base
protected
def
set_slug
self
.
slug
=
self
.
title
.
parameterize
end
class
<<
self
def
regenerate_from
wiki
def
self
.
regenerate_from
wiki
regenerated_field
=
[
:slug
,
:content
,
:title
]
new_wiki
=
Wiki
.
new
...
...
@@ -30,7 +26,11 @@ class Wiki < ActiveRecord::Base
end
new_wiki
end
def
set_slug
self
.
slug
=
self
.
title
.
parameterize
end
end
# == Schema Information
...
...
app/roles/account.rb
View file @
dc33f71b
...
...
@@ -45,7 +45,7 @@ module Account
# Remove user from all projects and
# set blocked attribute to true
def
block
users_projects
.
all
.
each
do
|
membership
|
users_projects
.
find_
each
do
|
membership
|
return
false
unless
membership
.
destroy
end
...
...
app/roles/authority.rb
View file @
dc33f71b
app/roles/issue_commonality.rb
View file @
dc33f71b
...
...
@@ -8,12 +8,9 @@ module IssueCommonality
belongs_to
:assignee
,
class_name:
"User"
has_many
:notes
,
as: :noteable
,
dependent: :destroy
validates_presence_of
:project_id
validates_presence_of
:author_id
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:project
,
presence:
true
validates
:author
,
presence:
true
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:closed
,
inclusion:
{
in:
[
true
,
false
]
}
scope
:opened
,
where
(
closed:
false
)
...
...
app/roles/push_event.rb
View file @
dc33f71b
spec/models/group_spec.rb
View file @
dc33f71b
...
...
@@ -20,5 +20,5 @@ describe Group do
it
{
should
validate_uniqueness_of
(
:name
)
}
it
{
should
validate_presence_of
:code
}
it
{
should
validate_uniqueness_of
(
:code
)
}
it
{
should
validate_presence_of
:owner
_id
}
it
{
should
validate_presence_of
:owner
}
end
spec/models/milestone_spec.rb
View file @
dc33f71b
...
...
@@ -12,7 +12,7 @@ describe Milestone do
describe
"Validation"
do
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
validate_presence_of
(
:project
_id
)
}
it
{
should
validate_presence_of
(
:project
)
}
it
{
should
ensure_inclusion_of
(
:closed
).
in_array
([
true
,
false
])
}
end
...
...
spec/models/protected_branch_spec.rb
View file @
dc33f71b
...
...
@@ -10,7 +10,7 @@ describe ProtectedBranch do
end
describe
'Validation'
do
it
{
should
validate_presence_of
(
:project
_id
)
}
it
{
should
validate_presence_of
(
:project
)
}
it
{
should
validate_presence_of
(
:name
)
}
end
...
...
spec/models/snippet_spec.rb
View file @
dc33f71b
...
...
@@ -13,8 +13,8 @@ describe Snippet do
end
describe
"Validation"
do
it
{
should
validate_presence_of
(
:author
_id
)
}
it
{
should
validate_presence_of
(
:project
_id
)
}
it
{
should
validate_presence_of
(
:author
)
}
it
{
should
validate_presence_of
(
:project
)
}
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
ensure_length_of
(
:title
).
is_within
(
0
..
255
)
}
...
...
spec/models/users_project_spec.rb
View file @
dc33f71b
...
...
@@ -13,10 +13,10 @@ describe UsersProject do
describe
"Validation"
do
let!
(
:users_project
)
{
create
(
:users_project
)
}
it
{
should
validate_presence_of
(
:user
_id
)
}
it
{
should
validate_presence_of
(
:user
)
}
it
{
should
validate_uniqueness_of
(
:user_id
).
scoped_to
(
:project_id
).
with_message
(
/already exists/
)
}
it
{
should
validate_presence_of
(
:project
_id
)
}
it
{
should
validate_presence_of
(
:project
)
}
end
describe
"Delegate methods"
do
...
...
spec/models/wiki_spec.rb
View file @
dc33f71b
...
...
@@ -16,6 +16,6 @@ describe Wiki do
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
ensure_length_of
(
:title
).
is_within
(
1
..
250
)
}
it
{
should
validate_presence_of
(
:content
)
}
it
{
should
validate_presence_of
(
:user
_id
)
}
it
{
should
validate_presence_of
(
:user
)
}
end
end
spec/roles/issue_commonality_spec.rb
View file @
dc33f71b
...
...
@@ -11,8 +11,8 @@ describe Issue, "IssueCommonality" do
end
describe
"Validation"
do
it
{
should
validate_presence_of
(
:project
_id
)
}
it
{
should
validate_presence_of
(
:author
_id
)
}
it
{
should
validate_presence_of
(
:project
)
}
it
{
should
validate_presence_of
(
:author
)
}
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
ensure_length_of
(
:title
).
is_at_least
(
0
).
is_at_most
(
255
)
}
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