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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e6c0673e
Commit
e6c0673e
authored
Jan 03, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rspec models Milestone, Commit, UsersProject
parent
2095780f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
157 additions
and
1 deletion
+157
-1
app/models/commit.rb
app/models/commit.rb
+1
-1
app/models/users_project.rb
app/models/users_project.rb
+4
-0
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+61
-0
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+50
-0
spec/models/users_project_spec.rb
spec/models/users_project_spec.rb
+41
-0
No files found.
app/models/commit.rb
View file @
e6c0673e
...
@@ -11,7 +11,7 @@ class Commit
...
@@ -11,7 +11,7 @@ class Commit
attr_accessor
:commit
,
:head
,
:refs
attr_accessor
:commit
,
:head
,
:refs
delegate
:message
,
:authored_date
,
:committed_date
,
:parents
,
:sha
,
delegate
:message
,
:authored_date
,
:committed_date
,
:parents
,
:sha
,
:date
,
:committer
,
:author
,
:
message
,
:
diffs
,
:tree
,
:id
,
:date
,
:committer
,
:author
,
:diffs
,
:tree
,
:id
,
:to_patch
,
to: :commit
:to_patch
,
to: :commit
class
<<
self
class
<<
self
...
...
app/models/users_project.rb
View file @
e6c0673e
...
@@ -35,6 +35,10 @@ class UsersProject < ActiveRecord::Base
...
@@ -35,6 +35,10 @@ class UsersProject < ActiveRecord::Base
delegate
:name
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:email
,
to: :user
,
prefix:
true
scope
:guests
,
where
(
project_access:
GUEST
)
scope
:reporters
,
where
(
project_access:
REPORTER
)
scope
:developers
,
where
(
project_access:
DEVELOPER
)
scope
:masters
,
where
(
project_access:
MASTER
)
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
class
<<
self
class
<<
self
...
...
spec/models/commit_spec.rb
View file @
e6c0673e
...
@@ -34,4 +34,65 @@ describe Commit do
...
@@ -34,4 +34,65 @@ describe Commit do
end
end
end
end
end
end
describe
"Commit info"
do
before
do
@committer
=
double
(
email:
'mike@smith.com'
,
name:
'Mike Smith'
)
@author
=
double
(
email:
'john@smith.com'
,
name:
'John Smith'
)
@raw_commit
=
double
(
id:
"bcf03b5de6abcf03b5de6c"
,
author:
@author
,
committer:
@committer
,
committed_date:
Date
.
yesterday
,
message:
'Refactoring specs'
)
@commit
=
Commit
.
new
(
@raw_commit
)
end
it
{
@commit
.
short_id
.
should
==
"bcf03b5de6a"
}
it
{
@commit
.
safe_message
.
should
==
@raw_commit
.
message
}
it
{
@commit
.
created_at
.
should
==
@raw_commit
.
committed_date
}
it
{
@commit
.
author_email
.
should
==
@author
.
email
}
it
{
@commit
.
author_name
.
should
==
@author
.
name
}
it
{
@commit
.
committer_name
.
should
==
@committer
.
name
}
it
{
@commit
.
committer_email
.
should
==
@committer
.
email
}
it
{
@commit
.
different_committer?
.
should
be_true
}
end
describe
"Class methods"
do
subject
{
Commit
}
it
{
should
respond_to
(
:find_or_first
)
}
it
{
should
respond_to
(
:fresh_commits
)
}
it
{
should
respond_to
(
:commits_with_refs
)
}
it
{
should
respond_to
(
:commits_since
)
}
it
{
should
respond_to
(
:commits_between
)
}
it
{
should
respond_to
(
:commits
)
}
it
{
should
respond_to
(
:compare
)
}
end
describe
"delegation"
do
subject
{
commit
}
it
{
should
respond_to
(
:message
)
}
it
{
should
respond_to
(
:authored_date
)
}
it
{
should
respond_to
(
:committed_date
)
}
it
{
should
respond_to
(
:parents
)
}
it
{
should
respond_to
(
:date
)
}
it
{
should
respond_to
(
:committer
)
}
it
{
should
respond_to
(
:author
)
}
it
{
should
respond_to
(
:diffs
)
}
it
{
should
respond_to
(
:tree
)
}
it
{
should
respond_to
(
:id
)
}
it
{
should
respond_to
(
:to_patch
)
}
end
end
end
spec/models/milestone_spec.rb
View file @
e6c0673e
...
@@ -63,4 +63,54 @@ describe Milestone do
...
@@ -63,4 +63,54 @@ describe Milestone do
milestone
.
expires_at
.
should
be_present
milestone
.
expires_at
.
should
be_present
end
end
end
end
describe
:expired?
do
context
"expired"
do
before
do
milestone
.
stub
(
due_date:
Date
.
today
.
prev_year
)
end
it
{
milestone
.
expired?
.
should
be_true
}
end
context
"not expired"
do
before
do
milestone
.
stub
(
due_date:
Date
.
today
.
next_year
)
end
it
{
milestone
.
expired?
.
should
be_false
}
end
end
describe
:percent_complete
do
before
do
milestone
.
stub
(
closed_items_count:
3
,
total_items_count:
4
)
end
it
{
milestone
.
percent_complete
.
should
==
75
}
end
describe
:items_count
do
before
do
milestone
.
issues
<<
create
(
:issue
)
milestone
.
issues
<<
create
(
:issue
,
closed:
true
)
milestone
.
merge_requests
<<
create
(
:merge_request
)
end
it
{
milestone
.
closed_items_count
.
should
==
1
}
it
{
milestone
.
open_items_count
.
should
==
2
}
it
{
milestone
.
total_items_count
.
should
==
3
}
it
{
milestone
.
is_empty?
.
should
be_false
}
end
describe
:can_be_closed?
do
it
{
milestone
.
can_be_closed?
.
should
be_true
}
end
describe
:open?
do
it
{
milestone
.
open?
.
should
be_true
}
end
end
end
spec/models/users_project_spec.rb
View file @
e6c0673e
...
@@ -69,4 +69,45 @@ describe UsersProject do
...
@@ -69,4 +69,45 @@ describe UsersProject do
it
{
@project_1
.
users
.
should_not
include
(
@user_2
)
}
it
{
@project_1
.
users
.
should_not
include
(
@user_2
)
}
end
end
end
end
describe
:add_users_into_projects
do
before
do
@project_1
=
create
:project
@project_2
=
create
:project
@user_1
=
create
:user
@user_2
=
create
:user
UsersProject
.
add_users_into_projects
(
[
@project_1
.
id
,
@project_2
.
id
],
[
@user_1
.
id
,
@user_2
.
id
],
UsersProject
::
MASTER
)
end
it
{
@project_1
.
users
.
should
include
(
@user_1
)
}
it
{
@project_1
.
users
.
should
include
(
@user_2
)
}
it
{
@project_2
.
users
.
should
include
(
@user_1
)
}
it
{
@project_2
.
users
.
should
include
(
@user_2
)
}
end
describe
:truncate_teams
do
before
do
@project_1
=
create
:project
@project_2
=
create
:project
@user_1
=
create
:user
@user_2
=
create
:user
@project_1
.
add_access
@user_1
,
:write
@project_2
.
add_access
@user_2
,
:read
UsersProject
.
truncate_teams
([
@project_1
.
id
,
@project_2
.
id
])
end
it
{
@project_1
.
users
.
should
be_empty
}
it
{
@project_2
.
users
.
should
be_empty
}
end
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