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
095ac7d3
Commit
095ac7d3
authored
May 01, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto-correct `RSpec/DescribedClass` violations
parent
e979674b
Changes
52
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
220 additions
and
220 deletions
+220
-220
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+4
-4
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+6
-6
spec/finders/merge_requests_finder_spec.rb
spec/finders/merge_requests_finder_spec.rb
+5
-5
spec/finders/snippets_finder_spec.rb
spec/finders/snippets_finder_spec.rb
+18
-18
spec/lib/banzai/renderer_spec.rb
spec/lib/banzai/renderer_spec.rb
+1
-1
spec/lib/ee/gitlab/ldap/person_spec.rb
spec/lib/ee/gitlab/ldap/person_spec.rb
+3
-3
spec/lib/gitlab/changes_list_spec.rb
spec/lib/gitlab/changes_list_spec.rb
+1
-1
spec/lib/gitlab/ci/build/credentials/factory_spec.rb
spec/lib/gitlab/ci/build/credentials/factory_spec.rb
+2
-2
spec/lib/gitlab/ci/build/credentials/registry_spec.rb
spec/lib/gitlab/ci/build/credentials/registry_spec.rb
+3
-3
spec/lib/gitlab/current_settings_spec.rb
spec/lib/gitlab/current_settings_spec.rb
+2
-2
spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb
spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb
+1
-1
spec/lib/gitlab/git/util_spec.rb
spec/lib/gitlab/git/util_spec.rb
+1
-1
spec/lib/gitlab/gitaly_client/ref_spec.rb
spec/lib/gitlab/gitaly_client/ref_spec.rb
+1
-1
spec/lib/gitlab/ldap/person_spec.rb
spec/lib/gitlab/ldap/person_spec.rb
+3
-3
spec/lib/gitlab/metrics_spec.rb
spec/lib/gitlab/metrics_spec.rb
+14
-14
spec/lib/gitlab/mirror_spec.rb
spec/lib/gitlab/mirror_spec.rb
+30
-30
spec/lib/gitlab/sidekiq_throttler_spec.rb
spec/lib/gitlab/sidekiq_throttler_spec.rb
+2
-2
spec/lib/gitlab/slash_commands/dsl_spec.rb
spec/lib/gitlab/slash_commands/dsl_spec.rb
+1
-1
spec/lib/gitlab/template/gitignore_template_spec.rb
spec/lib/gitlab/template/gitignore_template_spec.rb
+1
-1
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
+1
-1
spec/lib/gitlab/template/issue_template_spec.rb
spec/lib/gitlab/template/issue_template_spec.rb
+1
-1
spec/lib/gitlab/template/merge_request_template_spec.rb
spec/lib/gitlab/template/merge_request_template_spec.rb
+1
-1
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+2
-2
spec/mailers/emails/csv_export_spec.rb
spec/mailers/emails/csv_export_spec.rb
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+45
-45
spec/models/historical_data_spec.rb
spec/models/historical_data_spec.rb
+8
-8
spec/models/ldap_group_link_spec.rb
spec/models/ldap_group_link_spec.rb
+1
-1
spec/models/license_spec.rb
spec/models/license_spec.rb
+13
-13
spec/models/project_services/jenkins_service_spec.rb
spec/models/project_services/jenkins_service_spec.rb
+4
-4
spec/models/remote_mirror_spec.rb
spec/models/remote_mirror_spec.rb
+2
-2
spec/requests/api/helpers/internal_helpers_spec.rb
spec/requests/api/helpers/internal_helpers_spec.rb
+1
-1
spec/requests/api/helpers_spec.rb
spec/requests/api/helpers_spec.rb
+1
-1
spec/services/merge_requests/ff_merge_service_spec.rb
spec/services/merge_requests/ff_merge_service_spec.rb
+2
-2
spec/services/merge_requests/get_urls_service_spec.rb
spec/services/merge_requests/get_urls_service_spec.rb
+2
-2
spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
...s/merge_requests/merge_request_diff_cache_service_spec.rb
+1
-1
spec/services/merge_requests/rebase_service_spec.rb
spec/services/merge_requests/rebase_service_spec.rb
+1
-1
spec/services/merge_requests/resolve_service_spec.rb
spec/services/merge_requests/resolve_service_spec.rb
+6
-6
spec/services/projects/housekeeping_service_spec.rb
spec/services/projects/housekeeping_service_spec.rb
+1
-1
spec/tasks/config_lint_spec.rb
spec/tasks/config_lint_spec.rb
+2
-2
spec/workers/admin_emails_worker_spec.rb
spec/workers/admin_emails_worker_spec.rb
+3
-3
spec/workers/delete_user_worker_spec.rb
spec/workers/delete_user_worker_spec.rb
+2
-2
spec/workers/emails_on_push_worker_spec.rb
spec/workers/emails_on_push_worker_spec.rb
+1
-1
spec/workers/git_garbage_collect_worker_spec.rb
spec/workers/git_garbage_collect_worker_spec.rb
+1
-1
spec/workers/gitlab_usage_ping_worker_spec.rb
spec/workers/gitlab_usage_ping_worker_spec.rb
+1
-1
spec/workers/group_destroy_worker_spec.rb
spec/workers/group_destroy_worker_spec.rb
+1
-1
spec/workers/merge_worker_spec.rb
spec/workers/merge_worker_spec.rb
+1
-1
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+10
-10
spec/workers/project_destroy_worker_spec.rb
spec/workers/project_destroy_worker_spec.rb
+1
-1
spec/workers/project_update_repository_storage_worker_spec.rb
.../workers/project_update_repository_storage_worker_spec.rb
+1
-1
spec/workers/remove_expired_members_worker_spec.rb
spec/workers/remove_expired_members_worker_spec.rb
+1
-1
spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb
spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb
+1
-1
spec/workers/repository_fork_worker_spec.rb
spec/workers/repository_fork_worker_spec.rb
+1
-1
No files found.
spec/controllers/application_controller_spec.rb
View file @
095ac7d3
...
...
@@ -4,7 +4,7 @@ describe ApplicationController do
let
(
:user
)
{
create
(
:user
)
}
describe
'#check_password_expiration'
do
let
(
:controller
)
{
ApplicationController
.
new
}
let
(
:controller
)
{
described_class
.
new
}
it
'redirects if the user is over their password expiry'
do
user
.
password_expires_at
=
Time
.
new
(
2002
)
...
...
@@ -34,7 +34,7 @@ describe ApplicationController do
describe
"#authenticate_user_from_token!"
do
describe
"authenticating a user from a private token"
do
controller
(
ApplicationController
)
do
controller
(
described_class
)
do
def
index
render
text:
"authenticated"
end
...
...
@@ -66,7 +66,7 @@ describe ApplicationController do
end
describe
"authenticating a user from a personal access token"
do
controller
(
ApplicationController
)
do
controller
(
described_class
)
do
def
index
render
text:
'authenticated'
end
...
...
@@ -115,7 +115,7 @@ describe ApplicationController do
end
context
'two-factor authentication'
do
let
(
:controller
)
{
ApplicationController
.
new
}
let
(
:controller
)
{
described_class
.
new
}
describe
'#check_two_factor_requirement'
do
subject
{
controller
.
send
:check_two_factor_requirement
}
...
...
spec/finders/issues_finder_spec.rb
View file @
095ac7d3
...
...
@@ -16,7 +16,7 @@ describe IssuesFinder do
set
(
:label_link
)
{
create
(
:label_link
,
label:
label
,
target:
issue2
)
}
let
(
:search_user
)
{
user
}
let
(
:params
)
{
{}
}
let
(
:issues
)
{
IssuesFinder
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
let
(
:issues
)
{
described_class
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
before
(
:context
)
do
project1
.
team
<<
[
user
,
:master
]
...
...
@@ -300,23 +300,23 @@ describe IssuesFinder do
let!
(
:confidential_issue
)
{
create
(
:issue
,
project:
project
,
confidential:
true
)
}
it
'returns non confidential issues for nil user'
do
expect
(
IssuesFinder
.
send
(
:not_restricted_by_confidentiality
,
nil
)).
to
include
(
public_issue
)
expect
(
described_class
.
send
(
:not_restricted_by_confidentiality
,
nil
)).
to
include
(
public_issue
)
end
it
'returns non confidential issues for user not authorized for the issues projects'
do
expect
(
IssuesFinder
.
send
(
:not_restricted_by_confidentiality
,
user
)).
to
include
(
public_issue
)
expect
(
described_class
.
send
(
:not_restricted_by_confidentiality
,
user
)).
to
include
(
public_issue
)
end
it
'returns all issues for user authorized for the issues projects'
do
expect
(
IssuesFinder
.
send
(
:not_restricted_by_confidentiality
,
authorized_user
)).
to
include
(
public_issue
,
confidential_issue
)
expect
(
described_class
.
send
(
:not_restricted_by_confidentiality
,
authorized_user
)).
to
include
(
public_issue
,
confidential_issue
)
end
it
'returns all issues for an admin user'
do
expect
(
IssuesFinder
.
send
(
:not_restricted_by_confidentiality
,
admin_user
)).
to
include
(
public_issue
,
confidential_issue
)
expect
(
described_class
.
send
(
:not_restricted_by_confidentiality
,
admin_user
)).
to
include
(
public_issue
,
confidential_issue
)
end
it
'returns all issues for an auditor user'
do
expect
(
IssuesFinder
.
send
(
:not_restricted_by_confidentiality
,
auditor_user
)).
to
include
(
public_issue
,
confidential_issue
)
expect
(
described_class
.
send
(
:not_restricted_by_confidentiality
,
auditor_user
)).
to
include
(
public_issue
,
confidential_issue
)
end
end
end
spec/finders/merge_requests_finder_spec.rb
View file @
095ac7d3
...
...
@@ -23,32 +23,32 @@ describe MergeRequestsFinder do
describe
"#execute"
do
it
'filters by scope'
do
params
=
{
scope:
'authored'
,
state:
'opened'
}
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
expect
(
merge_requests
.
size
).
to
eq
(
3
)
end
it
'filters by project'
do
params
=
{
project_id:
project1
.
id
,
scope:
'authored'
,
state:
'opened'
}
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
expect
(
merge_requests
.
size
).
to
eq
(
1
)
end
it
'ignores sorting by weight'
do
params
=
{
project_id:
project1
.
id
,
scope:
'authored'
,
state:
'opened'
,
weight:
Issue
::
WEIGHT_ANY
}
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
expect
(
merge_requests
.
size
).
to
eq
(
1
)
end
it
'filters by non_archived'
do
params
=
{
non_archived:
true
}
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
expect
(
merge_requests
.
size
).
to
eq
(
3
)
end
it
'filters by iid'
do
params
=
{
project_id:
project1
.
id
,
iids:
merge_request1
.
iid
}
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
merge_requests
=
described_class
.
new
(
user
,
params
).
execute
expect
(
merge_requests
).
to
contain_exactly
(
merge_request1
)
end
...
...
spec/finders/snippets_finder_spec.rb
View file @
095ac7d3
...
...
@@ -14,14 +14,14 @@ describe SnippetsFinder do
let!
(
:snippet3
)
{
create
(
:personal_snippet
,
:public
)
}
it
"returns all private and internal snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :all
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :all
)
expect
(
snippets
).
to
include
(
snippet2
,
snippet3
)
expect
(
snippets
).
not_to
include
(
snippet1
)
end
it
"returns all public snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
nil
,
filter: :all
)
snippets
=
described_class
.
new
.
execute
(
nil
,
filter: :all
)
expect
(
snippets
).
to
include
(
snippet3
)
expect
(
snippets
).
not_to
include
(
snippet1
,
snippet2
)
...
...
@@ -34,7 +34,7 @@ describe SnippetsFinder do
let!
(
:snippet3
)
{
create
(
:personal_snippet
,
:public
)
}
it
"returns public public snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
nil
,
filter: :public
)
snippets
=
described_class
.
new
.
execute
(
nil
,
filter: :public
)
expect
(
snippets
).
to
include
(
snippet3
)
expect
(
snippets
).
not_to
include
(
snippet1
,
snippet2
)
...
...
@@ -47,40 +47,40 @@ describe SnippetsFinder do
let!
(
:snippet3
)
{
create
(
:personal_snippet
,
:public
,
author:
user
)
}
it
"returns all public and internal snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user1
,
filter: :by_user
,
user:
user
)
snippets
=
described_class
.
new
.
execute
(
user1
,
filter: :by_user
,
user:
user
)
expect
(
snippets
).
to
include
(
snippet2
,
snippet3
)
expect
(
snippets
).
not_to
include
(
snippet1
)
end
it
"returns internal snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
,
scope:
"are_internal"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
,
scope:
"are_internal"
)
expect
(
snippets
).
to
include
(
snippet2
)
expect
(
snippets
).
not_to
include
(
snippet1
,
snippet3
)
end
it
"returns private snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
,
scope:
"are_private"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
,
scope:
"are_private"
)
expect
(
snippets
).
to
include
(
snippet1
)
expect
(
snippets
).
not_to
include
(
snippet2
,
snippet3
)
end
it
"returns public snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
,
scope:
"are_public"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
,
scope:
"are_public"
)
expect
(
snippets
).
to
include
(
snippet3
)
expect
(
snippets
).
not_to
include
(
snippet1
,
snippet2
)
end
it
"returns all snippets"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_user
,
user:
user
)
expect
(
snippets
).
to
include
(
snippet1
,
snippet2
,
snippet3
)
end
it
"returns only public snippets if unauthenticated user"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
nil
,
filter: :by_user
,
user:
user
)
snippets
=
described_class
.
new
.
execute
(
nil
,
filter: :by_user
,
user:
user
)
expect
(
snippets
).
to
include
(
snippet3
)
expect
(
snippets
).
not_to
include
(
snippet2
,
snippet1
)
...
...
@@ -95,35 +95,35 @@ describe SnippetsFinder do
end
it
"returns public snippets for unauthorized user"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
nil
,
filter: :by_project
,
project:
project1
)
snippets
=
described_class
.
new
.
execute
(
nil
,
filter: :by_project
,
project:
project1
)
expect
(
snippets
).
to
include
(
@snippet3
)
expect
(
snippets
).
not_to
include
(
@snippet1
,
@snippet2
)
end
it
"returns public and internal snippets for non project members"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
expect
(
snippets
).
to
include
(
@snippet2
,
@snippet3
)
expect
(
snippets
).
not_to
include
(
@snippet1
)
end
it
"returns public snippets for non project members"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_public"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_public"
)
expect
(
snippets
).
to
include
(
@snippet3
)
expect
(
snippets
).
not_to
include
(
@snippet1
,
@snippet2
)
end
it
"returns internal snippets for non project members"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_internal"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_internal"
)
expect
(
snippets
).
to
include
(
@snippet2
)
expect
(
snippets
).
not_to
include
(
@snippet1
,
@snippet3
)
end
it
"does not return private snippets for non project members"
do
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_private"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_private"
)
expect
(
snippets
).
not_to
include
(
@snippet1
,
@snippet2
,
@snippet3
)
end
...
...
@@ -131,7 +131,7 @@ describe SnippetsFinder do
it
"returns all snippets for project members"
do
project1
.
team
<<
[
user
,
:developer
]
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
expect
(
snippets
).
to
include
(
@snippet1
,
@snippet2
,
@snippet3
)
end
...
...
@@ -139,7 +139,7 @@ describe SnippetsFinder do
it
"returns private snippets for project members"
do
project1
.
team
<<
[
user
,
:developer
]
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_private"
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
,
scope:
"are_private"
)
expect
(
snippets
).
to
include
(
@snippet1
)
end
...
...
@@ -147,7 +147,7 @@ describe SnippetsFinder do
it
"returns all snippets for admin users"
do
user
=
create
(
:user
,
:admin
)
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
expect
(
snippets
).
to
include
(
@snippet1
,
@snippet2
,
@snippet3
)
end
...
...
@@ -155,7 +155,7 @@ describe SnippetsFinder do
it
"returns all snippets for auditor users"
do
user
=
create
(
:user
,
:auditor
)
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
snippets
=
described_class
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
expect
(
snippets
).
to
include
(
@snippet1
,
@snippet2
,
@snippet3
)
end
...
...
spec/lib/banzai/renderer_spec.rb
View file @
095ac7d3
...
...
@@ -11,7 +11,7 @@ describe Banzai::Renderer do
end
describe
'#render_field'
do
let
(
:renderer
)
{
Banzai
::
Renderer
}
let
(
:renderer
)
{
described_class
}
subject
{
renderer
.
render_field
(
object
,
:field
)
}
context
'with a stale cache'
do
...
...
spec/lib/ee/gitlab/ldap/person_spec.rb
View file @
095ac7d3
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
LDAP
::
Person
do
it
'includes the EE module'
do
expect
(
Gitlab
::
LDAP
::
Person
).
to
include
(
EE
::
Gitlab
::
LDAP
::
Person
)
expect
(
described_class
).
to
include
(
EE
::
Gitlab
::
LDAP
::
Person
)
end
describe
'#kerberos_principal'
do
...
...
@@ -12,7 +12,7 @@ describe Gitlab::LDAP::Person do
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
ldif
)
end
subject
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
subject
{
described_class
.
new
(
entry
,
'ldapmain'
)
}
context
'when sAMAccountName is not defined (non-AD LDAP server)'
do
let
(
:sam_account_name
)
{
nil
}
...
...
@@ -38,7 +38,7 @@ describe Gitlab::LDAP::Person do
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com
\n
#{
keys
}
"
)
end
subject
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
subject
{
described_class
.
new
(
entry
,
'ldapmain'
)
}
before
do
allow_any_instance_of
(
Gitlab
::
LDAP
::
Config
).
to
receive_messages
(
sync_ssh_keys:
ssh_key_attribute_name
)
...
...
spec/lib/gitlab/changes_list_spec.rb
View file @
095ac7d3
...
...
@@ -5,7 +5,7 @@ describe Gitlab::ChangesList do
let
(
:invalid_changes
)
{
1
}
context
'when changes is a valid string'
do
let
(
:changes_list
)
{
Gitlab
::
ChangesList
.
new
(
valid_changes_string
)
}
let
(
:changes_list
)
{
described_class
.
new
(
valid_changes_string
)
}
it
'splits elements by newline character'
do
expect
(
changes_list
).
to
contain_exactly
({
...
...
spec/lib/gitlab/ci/build/credentials/factory_spec.rb
View file @
095ac7d3
...
...
@@ -3,14 +3,14 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Credentials
::
Factory
do
let
(
:build
)
{
create
(
:ci_build
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
subject
{
Gitlab
::
Ci
::
Build
::
Credentials
::
Factory
.
new
(
build
).
create!
}
subject
{
described_class
.
new
(
build
).
create!
}
class
TestProvider
def
initialize
(
build
);
end
end
before
do
allow_any_instance_of
(
Gitlab
::
Ci
::
Build
::
Credentials
::
Factory
).
to
receive
(
:providers
).
and_return
([
TestProvider
])
allow_any_instance_of
(
described_class
).
to
receive
(
:providers
).
and_return
([
TestProvider
])
end
context
'when provider is valid'
do
...
...
spec/lib/gitlab/ci/build/credentials/registry_spec.rb
View file @
095ac7d3
...
...
@@ -4,14 +4,14 @@ describe Gitlab::Ci::Build::Credentials::Registry do
let
(
:build
)
{
create
(
:ci_build
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let
(
:registry_url
)
{
'registry.example.com:5005'
}
subject
{
Gitlab
::
Ci
::
Build
::
Credentials
::
Registry
.
new
(
build
)
}
subject
{
described_class
.
new
(
build
)
}
before
do
stub_container_registry_config
(
host_port:
registry_url
)
end
it
'contains valid DockerRegistry credentials'
do
expect
(
subject
).
to
be_kind_of
(
Gitlab
::
Ci
::
Build
::
Credentials
::
Registry
)
expect
(
subject
).
to
be_kind_of
(
described_class
)
expect
(
subject
.
username
).
to
eq
'gitlab-ci-token'
expect
(
subject
.
password
).
to
eq
build
.
token
...
...
@@ -20,7 +20,7 @@ describe Gitlab::Ci::Build::Credentials::Registry do
end
describe
'.valid?'
do
subject
{
Gitlab
::
Ci
::
Build
::
Credentials
::
Registry
.
new
(
build
).
valid?
}
subject
{
described_class
.
new
(
build
).
valid?
}
context
'when registry is enabled'
do
before
do
...
...
spec/lib/gitlab/current_settings_spec.rb
View file @
095ac7d3
...
...
@@ -10,7 +10,7 @@ describe Gitlab::CurrentSettings do
describe
'#current_application_settings'
do
context
'with DB available'
do
before
do
allow_any_instance_of
(
Gitlab
::
CurrentSetting
s
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
allow_any_instance_of
(
described_clas
s
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
end
it
'attempts to use cached values first'
do
...
...
@@ -36,7 +36,7 @@ describe Gitlab::CurrentSettings do
context
'with DB unavailable'
do
before
do
allow_any_instance_of
(
Gitlab
::
CurrentSetting
s
).
to
receive
(
:connect_to_db?
).
and_return
(
false
)
allow_any_instance_of
(
described_clas
s
).
to
receive
(
:connect_to_db?
).
and_return
(
false
)
end
it
'returns an in-memory ApplicationSetting object'
do
...
...
spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb
View file @
095ac7d3
...
...
@@ -20,7 +20,7 @@ describe Gitlab::CycleAnalytics::BaseEventFetcher do
before
do
allow_any_instance_of
(
Gitlab
::
ReferenceExtractor
).
to
receive
(
:issues
).
and_return
(
Issue
.
all
)
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
BaseEventFetcher
).
to
receive
(
:serialize
)
do
|
event
|
allow_any_instance_of
(
described_class
).
to
receive
(
:serialize
)
do
|
event
|
event
end
...
...
spec/lib/gitlab/git/util_spec.rb
View file @
095ac7d3
...
...
@@ -9,7 +9,7 @@ describe Gitlab::Git::Util do
[
"foo
\n\n
"
,
2
],
].
each
do
|
string
,
line_count
|
it
"counts
#{
line_count
}
lines in
#{
string
.
inspect
}
"
do
expect
(
Gitlab
::
Git
::
Util
.
count_lines
(
string
)).
to
eq
(
line_count
)
expect
(
described_class
.
count_lines
(
string
)).
to
eq
(
line_count
)
end
end
end
...
...
spec/lib/gitlab/gitaly_client/ref_spec.rb
View file @
095ac7d3
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
GitalyClient
::
Ref
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:repo_path
)
{
project
.
repository
.
path_to_repo
}
let
(
:client
)
{
Gitlab
::
GitalyClient
::
Ref
.
new
(
project
.
repository
)
}
let
(
:client
)
{
described_class
.
new
(
project
.
repository
)
}
before
do
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:enabled
).
and_return
(
true
)
...
...
spec/lib/gitlab/ldap/person_spec.rb
View file @
095ac7d3
...
...
@@ -20,7 +20,7 @@ describe Gitlab::LDAP::Person do
it
'uses the configured name attribute and handles values as an array'
do
name
=
'John Doe'
entry
[
'cn'
]
=
[
name
]
person
=
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
person
=
described_class
.
new
(
entry
,
'ldapmain'
)
expect
(
person
.
name
).
to
eq
(
name
)
end
...
...
@@ -30,7 +30,7 @@ describe Gitlab::LDAP::Person do
it
'returns the value of mail, if present'
do
mail
=
'john@example.com'
entry
[
'mail'
]
=
mail
person
=
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
person
=
described_class
.
new
(
entry
,
'ldapmain'
)
expect
(
person
.
email
).
to
eq
([
mail
])
end
...
...
@@ -38,7 +38,7 @@ describe Gitlab::LDAP::Person do
it
'returns the value of userPrincipalName, if mail and email are not present'
do
user_principal_name
=
'john.doe@example.com'
entry
[
'userPrincipalName'
]
=
user_principal_name
person
=
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
person
=
described_class
.
new
(
entry
,
'ldapmain'
)
expect
(
person
.
email
).
to
eq
([
user_principal_name
])
end
...
...
spec/lib/gitlab/metrics_spec.rb
View file @
095ac7d3
...
...
@@ -20,7 +20,7 @@ describe Gitlab::Metrics do
expect
(
pool
).
to
receive
(
:with
).
and_yield
(
connection
)
expect
(
connection
).
to
receive
(
:write_points
).
with
(
an_instance_of
(
Array
))
expect
(
Gitlab
::
Metric
s
).
to
receive
(
:pool
).
and_return
(
pool
)
expect
(
described_clas
s
).
to
receive
(
:pool
).
and_return
(
pool
)
described_class
.
submit_metrics
([{
'series'
=>
'kittens'
,
'tags'
=>
{}
}])
end
...
...
@@ -64,7 +64,7 @@ describe Gitlab::Metrics do
describe
'.measure'
do
context
'without a transaction'
do
it
'returns the return value of the block'
do
val
=
Gitlab
::
Metric
s
.
measure
(
:foo
)
{
10
}
val
=
described_clas
s
.
measure
(
:foo
)
{
10
}
expect
(
val
).
to
eq
(
10
)
end
...
...
@@ -74,7 +74,7 @@ describe Gitlab::Metrics do
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
}
before
do
allow
(
Gitlab
::
Metric
s
).
to
receive
(
:current_transaction
).
allow
(
described_clas
s
).
to
receive
(
:current_transaction
).
and_return
(
transaction
)
end
...
...
@@ -88,11 +88,11 @@ describe Gitlab::Metrics do
expect
(
transaction
).
to
receive
(
:increment
).
with
(
'foo_call_count'
,
1
)
Gitlab
::
Metric
s
.
measure
(
:foo
)
{
10
}
described_clas
s
.
measure
(
:foo
)
{
10
}
end
it
'returns the return value of the block'
do
val
=
Gitlab
::
Metric
s
.
measure
(
:foo
)
{
10
}
val
=
described_clas
s
.
measure
(
:foo
)
{
10
}
expect
(
val
).
to
eq
(
10
)
end
...
...
@@ -105,7 +105,7 @@ describe Gitlab::Metrics do
expect_any_instance_of
(
Gitlab
::
Metrics
::
Transaction
).
not_to
receive
(
:add_tag
)
Gitlab
::
Metric
s
.
tag_transaction
(
:foo
,
'bar'
)
described_clas
s
.
tag_transaction
(
:foo
,
'bar'
)
end
end
...
...
@@ -113,13 +113,13 @@ describe Gitlab::Metrics do
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
}
it
'adds the tag to the transaction'
do
expect
(
Gitlab
::
Metric
s
).
to
receive
(
:current_transaction
).
expect
(
described_clas
s
).
to
receive
(
:current_transaction
).
and_return
(
transaction
)
expect
(
transaction
).
to
receive
(
:add_tag
).
with
(
:foo
,
'bar'
)
Gitlab
::
Metric
s
.
tag_transaction
(
:foo
,
'bar'
)
described_clas
s
.
tag_transaction
(
:foo
,
'bar'
)
end
end
end
...
...
@@ -130,7 +130,7 @@ describe Gitlab::Metrics do
expect_any_instance_of
(
Gitlab
::
Metrics
::
Transaction
).
not_to
receive
(
:action
=
)
Gitlab
::
Metric
s
.
action
=
'foo'
described_clas
s
.
action
=
'foo'
end
end
...
...
@@ -138,12 +138,12 @@ describe Gitlab::Metrics do
it
'sets the action of a transaction'
do
trans
=
Gitlab
::
Metrics
::
Transaction
.
new
expect
(
Gitlab
::
Metric
s
).
to
receive
(
:current_transaction
).
expect
(
described_clas
s
).
to
receive
(
:current_transaction
).
and_return
(
trans
)
expect
(
trans
).
to
receive
(
:action
=
).
with
(
'foo'
)
Gitlab
::
Metric
s
.
action
=
'foo'
described_clas
s
.
action
=
'foo'
end
end
end
...
...
@@ -160,7 +160,7 @@ describe Gitlab::Metrics do
expect_any_instance_of
(
Gitlab
::
Metrics
::
Transaction
).
not_to
receive
(
:add_event
)
Gitlab
::
Metric
s
.
add_event
(
:meow
)
described_clas
s
.
add_event
(
:meow
)
end
end
...
...
@@ -170,10 +170,10 @@ describe Gitlab::Metrics do
expect
(
transaction
).
to
receive
(
:add_event
).
with
(
:meow
)
expect
(
Gitlab
::
Metric
s
).
to
receive
(
:current_transaction
).
expect
(
described_clas
s
).
to
receive
(
:current_transaction
).
and_return
(
transaction
)
Gitlab
::
Metric
s
.
add_event
(
:meow
)
described_clas
s
.
add_event
(
:meow
)
end
end
end
...
...
spec/lib/gitlab/mirror_spec.rb
View file @
095ac7d3
...
...
@@ -12,7 +12,7 @@ describe Gitlab::Mirror do
it
'returns only fifteen minutes'
do
times
=
[
Gitlab
::
Mirror
::
FIFTEEN
]
expect
(
Gitlab
::
Mirror
.
sync_times
).
to
match_array
(
times
)
expect
(
described_class
.
sync_times
).
to
match_array
(
times
)
end
end
...
...
@@ -22,7 +22,7 @@ describe Gitlab::Mirror do
it
'returns only fifteen and hourly sync_times'
do
times
=
[
Gitlab
::
Mirror
::
FIFTEEN
,
Gitlab
::
Mirror
::
HOURLY
]
expect
(
Gitlab
::
Mirror
.
sync_times
).
to
match_array
(
times
)
expect
(
described_class
.
sync_times
).
to
match_array
(
times
)
end
end
...
...
@@ -33,7 +33,7 @@ describe Gitlab::Mirror do
it
'returns only fifteen hourly and three hour sync_times'
do
times
=
[
Gitlab
::
Mirror
::
FIFTEEN
,
Gitlab
::
Mirror
::
HOURLY
,
Gitlab
::
Mirror
::
THREE
]
expect
(
Gitlab
::
Mirror
.
sync_times
).
to
match_array
(
times
)
expect
(
described_class
.
sync_times
).
to
match_array
(
times
)
end
end
...
...
@@ -43,7 +43,7 @@ describe Gitlab::Mirror do
it
'returns only fifteen, hourly, three and six hour sync_times'
do
times
=
[
Gitlab
::
Mirror
::
FIFTEEN
,
Gitlab
::
Mirror
::
HOURLY
,
Gitlab
::
Mirror
::
THREE
,
Gitlab
::
Mirror
::
SIX
]
expect
(
Gitlab
::
Mirror
.
sync_times
).
to
match_array
(
times
)
expect
(
described_class
.
sync_times
).
to
match_array
(
times
)
end
end
...
...
@@ -53,7 +53,7 @@ describe Gitlab::Mirror do
it
'returns only fifteen, hourly, three, six and twelve hour sync_times'
do
times
=
[
Gitlab
::
Mirror
::
FIFTEEN
,
Gitlab
::
Mirror
::
HOURLY
,
Gitlab
::
Mirror
::
THREE
,
Gitlab
::
Mirror
::
SIX
,
Gitlab
::
Mirror
::
TWELVE
]
expect
(
Gitlab
::
Mirror
.
sync_times
).
to
match_array
(
times
)
expect
(
described_class
.
sync_times
).
to
match_array
(
times
)
end
end
end
...
...
@@ -64,7 +64,7 @@ describe Gitlab::Mirror do
it
'returns daily hourly and fifteen sync_times'
do
times
=
[
Gitlab
::
Mirror
::
FIFTEEN
,
Gitlab
::
Mirror
::
HOURLY
,
Gitlab
::
Mirror
::
THREE
,
Gitlab
::
Mirror
::
SIX
,
Gitlab
::
Mirror
::
TWELVE
,
Gitlab
::
Mirror
::
DAILY
]
expect
(
Gitlab
::
Mirror
.
sync_times
).
to
match_array
(
times
)
expect
(
described_class
.
sync_times
).
to
match_array
(
times
)
end
end
...
...
@@ -90,7 +90,7 @@ describe Gitlab::Mirror do
before
{
setup_mirrors_cron_job
(
Gitlab
::
Mirror
::
HOURLY
,
Gitlab
::
Mirror
::
DAILY
)
}
it
'changes cron of update_all_mirrors_worker to daily'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
hourly_cron
).
to
(
daily_cron
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
hourly_cron
).
to
(
daily_cron
)
end
end
...
...
@@ -98,7 +98,7 @@ describe Gitlab::Mirror do
before
{
setup_mirrors_cron_job
(
Gitlab
::
Mirror
::
DAILY
,
Gitlab
::
Mirror
::
TWELVE
)
}
it
'changes cron of update_all_mirrors_worker to every twelve hours'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
twelve_cron
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
twelve_cron
)
end
end
...
...
@@ -106,7 +106,7 @@ describe Gitlab::Mirror do
before
{
setup_mirrors_cron_job
(
Gitlab
::
Mirror
::
DAILY
,
Gitlab
::
Mirror
::
SIX
)
}
it
'changes cron of update_all_mirrors_worker to every six hours'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
six_cron
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
six_cron
)
end
end
...
...
@@ -114,7 +114,7 @@ describe Gitlab::Mirror do
before
{
setup_mirrors_cron_job
(
Gitlab
::
Mirror
::
DAILY
,
Gitlab
::
Mirror
::
THREE
)
}
it
'changes cron of update_all_mirrors_worker to every three hours'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
three_cron
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
three_cron
)
end
end
...
...
@@ -122,7 +122,7 @@ describe Gitlab::Mirror do
before
{
setup_mirrors_cron_job
(
Gitlab
::
Mirror
::
DAILY
,
Gitlab
::
Mirror
::
HOURLY
)
}
it
'changes cron of update_all_mirrors_worker to hourly'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
hourly_cron
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
hourly_cron
)
end
end
...
...
@@ -130,7 +130,7 @@ describe Gitlab::Mirror do
before
{
setup_mirrors_cron_job
(
Gitlab
::
Mirror
::
DAILY
,
Gitlab
::
Mirror
::
FIFTEEN
)
}
it
'changes cron of update_all_mirrors_worker to fifteen'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
fifteen_cron
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
}.
from
(
daily_cron
).
to
(
fifteen_cron
)
end
end
end
...
...
@@ -144,7 +144,7 @@ describe Gitlab::Mirror do
before
{
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:minimum_mirror_sync_time
).
and_return
(
Gitlab
::
Mirror
::
DAILY
)
}
it
'creates update_all_mirrors_worker with cron of daily sync_time'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
).
to
eq
(
daily_cron
)
end
end
...
...
@@ -153,7 +153,7 @@ describe Gitlab::Mirror do
before
{
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:minimum_mirror_sync_time
).
and_return
(
Gitlab
::
Mirror
::
TWELVE
)
}
it
'creates update_all_mirrors_worker with cron of every twelve hours sync_time'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
).
to
eq
(
twelve_cron
)
end
end
...
...
@@ -162,7 +162,7 @@ describe Gitlab::Mirror do
before
{
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:minimum_mirror_sync_time
).
and_return
(
Gitlab
::
Mirror
::
SIX
)
}
it
'creates update_all_mirrors_worker with cron of every six hours sync_time'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
).
to
eq
(
six_cron
)
end
end
...
...
@@ -171,7 +171,7 @@ describe Gitlab::Mirror do
before
{
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:minimum_mirror_sync_time
).
and_return
(
Gitlab
::
Mirror
::
THREE
)
}
it
'creates update_all_mirrors_worker with cron of every three hours sync_time'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
).
to
eq
(
three_cron
)
end
end
...
...
@@ -180,14 +180,14 @@ describe Gitlab::Mirror do
before
{
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:minimum_mirror_sync_time
).
and_return
(
Gitlab
::
Mirror
::
HOURLY
)
}
it
'creates update_all_mirrors_worker with cron of hourly sync_time'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
).
to
eq
(
hourly_cron
)
end
end
describe
'with fifteen minimum_mirror_sync_time'
do
it
'creates update_all_mirrors_worker with cron of fifteen sync_time'
do
expect
{
Gitlab
::
Mirror
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
{
described_class
.
configure_cron_job!
}.
to
change
{
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
)
}.
from
(
nil
).
to
(
Sidekiq
::
Cron
::
Job
)
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
"update_all_mirrors_worker"
).
cron
).
to
eq
(
fifteen_cron
)
end
end
...
...
@@ -198,19 +198,19 @@ describe Gitlab::Mirror do
it
'returns true if at beginning_of_day'
do
Timecop
.
freeze
(
DateTime
.
now
.
beginning_of_day
)
expect
(
Gitlab
::
Mirror
.
at_beginning_of_day?
).
to
be
true
expect
(
described_class
.
at_beginning_of_day?
).
to
be
true
end
it
'returns true during the first 14 minutes of the day'
do
Timecop
.
freeze
(
DateTime
.
now
.
beginning_of_day
+
14
.
minutes
)
expect
(
Gitlab
::
Mirror
.
at_beginning_of_day?
).
to
be
true
expect
(
described_class
.
at_beginning_of_day?
).
to
be
true
end
it
'returns false if some time after the day started'
do
Timecop
.
freeze
(
DateTime
.
now
.
midday
)
expect
(
Gitlab
::
Mirror
.
at_beginning_of_day?
).
to
be
false
expect
(
described_class
.
at_beginning_of_day?
).
to
be
false
end
after
{
Timecop
.
return
}
...
...
@@ -223,19 +223,19 @@ describe Gitlab::Mirror do
describe
'at beginning of day'
do
let!
(
:time
)
{
{
hour:
0
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
).
to
be
true
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
).
to
be
true
}
end
describe
'at beginning of hour'
do
let!
(
:time
)
{
{
hour:
1
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
).
to
be
true
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
).
to
be
true
}
end
describe
'at beginning of hour'
do
let!
(
:time
)
{
{
hour:
1
,
min:
15
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
).
to
be
false
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
).
to
be
false
}
end
end
...
...
@@ -243,36 +243,36 @@ describe Gitlab::Mirror do
describe
'three'
do
let!
(
:time
)
{
{
hour:
3
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
(
3
)).
to
be
true
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
(
3
)).
to
be
true
}
describe
'with another hour'
do
let!
(
:time
)
{
{
hour:
4
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
(
3
)).
to
be
false
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
(
3
)).
to
be
false
}
end
end
describe
'six'
do
let!
(
:time
)
{
{
hour:
6
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
(
6
)).
to
be
true
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
(
6
)).
to
be
true
}
describe
'with another hour'
do
let!
(
:time
)
{
{
hour:
4
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
(
6
)).
to
be
false
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
(
6
)).
to
be
false
}
end
end
describe
'twelve'
do
let!
(
:time
)
{
{
hour:
12
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
(
12
)).
to
be
true
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
(
12
)).
to
be
true
}
describe
'with another hour'
do
let!
(
:time
)
{
{
hour:
4
}
}
it
{
expect
(
Gitlab
::
Mirror
.
at_beginning_of_hour?
(
12
)).
to
be
false
}
it
{
expect
(
described_class
.
at_beginning_of_hour?
(
12
)).
to
be
false
}
end
end
end
...
...
spec/lib/gitlab/sidekiq_throttler_spec.rb
View file @
095ac7d3
...
...
@@ -13,14 +13,14 @@ describe Gitlab::SidekiqThrottler do
describe
'#execute!'
do
it
'sets limits on the selected queues'
do
Gitlab
::
SidekiqThrottler
.
execute!
described_class
.
execute!
expect
(
Sidekiq
::
Queue
[
'build'
].
limit
).
to
eq
4
expect
(
Sidekiq
::
Queue
[
'project_cache'
].
limit
).
to
eq
4
end
it
'does not set limits on other queues'
do
Gitlab
::
SidekiqThrottler
.
execute!
described_class
.
execute!
expect
(
Sidekiq
::
Queue
[
'merge'
].
limit
).
to
be_nil
end
...
...
spec/lib/gitlab/slash_commands/dsl_spec.rb
View file @
095ac7d3
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
SlashCommands
::
Dsl
do
before
:all
do
DummyClass
=
Struct
.
new
(
:project
)
do
include
Gitlab
::
SlashCommands
::
Dsl
include
Gitlab
::
SlashCommands
::
Dsl
# rubocop:disable RSpec/DescribedClass
desc
'A command with no args'
command
:no_args
,
:none
do
...
...
spec/lib/gitlab/template/gitignore_template_spec.rb
View file @
095ac7d3
...
...
@@ -24,7 +24,7 @@ describe Gitlab::Template::GitignoreTemplate do
it
'returns the Gitignore object of a valid file'
do
ruby
=
subject
.
find
(
'Ruby'
)
expect
(
ruby
).
to
be_a
Gitlab
::
Template
::
GitignoreTemplate
expect
(
ruby
).
to
be_a
described_class
expect
(
ruby
.
name
).
to
eq
(
'Ruby'
)
end
end
...
...
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
View file @
095ac7d3
...
...
@@ -25,7 +25,7 @@ describe Gitlab::Template::GitlabCiYmlTemplate do
it
'returns the GitlabCiYml object of a valid file'
do
ruby
=
subject
.
find
(
'Ruby'
)
expect
(
ruby
).
to
be_a
Gitlab
::
Template
::
GitlabCiYmlTemplate
expect
(
ruby
).
to
be_a
described_class
expect
(
ruby
.
name
).
to
eq
(
'Ruby'
)
end
end
...
...
spec/lib/gitlab/template/issue_template_spec.rb
View file @
095ac7d3
...
...
@@ -37,7 +37,7 @@ describe Gitlab::Template::IssueTemplate do
it
'returns the issue object of a valid file'
do
ruby
=
subject
.
find
(
'bug'
,
project
)
expect
(
ruby
).
to
be_a
Gitlab
::
Template
::
IssueTemplate
expect
(
ruby
).
to
be_a
described_class
expect
(
ruby
.
name
).
to
eq
(
'bug'
)
end
end
...
...
spec/lib/gitlab/template/merge_request_template_spec.rb
View file @
095ac7d3
...
...
@@ -37,7 +37,7 @@ describe Gitlab::Template::MergeRequestTemplate do
it
'returns the merge request object of a valid file'
do
ruby
=
subject
.
find
(
'bug'
,
project
)
expect
(
ruby
).
to
be_a
Gitlab
::
Template
::
MergeRequestTemplate
expect
(
ruby
).
to
be_a
described_class
expect
(
ruby
.
name
).
to
eq
(
'bug'
)
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
095ac7d3
...
...
@@ -6,7 +6,7 @@ describe Gitlab::UsageData do
let!
(
:board
)
{
create
(
:board
,
project:
project
)
}
describe
'#data'
do
subject
{
Gitlab
::
UsageData
.
data
}
subject
{
described_class
.
data
}
it
"gathers usage data"
do
expect
(
subject
.
keys
).
to
match_array
(
%i(
...
...
@@ -70,7 +70,7 @@ describe Gitlab::UsageData do
end
describe
'#license_usage_data'
do
subject
{
Gitlab
::
UsageData
.
license_usage_data
}
subject
{
described_class
.
license_usage_data
}
it
"gathers license data"
do
license
=
::
License
.
current
...
...
spec/mailers/emails/csv_export_spec.rb
View file @
095ac7d3
...
...
@@ -9,7 +9,7 @@ describe Emails::CsvExport do
let
(
:user
)
{
create
(
:user
)
}
let
(
:empty_project
)
{
create
(
:empty_project
,
path:
'myproject'
)
}
let
(
:export_status
)
{
{
truncated:
false
,
rows_expected:
3
,
rows_written:
3
}
}
subject
{
Notify
.
issues_csv_email
(
user
,
empty_project
,
"dummy content"
,
export_status
)
}
subject
{
described_class
.
issues_csv_email
(
user
,
empty_project
,
"dummy content"
,
export_status
)
}
let
(
:attachment
)
{
subject
.
attachments
.
first
}
it
'attachment has csv mime type'
do
...
...
spec/mailers/notify_spec.rb
View file @
095ac7d3
...
...
@@ -40,7 +40,7 @@ describe Notify do
let
(
:issue_with_description
)
{
create
(
:issue
,
author:
current_user
,
assignee:
assignee
,
project:
project
,
description:
'My awesome description'
)
}
describe
'that are new'
do
subject
{
Notify
.
new_issue_email
(
issue
.
assignee_id
,
issue
.
id
)
}
subject
{
described_class
.
new_issue_email
(
issue
.
assignee_id
,
issue
.
id
)
}
it_behaves_like
'an assignee email'
it_behaves_like
'an email starting a new thread with reply-by-email enabled'
do
...
...
@@ -69,7 +69,7 @@ describe Notify do
end
describe
'that are new with a description'
do
subject
{
Notify
.
new_issue_email
(
issue_with_description
.
assignee_id
,
issue_with_description
.
id
)
}
subject
{
described_class
.
new_issue_email
(
issue_with_description
.
assignee_id
,
issue_with_description
.
id
)
}
it_behaves_like
'it should show Gmail Actions View Issue link'
...
...
@@ -79,7 +79,7 @@ describe Notify do
end
describe
'that have been reassigned'
do
subject
{
Notify
.
reassigned_issue_email
(
recipient
.
id
,
issue
.
id
,
previous_assignee
.
id
,
current_user
.
id
)
}
subject
{
described_class
.
reassigned_issue_email
(
recipient
.
id
,
issue
.
id
,
previous_assignee
.
id
,
current_user
.
id
)
}
it_behaves_like
'a multiple recipients email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -105,7 +105,7 @@ describe Notify do
end
describe
'that have been relabeled'
do
subject
{
Notify
.
relabeled_issue_email
(
recipient
.
id
,
issue
.
id
,
%w[foo bar baz]
,
current_user
.
id
)
}
subject
{
described_class
.
relabeled_issue_email
(
recipient
.
id
,
issue
.
id
,
%w[foo bar baz]
,
current_user
.
id
)
}
it_behaves_like
'a multiple recipients email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -132,7 +132,7 @@ describe Notify do
describe
'status changed'
do
let
(
:status
)
{
'closed'
}
subject
{
Notify
.
issue_status_changed_email
(
recipient
.
id
,
issue
.
id
,
status
,
current_user
.
id
)
}
subject
{
described_class
.
issue_status_changed_email
(
recipient
.
id
,
issue
.
id
,
status
,
current_user
.
id
)
}
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
let
(
:model
)
{
issue
}
...
...
@@ -158,7 +158,7 @@ describe Notify do
describe
'moved to another project'
do
let
(
:new_issue
)
{
create
(
:issue
)
}
subject
{
Notify
.
issue_moved_email
(
recipient
,
issue
,
new_issue
,
current_user
)
}
subject
{
described_class
.
issue_moved_email
(
recipient
,
issue
,
new_issue
,
current_user
)
}
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
let
(
:model
)
{
issue
}
...
...
@@ -191,7 +191,7 @@ describe Notify do
let
(
:merge_request_with_approver
)
{
create
(
:merge_request_with_approver
,
author:
current_user
,
assignee:
assignee
,
source_project:
project
,
target_project:
project
)
}
describe
'that are new'
do
subject
{
Notify
.
new_merge_request_email
(
merge_request
.
assignee_id
,
merge_request
.
id
)
}
subject
{
described_class
.
new_merge_request_email
(
merge_request
.
assignee_id
,
merge_request
.
id
)
}
it_behaves_like
'an assignee email'
it_behaves_like
'an email starting a new thread with reply-by-email enabled'
do
...
...
@@ -223,7 +223,7 @@ describe Notify do
describe
"that are new with approver"
do
subject
do
Notify
.
new_merge_request_email
(
described_class
.
new_merge_request_email
(
merge_request_with_approver
.
assignee_id
,
merge_request_with_approver
.
id
)
...
...
@@ -236,7 +236,7 @@ describe Notify do
describe
'that are new with a description'
do
subject
do
Notify
.
new_merge_request_email
(
described_class
.
new_merge_request_email
(
merge_request_with_description
.
assignee_id
,
merge_request_with_description
.
id
)
...
...
@@ -251,7 +251,7 @@ describe Notify do
end
describe
'that are reassigned'
do
subject
{
Notify
.
reassigned_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
previous_assignee
.
id
,
current_user
.
id
)
}
subject
{
described_class
.
reassigned_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
previous_assignee
.
id
,
current_user
.
id
)
}
it_behaves_like
'a multiple recipients email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -277,7 +277,7 @@ describe Notify do
end
describe
'that have been relabeled'
do
subject
{
Notify
.
relabeled_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
%w[foo bar baz]
,
current_user
.
id
)
}
subject
{
described_class
.
relabeled_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
%w[foo bar baz]
,
current_user
.
id
)
}
it_behaves_like
'a multiple recipients email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -302,7 +302,7 @@ describe Notify do
describe
'status changed'
do
let
(
:status
)
{
'reopened'
}
subject
{
Notify
.
merge_request_status_email
(
recipient
.
id
,
merge_request
.
id
,
status
,
current_user
.
id
)
}
subject
{
described_class
.
merge_request_status_email
(
recipient
.
id
,
merge_request
.
id
,
status
,
current_user
.
id
)
}
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
let
(
:model
)
{
merge_request
}
...
...
@@ -328,7 +328,7 @@ describe Notify do
describe
'that are approved'
do
let
(
:last_approver
)
{
create
(
:user
)
}
subject
{
Notify
.
approved_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
last_approver
.
id
)
}
subject
{
described_class
.
approved_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
last_approver
.
id
)
}
before
do
merge_request
.
approvals
.
create
(
user:
merge_request
.
assignee
)
...
...
@@ -378,7 +378,7 @@ describe Notify do
describe
'that are unapproved'
do
let
(
:last_unapprover
)
{
create
(
:user
)
}
subject
{
Notify
.
unapproved_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
last_unapprover
.
id
)
}
subject
{
described_class
.
unapproved_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
last_unapprover
.
id
)
}
before
do
merge_request
.
approvals
.
create
(
user:
merge_request
.
assignee
)
...
...
@@ -415,7 +415,7 @@ describe Notify do
end
describe
'that are merged'
do
subject
{
Notify
.
merged_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
merge_author
.
id
)
}
subject
{
described_class
.
merged_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
merge_author
.
id
)
}
it_behaves_like
'a multiple recipients email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -444,7 +444,7 @@ describe Notify do
describe
'project was moved'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
project_was_moved_email
(
project
.
id
,
user
.
id
,
"gitlab/gitlab"
)
}
subject
{
described_class
.
project_was_moved_email
(
project
.
id
,
user
.
id
,
"gitlab/gitlab"
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -470,7 +470,7 @@ describe Notify do
project
.
request_access
(
user
)
project
.
requesters
.
find_by
(
user_id:
user
.
id
)
end
subject
{
Notify
.
member_access_requested_email
(
'project'
,
project_member
.
id
)
}
subject
{
described_class
.
member_access_requested_email
(
'project'
,
project_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -497,7 +497,7 @@ describe Notify do
project
.
request_access
(
user
)
project
.
requesters
.
find_by
(
user_id:
user
.
id
)
end
subject
{
Notify
.
member_access_requested_email
(
'project'
,
project_member
.
id
)
}
subject
{
described_class
.
member_access_requested_email
(
'project'
,
project_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -523,7 +523,7 @@ describe Notify do
project
.
request_access
(
user
)
project
.
requesters
.
find_by
(
user_id:
user
.
id
)
end
subject
{
Notify
.
member_access_denied_email
(
'project'
,
project
.
id
,
user
.
id
)
}
subject
{
described_class
.
member_access_denied_email
(
'project'
,
project
.
id
,
user
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -541,7 +541,7 @@ describe Notify do
let
(
:project
)
{
create
(
:empty_project
,
:public
,
:access_requestable
,
namespace:
owner
.
namespace
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project_member
)
{
create
(
:project_member
,
project:
project
,
user:
user
)
}
subject
{
Notify
.
member_access_granted_email
(
'project'
,
project_member
.
id
)
}
subject
{
described_class
.
member_access_granted_email
(
'project'
,
project_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -572,7 +572,7 @@ describe Notify do
let
(
:master
)
{
create
(
:user
).
tap
{
|
u
|
project
.
team
<<
[
u
,
:master
]
}
}
let
(
:project_member
)
{
invite_to_project
(
project
,
inviter:
master
)
}
subject
{
Notify
.
member_invited_email
(
'project'
,
project_member
.
id
,
project_member
.
invite_token
)
}
subject
{
described_class
.
member_invited_email
(
'project'
,
project_member
.
id
,
project_member
.
invite_token
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -597,7 +597,7 @@ describe Notify do
invitee
end
subject
{
Notify
.
member_invite_accepted_email
(
'project'
,
project_member
.
id
)
}
subject
{
described_class
.
member_invite_accepted_email
(
'project'
,
project_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -621,7 +621,7 @@ describe Notify do
invitee
end
subject
{
Notify
.
member_invite_declined_email
(
'project'
,
project
.
id
,
project_member
.
invite_email
,
master
.
id
)
}
subject
{
described_class
.
member_invite_declined_email
(
'project'
,
project
.
id
,
project_member
.
invite_email
,
master
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -681,7 +681,7 @@ describe Notify do
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
commit
)
}
subject
{
Notify
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -703,7 +703,7 @@ describe Notify do
let
(
:note_on_merge_request_path
)
{
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
,
anchor:
"note_
#{
note
.
id
}
"
)
}
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
merge_request
)
}
subject
{
Notify
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -725,7 +725,7 @@ describe Notify do
let
(
:note_on_issue_path
)
{
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
,
anchor:
"note_
#{
note
.
id
}
"
)
}
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
issue
)
}
subject
{
Notify
.
note_issue_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_issue_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -787,7 +787,7 @@ describe Notify do
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
commit
)
}
subject
{
Notify
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a discussion note email'
,
:discussion_note_on_commit
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -811,7 +811,7 @@ describe Notify do
let
(
:note_on_merge_request_path
)
{
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
,
anchor:
"note_
#{
note
.
id
}
"
)
}
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
merge_request
)
}
subject
{
Notify
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a discussion note email'
,
:discussion_note_on_merge_request
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -835,7 +835,7 @@ describe Notify do
let
(
:note_on_issue_path
)
{
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
,
anchor:
"note_
#{
note
.
id
}
"
)
}
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
issue
)
}
subject
{
Notify
.
note_issue_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_issue_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a discussion note email'
,
:discussion_note_on_issue
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
...
...
@@ -905,7 +905,7 @@ describe Notify do
let
(
:commit
)
{
project
.
commit
}
let
(
:note
)
{
create
(
:diff_note_on_commit
)
}
subject
{
Notify
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'an email for a note on a diff discussion'
,
:diff_note_on_commit
it_behaves_like
'it should show Gmail Actions View Commit link'
...
...
@@ -916,7 +916,7 @@ describe Notify do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:note
)
{
create
(
:diff_note_on_merge_request
)
}
subject
{
Notify
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
subject
{
described_class
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'an email for a note on a diff discussion'
,
:diff_note_on_merge_request
it_behaves_like
'it should show Gmail Actions View Merge request link'
...
...
@@ -933,7 +933,7 @@ describe Notify do
group
.
request_access
(
user
)
group
.
requesters
.
find_by
(
user_id:
user
.
id
)
end
subject
{
Notify
.
member_access_requested_email
(
'group'
,
group_member
.
id
)
}
subject
{
described_class
.
member_access_requested_email
(
'group'
,
group_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -954,7 +954,7 @@ describe Notify do
group
.
request_access
(
user
)
group
.
requesters
.
find_by
(
user_id:
user
.
id
)
end
subject
{
Notify
.
member_access_denied_email
(
'group'
,
group
.
id
,
user
.
id
)
}
subject
{
described_class
.
member_access_denied_email
(
'group'
,
group
.
id
,
user
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -972,7 +972,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group_member
)
{
create
(
:group_member
,
group:
group
,
user:
user
)
}
subject
{
Notify
.
member_access_granted_email
(
'group'
,
group_member
.
id
)
}
subject
{
described_class
.
member_access_granted_email
(
'group'
,
group_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -1003,7 +1003,7 @@ describe Notify do
let
(
:owner
)
{
create
(
:user
).
tap
{
|
u
|
group
.
add_user
(
u
,
Gitlab
::
Access
::
OWNER
)
}
}
let
(
:group_member
)
{
invite_to_group
(
group
,
inviter:
owner
)
}
subject
{
Notify
.
member_invited_email
(
'group'
,
group_member
.
id
,
group_member
.
invite_token
)
}
subject
{
described_class
.
member_invited_email
(
'group'
,
group_member
.
id
,
group_member
.
invite_token
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -1028,7 +1028,7 @@ describe Notify do
invitee
end
subject
{
Notify
.
member_invite_accepted_email
(
'group'
,
group_member
.
id
)
}
subject
{
described_class
.
member_invite_accepted_email
(
'group'
,
group_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -1052,7 +1052,7 @@ describe Notify do
invitee
end
subject
{
Notify
.
member_invite_declined_email
(
'group'
,
group
.
id
,
group_member
.
invite_email
,
owner
.
id
)
}
subject
{
described_class
.
member_invite_declined_email
(
'group'
,
group
.
id
,
group_member
.
invite_email
,
owner
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
...
...
@@ -1101,7 +1101,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"empty-branch"
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/empty-branch'
,
action: :create
)
}
subject
{
described_class
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/empty-branch'
,
action: :create
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user cannot unsubscribe through footer link'
...
...
@@ -1127,7 +1127,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"v1.0"
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :create
)
}
subject
{
described_class
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :create
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user cannot unsubscribe through footer link"
...
...
@@ -1152,7 +1152,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :delete
)
}
subject
{
described_class
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :delete
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user cannot unsubscribe through footer link'
...
...
@@ -1174,7 +1174,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :delete
)
}
subject
{
described_class
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :delete
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user cannot unsubscribe through footer link'
...
...
@@ -1203,7 +1203,7 @@ describe Notify do
let
(
:send_from_committer_email
)
{
false
}
let
(
:diff_refs
)
{
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
project
.
merge_base_commit
(
sample_image_commit
.
id
,
sample_commit
.
id
).
id
,
head_sha:
sample_commit
.
id
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
diff_refs:
diff_refs
,
send_from_committer_email:
send_from_committer_email
)
}
subject
{
described_class
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
diff_refs:
diff_refs
,
send_from_committer_email:
send_from_committer_email
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user cannot unsubscribe through footer link'
...
...
@@ -1296,7 +1296,7 @@ describe Notify do
let
(
:diff_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commits
.
first
)
}
let
(
:diff_refs
)
{
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
project
.
merge_base_commit
(
sample_image_commit
.
id
,
sample_commit
.
id
).
id
,
head_sha:
sample_commit
.
id
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
diff_refs:
diff_refs
)
}
subject
{
described_class
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
diff_refs:
diff_refs
)
}
it_behaves_like
'it should show Gmail Actions View Commit link'
it_behaves_like
'a user cannot unsubscribe through footer link'
...
...
@@ -1323,7 +1323,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
@email
=
Notify
.
send_admin_notification
(
user
.
id
,
'Admin announcement'
,
'Text'
)
}
subject
{
@email
=
described_class
.
send_admin_notification
(
user
.
id
,
'Admin announcement'
,
'Text'
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
@@ -1348,7 +1348,7 @@ describe Notify do
describe
'HTML emails setting'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:multipart_mail
)
{
Notify
.
project_was_moved_email
(
project
.
id
,
user
.
id
,
"gitlab/gitlab"
)
}
let
(
:multipart_mail
)
{
described_class
.
project_was_moved_email
(
project
.
id
,
user
.
id
,
"gitlab/gitlab"
)
}
context
'when disabled'
do
it
'only sends the text template'
do
...
...
spec/models/historical_data_spec.rb
View file @
095ac7d3
...
...
@@ -3,25 +3,25 @@ require 'spec_helper'
describe
HistoricalData
do
before
do
(
1
..
12
).
each
do
|
i
|
HistoricalData
.
create!
(
date:
Date
.
new
(
2014
,
i
,
1
),
active_user_count:
i
*
100
)
described_class
.
create!
(
date:
Date
.
new
(
2014
,
i
,
1
),
active_user_count:
i
*
100
)
end
end
describe
".during"
do
it
"returns the historical data during the specified period"
do
expect
(
HistoricalData
.
during
(
Date
.
new
(
2014
,
1
,
1
)
..
Date
.
new
(
2014
,
12
,
31
)).
average
(
:active_user_count
)).
to
eq
(
650
)
expect
(
described_class
.
during
(
Date
.
new
(
2014
,
1
,
1
)
..
Date
.
new
(
2014
,
12
,
31
)).
average
(
:active_user_count
)).
to
eq
(
650
)
end
end
describe
".up_until"
do
it
"returns the historical data up until the specified date"
do
expect
(
HistoricalData
.
up_until
(
Date
.
new
(
2014
,
6
,
1
)).
average
(
:active_user_count
)).
to
eq
(
350
)
expect
(
described_class
.
up_until
(
Date
.
new
(
2014
,
6
,
1
)).
average
(
:active_user_count
)).
to
eq
(
350
)
end
end
describe
".at"
do
it
"returns the historical data at the specified date"
do
expect
(
HistoricalData
.
at
(
Date
.
new
(
2014
,
8
,
1
)).
active_user_count
).
to
eq
(
800
)
expect
(
described_class
.
at
(
Date
.
new
(
2014
,
8
,
1
)).
active_user_count
).
to
eq
(
800
)
end
end
...
...
@@ -31,9 +31,9 @@ describe HistoricalData do
end
it
"creates a new historical data record"
do
HistoricalData
.
track!
described_class
.
track!
data
=
HistoricalData
.
last
data
=
described_class
.
last
expect
(
data
.
date
).
to
eq
(
Date
.
today
)
expect
(
data
.
active_user_count
).
to
eq
(
5
)
end
...
...
@@ -42,12 +42,12 @@ describe HistoricalData do
describe
".max_historical_user_count"
do
before
do
(
1
..
3
).
each
do
|
i
|
HistoricalData
.
create!
(
date:
Time
.
now
-
i
.
days
,
active_user_count:
i
*
100
)
described_class
.
create!
(
date:
Time
.
now
-
i
.
days
,
active_user_count:
i
*
100
)
end
end
it
"returns max user count for the past year"
do
expect
(
HistoricalData
.
max_historical_user_count
).
to
eq
(
300
)
expect
(
described_class
.
max_historical_user_count
).
to
eq
(
300
)
end
end
end
spec/models/ldap_group_link_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
LdapGroupLink
do
let
(
:klass
)
{
LdapGroupLink
}
let
(
:klass
)
{
described_class
}
let
(
:ldap_group_link
)
{
build
:ldap_group_link
}
describe
"validation"
do
...
...
spec/models/license_spec.rb
View file @
095ac7d3
...
...
@@ -25,7 +25,7 @@ describe License do
describe
"Historical active user count"
do
let
(
:active_user_count
)
{
User
.
active
.
count
+
10
}
let
(
:date
)
{
License
.
current
.
starts_at
}
let
(
:date
)
{
described_class
.
current
.
starts_at
}
let!
(
:historical_data
)
{
HistoricalData
.
create!
(
date:
date
,
active_user_count:
active_user_count
)
}
context
"when there is no active user count restriction"
do
...
...
@@ -54,7 +54,7 @@ describe License do
end
context
"in the year before the license started"
do
let
(
:date
)
{
License
.
current
.
starts_at
-
6
.
months
}
let
(
:date
)
{
described_class
.
current
.
starts_at
-
6
.
months
}
it
"is invalid"
do
expect
(
license
).
not_to
be_valid
...
...
@@ -62,7 +62,7 @@ describe License do
end
context
"earlier than a year before the license started"
do
let
(
:date
)
{
License
.
current
.
starts_at
-
2
.
years
}
let
(
:date
)
{
described_class
.
current
.
starts_at
-
2
.
years
}
it
"is valid"
do
expect
(
license
).
to
be_valid
...
...
@@ -204,11 +204,11 @@ describe License do
end
describe
"Class methods"
do
let!
(
:license
)
{
License
.
last
}
let!
(
:license
)
{
described_class
.
last
}
before
do
License
.
reset_current
allow
(
License
).
to
receive
(
:last
).
and_return
(
license
)
described_class
.
reset_current
allow
(
described_class
).
to
receive
(
:last
).
and_return
(
license
)
end
describe
".current"
do
...
...
@@ -216,7 +216,7 @@ describe License do
let!
(
:license
)
{
nil
}
it
"returns nil"
do
expect
(
License
.
current
).
to
be_nil
expect
(
described_class
.
current
).
to
be_nil
end
end
...
...
@@ -226,13 +226,13 @@ describe License do
end
it
"returns nil"
do
expect
(
License
.
current
).
to
be_nil
expect
(
described_class
.
current
).
to
be_nil
end
end
context
"when the license is valid"
do
it
"returns the license"
do
expect
(
License
.
current
)
expect
(
described_class
.
current
)
end
end
end
...
...
@@ -240,11 +240,11 @@ describe License do
describe
".block_changes?"
do
context
"when there is no current license"
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
allow
(
described_class
).
to
receive
(
:current
).
and_return
(
nil
)
end
it
"returns true"
do
expect
(
License
.
block_changes?
).
to
be_truthy
expect
(
described_class
.
block_changes?
).
to
be_truthy
end
end
...
...
@@ -254,13 +254,13 @@ describe License do
end
it
"returns true"
do
expect
(
License
.
block_changes?
).
to
be_truthy
expect
(
described_class
.
block_changes?
).
to
be_truthy
end
end
context
"when the current license doesn't block changes"
do
it
"returns false"
do
expect
(
License
.
block_changes?
).
to
be_falsey
expect
(
described_class
.
block_changes?
).
to
be_falsey
end
end
end
...
...
spec/models/project_services/jenkins_service_spec.rb
View file @
095ac7d3
...
...
@@ -23,7 +23,7 @@ describe JenkinsService do
describe
'username validation'
do
before
do
@jenkins_service
=
JenkinsService
.
create
(
@jenkins_service
=
described_class
.
create
(
active:
active
,
project:
project
,
properties:
{
...
...
@@ -67,7 +67,7 @@ describe JenkinsService do
let
(
:username
)
{
nil
}
let
(
:password
)
{
nil
}
let
(
:jenkins_service
)
do
JenkinsService
.
new
(
described_class
.
new
(
project:
project
,
properties:
{
jenkins_url:
jenkins_url
,
...
...
@@ -165,7 +165,7 @@ describe JenkinsService do
context
'when a password was previously set'
do
before
do
@jenkins_service
=
JenkinsService
.
create
(
@jenkins_service
=
described_class
.
create
(
project:
project
,
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
...
...
@@ -211,7 +211,7 @@ describe JenkinsService do
context
'when no password was previously set'
do
before
do
@jenkins_service
=
JenkinsService
.
create
(
@jenkins_service
=
described_class
.
create
(
project:
create
(
:project
),
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
...
...
spec/models/remote_mirror_spec.rb
View file @
095ac7d3
...
...
@@ -81,7 +81,7 @@ describe RemoteMirror do
last_update_at:
nil
,
updated_at:
25
.
hours
.
ago
)
expect
(
RemoteMirror
.
stuck
.
last
).
to
eq
(
mirror
)
expect
(
described_class
.
stuck
.
last
).
to
eq
(
mirror
)
end
end
...
...
@@ -110,7 +110,7 @@ describe RemoteMirror do
context
'without project'
do
it
'returns nil'
do
allow_any_instance_of
(
RemoteMirror
).
to
receive
(
:project
).
and_return
(
nil
)
allow_any_instance_of
(
described_class
).
to
receive
(
:project
).
and_return
(
nil
)
expect
(
remote_mirror
.
sync
).
to
be_nil
end
...
...
spec/requests/api/helpers/internal_helpers_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
::
API
::
Helpers
::
InternalHelpers
do
include
::
API
::
Helpers
::
InternalHelper
s
include
described_clas
s
describe
'.clean_project_path'
do
project
=
'namespace/project'
...
...
spec/requests/api/helpers_spec.rb
View file @
095ac7d3
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
API
::
Helpers
do
include
API
::
APIGuard
::
HelperMethods
include
API
::
Helper
s
include
described_clas
s
include
SentryHelper
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/services/merge_requests/ff_merge_service_spec.rb
View file @
095ac7d3
...
...
@@ -18,7 +18,7 @@ describe MergeRequests::FfMergeService do
describe
'#execute'
do
context
'valid params'
do
let
(
:service
)
{
MergeRequests
::
FfMergeService
.
new
(
project
,
user
,
{})
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
{})
}
before
do
allow
(
service
).
to
receive
(
:execute_hooks
)
...
...
@@ -50,7 +50,7 @@ describe MergeRequests::FfMergeService do
end
context
"error handling"
do
let
(
:service
)
{
MergeRequests
::
FfMergeService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
before
do
allow
(
Rails
.
logger
).
to
receive
(
:error
)
...
...
spec/services/merge_requests/get_urls_service_spec.rb
View file @
095ac7d3
...
...
@@ -2,7 +2,7 @@ require "spec_helper"
describe
MergeRequests
::
GetUrlsService
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:service
)
{
MergeRequests
::
GetUrlsService
.
new
(
project
)
}
let
(
:service
)
{
described_class
.
new
(
project
)
}
let
(
:source_branch
)
{
"my_branch"
}
let
(
:new_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new?merge_request%5Bsource_branch%5D=
#{
source_branch
}
"
}
let
(
:show_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/
#{
merge_request
.
iid
}
"
}
...
...
@@ -89,7 +89,7 @@ describe MergeRequests::GetUrlsService do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
forked_project
,
target_project:
project
,
source_branch:
source_branch
)
}
let
(
:changes
)
{
existing_branch_changes
}
# Source project is now the forked one
let
(
:service
)
{
MergeRequests
::
GetUrlsService
.
new
(
forked_project
)
}
let
(
:service
)
{
described_class
.
new
(
forked_project
)
}
before
do
allow
(
forked_project
).
to
receive
(
:empty_repo?
).
and_return
(
false
)
...
...
spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
MergeRequests
::
MergeRequestDiffCacheService
do
let
(
:subject
)
{
MergeRequests
::
MergeRequestDiffCacheService
.
new
}
let
(
:subject
)
{
described_class
.
new
}
describe
'#execute'
do
it
'retrieves the diff files to cache the highlighted result'
do
...
...
spec/services/merge_requests/rebase_service_spec.rb
View file @
095ac7d3
...
...
@@ -15,7 +15,7 @@ describe MergeRequests::RebaseService do
describe
'#execute'
do
context
'valid params'
do
let
(
:service
)
{
MergeRequests
::
RebaseService
.
new
(
project
,
user
,
{})
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
{})
}
before
do
service
.
execute
(
merge_request
)
...
...
spec/services/merge_requests/resolve_service_spec.rb
View file @
095ac7d3
...
...
@@ -50,7 +50,7 @@ describe MergeRequests::ResolveService do
context
'when the source and target project are the same'
do
before
do
MergeRequests
::
ResolveService
.
new
(
project
,
user
,
params
).
execute
(
merge_request
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
merge_request
)
end
it
'creates a commit with the message'
do
...
...
@@ -75,7 +75,7 @@ describe MergeRequests::ResolveService do
end
before
do
MergeRequests
::
ResolveService
.
new
(
fork_project
,
user
,
params
).
execute
(
merge_request_from_fork
)
described_class
.
new
(
fork_project
,
user
,
params
).
execute
(
merge_request_from_fork
)
end
it
'creates a commit with the message'
do
...
...
@@ -115,7 +115,7 @@ describe MergeRequests::ResolveService do
end
before
do
MergeRequests
::
ResolveService
.
new
(
project
,
user
,
params
).
execute
(
merge_request
)
described_class
.
new
(
project
,
user
,
params
).
execute
(
merge_request
)
end
it
'creates a commit with the message'
do
...
...
@@ -154,7 +154,7 @@ describe MergeRequests::ResolveService do
}
end
let
(
:service
)
{
MergeRequests
::
ResolveService
.
new
(
project
,
user
,
invalid_params
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
invalid_params
)
}
it
'raises a MissingResolution error'
do
expect
{
service
.
execute
(
merge_request
)
}.
...
...
@@ -180,7 +180,7 @@ describe MergeRequests::ResolveService do
}
end
let
(
:service
)
{
MergeRequests
::
ResolveService
.
new
(
project
,
user
,
invalid_params
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
invalid_params
)
}
it
'raises a MissingResolution error'
do
expect
{
service
.
execute
(
merge_request
)
}.
...
...
@@ -202,7 +202,7 @@ describe MergeRequests::ResolveService do
}
end
let
(
:service
)
{
MergeRequests
::
ResolveService
.
new
(
project
,
user
,
invalid_params
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
invalid_params
)
}
it
'raises a MissingFiles error'
do
expect
{
service
.
execute
(
merge_request
)
}.
...
...
spec/services/projects/housekeeping_service_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
Projects
::
HousekeepingService
do
subject
{
Projects
::
HousekeepingService
.
new
(
project
)
}
subject
{
described_class
.
new
(
project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
...
...
spec/tasks/config_lint_spec.rb
View file @
095ac7d3
...
...
@@ -5,11 +5,11 @@ describe ConfigLint do
let
(
:files
){
[
'lib/support/fake.sh'
]
}
it
'errors out if any bash scripts have errors'
do
expect
{
ConfigLint
.
run
(
files
){
system
(
'exit 1'
)
}
}.
to
raise_error
(
SystemExit
)
expect
{
described_class
.
run
(
files
){
system
(
'exit 1'
)
}
}.
to
raise_error
(
SystemExit
)
end
it
'passes if all scripts are fine'
do
expect
{
ConfigLint
.
run
(
files
){
system
(
'exit 0'
)
}
}.
not_to
raise_error
expect
{
described_class
.
run
(
files
){
system
(
'exit 0'
)
}
}.
not_to
raise_error
end
end
...
...
spec/workers/admin_emails_worker_spec.rb
View file @
095ac7d3
...
...
@@ -26,7 +26,7 @@ describe AdminEmailsWorker do
it
"sends email to subscribed users"
do
perform_enqueued_jobs
do
AdminEmailsWorker
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
described_class
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
be
2
end
end
...
...
@@ -37,7 +37,7 @@ describe AdminEmailsWorker do
it
"sends email to subscribed users"
do
perform_enqueued_jobs
do
AdminEmailsWorker
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
described_class
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
be
2
end
end
...
...
@@ -48,7 +48,7 @@ describe AdminEmailsWorker do
it
"sends email to subscribed users"
do
perform_enqueued_jobs
do
AdminEmailsWorker
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
described_class
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
be
4
end
end
...
...
spec/workers/delete_user_worker_spec.rb
View file @
095ac7d3
...
...
@@ -8,13 +8,13 @@ describe DeleteUserWorker do
expect_any_instance_of
(
Users
::
DestroyService
).
to
receive
(
:execute
).
with
(
user
,
{})
DeleteUserWorker
.
new
.
perform
(
current_user
.
id
,
user
.
id
)
described_class
.
new
.
perform
(
current_user
.
id
,
user
.
id
)
end
it
"uses symbolized keys"
do
expect_any_instance_of
(
Users
::
DestroyService
).
to
receive
(
:execute
).
with
(
user
,
test:
"test"
)
DeleteUserWorker
.
new
.
perform
(
current_user
.
id
,
user
.
id
,
"test"
=>
"test"
)
described_class
.
new
.
perform
(
current_user
.
id
,
user
.
id
,
"test"
=>
"test"
)
end
end
spec/workers/emails_on_push_worker_spec.rb
View file @
095ac7d3
...
...
@@ -12,7 +12,7 @@ describe EmailsOnPushWorker do
let
(
:perform
)
{
subject
.
perform
(
project
.
id
,
recipients
,
data
.
stringify_keys
)
}
let
(
:email
)
{
ActionMailer
::
Base
.
deliveries
.
last
}
subject
{
EmailsOnPushWorker
.
new
}
subject
{
described_class
.
new
}
describe
"#perform"
do
context
"when push is a new branch"
do
...
...
spec/workers/git_garbage_collect_worker_spec.rb
View file @
095ac7d3
...
...
@@ -6,7 +6,7 @@ describe GitGarbageCollectWorker do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:shell
)
{
Gitlab
::
Shell
.
new
}
subject
{
GitGarbageCollectWorker
.
new
}
subject
{
described_class
.
new
}
describe
"#perform"
do
it
"flushes ref caches when the task is 'gc'"
do
...
...
spec/workers/gitlab_usage_ping_worker_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
GitlabUsagePingWorker
do
subject
{
GitlabUsagePingWorker
.
new
}
subject
{
described_class
.
new
}
it
"sends POST request"
do
stub_application_setting
(
usage_ping_enabled:
true
)
...
...
spec/workers/group_destroy_worker_spec.rb
View file @
095ac7d3
...
...
@@ -5,7 +5,7 @@ describe GroupDestroyWorker do
let
(
:user
)
{
create
(
:admin
)
}
let!
(
:project
)
{
create
(
:empty_project
,
namespace:
group
)
}
subject
{
GroupDestroyWorker
.
new
}
subject
{
described_class
.
new
}
describe
"#perform"
do
it
"deletes the project"
do
...
...
spec/workers/merge_worker_spec.rb
View file @
095ac7d3
...
...
@@ -15,7 +15,7 @@ describe MergeWorker do
it
'clears cache of source repo after removing source branch'
do
expect
(
source_project
.
repository
.
branch_names
).
to
include
(
'markdown'
)
MergeWorker
.
new
.
perform
(
described_class
.
new
.
perform
(
merge_request
.
id
,
merge_request
.
author_id
,
commit_message:
'wow such merge'
,
should_remove_source_branch:
true
)
...
...
spec/workers/post_receive_spec.rb
View file @
095ac7d3
...
...
@@ -10,7 +10,7 @@ describe PostReceive do
context
"as a resque worker"
do
it
"reponds to #perform"
do
expect
(
PostReceive
.
new
).
to
respond_to
(
:perform
)
expect
(
described_class
.
new
).
to
respond_to
(
:perform
)
end
end
...
...
@@ -25,7 +25,7 @@ describe PostReceive do
it
"calls GitTagPushService"
do
expect_any_instance_of
(
GitPushService
).
to
receive
(
:execute
).
and_return
(
true
)
expect_any_instance_of
(
GitTagPushService
).
not_to
receive
(
:execute
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
...
...
@@ -35,7 +35,7 @@ describe PostReceive do
it
"calls GitTagPushService"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
GitTagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
...
...
@@ -45,12 +45,12 @@ describe PostReceive do
it
"does not call any of the services"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
GitTagPushService
).
not_to
receive
(
:execute
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
context
"gitlab-ci.yml"
do
subject
{
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
}
subject
{
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
}
context
"creates a Ci::Pipeline for every change"
do
before
do
...
...
@@ -75,7 +75,7 @@ describe PostReceive do
context
"webhook"
do
it
"fetches the correct project"
do
expect
(
Project
).
to
receive
(
:find_by_full_path
).
with
(
project
.
path_with_namespace
).
and_return
(
project
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
it
"triggers wiki index update"
do
...
...
@@ -86,7 +86,7 @@ describe PostReceive do
repo_path
=
"
#{
pwd
(
project
)
}
.wiki"
PostReceive
.
new
.
perform
(
repo_path
,
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
repo_path
,
key_id
,
base64_changes
)
end
it
"does not run if the author is not in the project"
do
...
...
@@ -96,7 +96,7 @@ describe PostReceive do
expect
(
project
).
not_to
receive
(
:execute_hooks
)
expect
(
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)).
to
be_falsey
expect
(
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)).
to
be_falsey
end
it
"asks the project to trigger all hooks"
do
...
...
@@ -104,14 +104,14 @@ describe PostReceive do
expect
(
project
).
to
receive
(
:execute_hooks
).
twice
expect
(
project
).
to
receive
(
:execute_services
).
twice
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
it
"enqueues a UpdateMergeRequestsWorker job"
do
allow
(
Project
).
to
receive
(
:find_by_full_path
).
and_return
(
project
)
expect
(
UpdateMergeRequestsWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
project
.
owner
.
id
,
any_args
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
...
...
spec/workers/project_destroy_worker_spec.rb
View file @
095ac7d3
...
...
@@ -4,7 +4,7 @@ describe ProjectDestroyWorker do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:path
)
{
project
.
repository
.
path_to_repo
}
subject
{
ProjectDestroyWorker
.
new
}
subject
{
described_class
.
new
}
describe
"#perform"
do
it
"deletes the project"
do
...
...
spec/workers/project_update_repository_storage_worker_spec.rb
View file @
095ac7d3
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
ProjectUpdateRepositoryStorageWorker
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
ProjectUpdateRepositoryStorageWorker
.
new
}
subject
{
described_class
.
new
}
describe
"#perform"
do
it
"should call the update repository storage service"
do
...
...
spec/workers/remove_expired_members_worker_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
RemoveExpiredMembersWorker
do
let
(
:worker
)
{
RemoveExpiredMembersWorker
.
new
}
let
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
context
'project members'
do
...
...
spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb
View file @
095ac7d3
require
'spec_helper'
describe
RemoveUnreferencedLfsObjectsWorker
do
let
(
:worker
)
{
RemoveUnreferencedLfsObjectsWorker
.
new
}
let
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
let!
(
:unreferenced_lfs_object1
)
{
create
(
:lfs_object
,
oid:
'1'
)
}
...
...
spec/workers/repository_fork_worker_spec.rb
View file @
095ac7d3
...
...
@@ -5,7 +5,7 @@ describe RepositoryForkWorker do
let
(
:fork_project
)
{
create
(
:project
,
:repository
,
forked_from_project:
project
)
}
let
(
:shell
)
{
Gitlab
::
Shell
.
new
}
subject
{
RepositoryForkWorker
.
new
}
subject
{
described_class
.
new
}
before
do
allow
(
subject
).
to
receive
(
:gitlab_shell
).
and_return
(
shell
)
...
...
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