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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
77d06454
Commit
77d06454
authored
Aug 28, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple model spec changes made possible by new factories
parent
0bc90940
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
95 deletions
+37
-95
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+9
-28
spec/models/key_spec.rb
spec/models/key_spec.rb
+6
-11
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+6
-18
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+2
-5
spec/models/note_spec.rb
spec/models/note_spec.rb
+8
-13
spec/models/user_spec.rb
spec/models/user_spec.rb
+6
-20
No files found.
spec/models/issue_spec.rb
View file @
77d06454
...
@@ -19,11 +19,7 @@ describe Issue do
...
@@ -19,11 +19,7 @@ describe Issue do
it
{
Issue
.
should
respond_to
:opened
}
it
{
Issue
.
should
respond_to
:opened
}
end
end
subject
{
Factory
.
create
(
:issue
,
subject
{
Factory
.
create
(
:issue
)
}
author:
Factory
(
:user
),
assignee:
Factory
(
:user
),
project:
Factory
.
create
(
:project
))
}
it
{
should
be_valid
}
describe
'#is_being_reassigned?'
do
describe
'#is_being_reassigned?'
do
it
'returns true if the issue assignee has changed'
do
it
'returns true if the issue assignee has changed'
do
...
@@ -41,11 +37,7 @@ describe Issue do
...
@@ -41,11 +37,7 @@ describe Issue do
subject
.
is_being_closed?
.
should
be_true
subject
.
is_being_closed?
.
should
be_true
end
end
it
'returns false if the closed attribute has changed and is now false'
do
it
'returns false if the closed attribute has changed and is now false'
do
issue
=
Factory
.
create
(
:issue
,
issue
=
Factory
.
create
(
:closed_issue
)
closed:
true
,
author:
Factory
(
:user
),
assignee:
Factory
(
:user
),
project:
Factory
.
create
(
:project
))
issue
.
closed
=
false
issue
.
closed
=
false
issue
.
is_being_closed?
.
should
be_false
issue
.
is_being_closed?
.
should
be_false
end
end
...
@@ -57,11 +49,7 @@ describe Issue do
...
@@ -57,11 +49,7 @@ describe Issue do
describe
'#is_being_reopened?'
do
describe
'#is_being_reopened?'
do
it
'returns true if the closed attribute has changed and is now false'
do
it
'returns true if the closed attribute has changed and is now false'
do
issue
=
Factory
.
create
(
:issue
,
issue
=
Factory
.
create
(
:closed_issue
)
closed:
true
,
author:
Factory
(
:user
),
assignee:
Factory
(
:user
),
project:
Factory
.
create
(
:project
))
issue
.
closed
=
false
issue
.
closed
=
false
issue
.
is_being_reopened?
.
should
be_true
issue
.
is_being_reopened?
.
should
be_true
end
end
...
@@ -75,40 +63,33 @@ describe Issue do
...
@@ -75,40 +63,33 @@ describe Issue do
end
end
describe
"plus 1"
do
describe
"plus 1"
do
let
(
:project
)
{
Factory
(
:project
)
}
subject
{
Factory
.
create
(
:issue
)
}
subject
{
Factory
.
create
(
:issue
,
author:
Factory
(
:user
),
assignee:
Factory
(
:user
),
project:
project
)
}
it
"with no notes has a 0/0 score"
do
it
"with no notes has a 0/0 score"
do
subject
.
upvotes
.
should
==
0
subject
.
upvotes
.
should
==
0
end
end
it
"should recognize non-+1 notes"
do
it
"should recognize non-+1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
)
subject
.
should
have
(
1
).
note
subject
.
should
have
(
1
).
note
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
upvotes
.
should
==
0
subject
.
upvotes
.
should
==
0
end
end
it
"should recognize a single +1 note"
do
it
"should recognize a single +1 note"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
upvotes
.
should
==
1
subject
.
upvotes
.
should
==
1
end
end
it
"should recognize a multiple +1 notes"
do
it
"should recognize a multiple +1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
,
project:
Factory
(
:project
,
path:
'plustwo'
,
code:
'plustwo'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
)
subject
.
upvotes
.
should
==
2
subject
.
upvotes
.
should
==
2
end
end
end
end
describe
".search"
do
describe
".search"
do
let!
(
:issue
)
{
Factory
.
create
(
:issue
,
title:
"Searchable issue"
,
let!
(
:issue
)
{
Factory
.
create
(
:issue
,
title:
"Searchable issue"
)
}
project:
Factory
.
create
(
:project
))
}
it
"matches by title"
do
it
"matches by title"
do
Issue
.
search
(
'able'
).
all
.
should
==
[
issue
]
Issue
.
search
(
'able'
).
all
.
should
==
[
issue
]
...
...
spec/models/key_spec.rb
View file @
77d06454
...
@@ -17,20 +17,15 @@ describe Key do
...
@@ -17,20 +17,15 @@ describe Key do
context
"validation of uniqueness"
do
context
"validation of uniqueness"
do
context
"as a deploy key"
do
context
"as a deploy key"
do
let
(
:project
)
{
Factory
.
create
(
:project
,
path:
'alpha'
,
code:
'alpha'
)
}
let!
(
:deploy_key
)
{
create
(
:deploy_key
)
}
let
(
:another_project
)
{
Factory
.
create
(
:project
,
path:
'beta'
,
code:
'beta'
)
}
before
do
deploy_key
=
Factory
.
create
(
:key
,
project:
project
)
end
it
"does not accept the same key twice for a project"
do
it
"does not accept the same key twice for a project"
do
key
=
Factory
.
new
(
:key
,
project:
project
)
key
=
build
(
:key
,
project:
deploy_key
.
project
)
key
.
should_not
be_valid
key
.
should_not
be_valid
end
end
it
"does accept the same key for another project"
do
it
"does accept the same key for another project"
do
key
=
Factory
.
new
(
:key
,
project:
another_project
)
key
=
build
(
:key
,
project_id:
0
)
key
.
should
be_valid
key
.
should
be_valid
end
end
end
end
...
@@ -39,12 +34,12 @@ describe Key do
...
@@ -39,12 +34,12 @@ describe Key do
let
(
:user
)
{
Factory
.
create
(
:user
)
}
let
(
:user
)
{
Factory
.
create
(
:user
)
}
it
"accepts the key once"
do
it
"accepts the key once"
do
Factory
.
new
(
:key
,
user:
user
).
should
be_valid
build
(
:key
,
user:
user
).
should
be_valid
end
end
it
"does not accepts the key twice"
do
it
"does not accepts the key twice"
do
Factory
.
create
(
:key
,
user:
user
)
create
(
:key
,
user:
user
)
Factory
.
new
(
:key
,
user:
user
).
should_not
be_valid
build
(
:key
,
user:
user
).
should_not
be_valid
end
end
end
end
end
end
...
...
spec/models/merge_request_spec.rb
View file @
77d06454
...
@@ -20,46 +20,34 @@ describe MergeRequest do
...
@@ -20,46 +20,34 @@ describe MergeRequest do
it
{
MergeRequest
.
should
respond_to
:opened
}
it
{
MergeRequest
.
should
respond_to
:opened
}
end
end
it
{
Factory
.
create
(
:merge_request
,
author:
Factory
(
:user
),
assignee:
Factory
(
:user
),
project:
Factory
.
create
(
:project
)).
should
be_valid
}
describe
"plus 1"
do
describe
"plus 1"
do
let
(
:project
)
{
Factory
(
:project
)
}
subject
{
Factory
.
create
(
:merge_request
)
}
subject
{
Factory
.
create
(
:merge_request
,
author:
Factory
(
:user
),
assignee:
Factory
(
:user
),
project:
project
)
}
it
"with no notes has a 0/0 score"
do
it
"with no notes has a 0/0 score"
do
subject
.
upvotes
.
should
==
0
subject
.
upvotes
.
should
==
0
end
end
it
"should recognize non-+1 notes"
do
it
"should recognize non-+1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
)
subject
.
should
have
(
1
).
note
subject
.
should
have
(
1
).
note
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
upvotes
.
should
==
0
subject
.
upvotes
.
should
==
0
end
end
it
"should recognize a single +1 note"
do
it
"should recognize a single +1 note"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
upvotes
.
should
==
1
subject
.
upvotes
.
should
==
1
end
end
it
"should recognize a multiple +1 notes"
do
it
"should recognize a multiple +1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
,
project:
Factory
(
:project
,
path:
'plusone'
,
code:
'plusone'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
,
project:
Factory
(
:project
,
path:
'plustwo'
,
code:
'plustwo'
)
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
)
subject
.
upvotes
.
should
==
2
subject
.
upvotes
.
should
==
2
end
end
end
end
describe
".search"
do
describe
".search"
do
let!
(
:issue
)
{
Factory
.
create
(
:issue
,
title:
"Searchable issue"
,
let!
(
:issue
)
{
Factory
.
create
(
:issue
,
title:
"Searchable issue"
)
}
project:
Factory
.
create
(
:project
))
}
it
"matches by title"
do
it
"matches by title"
do
Issue
.
search
(
'able'
).
all
.
should
==
[
issue
]
Issue
.
search
(
'able'
).
all
.
should
==
[
issue
]
...
...
spec/models/milestone_spec.rb
View file @
77d06454
...
@@ -25,11 +25,8 @@ describe Milestone do
...
@@ -25,11 +25,8 @@ describe Milestone do
it
{
should
validate_presence_of
(
:project_id
)
}
it
{
should
validate_presence_of
(
:project_id
)
}
end
end
let
(
:project
)
{
Factory
:project
}
let
(
:milestone
)
{
Factory
:milestone
}
let
(
:milestone
)
{
Factory
:milestone
,
project:
project
}
let
(
:issue
)
{
Factory
:issue
}
let
(
:issue
)
{
Factory
:issue
,
project:
project
}
it
{
milestone
.
should
be_valid
}
describe
"#percent_complete"
do
describe
"#percent_complete"
do
it
"should not count open issues"
do
it
"should not count open issues"
do
...
...
spec/models/note_spec.rb
View file @
77d06454
require
'spec_helper'
require
'spec_helper'
describe
Note
do
describe
Note
do
let
(
:project
)
{
Factory
:project
}
let!
(
:commit
)
{
project
.
commit
}
describe
"Associations"
do
describe
"Associations"
do
it
{
should
belong_to
(
:project
)
}
it
{
should
belong_to
(
:project
)
}
end
end
...
@@ -13,8 +10,6 @@ describe Note do
...
@@ -13,8 +10,6 @@ describe Note do
it
{
should
validate_presence_of
(
:project
)
}
it
{
should
validate_presence_of
(
:project
)
}
end
end
it
{
Factory
.
create
(
:note
,
project:
project
).
should
be_valid
}
describe
"Scopes"
do
describe
"Scopes"
do
it
"should have a today named scope that returns ..."
do
it
"should have a today named scope that returns ..."
do
Note
.
today
.
where_values
.
should
==
[
"created_at >= '
#{
Date
.
today
}
'"
]
Note
.
today
.
where_values
.
should
==
[
"created_at >= '
#{
Date
.
today
}
'"
]
...
@@ -25,26 +20,27 @@ describe Note do
...
@@ -25,26 +20,27 @@ describe Note do
let
(
:project
)
{
Factory
(
:project
)
}
let
(
:project
)
{
Factory
(
:project
)
}
it
"recognizes a neutral note"
do
it
"recognizes a neutral note"
do
note
=
Factory
(
:note
,
project:
project
,
note:
"This is not a +1 note"
)
note
=
Factory
(
:note
,
note:
"This is not a +1 note"
)
note
.
should_not
be_upvote
note
.
should_not
be_upvote
end
end
it
"recognizes a +1 note"
do
it
"recognizes a +1 note"
do
note
=
Factory
(
:note
,
project:
project
,
note:
"+1 for this"
)
note
=
Factory
(
:note
,
note:
"+1 for this"
)
note
.
should
be_upvote
note
.
should
be_upvote
end
end
it
"recognizes a -1 note as no vote"
do
it
"recognizes a -1 note as no vote"
do
note
=
Factory
(
:note
,
project:
project
,
note:
"-1 for this"
)
note
=
Factory
(
:note
,
note:
"-1 for this"
)
note
.
should_not
be_upvote
note
.
should_not
be_upvote
end
end
end
end
describe
"Commit notes"
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
commit
}
describe
"Commit notes"
do
before
do
before
do
@note
=
Factory
:note
,
@note
=
Factory
:note
,
project:
project
,
noteable_id:
commit
.
id
,
noteable_id:
commit
.
id
,
noteable_type:
"Commit"
noteable_type:
"Commit"
end
end
...
@@ -58,7 +54,6 @@ describe Note do
...
@@ -58,7 +54,6 @@ describe Note do
describe
"Pre-line commit notes"
do
describe
"Pre-line commit notes"
do
before
do
before
do
@note
=
Factory
:note
,
@note
=
Factory
:note
,
project:
project
,
noteable_id:
commit
.
id
,
noteable_id:
commit
.
id
,
noteable_type:
"Commit"
,
noteable_type:
"Commit"
,
line_code:
"0_16_1"
line_code:
"0_16_1"
...
@@ -91,8 +86,8 @@ describe Note do
...
@@ -91,8 +86,8 @@ describe Note do
describe
:authorization
do
describe
:authorization
do
before
do
before
do
@p1
=
project
@p1
=
create
(
:project
)
@p2
=
Factory
:project
,
code:
"alien"
,
path:
"gitlabhq_1"
@p2
=
Factory
:project
@u1
=
Factory
:user
@u1
=
Factory
:user
@u2
=
Factory
:user
@u2
=
Factory
:user
@u3
=
Factory
:user
@u3
=
Factory
:user
...
...
spec/models/user_spec.rb
View file @
77d06454
...
@@ -3,11 +3,12 @@ require 'spec_helper'
...
@@ -3,11 +3,12 @@ require 'spec_helper'
describe
User
do
describe
User
do
describe
"Associations"
do
describe
"Associations"
do
it
{
should
have_many
(
:projects
)
}
it
{
should
have_many
(
:projects
)
}
it
{
should
have_many
(
:users_projects
)
}
it
{
should
have_many
(
:users_projects
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:issues
)
}
it
{
should
have_many
(
:issues
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:assigned_issues
)
}
it
{
should
have_many
(
:assigned_issues
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:merge_requests
)
}
it
{
should
have_many
(
:merge_requests
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:assigned_merge_requests
)
}
it
{
should
have_many
(
:assigned_merge_requests
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:notes
).
dependent
(
:destroy
)
}
end
end
describe
"Respond to"
do
describe
"Respond to"
do
...
@@ -49,21 +50,6 @@ describe User do
...
@@ -49,21 +50,6 @@ describe User do
user
=
Factory
(
:user
)
user
=
Factory
(
:user
)
user
.
authentication_token
.
should_not
==
""
user
.
authentication_token
.
should_not
==
""
end
end
describe
"dependent"
do
before
do
@user
=
Factory
:user
@note
=
Factory
:note
,
author:
@user
,
project:
Factory
(
:project
)
end
it
"should destroy all notes with user"
do
Note
.
find_by_id
(
@note
.
id
).
should_not
be_nil
@user
.
destroy
Note
.
find_by_id
(
@note
.
id
).
should
be_nil
end
end
end
end
# == Schema Information
# == Schema Information
#
#
...
...
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