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
Kazuhiko Shiozaki
gitlab-ce
Commits
9d4d40de
Commit
9d4d40de
authored
Aug 29, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move IssueCommonality and Upvote specs out of models and into their own specs
parent
14daf2e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
66 deletions
+104
-66
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+5
-34
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+3
-32
spec/roles/issue_commonality_spec.rb
spec/roles/issue_commonality_spec.rb
+69
-0
spec/roles/upvote_spec.rb
spec/roles/upvote_spec.rb
+27
-0
No files found.
spec/models/issue_spec.rb
View file @
9d4d40de
...
...
@@ -19,6 +19,11 @@ describe Issue do
it
{
Issue
.
should
respond_to
:opened
}
end
describe
'modules'
do
it
{
should
include_module
(
IssueCommonality
)
}
it
{
should
include_module
(
Upvote
)
}
end
subject
{
Factory
.
create
(
:issue
)
}
describe
'#is_being_reassigned?'
do
...
...
@@ -61,40 +66,6 @@ describe Issue do
subject
.
is_being_reopened?
.
should
be_false
end
end
describe
"plus 1"
do
subject
{
Factory
.
create
(
:issue
)
}
it
"with no notes has a 0/0 score"
do
subject
.
upvotes
.
should
==
0
end
it
"should recognize non-+1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
)
subject
.
should
have
(
1
).
note
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
upvotes
.
should
==
0
end
it
"should recognize a single +1 note"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
upvotes
.
should
==
1
end
it
"should recognize a multiple +1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
)
subject
.
upvotes
.
should
==
2
end
end
describe
".search"
do
let!
(
:issue
)
{
Factory
.
create
(
:issue
,
title:
"Searchable issue"
)
}
it
"matches by title"
do
Issue
.
search
(
'able'
).
all
.
should
==
[
issue
]
end
end
end
# == Schema Information
#
...
...
spec/models/merge_request_spec.rb
View file @
9d4d40de
...
...
@@ -20,38 +20,9 @@ describe MergeRequest do
it
{
MergeRequest
.
should
respond_to
:opened
}
end
describe
"plus 1"
do
subject
{
Factory
.
create
(
:merge_request
)
}
it
"with no notes has a 0/0 score"
do
subject
.
upvotes
.
should
==
0
end
it
"should recognize non-+1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"No +1 here"
)
subject
.
should
have
(
1
).
note
subject
.
notes
.
first
.
upvote?
.
should
be_false
subject
.
upvotes
.
should
==
0
end
it
"should recognize a single +1 note"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
upvotes
.
should
==
1
end
it
"should recognize a multiple +1 notes"
do
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 This is awesome"
)
subject
.
notes
<<
Factory
(
:note
,
note:
"+1 I want this"
)
subject
.
upvotes
.
should
==
2
end
end
describe
".search"
do
let!
(
:issue
)
{
Factory
.
create
(
:issue
,
title:
"Searchable issue"
)
}
it
"matches by title"
do
Issue
.
search
(
'able'
).
all
.
should
==
[
issue
]
end
describe
'modules'
do
it
{
should
include_module
(
IssueCommonality
)
}
it
{
should
include_module
(
Upvote
)
}
end
end
# == Schema Information
...
...
spec/roles/issue_commonality_spec.rb
0 → 100644
View file @
9d4d40de
require
'spec_helper'
describe
Issue
,
"IssueCommonality"
do
let
(
:issue
)
{
create
(
:issue
)
}
describe
"Associations"
do
it
{
should
belong_to
(
:project
)
}
it
{
should
belong_to
(
:author
)
}
it
{
should
belong_to
(
:assignee
)
}
it
{
should
have_many
(
:notes
).
dependent
(
:destroy
)
}
end
describe
"Validation"
do
it
{
should
validate_presence_of
(
:project_id
)
}
it
{
should
validate_presence_of
(
:author_id
)
}
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
ensure_length_of
(
:title
).
is_at_least
(
0
).
is_at_most
(
255
)
}
end
describe
"Scope"
do
it
{
described_class
.
should
respond_to
(
:opened
)
}
it
{
described_class
.
should
respond_to
(
:closed
)
}
it
{
described_class
.
should
respond_to
(
:assigned
)
}
end
it
"has an :author_id_of_changes accessor"
do
issue
.
should
respond_to
(
:author_id_of_changes
)
issue
.
should
respond_to
(
:author_id_of_changes
=
)
end
describe
".search"
do
let!
(
:searchable_issue
)
{
create
(
:issue
,
title:
"Searchable issue"
)
}
it
"matches by title"
do
described_class
.
search
(
'able'
).
all
.
should
==
[
searchable_issue
]
end
end
describe
"#today?"
do
it
"returns true when created today"
do
# Avoid timezone differences and just return exactly what we want
Date
.
stub
(
:today
).
and_return
(
issue
.
created_at
.
to_date
)
issue
.
today?
.
should
be_true
end
it
"returns false when not created today"
do
Date
.
stub
(
:today
).
and_return
(
Date
.
yesterday
)
issue
.
today?
.
should
be_false
end
end
describe
"#new?"
do
it
"returns true when created today and record hasn't been updated"
do
issue
.
stub
(
:today?
).
and_return
(
true
)
issue
.
new?
.
should
be_true
end
it
"returns false when not created today"
do
issue
.
stub
(
:today?
).
and_return
(
false
)
issue
.
new?
.
should
be_false
end
it
"returns false when record has been updated"
do
issue
.
stub
(
:today?
).
and_return
(
true
)
issue
.
touch
issue
.
new?
.
should
be_false
end
end
end
spec/roles/upvote_spec.rb
0 → 100644
View file @
9d4d40de
require
'spec_helper'
describe
Issue
,
"Upvote"
do
let
(
:issue
)
{
create
(
:issue
)
}
it
"with no notes has a 0/0 score"
do
issue
.
upvotes
.
should
==
0
end
it
"should recognize non-+1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"No +1 here"
)
issue
.
should
have
(
1
).
note
issue
.
notes
.
first
.
upvote?
.
should
be_false
issue
.
upvotes
.
should
==
0
end
it
"should recognize a single +1 note"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
upvotes
.
should
==
1
end
it
"should recognize multiple +1 notes"
do
issue
.
notes
<<
create
(
:note
,
note:
"+1 This is awesome"
)
issue
.
notes
<<
create
(
:note
,
note:
"+1 I want this"
)
issue
.
upvotes
.
should
==
2
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