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
48015ded
Commit
48015ded
authored
Oct 12, 2016
by
Semyon Pupkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Union examples in event spec fo speed up
parent
d57d892e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
49 deletions
+61
-49
spec/models/event_spec.rb
spec/models/event_spec.rb
+61
-49
No files found.
spec/models/event_spec.rb
View file @
48015ded
...
@@ -27,17 +27,17 @@ describe Event, models: true do
...
@@ -27,17 +27,17 @@ describe Event, models: true do
end
end
describe
"Push event"
do
describe
"Push event"
do
before
do
let
(
:project
)
{
create
(
:project
)
}
project
=
create
(
:project
)
let
(
:user
)
{
project
.
owner
}
@user
=
project
.
owner
let
(
:event
)
{
create_event
(
project
,
user
)
}
@event
=
create_event
(
project
,
@user
)
end
it
{
expect
(
@event
.
push?
).
to
be_truthy
}
it
do
it
{
expect
(
@event
.
visible_to_user?
).
to
be_truthy
}
expect
(
event
.
push?
).
to
be_truthy
it
{
expect
(
@event
.
tag?
).
to
be_falsey
}
expect
(
event
.
visible_to_user?
).
to
be_truthy
it
{
expect
(
@event
.
branch_name
).
to
eq
(
"master"
)
}
expect
(
event
.
tag?
).
to
be_falsey
it
{
expect
(
@event
.
author
).
to
eq
(
@user
)
}
expect
(
event
.
branch_name
).
to
eq
(
"master"
)
expect
(
event
.
author
).
to
eq
(
user
)
end
end
end
describe
'#note?'
do
describe
'#note?'
do
...
@@ -79,23 +79,27 @@ describe Event, models: true do
...
@@ -79,23 +79,27 @@ describe Event, models: true do
context
'for non confidential issues'
do
context
'for non confidential issues'
do
let
(
:target
)
{
issue
}
let
(
:target
)
{
issue
}
it
{
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
}
it
do
it
{
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
end
context
'for confidential issues'
do
context
'for confidential issues'
do
let
(
:target
)
{
confidential_issue
}
let
(
:target
)
{
confidential_issue
}
it
{
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
}
it
do
it
{
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
it
{
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
}
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
end
end
end
...
@@ -103,23 +107,27 @@ describe Event, models: true do
...
@@ -103,23 +107,27 @@ describe Event, models: true do
context
'on non confidential issues'
do
context
'on non confidential issues'
do
let
(
:target
)
{
note_on_issue
}
let
(
:target
)
{
note_on_issue
}
it
{
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
}
it
do
it
{
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
end
context
'on confidential issues'
do
context
'on confidential issues'
do
let
(
:target
)
{
note_on_confidential_issue
}
let
(
:target
)
{
note_on_confidential_issue
}
it
{
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
}
it
do
it
{
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
it
{
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
}
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
end
end
end
...
@@ -129,22 +137,26 @@ describe Event, models: true do
...
@@ -129,22 +137,26 @@ describe Event, models: true do
let
(
:note_on_merge_request
)
{
create
(
:legacy_diff_note_on_merge_request
,
noteable:
merge_request
,
project:
project
)
}
let
(
:note_on_merge_request
)
{
create
(
:legacy_diff_note_on_merge_request
,
noteable:
merge_request
,
project:
project
)
}
let
(
:target
)
{
note_on_merge_request
}
let
(
:target
)
{
note_on_merge_request
}
it
{
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
}
it
do
it
{
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
true
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
context
'private project'
do
context
'private project'
do
let
(
:project
)
{
create
(
:project
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
:private
)
}
it
{
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
}
it
do
it
{
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
non_member
)).
to
eq
false
it
{
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
author
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
assignee
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
}
expect
(
event
.
visible_to_user?
(
member
)).
to
eq
true
it
{
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
}
expect
(
event
.
visible_to_user?
(
guest
)).
to
eq
false
expect
(
event
.
visible_to_user?
(
admin
)).
to
eq
true
end
end
end
end
end
end
end
...
@@ -214,6 +226,6 @@ describe Event, models: true do
...
@@ -214,6 +226,6 @@ describe Event, models: true do
action:
Event
::
PUSHED
,
action:
Event
::
PUSHED
,
data:
data
,
data:
data
,
author_id:
user
.
id
author_id:
user
.
id
}.
merge
(
attrs
))
}.
merge
!
(
attrs
))
end
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