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
19a52197
Commit
19a52197
authored
Sep 05, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1378 from NARKOZ/validations
validate boolean attributes
parents
982a4095
0b559cde
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
4 deletions
+12
-4
Gemfile.lock
Gemfile.lock
+1
-1
app/models/project.rb
app/models/project.rb
+2
-0
app/roles/issue_commonality.rb
app/roles/issue_commonality.rb
+1
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+1
-0
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+1
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-2
No files found.
Gemfile.lock
View file @
19a52197
...
...
@@ -323,7 +323,7 @@ GEM
multi_json (~> 1.0)
rubyzip
settingslogic (2.0.8)
shoulda-matchers (1.
1
.0)
shoulda-matchers (1.
3
.0)
activesupport (>= 3.0.0)
simplecov (0.6.4)
multi_json (~> 1.0)
...
...
app/models/project.rb
View file @
19a52197
...
...
@@ -104,6 +104,8 @@ class Project < ActiveRecord::Base
length:
{
within:
1
..
255
}
validates
:owner
,
presence:
true
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validate
:check_limit
validate
:repo_name
...
...
app/roles/issue_commonality.rb
View file @
19a52197
...
...
@@ -16,7 +16,7 @@ module IssueCommonality
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:closed
,
inclusion:
{
in:
[
true
,
false
]
}
scope
:opened
,
where
(
closed:
false
)
scope
:closed
,
where
(
closed:
true
)
...
...
spec/models/issue_spec.rb
View file @
19a52197
...
...
@@ -7,6 +7,7 @@ describe Issue do
describe
"Validation"
do
it
{
should
ensure_length_of
(
:description
).
is_within
(
0
..
2000
)
}
it
{
should
ensure_inclusion_of
(
:closed
).
in_array
([
true
,
false
])
}
end
describe
'modules'
do
...
...
spec/models/milestone_spec.rb
View file @
19a52197
...
...
@@ -9,6 +9,7 @@ describe Milestone do
describe
"Validation"
do
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
validate_presence_of
(
:project_id
)
}
it
{
should
ensure_inclusion_of
(
:closed
).
in_array
([
true
,
false
])
}
end
let
(
:milestone
)
{
Factory
:milestone
}
...
...
spec/models/project_spec.rb
View file @
19a52197
...
...
@@ -37,6 +37,10 @@ describe Project do
# TODO: Formats
it
{
should
validate_presence_of
(
:owner
)
}
it
{
should
ensure_inclusion_of
(
:issues_enabled
).
in_array
([
true
,
false
])
}
it
{
should
ensure_inclusion_of
(
:wall_enabled
).
in_array
([
true
,
false
])
}
it
{
should
ensure_inclusion_of
(
:merge_requests_enabled
).
in_array
([
true
,
false
])
}
it
{
should
ensure_inclusion_of
(
:wiki_enabled
).
in_array
([
true
,
false
])
}
it
"should not allow new projects beyond user limits"
do
project
.
stub
(
:owner
).
and_return
(
double
(
can_create_project?:
false
,
projects_limit:
1
))
...
...
@@ -239,7 +243,7 @@ describe Project do
end
end
describe
:update_merge_requests
do
describe
:update_merge_requests
do
let
(
:project
)
{
Factory
:project
}
before
do
...
...
@@ -259,7 +263,7 @@ describe Project do
@merge_request
.
closed
.
should
be_true
end
it
"should update merge request commits with new one if pushed to source branch"
do
it
"should update merge request commits with new one if pushed to source branch"
do
@merge_request
.
last_commit
.
should
==
nil
project
.
update_merge_requests
(
"8716fc78f3c65bbf7bcf7b574febd583bc5d2812"
,
"bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
,
"refs/heads/master"
,
@key
.
user
)
@merge_request
.
reload
...
...
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