Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
cddc5cac
Commit
cddc5cac
authored
Jul 25, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use described_class when possible
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
ddccd24c
Changes
106
Show whitespace changes
Inline
Side-by-side
Showing
106 changed files
with
390 additions
and
390 deletions
+390
-390
spec/initializers/settings_spec.rb
spec/initializers/settings_spec.rb
+20
-20
spec/lib/disable_email_interceptor_spec.rb
spec/lib/disable_email_interceptor_spec.rb
+2
-2
spec/lib/event_filter_spec.rb
spec/lib/event_filter_spec.rb
+8
-8
spec/lib/extracts_path_spec.rb
spec/lib/extracts_path_spec.rb
+1
-1
spec/lib/file_size_validator_spec.rb
spec/lib/file_size_validator_spec.rb
+1
-1
spec/lib/gitlab/bitbucket_import/importer_spec.rb
spec/lib/gitlab/bitbucket_import/importer_spec.rb
+1
-1
spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
+1
-1
spec/lib/gitlab/ci_access_spec.rb
spec/lib/gitlab/ci_access_spec.rb
+1
-1
spec/lib/gitlab/conflict/file_spec.rb
spec/lib/gitlab/conflict/file_spec.rb
+2
-2
spec/lib/gitlab/conflict/parser_spec.rb
spec/lib/gitlab/conflict/parser_spec.rb
+1
-1
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+1
-1
spec/lib/gitlab/diff/highlight_spec.rb
spec/lib/gitlab/diff/highlight_spec.rb
+2
-2
spec/lib/gitlab/diff/parser_spec.rb
spec/lib/gitlab/diff/parser_spec.rb
+1
-1
spec/lib/gitlab/git/hook_spec.rb
spec/lib/gitlab/git/hook_spec.rb
+4
-4
spec/lib/gitlab/git/rev_list_spec.rb
spec/lib/gitlab/git/rev_list_spec.rb
+2
-2
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+3
-3
spec/lib/gitlab/git_access_wiki_spec.rb
spec/lib/gitlab/git_access_wiki_spec.rb
+1
-1
spec/lib/gitlab/git_ref_validator_spec.rb
spec/lib/gitlab/git_ref_validator_spec.rb
+21
-21
spec/lib/gitlab/git_spec.rb
spec/lib/gitlab/git_spec.rb
+3
-3
spec/lib/gitlab/gitlab_import/client_spec.rb
spec/lib/gitlab/gitlab_import/client_spec.rb
+1
-1
spec/lib/gitlab/gitlab_import/project_creator_spec.rb
spec/lib/gitlab/gitlab_import/project_creator_spec.rb
+1
-1
spec/lib/gitlab/google_code_import/project_creator_spec.rb
spec/lib/gitlab/google_code_import/project_creator_spec.rb
+1
-1
spec/lib/gitlab/highlight_spec.rb
spec/lib/gitlab/highlight_spec.rb
+2
-2
spec/lib/gitlab/key_fingerprint_spec.rb
spec/lib/gitlab/key_fingerprint_spec.rb
+1
-1
spec/lib/gitlab/ldap/access_spec.rb
spec/lib/gitlab/ldap/access_spec.rb
+1
-1
spec/lib/gitlab/ldap/auth_hash_spec.rb
spec/lib/gitlab/ldap/auth_hash_spec.rb
+1
-1
spec/lib/gitlab/ldap/config_spec.rb
spec/lib/gitlab/ldap/config_spec.rb
+3
-3
spec/lib/gitlab/ldap/user_spec.rb
spec/lib/gitlab/ldap/user_spec.rb
+2
-2
spec/lib/gitlab/markup_helper_spec.rb
spec/lib/gitlab/markup_helper_spec.rb
+6
-6
spec/lib/gitlab/o_auth/auth_hash_spec.rb
spec/lib/gitlab/o_auth/auth_hash_spec.rb
+1
-1
spec/lib/gitlab/o_auth/user_spec.rb
spec/lib/gitlab/o_auth/user_spec.rb
+1
-1
spec/lib/gitlab/project_transfer_spec.rb
spec/lib/gitlab/project_transfer_spec.rb
+1
-1
spec/lib/gitlab/reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+1
-1
spec/lib/gitlab/request_context_spec.rb
spec/lib/gitlab/request_context_spec.rb
+2
-2
spec/lib/gitlab/shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+3
-3
spec/lib/gitlab/upgrader_spec.rb
spec/lib/gitlab/upgrader_spec.rb
+1
-1
spec/lib/gitlab/user_access_spec.rb
spec/lib/gitlab/user_access_spec.rb
+2
-2
spec/lib/gitlab/workhorse_spec.rb
spec/lib/gitlab/workhorse_spec.rb
+2
-2
spec/lib/repository_cache_spec.rb
spec/lib/repository_cache_spec.rb
+1
-1
spec/lib/system_check_spec.rb
spec/lib/system_check_spec.rb
+1
-1
spec/models/ability_spec.rb
spec/models/ability_spec.rb
+1
-1
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+3
-3
spec/models/broadcast_message_spec.rb
spec/models/broadcast_message_spec.rb
+4
-4
spec/models/ci/pipeline_schedule_spec.rb
spec/models/ci/pipeline_schedule_spec.rb
+2
-2
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+7
-7
spec/models/global_milestone_spec.rb
spec/models/global_milestone_spec.rb
+7
-7
spec/models/group_milestone_spec.rb
spec/models/group_milestone_spec.rb
+2
-2
spec/models/group_spec.rb
spec/models/group_spec.rb
+1
-1
spec/models/guest_spec.rb
spec/models/guest_spec.rb
+5
-5
spec/models/hooks/project_hook_spec.rb
spec/models/hooks/project_hook_spec.rb
+2
-2
spec/models/hooks/system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+1
-1
spec/models/member_spec.rb
spec/models/member_spec.rb
+1
-1
spec/models/members/project_member_spec.rb
spec/models/members/project_member_spec.rb
+1
-1
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+1
-1
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+5
-5
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+7
-7
spec/models/note_spec.rb
spec/models/note_spec.rb
+1
-1
spec/models/project_services/asana_service_spec.rb
spec/models/project_services/asana_service_spec.rb
+1
-1
spec/models/project_services/assembla_service_spec.rb
spec/models/project_services/assembla_service_spec.rb
+1
-1
spec/models/project_services/campfire_service_spec.rb
spec/models/project_services/campfire_service_spec.rb
+1
-1
spec/models/project_services/flowdock_service_spec.rb
spec/models/project_services/flowdock_service_spec.rb
+1
-1
spec/models/project_services/gemnasium_service_spec.rb
spec/models/project_services/gemnasium_service_spec.rb
+1
-1
spec/models/project_services/gitlab_issue_tracker_service_spec.rb
...els/project_services/gitlab_issue_tracker_service_spec.rb
+2
-2
spec/models/project_services/hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+1
-1
spec/models/project_services/irker_service_spec.rb
spec/models/project_services/irker_service_spec.rb
+1
-1
spec/models/project_services/jira_service_spec.rb
spec/models/project_services/jira_service_spec.rb
+4
-4
spec/models/project_services/pivotaltracker_service_spec.rb
spec/models/project_services/pivotaltracker_service_spec.rb
+1
-1
spec/models/project_services/pushover_service_spec.rb
spec/models/project_services/pushover_service_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+9
-9
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+1
-1
spec/models/protected_branch_spec.rb
spec/models/protected_branch_spec.rb
+18
-18
spec/models/redirect_route_spec.rb
spec/models/redirect_route_spec.rb
+1
-1
spec/models/route_spec.rb
spec/models/route_spec.rb
+2
-2
spec/models/sent_notification_spec.rb
spec/models/sent_notification_spec.rb
+2
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+64
-64
spec/models/wiki_directory_spec.rb
spec/models/wiki_directory_spec.rb
+2
-2
spec/models/wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+7
-7
spec/policies/global_policy_spec.rb
spec/policies/global_policy_spec.rb
+1
-1
spec/policies/user_policy_spec.rb
spec/policies/user_policy_spec.rb
+1
-1
spec/services/create_release_service_spec.rb
spec/services/create_release_service_spec.rb
+1
-1
spec/services/event_create_service_spec.rb
spec/services/event_create_service_spec.rb
+1
-1
spec/services/git_hooks_service_spec.rb
spec/services/git_hooks_service_spec.rb
+1
-1
spec/services/git_tag_push_service_spec.rb
spec/services/git_tag_push_service_spec.rb
+2
-2
spec/services/groups/destroy_service_spec.rb
spec/services/groups/destroy_service_spec.rb
+1
-1
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+1
-1
spec/services/labels/create_service_spec.rb
spec/services/labels/create_service_spec.rb
+18
-18
spec/services/labels/update_service_spec.rb
spec/services/labels/update_service_spec.rb
+6
-6
spec/services/merge_requests/build_service_spec.rb
spec/services/merge_requests/build_service_spec.rb
+1
-1
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+7
-7
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+1
-1
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+7
-7
spec/services/milestones/close_service_spec.rb
spec/services/milestones/close_service_spec.rb
+1
-1
spec/services/milestones/create_service_spec.rb
spec/services/milestones/create_service_spec.rb
+1
-1
spec/services/notes/post_process_service_spec.rb
spec/services/notes/post_process_service_spec.rb
+1
-1
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+1
-1
spec/services/pages_service_spec.rb
spec/services/pages_service_spec.rb
+1
-1
spec/services/projects/destroy_service_spec.rb
spec/services/projects/destroy_service_spec.rb
+3
-3
spec/services/projects/transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+2
-2
spec/services/projects/unlink_fork_service_spec.rb
spec/services/projects/unlink_fork_service_spec.rb
+1
-1
spec/services/repair_ldap_blocked_user_service_spec.rb
spec/services/repair_ldap_blocked_user_service_spec.rb
+1
-1
spec/services/search/global_service_spec.rb
spec/services/search/global_service_spec.rb
+4
-4
spec/services/search/group_service_spec.rb
spec/services/search/group_service_spec.rb
+1
-1
spec/services/search_service_spec.rb
spec/services/search_service_spec.rb
+28
-28
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+9
-9
spec/services/update_release_service_spec.rb
spec/services/update_release_service_spec.rb
+1
-1
spec/services/web_hook_service_spec.rb
spec/services/web_hook_service_spec.rb
+3
-3
No files found.
spec/initializers/settings_spec.rb
View file @
cddc5cac
...
...
@@ -5,37 +5,37 @@ describe Settings do
describe
'#host_without_www'
do
context
'URL with protocol'
do
it
'returns the host'
do
expect
(
Setting
s
.
host_without_www
(
'http://foo.com'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'http://www.foo.com'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'http://secure.foo.com'
)).
to
eq
'secure.foo.com'
expect
(
Setting
s
.
host_without_www
(
'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
expect
(
described_clas
s
.
host_without_www
(
'http://foo.com'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'http://www.foo.com'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'http://secure.foo.com'
)).
to
eq
'secure.foo.com'
expect
(
described_clas
s
.
host_without_www
(
'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
expect
(
Setting
s
.
host_without_www
(
'https://foo.com'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'https://www.foo.com'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'https://secure.foo.com'
)).
to
eq
'secure.foo.com'
expect
(
Setting
s
.
host_without_www
(
'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'secure.gravatar.com'
expect
(
described_clas
s
.
host_without_www
(
'https://foo.com'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'https://www.foo.com'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'https://secure.foo.com'
)).
to
eq
'secure.foo.com'
expect
(
described_clas
s
.
host_without_www
(
'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'secure.gravatar.com'
end
end
context
'URL without protocol'
do
it
'returns the host'
do
expect
(
Setting
s
.
host_without_www
(
'foo.com'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'www.foo.com'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'secure.foo.com'
)).
to
eq
'secure.foo.com'
expect
(
Setting
s
.
host_without_www
(
'www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
expect
(
described_clas
s
.
host_without_www
(
'foo.com'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'www.foo.com'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'secure.foo.com'
)).
to
eq
'secure.foo.com'
expect
(
described_clas
s
.
host_without_www
(
'www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
end
context
'URL with user/port'
do
it
'returns the host'
do
expect
(
Setting
s
.
host_without_www
(
'bob:pass@foo.com:8080'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'bob:pass@www.foo.com:8080'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'bob:pass@secure.foo.com:8080'
)).
to
eq
'secure.foo.com'
expect
(
Setting
s
.
host_without_www
(
'bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
expect
(
described_clas
s
.
host_without_www
(
'bob:pass@foo.com:8080'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'bob:pass@www.foo.com:8080'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'bob:pass@secure.foo.com:8080'
)).
to
eq
'secure.foo.com'
expect
(
described_clas
s
.
host_without_www
(
'bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
expect
(
Setting
s
.
host_without_www
(
'http://bob:pass@foo.com:8080'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'http://bob:pass@www.foo.com:8080'
)).
to
eq
'foo.com'
expect
(
Setting
s
.
host_without_www
(
'http://bob:pass@secure.foo.com:8080'
)).
to
eq
'secure.foo.com'
expect
(
Setting
s
.
host_without_www
(
'http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
expect
(
described_clas
s
.
host_without_www
(
'http://bob:pass@foo.com:8080'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'http://bob:pass@www.foo.com:8080'
)).
to
eq
'foo.com'
expect
(
described_clas
s
.
host_without_www
(
'http://bob:pass@secure.foo.com:8080'
)).
to
eq
'secure.foo.com'
expect
(
described_clas
s
.
host_without_www
(
'http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon'
)).
to
eq
'gravatar.com'
end
end
end
...
...
spec/lib/disable_email_interceptor_spec.rb
View file @
cddc5cac
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
DisableEmailInterceptor
do
before
do
Mail
.
register_interceptor
(
DisableEmailInterceptor
)
Mail
.
register_interceptor
(
described_class
)
end
it
'does not send emails'
do
...
...
@@ -14,7 +14,7 @@ describe DisableEmailInterceptor do
# Removing interceptor from the list because unregister_interceptor is
# implemented in later version of mail gem
# See: https://github.com/mikel/mail/pull/705
Mail
.
unregister_interceptor
(
DisableEmailInterceptor
)
Mail
.
unregister_interceptor
(
described_class
)
end
def
deliver_mail
...
...
spec/lib/event_filter_spec.rb
View file @
cddc5cac
...
...
@@ -16,42 +16,42 @@ describe EventFilter do
let!
(
:left_event
)
{
create
(
:event
,
:left
,
project:
public_project
,
target:
public_project
,
author:
source_user
)
}
it
'applies push filter'
do
events
=
EventFilter
.
new
(
EventFilter
.
push
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
described_class
.
push
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
push_event
)
end
it
'applies merged filter'
do
events
=
EventFilter
.
new
(
EventFilter
.
merged
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
described_class
.
merged
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
merged_event
)
end
it
'applies issue filter'
do
events
=
EventFilter
.
new
(
EventFilter
.
issue
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
described_class
.
issue
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
created_event
,
updated_event
,
closed_event
,
reopened_event
)
end
it
'applies comments filter'
do
events
=
EventFilter
.
new
(
EventFilter
.
comments
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
described_class
.
comments
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
comments_event
)
end
it
'applies team filter'
do
events
=
EventFilter
.
new
(
EventFilter
.
team
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
described_class
.
team
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
joined_event
,
left_event
)
end
it
'applies all filter'
do
events
=
EventFilter
.
new
(
EventFilter
.
all
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
described_class
.
all
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
push_event
,
merged_event
,
created_event
,
updated_event
,
closed_event
,
reopened_event
,
comments_event
,
joined_event
,
left_event
)
end
it
'applies no filter'
do
events
=
EventFilter
.
new
(
nil
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
nil
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
push_event
,
merged_event
,
created_event
,
updated_event
,
closed_event
,
reopened_event
,
comments_event
,
joined_event
,
left_event
)
end
it
'applies unknown filter'
do
events
=
EventFilter
.
new
(
''
).
apply_filter
(
Event
.
all
)
events
=
described_class
.
new
(
''
).
apply_filter
(
Event
.
all
)
expect
(
events
).
to
contain_exactly
(
push_event
,
merged_event
,
created_event
,
updated_event
,
closed_event
,
reopened_event
,
comments_event
,
joined_event
,
left_event
)
end
end
...
...
spec/lib/extracts_path_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
ExtractsPath
do
include
ExtractsPath
include
described_class
include
RepoHelpers
include
Gitlab
::
Routing
...
...
spec/lib/file_size_validator_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
FileSizeValidator
do
let
(
:validator
)
{
FileSizeValidator
.
new
(
options
)
}
let
(
:validator
)
{
described_class
.
new
(
options
)
}
let
(
:attachment
)
{
AttachmentUploader
.
new
}
let
(
:note
)
{
create
(
:note
)
}
...
...
spec/lib/gitlab/bitbucket_import/importer_spec.rb
View file @
cddc5cac
...
...
@@ -58,7 +58,7 @@ describe Gitlab::BitbucketImport::Importer do
)
end
let
(
:importer
)
{
Gitlab
::
BitbucketImport
::
Importer
.
new
(
project
)
}
let
(
:importer
)
{
described_class
.
new
(
project
)
}
let
(
:issues_statuses_sample_data
)
do
{
...
...
spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
View file @
cddc5cac
...
...
@@ -27,7 +27,7 @@ describe Gitlab::BitbucketImport::ProjectCreator do
it
'creates project'
do
allow_any_instance_of
(
Project
).
to
receive
(
:add_import_job
)
project_creator
=
Gitlab
::
BitbucketImport
::
ProjectCreator
.
new
(
repo
,
'vim'
,
namespace
,
user
,
access_params
)
project_creator
=
described_class
.
new
(
repo
,
'vim'
,
namespace
,
user
,
access_params
)
project
=
project_creator
.
execute
expect
(
project
.
import_url
).
to
eq
(
"ssh://git@bitbucket.org/asd/vim.git"
)
...
...
spec/lib/gitlab/ci_access_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
CiAccess
do
let
(
:access
)
{
Gitlab
::
CiAcce
ss
.
new
}
let
(
:access
)
{
described_cla
ss
.
new
}
describe
'#can_do_action?'
do
context
'when action is :build_download_code'
do
...
...
spec/lib/gitlab/conflict/file_spec.rb
View file @
cddc5cac
...
...
@@ -10,7 +10,7 @@ describe Gitlab::Conflict::File do
let
(
:index
)
{
rugged
.
merge_commits
(
our_commit
,
their_commit
)
}
let
(
:conflict
)
{
index
.
conflicts
.
last
}
let
(
:merge_file_result
)
{
index
.
merge_file
(
'files/ruby/regex.rb'
)
}
let
(
:conflict_file
)
{
Gitlab
::
Conflict
::
File
.
new
(
merge_file_result
,
conflict
,
merge_request:
merge_request
)
}
let
(
:conflict_file
)
{
described_class
.
new
(
merge_file_result
,
conflict
,
merge_request:
merge_request
)
}
describe
'#resolve_lines'
do
let
(
:section_keys
)
{
conflict_file
.
sections
.
map
{
|
section
|
section
[
:id
]
}.
compact
}
...
...
@@ -220,7 +220,7 @@ end
FILE
end
let
(
:conflict_file
)
{
Gitlab
::
Conflict
::
File
.
new
({
data:
file
},
conflict
,
merge_request:
merge_request
)
}
let
(
:conflict_file
)
{
described_class
.
new
({
data:
file
},
conflict
,
merge_request:
merge_request
)
}
let
(
:sections
)
{
conflict_file
.
sections
}
it
'sets the correct match line headers'
do
...
...
spec/lib/gitlab/conflict/parser_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
Conflict
::
Parser
do
let
(
:parser
)
{
Gitlab
::
Conflict
::
Parser
.
new
}
let
(
:parser
)
{
described_class
.
new
}
describe
'#parse'
do
def
parse_text
(
text
)
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
Database
::
MigrationHelpers
do
let
(
:model
)
do
ActiveRecord
::
Migration
.
new
.
extend
(
Gitlab
::
Database
::
MigrationHelper
s
described_clas
s
)
end
...
...
spec/lib/gitlab/diff/highlight_spec.rb
View file @
cddc5cac
...
...
@@ -10,7 +10,7 @@ describe Gitlab::Diff::Highlight do
describe
'#highlight'
do
context
"with a diff file"
do
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
,
repository:
project
.
repository
).
highlight
}
let
(
:subject
)
{
described_class
.
new
(
diff_file
,
repository:
project
.
repository
).
highlight
}
it
'returns Gitlab::Diff::Line elements'
do
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
...
...
@@ -41,7 +41,7 @@ describe Gitlab::Diff::Highlight do
end
context
"with diff lines"
do
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
.
diff_lines
,
repository:
project
.
repository
).
highlight
}
let
(
:subject
)
{
described_class
.
new
(
diff_file
.
diff_lines
,
repository:
project
.
repository
).
highlight
}
it
'returns Gitlab::Diff::Line elements'
do
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
...
...
spec/lib/gitlab/diff/parser_spec.rb
View file @
cddc5cac
...
...
@@ -6,7 +6,7 @@ describe Gitlab::Diff::Parser do
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
raw_diffs
.
first
}
let
(
:parser
)
{
Gitlab
::
Diff
::
Parser
.
new
}
let
(
:parser
)
{
described_class
.
new
}
describe
'#parse'
do
let
(
:diff
)
do
...
...
spec/lib/gitlab/git/hook_spec.rb
View file @
cddc5cac
...
...
@@ -5,7 +5,7 @@ describe Gitlab::Git::Hook do
before
do
# We need this because in the spec/spec_helper.rb we define it like this:
# allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil])
allow_any_instance_of
(
Gitlab
::
Git
::
Hook
).
to
receive
(
:trigger
).
and_call_original
allow_any_instance_of
(
described_class
).
to
receive
(
:trigger
).
and_call_original
end
describe
"#trigger"
do
...
...
@@ -48,7 +48,7 @@ describe Gitlab::Git::Hook do
it
"returns success with no errors"
do
create_hook
(
hook_name
)
hook
=
Gitlab
::
Git
::
Hook
.
new
(
hook_name
,
project
)
hook
=
described_class
.
new
(
hook_name
,
project
)
blank
=
Gitlab
::
Git
::
BLANK_SHA
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
'new_branch'
...
...
@@ -66,7 +66,7 @@ describe Gitlab::Git::Hook do
context
"when the hook is unsuccessful"
do
it
"returns failure with errors"
do
create_failing_hook
(
hook_name
)
hook
=
Gitlab
::
Git
::
Hook
.
new
(
hook_name
,
project
)
hook
=
described_class
.
new
(
hook_name
,
project
)
blank
=
Gitlab
::
Git
::
BLANK_SHA
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
'new_branch'
...
...
@@ -80,7 +80,7 @@ describe Gitlab::Git::Hook do
context
"when the hook doesn't exist"
do
it
"returns success with no errors"
do
hook
=
Gitlab
::
Git
::
Hook
.
new
(
'unknown_hook'
,
project
)
hook
=
described_class
.
new
(
'unknown_hook'
,
project
)
blank
=
Gitlab
::
Git
::
BLANK_SHA
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
'new_branch'
...
...
spec/lib/gitlab/git/rev_list_spec.rb
View file @
cddc5cac
...
...
@@ -11,7 +11,7 @@ describe Gitlab::Git::RevList do
end
context
"#new_refs"
do
let
(
:rev_list
)
{
Gitlab
::
Git
::
RevList
.
new
(
newrev:
'newrev'
,
path_to_repo:
project
.
repository
.
path_to_repo
)
}
let
(
:rev_list
)
{
described_class
.
new
(
newrev:
'newrev'
,
path_to_repo:
project
.
repository
.
path_to_repo
)
}
it
'calls out to `popen`'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
([
...
...
@@ -33,7 +33,7 @@ describe Gitlab::Git::RevList do
end
context
"#missed_ref"
do
let
(
:rev_list
)
{
Gitlab
::
Git
::
RevList
.
new
(
oldrev:
'oldrev'
,
newrev:
'newrev'
,
path_to_repo:
project
.
repository
.
path_to_repo
)
}
let
(
:rev_list
)
{
described_class
.
new
(
oldrev:
'oldrev'
,
newrev:
'newrev'
,
path_to_repo:
project
.
repository
.
path_to_repo
)
}
it
'calls out to `popen`'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
([
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
GitAccess
do
let
(
:pull_access_check
)
{
access
.
check
(
'git-upload-pack'
,
'_any'
)
}
let
(
:push_access_check
)
{
access
.
check
(
'git-receive-pack'
,
'_any'
)
}
let
(
:access
)
{
Gitlab
::
GitAcce
ss
.
new
(
actor
,
project
,
protocol
,
authentication_abilities:
authentication_abilities
,
redirected_path:
redirected_path
)
}
let
(
:access
)
{
described_cla
ss
.
new
(
actor
,
project
,
protocol
,
authentication_abilities:
authentication_abilities
,
redirected_path:
redirected_path
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:actor
)
{
user
}
...
...
@@ -280,7 +280,7 @@ describe Gitlab::GitAccess do
context
'when project is public'
do
let
(
:public_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:access
)
{
Gitlab
::
GitAcce
ss
.
new
(
nil
,
public_project
,
'web'
,
authentication_abilities:
[])
}
let
(
:access
)
{
described_cla
ss
.
new
(
nil
,
public_project
,
'web'
,
authentication_abilities:
[])
}
context
'when repository is enabled'
do
it
'give access to download code'
do
...
...
@@ -441,7 +441,7 @@ describe Gitlab::GitAccess do
end
permissions_matrix
[
role
].
each
do
|
action
,
allowed
|
context
action
do
context
action
.
to_s
do
subject
{
access
.
send
(
:check_push_access!
,
changes
[
action
])
}
it
do
...
...
spec/lib/gitlab/git_access_wiki_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
GitAccessWiki
do
let
(
:access
)
{
Gitlab
::
GitAccessWiki
.
new
(
user
,
project
,
'web'
,
authentication_abilities:
authentication_abilities
,
redirected_path:
redirected_path
)
}
let
(
:access
)
{
described_class
.
new
(
user
,
project
,
'web'
,
authentication_abilities:
authentication_abilities
,
redirected_path:
redirected_path
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:redirected_path
)
{
nil
}
...
...
spec/lib/gitlab/git_ref_validator_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
GitRefValidator
do
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/new'
)).
to
be_truthy
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'implement_@all'
)).
to
be_truthy
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'my_new_feature'
)).
to
be_truthy
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'#1'
)).
to
be_truthy
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/refs/heads/foo'
)).
to
be_truthy
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/~new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/^new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/:new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/?new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/*new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/[new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/new/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature/new.'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature\@{'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature\new'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature//new'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'feature new'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'refs/heads/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'refs/remotes/'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'refs/heads/feature'
)).
to
be_falsey
}
it
{
expect
(
Gitlab
::
GitRefValidator
.
validate
(
'refs/remotes/origin'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/new'
)).
to
be_truthy
}
it
{
expect
(
described_class
.
validate
(
'implement_@all'
)).
to
be_truthy
}
it
{
expect
(
described_class
.
validate
(
'my_new_feature'
)).
to
be_truthy
}
it
{
expect
(
described_class
.
validate
(
'#1'
)).
to
be_truthy
}
it
{
expect
(
described_class
.
validate
(
'feature/refs/heads/foo'
)).
to
be_truthy
}
it
{
expect
(
described_class
.
validate
(
'feature/~new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/^new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/:new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/?new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/*new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/[new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/new/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature/new.'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature\@{'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature\new'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature//new'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'feature new'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'refs/heads/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'refs/remotes/'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'refs/heads/feature'
)).
to
be_falsey
}
it
{
expect
(
described_class
.
validate
(
'refs/remotes/origin'
)).
to
be_falsey
}
end
spec/lib/gitlab/git_spec.rb
View file @
cddc5cac
...
...
@@ -6,7 +6,7 @@ describe Gitlab::Git do
describe
'committer_hash'
do
it
"returns a hash containing the given email and name"
do
committer_hash
=
Gitlab
::
Git
.
committer_hash
(
email:
committer_email
,
name:
committer_name
)
committer_hash
=
described_class
.
committer_hash
(
email:
committer_email
,
name:
committer_name
)
expect
(
committer_hash
[
:email
]).
to
eq
(
committer_email
)
expect
(
committer_hash
[
:name
]).
to
eq
(
committer_name
)
...
...
@@ -15,7 +15,7 @@ describe Gitlab::Git do
context
'when email is nil'
do
it
"returns nil"
do
committer_hash
=
Gitlab
::
Git
.
committer_hash
(
email:
nil
,
name:
committer_name
)
committer_hash
=
described_class
.
committer_hash
(
email:
nil
,
name:
committer_name
)
expect
(
committer_hash
).
to
be_nil
end
...
...
@@ -23,7 +23,7 @@ describe Gitlab::Git do
context
'when name is nil'
do
it
"returns nil"
do
committer_hash
=
Gitlab
::
Git
.
committer_hash
(
email:
committer_email
,
name:
nil
)
committer_hash
=
described_class
.
committer_hash
(
email:
committer_email
,
name:
nil
)
expect
(
committer_hash
).
to
be_nil
end
...
...
spec/lib/gitlab/gitlab_import/client_spec.rb
View file @
cddc5cac
...
...
@@ -4,7 +4,7 @@ describe Gitlab::GitlabImport::Client do
include
ImportSpecHelper
let
(
:token
)
{
'123456'
}
let
(
:client
)
{
Gitlab
::
GitlabImport
::
Client
.
new
(
token
)
}
let
(
:client
)
{
described_class
.
new
(
token
)
}
before
do
stub_omniauth_provider
(
'gitlab'
)
...
...
spec/lib/gitlab/gitlab_import/project_creator_spec.rb
View file @
cddc5cac
...
...
@@ -23,7 +23,7 @@ describe Gitlab::GitlabImport::ProjectCreator do
it
'creates project'
do
allow_any_instance_of
(
Project
).
to
receive
(
:add_import_job
)
project_creator
=
Gitlab
::
GitlabImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
user
,
access_params
)
project_creator
=
described_class
.
new
(
repo
,
namespace
,
user
,
access_params
)
project
=
project_creator
.
execute
expect
(
project
.
import_url
).
to
eq
(
"https://oauth2:asdffg@gitlab.com/asd/vim.git"
)
...
...
spec/lib/gitlab/google_code_import/project_creator_spec.rb
View file @
cddc5cac
...
...
@@ -18,7 +18,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
it
'creates project'
do
allow_any_instance_of
(
Project
).
to
receive
(
:add_import_job
)
project_creator
=
Gitlab
::
GoogleCodeImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
user
)
project_creator
=
described_class
.
new
(
repo
,
namespace
,
user
)
project
=
project_creator
.
execute
expect
(
project
.
import_url
).
to
eq
(
"https://vim.googlecode.com/git/"
)
...
...
spec/lib/gitlab/highlight_spec.rb
View file @
cddc5cac
...
...
@@ -12,7 +12,7 @@ describe Gitlab::Highlight do
let
(
:blob
)
{
repository
.
blob_at_branch
(
branch
,
path
)
}
let
(
:highlighter
)
do
Gitlab
::
Highlight
.
new
(
blob
.
path
,
blob
.
data
,
repository:
repository
)
described_class
.
new
(
blob
.
path
,
blob
.
data
,
repository:
repository
)
end
before
do
...
...
@@ -42,7 +42,7 @@ describe Gitlab::Highlight do
let
(
:path
)
{
'files/whitespace'
}
let
(
:blob
)
{
repository
.
blob_at_branch
(
branch
,
path
)
}
let
(
:lines
)
do
Gitlab
::
Highlight
.
highlight
(
blob
.
path
,
blob
.
data
,
repository:
repository
).
lines
described_class
.
highlight
(
blob
.
path
,
blob
.
data
,
repository:
repository
).
lines
end
it
'strips extra LFs'
do
...
...
spec/lib/gitlab/key_fingerprint_spec.rb
View file @
cddc5cac
...
...
@@ -6,7 +6,7 @@ describe Gitlab::KeyFingerprint do
describe
"#fingerprint"
do
it
"generates the key's fingerprint"
do
expect
(
Gitlab
::
KeyFingerprint
.
new
(
key
).
fingerprint
).
to
eq
(
fingerprint
)
expect
(
described_class
.
new
(
key
).
fingerprint
).
to
eq
(
fingerprint
)
end
end
end
spec/lib/gitlab/ldap/access_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Access
do
let
(
:access
)
{
Gitlab
::
LDAP
::
Acce
ss
.
new
user
}
let
(
:access
)
{
described_cla
ss
.
new
user
}
let
(
:user
)
{
create
(
:omniauth_user
)
}
describe
'.allowed?'
do
...
...
spec/lib/gitlab/ldap/auth_hash_spec.rb
View file @
cddc5cac
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
LDAP
::
AuthHash
do
let
(
:auth_hash
)
do
Gitlab
::
LDAP
::
AuthHash
.
new
(
described_class
.
new
(
OmniAuth
::
AuthHash
.
new
(
uid:
'123456'
,
provider:
'ldapmain'
,
...
...
spec/lib/gitlab/ldap/config_spec.rb
View file @
cddc5cac
...
...
@@ -3,11 +3,11 @@ require 'spec_helper'
describe
Gitlab
::
LDAP
::
Config
do
include
LdapHelpers
let
(
:config
)
{
Gitlab
::
LDAP
::
Config
.
new
(
'ldapmain'
)
}
let
(
:config
)
{
described_class
.
new
(
'ldapmain'
)
}
describe
'#initialize'
do
it
'requires a provider'
do
expect
{
Gitlab
::
LDAP
::
Config
.
new
}.
to
raise_error
ArgumentError
expect
{
described_class
.
new
}.
to
raise_error
ArgumentError
end
it
'works'
do
...
...
@@ -15,7 +15,7 @@ describe Gitlab::LDAP::Config do
end
it
'raises an error if a unknown provider is used'
do
expect
{
Gitlab
::
LDAP
::
Config
.
new
'unknown'
}.
to
raise_error
(
RuntimeError
)
expect
{
described_class
.
new
'unknown'
}.
to
raise_error
(
RuntimeError
)
end
end
...
...
spec/lib/gitlab/ldap/user_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
LDAP
::
User
do
let
(
:ldap_user
)
{
Gitlab
::
LDAP
::
User
.
new
(
auth_hash
)
}
let
(
:ldap_user
)
{
described_class
.
new
(
auth_hash
)
}
let
(
:gl_user
)
{
ldap_user
.
gl_user
}
let
(
:info
)
do
{
...
...
@@ -13,7 +13,7 @@ describe Gitlab::LDAP::User do
let
(
:auth_hash
)
do
OmniAuth
::
AuthHash
.
new
(
uid:
'my-uid'
,
provider:
'ldapmain'
,
info:
info
)
end
let
(
:ldap_user_upper_case
)
{
Gitlab
::
LDAP
::
User
.
new
(
auth_hash_upper_case
)
}
let
(
:ldap_user_upper_case
)
{
described_class
.
new
(
auth_hash_upper_case
)
}
let
(
:info_upper_case
)
do
{
name:
'John'
,
...
...
spec/lib/gitlab/markup_helper_spec.rb
View file @
cddc5cac
...
...
@@ -5,36 +5,36 @@ describe Gitlab::MarkupHelper do
%w(textile rdoc org creole wiki
mediawiki rst adoc ad asciidoc mdown md markdown)
.
each
do
|
type
|
it
"returns true for
#{
type
}
files"
do
expect
(
Gitlab
::
MarkupHelper
.
markup?
(
"README.
#{
type
}
"
)).
to
be_truthy
expect
(
described_class
.
markup?
(
"README.
#{
type
}
"
)).
to
be_truthy
end
end
it
'returns false when given a non-markup filename'
do
expect
(
Gitlab
::
MarkupHelper
.
markup?
(
'README.rb'
)).
not_to
be_truthy
expect
(
described_class
.
markup?
(
'README.rb'
)).
not_to
be_truthy
end
end
describe
'#gitlab_markdown?'
do
%w(mdown mkd mkdn md markdown)
.
each
do
|
type
|
it
"returns true for
#{
type
}
files"
do
expect
(
Gitlab
::
MarkupHelper
.
gitlab_markdown?
(
"README.
#{
type
}
"
)).
to
be_truthy
expect
(
described_class
.
gitlab_markdown?
(
"README.
#{
type
}
"
)).
to
be_truthy
end
end
it
'returns false when given a non-markdown filename'
do
expect
(
Gitlab
::
MarkupHelper
.
gitlab_markdown?
(
'README.rb'
)).
not_to
be_truthy
expect
(
described_class
.
gitlab_markdown?
(
'README.rb'
)).
not_to
be_truthy
end
end
describe
'#asciidoc?'
do
%w(adoc ad asciidoc ADOC)
.
each
do
|
type
|
it
"returns true for
#{
type
}
files"
do
expect
(
Gitlab
::
MarkupHelper
.
asciidoc?
(
"README.
#{
type
}
"
)).
to
be_truthy
expect
(
described_class
.
asciidoc?
(
"README.
#{
type
}
"
)).
to
be_truthy
end
end
it
'returns false when given a non-asciidoc filename'
do
expect
(
Gitlab
::
MarkupHelper
.
asciidoc?
(
'README.rb'
)).
not_to
be_truthy
expect
(
described_class
.
asciidoc?
(
'README.rb'
)).
not_to
be_truthy
end
end
end
spec/lib/gitlab/o_auth/auth_hash_spec.rb
View file @
cddc5cac
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
OAuth
::
AuthHash
do
let
(
:auth_hash
)
do
Gitlab
::
OAuth
::
AuthHash
.
new
(
described_class
.
new
(
OmniAuth
::
AuthHash
.
new
(
provider:
provider_ascii
,
uid:
uid_ascii
,
...
...
spec/lib/gitlab/o_auth/user_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
OAuth
::
User
do
let
(
:oauth_user
)
{
Gitlab
::
OAuth
::
User
.
new
(
auth_hash
)
}
let
(
:oauth_user
)
{
described_class
.
new
(
auth_hash
)
}
let
(
:gl_user
)
{
oauth_user
.
gl_user
}
let
(
:uid
)
{
'my-uid'
}
let
(
:provider
)
{
'my-provider'
}
...
...
spec/lib/gitlab/project_transfer_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
ProjectTransfer
do
before
do
@root_dir
=
File
.
join
(
Rails
.
root
,
"public"
,
"uploads"
)
@project_transfer
=
Gitlab
::
ProjectTransfer
.
new
@project_transfer
=
described_class
.
new
allow
(
@project_transfer
).
to
receive
(
:root_dir
).
and_return
(
@root_dir
)
@project_path_was
=
"test_project_was"
...
...
spec/lib/gitlab/reference_extractor_spec.rb
View file @
cddc5cac
...
...
@@ -7,7 +7,7 @@ describe Gitlab::ReferenceExtractor do
project
.
team
<<
[
project
.
creator
,
:developer
]
end
subject
{
Gitlab
::
ReferenceExtractor
.
new
(
project
,
project
.
creator
)
}
subject
{
described_class
.
new
(
project
,
project
.
creator
)
}
it
'accesses valid user objects'
do
@u_foo
=
create
(
:user
,
username:
'foo'
)
...
...
spec/lib/gitlab/request_context_spec.rb
View file @
cddc5cac
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
RequestContext
do
describe
'#client_ip'
do
subject
{
Gitlab
::
RequestContext
.
client_ip
}
subject
{
described_class
.
client_ip
}
let
(
:app
)
{
->
(
env
)
{}
}
let
(
:env
)
{
Hash
.
new
}
...
...
@@ -16,7 +16,7 @@ describe Gitlab::RequestContext do
before
do
allow_any_instance_of
(
Rack
::
Request
).
to
receive
(
:ip
).
and_return
(
ip
)
Gitlab
::
RequestContext
.
new
(
app
).
call
(
env
)
described_class
.
new
(
app
).
call
(
env
)
end
it
{
is_expected
.
to
eq
(
ip
)
}
...
...
spec/lib/gitlab/shell_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'stringio'
describe
Gitlab
::
Shell
do
let
(
:project
)
{
double
(
'Project'
,
id:
7
,
path:
'diaspora'
)
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let
(
:gitlab_shell
)
{
described_class
.
new
}
let
(
:popen_vars
)
{
{
'GIT_TERMINAL_PROMPT'
=>
ENV
[
'GIT_TERMINAL_PROMPT'
]
}
}
before
do
...
...
@@ -30,7 +30,7 @@ describe Gitlab::Shell do
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:secret_file
).
and_return
(
secret_file
)
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:path
).
and_return
(
'tmp/tests/shell-secret-test'
)
FileUtils
.
mkdir
(
'tmp/tests/shell-secret-test'
)
Gitlab
::
Shell
.
ensure_secret_token!
described_class
.
ensure_secret_token!
end
after
do
...
...
@@ -39,7 +39,7 @@ describe Gitlab::Shell do
end
it
'creates and links the secret token file'
do
secret_token
=
Gitlab
::
Shell
.
secret_token
secret_token
=
described_class
.
secret_token
expect
(
File
.
exist?
(
secret_file
)).
to
be
(
true
)
expect
(
File
.
read
(
secret_file
).
chomp
).
to
eq
(
secret_token
)
...
...
spec/lib/gitlab/upgrader_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
Upgrader
do
let
(
:upgrader
)
{
Gitlab
::
Upgrader
.
new
}
let
(
:upgrader
)
{
described_class
.
new
}
let
(
:current_version
)
{
Gitlab
::
VERSION
}
describe
'current_version_raw'
do
...
...
spec/lib/gitlab/user_access_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Gitlab
::
UserAccess
do
let
(
:access
)
{
Gitlab
::
UserAcce
ss
.
new
(
user
,
project:
project
)
}
let
(
:access
)
{
described_cla
ss
.
new
(
user
,
project:
project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -28,7 +28,7 @@ describe Gitlab::UserAccess do
describe
'push to empty project'
do
let
(
:empty_project
)
{
create
(
:project_empty_repo
)
}
let
(
:project_access
)
{
Gitlab
::
UserAcce
ss
.
new
(
user
,
project:
empty_project
)
}
let
(
:project_access
)
{
described_cla
ss
.
new
(
user
,
project:
empty_project
)
}
it
'returns true if user is master'
do
empty_project
.
team
<<
[
user
,
:master
]
...
...
spec/lib/gitlab/workhorse_spec.rb
View file @
cddc5cac
...
...
@@ -63,13 +63,13 @@ describe Gitlab::Workhorse do
end
context
'without ca_pem'
do
subject
{
Gitlab
::
Workhorse
.
terminal_websocket
(
terminal
)
}
subject
{
described_class
.
terminal_websocket
(
terminal
)
}
it
{
is_expected
.
to
eq
(
workhorse
)
}
end
context
'with ca_pem'
do
subject
{
Gitlab
::
Workhorse
.
terminal_websocket
(
terminal
(
ca_pem:
"foo"
))
}
subject
{
described_class
.
terminal_websocket
(
terminal
(
ca_pem:
"foo"
))
}
it
{
is_expected
.
to
eq
(
workhorse
(
ca_pem:
"foo"
))
}
end
...
...
spec/lib/repository_cache_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
RepositoryCache
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:backend
)
{
double
(
'backend'
).
as_null_object
}
let
(
:cache
)
{
RepositoryCache
.
new
(
'example'
,
project
.
id
,
backend
)
}
let
(
:cache
)
{
described_class
.
new
(
'example'
,
project
.
id
,
backend
)
}
describe
'#cache_key'
do
it
'includes the namespace'
do
...
...
spec/lib/system_check_spec.rb
View file @
cddc5cac
...
...
@@ -19,7 +19,7 @@ describe SystemCheck do
end
describe
'.run'
do
subject
{
SystemCheck
}
subject
{
described_class
}
it
'detects execution of SimpleCheck'
do
is_expected
.
to
execute_check
(
SimpleCheck
)
...
...
spec/models/ability_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Ability
do
context
'using a nil subject'
do
it
'has no permissions'
do
expect
(
Ability
.
policy_for
(
nil
,
nil
)).
to
be_banned
expect
(
described_class
.
policy_for
(
nil
,
nil
)).
to
be_banned
end
end
...
...
spec/models/application_setting_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
ApplicationSetting
do
let
(
:setting
)
{
ApplicationSetting
.
create_from_defaults
}
let
(
:setting
)
{
described_class
.
create_from_defaults
}
it
{
expect
(
setting
).
to
be_valid
}
it
{
expect
(
setting
.
uuid
).
to
be_present
}
...
...
@@ -159,10 +159,10 @@ describe ApplicationSetting do
context
'redis unavailable'
do
it
'returns an ApplicationSetting'
do
allow
(
Rails
.
cache
).
to
receive
(
:fetch
).
and_call_original
allow
(
ApplicationSetting
).
to
receive
(
:last
).
and_return
(
:last
)
allow
(
described_class
).
to
receive
(
:last
).
and_return
(
:last
)
expect
(
Rails
.
cache
).
to
receive
(
:fetch
).
with
(
ApplicationSetting
::
CACHE_KEY
).
and_raise
(
ArgumentError
)
expect
(
ApplicationSetting
.
current
).
to
eq
(
:last
)
expect
(
described_class
.
current
).
to
eq
(
:last
)
end
end
end
...
...
spec/models/broadcast_message_spec.rb
View file @
cddc5cac
...
...
@@ -24,26 +24,26 @@ describe BroadcastMessage do
it
'returns message if time match'
do
message
=
create
(
:broadcast_message
)
expect
(
BroadcastMessage
.
current
).
to
include
(
message
)
expect
(
described_class
.
current
).
to
include
(
message
)
end
it
'returns multiple messages if time match'
do
message1
=
create
(
:broadcast_message
)
message2
=
create
(
:broadcast_message
)
expect
(
BroadcastMessage
.
current
).
to
contain_exactly
(
message1
,
message2
)
expect
(
described_class
.
current
).
to
contain_exactly
(
message1
,
message2
)
end
it
'returns empty list if time not come'
do
create
(
:broadcast_message
,
:future
)
expect
(
BroadcastMessage
.
current
).
to
be_empty
expect
(
described_class
.
current
).
to
be_empty
end
it
'returns empty list if time has passed'
do
create
(
:broadcast_message
,
:expired
)
expect
(
BroadcastMessage
.
current
).
to
be_empty
expect
(
described_class
.
current
).
to
be_empty
end
end
...
...
spec/models/ci/pipeline_schedule_spec.rb
View file @
cddc5cac
...
...
@@ -46,7 +46,7 @@ describe Ci::PipelineSchedule do
end
it
'updates next_run_at automatically'
do
expect
(
Ci
::
PipelineSchedule
.
last
.
next_run_at
).
to
eq
(
expected_next_run_at
)
expect
(
described_class
.
last
.
next_run_at
).
to
eq
(
expected_next_run_at
)
end
end
...
...
@@ -61,7 +61,7 @@ describe Ci::PipelineSchedule do
it
'updates next_run_at automatically'
do
pipeline_schedule
.
update!
(
cron:
new_cron
)
expect
(
Ci
::
PipelineSchedule
.
last
.
next_run_at
).
to
eq
(
expected_next_run_at
)
expect
(
described_class
.
last
.
next_run_at
).
to
eq
(
expected_next_run_at
)
end
end
end
...
...
spec/models/ci/runner_spec.rb
View file @
cddc5cac
...
...
@@ -50,7 +50,7 @@ describe Ci::Runner do
end
describe
'.online'
do
subject
{
Ci
::
Runner
.
online
}
subject
{
described_class
.
online
}
before
do
@runner1
=
FactoryGirl
.
create
(
:ci_runner
,
:shared
,
contacted_at:
1
.
year
.
ago
)
...
...
@@ -352,13 +352,13 @@ describe Ci::Runner do
end
context
'does not give owned runner'
do
subject
{
Ci
::
Runner
.
assignable_for
(
project
)
}
subject
{
described_class
.
assignable_for
(
project
)
}
it
{
is_expected
.
to
be_empty
}
end
context
'does not give shared runner'
do
subject
{
Ci
::
Runner
.
assignable_for
(
another_project
)
}
subject
{
described_class
.
assignable_for
(
another_project
)
}
it
{
is_expected
.
to
be_empty
}
end
...
...
@@ -366,13 +366,13 @@ describe Ci::Runner do
context
'with unlocked runner'
do
context
'does not give owned runner'
do
subject
{
Ci
::
Runner
.
assignable_for
(
project
)
}
subject
{
described_class
.
assignable_for
(
project
)
}
it
{
is_expected
.
to
be_empty
}
end
context
'does give a specific runner'
do
subject
{
Ci
::
Runner
.
assignable_for
(
another_project
)
}
subject
{
described_class
.
assignable_for
(
another_project
)
}
it
{
is_expected
.
to
contain_exactly
(
runner
)
}
end
...
...
@@ -384,13 +384,13 @@ describe Ci::Runner do
end
context
'does not give owned runner'
do
subject
{
Ci
::
Runner
.
assignable_for
(
project
)
}
subject
{
described_class
.
assignable_for
(
project
)
}
it
{
is_expected
.
to
be_empty
}
end
context
'does not give a locked runner'
do
subject
{
Ci
::
Runner
.
assignable_for
(
another_project
)
}
subject
{
described_class
.
assignable_for
(
another_project
)
}
it
{
is_expected
.
to
be_empty
}
end
...
...
spec/models/global_milestone_spec.rb
View file @
cddc5cac
...
...
@@ -72,7 +72,7 @@ describe GlobalMilestone do
project3
]
@global_milestones
=
GlobalMilestone
.
build_collection
(
projects
,
{})
@global_milestones
=
described_class
.
build_collection
(
projects
,
{})
end
it
'has all project milestones'
do
...
...
@@ -106,7 +106,7 @@ describe GlobalMilestone do
it
'returns the quantity of global milestones in each possible state'
do
expected_count
=
{
opened:
1
,
closed:
2
,
all:
2
}
count
=
GlobalMilestone
.
states_count
(
Project
.
all
)
count
=
described_class
.
states_count
(
Project
.
all
)
expect
(
count
).
to
eq
(
expected_count
)
end
...
...
@@ -120,7 +120,7 @@ describe GlobalMilestone do
it
'returns 0 as the quantity of global milestones in each state'
do
expected_count
=
{
opened:
0
,
closed:
0
,
all:
0
}
count
=
GlobalMilestone
.
states_count
(
Project
.
all
)
count
=
described_class
.
states_count
(
Project
.
all
)
expect
(
count
).
to
eq
(
expected_count
)
end
...
...
@@ -141,7 +141,7 @@ describe GlobalMilestone do
]
milestones_relation
=
Milestone
.
where
(
id:
milestones
.
map
(
&
:id
))
@global_milestone
=
GlobalMilestone
.
new
(
milestone1_project1
.
title
,
milestones_relation
)
@global_milestone
=
described_class
.
new
(
milestone1_project1
.
title
,
milestones_relation
)
end
it
'has exactly one group milestone'
do
...
...
@@ -157,7 +157,7 @@ describe GlobalMilestone do
let
(
:milestone
)
{
create
(
:milestone
,
title:
"git / test"
,
project:
project1
)
}
it
'strips out slashes and spaces'
do
global_milestone
=
GlobalMilestone
.
new
(
milestone
.
title
,
Milestone
.
where
(
id:
milestone
.
id
))
global_milestone
=
described_class
.
new
(
milestone
.
title
,
Milestone
.
where
(
id:
milestone
.
id
))
expect
(
global_milestone
.
safe_title
).
to
eq
(
'git-test'
)
end
...
...
@@ -171,7 +171,7 @@ describe GlobalMilestone do
create
(
:active_milestone
,
title:
title
),
create
(
:closed_milestone
,
title:
title
)
]
global_milestone
=
GlobalMilestone
.
new
(
title
,
milestones
)
global_milestone
=
described_class
.
new
(
title
,
milestones
)
expect
(
global_milestone
.
state
).
to
eq
(
'active'
)
end
...
...
@@ -184,7 +184,7 @@ describe GlobalMilestone do
create
(
:closed_milestone
,
title:
title
),
create
(
:closed_milestone
,
title:
title
)
]
global_milestone
=
GlobalMilestone
.
new
(
title
,
milestones
)
global_milestone
=
described_class
.
new
(
title
,
milestones
)
expect
(
global_milestone
.
state
).
to
eq
(
'closed'
)
end
...
...
spec/models/group_milestone_spec.rb
View file @
cddc5cac
...
...
@@ -9,7 +9,7 @@ describe GroupMilestone do
describe
'.build'
do
it
'returns milestone with group assigned'
do
milestone
=
GroupMilestone
.
build
(
milestone
=
described_class
.
build
(
group
,
[
project
],
project_milestone
.
title
...
...
@@ -25,7 +25,7 @@ describe GroupMilestone do
end
it
'returns array of milestones, each with group assigned'
do
milestones
=
GroupMilestone
.
build_collection
(
group
,
[
project
],
{})
milestones
=
described_class
.
build_collection
(
group
,
[
project
],
{})
expect
(
milestones
).
to
all
(
have_attributes
(
group:
group
))
end
end
...
...
spec/models/group_spec.rb
View file @
cddc5cac
...
...
@@ -357,7 +357,7 @@ describe Group do
subject
{
build
(
:group
,
:nested
)
}
it
{
is_expected
.
to
be_valid
}
it
{
expect
(
subject
.
parent
).
to
be_kind_of
(
Group
)
}
it
{
expect
(
subject
.
parent
).
to
be_kind_of
(
described_class
)
}
end
describe
'#members_with_parents'
,
:nested_groups
do
...
...
spec/models/guest_spec.rb
View file @
cddc5cac
...
...
@@ -8,13 +8,13 @@ describe Guest do
describe
'.can_pull?'
do
context
'when project is private'
do
it
'does not allow to pull the repo'
do
expect
(
Guest
.
can?
(
:download_code
,
private_project
)).
to
eq
(
false
)
expect
(
described_class
.
can?
(
:download_code
,
private_project
)).
to
eq
(
false
)
end
end
context
'when project is internal'
do
it
'does not allow to pull the repo'
do
expect
(
Guest
.
can?
(
:download_code
,
internal_project
)).
to
eq
(
false
)
expect
(
described_class
.
can?
(
:download_code
,
internal_project
)).
to
eq
(
false
)
end
end
...
...
@@ -23,7 +23,7 @@ describe Guest do
it
'does not allow to pull the repo'
do
public_project
.
project_feature
.
update_attribute
(
:repository_access_level
,
ProjectFeature
::
DISABLED
)
expect
(
Guest
.
can?
(
:download_code
,
public_project
)).
to
eq
(
false
)
expect
(
described_class
.
can?
(
:download_code
,
public_project
)).
to
eq
(
false
)
end
end
...
...
@@ -31,13 +31,13 @@ describe Guest do
it
'does not allow to pull the repo'
do
public_project
.
project_feature
.
update_attribute
(
:repository_access_level
,
ProjectFeature
::
PRIVATE
)
expect
(
Guest
.
can?
(
:download_code
,
public_project
)).
to
eq
(
false
)
expect
(
described_class
.
can?
(
:download_code
,
public_project
)).
to
eq
(
false
)
end
end
context
'when repository is enabled'
do
it
'allows to pull the repo'
do
expect
(
Guest
.
can?
(
:download_code
,
public_project
)).
to
eq
(
true
)
expect
(
described_class
.
can?
(
:download_code
,
public_project
)).
to
eq
(
true
)
end
end
end
...
...
spec/models/hooks/project_hook_spec.rb
View file @
cddc5cac
...
...
@@ -13,7 +13,7 @@ describe ProjectHook do
it
'returns hooks for push events only'
do
hook
=
create
(
:project_hook
,
push_events:
true
)
create
(
:project_hook
,
push_events:
false
)
expect
(
ProjectHook
.
push_hooks
).
to
eq
([
hook
])
expect
(
described_class
.
push_hooks
).
to
eq
([
hook
])
end
end
...
...
@@ -21,7 +21,7 @@ describe ProjectHook do
it
'returns hooks for tag push events only'
do
hook
=
create
(
:project_hook
,
tag_push_events:
true
)
create
(
:project_hook
,
tag_push_events:
false
)
expect
(
ProjectHook
.
tag_push_hooks
).
to
eq
([
hook
])
expect
(
described_class
.
tag_push_hooks
).
to
eq
([
hook
])
end
end
end
spec/models/hooks/system_hook_spec.rb
View file @
cddc5cac
...
...
@@ -122,7 +122,7 @@ describe SystemHook do
it
'returns hooks for repository update events only'
do
hook
=
create
(
:system_hook
,
repository_update_events:
true
)
create
(
:system_hook
,
repository_update_events:
false
)
expect
(
SystemHook
.
repository_update_hooks
).
to
eq
([
hook
])
expect
(
described_class
.
repository_update_hooks
).
to
eq
([
hook
])
end
end
...
...
spec/models/member_spec.rb
View file @
cddc5cac
...
...
@@ -6,7 +6,7 @@ describe Member do
end
describe
"Validation"
do
subject
{
Member
.
new
(
access_level:
Member
::
GUEST
)
}
subject
{
described_class
.
new
(
access_level:
Member
::
GUEST
)
}
it
{
is_expected
.
to
validate_presence_of
(
:user
)
}
it
{
is_expected
.
to
validate_presence_of
(
:source
)
}
...
...
spec/models/members/project_member_spec.rb
View file @
cddc5cac
...
...
@@ -139,7 +139,7 @@ describe ProjectMember do
@project_1
.
team
<<
[
@user_1
,
:developer
]
@project_2
.
team
<<
[
@user_2
,
:reporter
]
ProjectMember
.
truncate_teams
([
@project_1
.
id
,
@project_2
.
id
])
described_class
.
truncate_teams
([
@project_1
.
id
,
@project_2
.
id
])
end
it
{
expect
(
@project_1
.
users
).
to
be_empty
}
...
...
spec/models/merge_request_diff_spec.rb
View file @
cddc5cac
...
...
@@ -98,7 +98,7 @@ describe MergeRequestDiff do
end
it
'saves empty state'
do
allow_any_instance_of
(
MergeRequestDiff
).
to
receive_message_chain
(
:compare
,
:commits
)
allow_any_instance_of
(
described_class
).
to
receive_message_chain
(
:compare
,
:commits
)
.
and_return
([])
mr_diff
=
create
(
:merge_request
).
merge_request_diff
...
...
spec/models/milestone_spec.rb
View file @
cddc5cac
...
...
@@ -37,13 +37,13 @@ describe Milestone do
describe
"unique milestone title"
do
context
"per project"
do
it
"does not accept the same title in a project twice"
do
new_milestone
=
Milestone
.
new
(
project:
milestone
.
project
,
title:
milestone
.
title
)
new_milestone
=
described_class
.
new
(
project:
milestone
.
project
,
title:
milestone
.
title
)
expect
(
new_milestone
).
not_to
be_valid
end
it
"accepts the same title in another project"
do
project
=
create
(
:empty_project
)
new_milestone
=
Milestone
.
new
(
project:
project
,
title:
milestone
.
title
)
new_milestone
=
described_class
.
new
(
project:
project
,
title:
milestone
.
title
)
expect
(
new_milestone
).
to
be_valid
end
...
...
@@ -58,7 +58,7 @@ describe Milestone do
end
it
"does not accept the same title in a group twice"
do
new_milestone
=
Milestone
.
new
(
group:
group
,
title:
milestone
.
title
)
new_milestone
=
described_class
.
new
(
group:
group
,
title:
milestone
.
title
)
expect
(
new_milestone
).
not_to
be_valid
end
...
...
@@ -66,7 +66,7 @@ describe Milestone do
it
"does not accept the same title of a child project milestone"
do
create
(
:milestone
,
project:
group
.
projects
.
first
)
new_milestone
=
Milestone
.
new
(
group:
group
,
title:
milestone
.
title
)
new_milestone
=
described_class
.
new
(
group:
group
,
title:
milestone
.
title
)
expect
(
new_milestone
).
not_to
be_valid
end
...
...
@@ -214,7 +214,7 @@ describe Milestone do
# The call to `#try` is because this returns a relation with a Postgres DB,
# and an array of IDs with a MySQL DB.
let
(
:milestone_ids
)
{
Milestone
.
upcoming_ids_by_projects
(
projects
).
map
{
|
id
|
id
.
try
(
:id
)
||
id
}
}
let
(
:milestone_ids
)
{
described_class
.
upcoming_ids_by_projects
(
projects
).
map
{
|
id
|
id
.
try
(
:id
)
||
id
}
}
it
'returns the next upcoming open milestone ID for each project'
do
expect
(
milestone_ids
).
to
contain_exactly
(
current_milestone_project_1
.
id
,
current_milestone_project_2
.
id
)
...
...
spec/models/namespace_spec.rb
View file @
cddc5cac
...
...
@@ -133,7 +133,7 @@ describe Namespace do
it
"sums all project storage counters in the namespace"
do
project1
project2
statistics
=
Namespace
.
with_statistics
.
find
(
namespace
.
id
)
statistics
=
described_class
.
with_statistics
.
find
(
namespace
.
id
)
expect
(
statistics
.
storage_size
).
to
eq
666
expect
(
statistics
.
repository_size
).
to
eq
111
...
...
@@ -142,7 +142,7 @@ describe Namespace do
end
it
"correctly handles namespaces without projects"
do
statistics
=
Namespace
.
with_statistics
.
find
(
namespace
.
id
)
statistics
=
described_class
.
with_statistics
.
find
(
namespace
.
id
)
expect
(
statistics
.
storage_size
).
to
eq
0
expect
(
statistics
.
repository_size
).
to
eq
0
...
...
@@ -286,9 +286,9 @@ describe Namespace do
@namespace
=
create
(
:namespace
,
name:
'WoW'
,
path:
'woW'
)
end
it
{
expect
(
Namespace
.
find_by_path_or_name
(
'wow'
)).
to
eq
(
@namespace
)
}
it
{
expect
(
Namespace
.
find_by_path_or_name
(
'WOW'
)).
to
eq
(
@namespace
)
}
it
{
expect
(
Namespace
.
find_by_path_or_name
(
'unknown'
)).
to
eq
(
nil
)
}
it
{
expect
(
described_class
.
find_by_path_or_name
(
'wow'
)).
to
eq
(
@namespace
)
}
it
{
expect
(
described_class
.
find_by_path_or_name
(
'WOW'
)).
to
eq
(
@namespace
)
}
it
{
expect
(
described_class
.
find_by_path_or_name
(
'unknown'
)).
to
eq
(
nil
)
}
end
describe
".clean_path"
do
...
...
@@ -296,8 +296,8 @@ describe Namespace do
let!
(
:namespace
)
{
create
(
:namespace
,
path:
"JohnGitLab-etc1"
)
}
it
"cleans the path and makes sure it's available"
do
expect
(
Namespace
.
clean_path
(
"-john+gitlab-ETC%.git@gmail.com"
)).
to
eq
(
"johngitlab-ETC2"
)
expect
(
Namespace
.
clean_path
(
"--%+--valid_*&%name=.git.%.atom.atom.@email.com"
)).
to
eq
(
"valid_name"
)
expect
(
described_class
.
clean_path
(
"-john+gitlab-ETC%.git@gmail.com"
)).
to
eq
(
"johngitlab-ETC2"
)
expect
(
described_class
.
clean_path
(
"--%+--valid_*&%name=.git.%.atom.atom.@email.com"
)).
to
eq
(
"valid_name"
)
end
end
...
...
spec/models/note_spec.rb
View file @
cddc5cac
...
...
@@ -525,7 +525,7 @@ describe Note do
it
"has a discussion id"
do
# The discussion_id is set in `after_initialize`, so `reload` won't work
reloaded_note
=
Note
.
find
(
note
.
id
)
reloaded_note
=
described_class
.
find
(
note
.
id
)
expect
(
reloaded_note
.
discussion_id
).
not_to
be_nil
expect
(
reloaded_note
.
discussion_id
).
to
match
(
/\A\h{40}\z/
)
...
...
spec/models/project_services/asana_service_spec.rb
View file @
cddc5cac
...
...
@@ -35,7 +35,7 @@ describe AsanaService do
end
before
do
@asana
=
AsanaService
.
new
@asana
=
described_class
.
new
allow
(
@asana
).
to
receive_messages
(
project:
project
,
project_id:
project
.
id
,
...
...
spec/models/project_services/assembla_service_spec.rb
View file @
cddc5cac
...
...
@@ -11,7 +11,7 @@ describe AssemblaService do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
@assembla_service
=
AssemblaService
.
new
@assembla_service
=
described_class
.
new
allow
(
@assembla_service
).
to
receive_messages
(
project_id:
project
.
id
,
project:
project
,
...
...
spec/models/project_services/campfire_service_spec.rb
View file @
cddc5cac
...
...
@@ -29,7 +29,7 @@ describe CampfireService do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
@campfire_service
=
CampfireService
.
new
@campfire_service
=
described_class
.
new
allow
(
@campfire_service
).
to
receive_messages
(
project_id:
project
.
id
,
project:
project
,
...
...
spec/models/project_services/flowdock_service_spec.rb
View file @
cddc5cac
...
...
@@ -29,7 +29,7 @@ describe FlowdockService do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
@flowdock_service
=
FlowdockService
.
new
@flowdock_service
=
described_class
.
new
allow
(
@flowdock_service
).
to
receive_messages
(
project_id:
project
.
id
,
project:
project
,
...
...
spec/models/project_services/gemnasium_service_spec.rb
View file @
cddc5cac
...
...
@@ -31,7 +31,7 @@ describe GemnasiumService do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
@gemnasium_service
=
GemnasiumService
.
new
@gemnasium_service
=
described_class
.
new
allow
(
@gemnasium_service
).
to
receive_messages
(
project_id:
project
.
id
,
project:
project
,
...
...
spec/models/project_services/gitlab_issue_tracker_service_spec.rb
View file @
cddc5cac
...
...
@@ -27,7 +27,7 @@ describe GitlabIssueTrackerService do
context
'with absolute urls'
do
before
do
allow
(
GitlabIssueTrackerService
).
to
receive
(
:default_url_options
).
and_return
(
script_name:
"/gitlab/root"
)
allow
(
described_class
).
to
receive
(
:default_url_options
).
and_return
(
script_name:
"/gitlab/root"
)
end
it
'gives the correct path'
do
...
...
@@ -39,7 +39,7 @@ describe GitlabIssueTrackerService do
context
'with relative urls'
do
before
do
allow
(
GitlabIssueTrackerService
).
to
receive
(
:default_url_options
).
and_return
(
script_name:
"/gitlab/root"
)
allow
(
described_class
).
to
receive
(
:default_url_options
).
and_return
(
script_name:
"/gitlab/root"
)
end
it
'gives the correct path'
do
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
cddc5cac
...
...
@@ -25,7 +25,7 @@ describe HipchatService do
end
describe
"Execute"
do
let
(
:hipchat
)
{
HipchatService
.
new
}
let
(
:hipchat
)
{
described_class
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:api_url
)
{
'https://hipchat.example.com/v2/room/123456/notification?auth_token=verySecret'
}
...
...
spec/models/project_services/irker_service_spec.rb
View file @
cddc5cac
...
...
@@ -27,7 +27,7 @@ describe IrkerService do
end
describe
'Execute'
do
let
(
:irker
)
{
IrkerService
.
new
}
let
(
:irker
)
{
described_class
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:sample_data
)
do
...
...
spec/models/project_services/jira_service_spec.rb
View file @
cddc5cac
...
...
@@ -78,7 +78,7 @@ describe JiraService do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
before
do
@jira_service
=
JiraService
.
new
@jira_service
=
described_class
.
new
allow
(
@jira_service
).
to
receive_messages
(
project_id:
project
.
id
,
project:
project
,
...
...
@@ -167,7 +167,7 @@ describe JiraService do
stub_config_setting
(
relative_url_root:
'/gitlab'
)
stub_config_setting
(
url:
Settings
.
send
(
:build_gitlab_url
))
allow
(
JiraService
).
to
receive
(
:default_url_options
)
do
allow
(
described_class
).
to
receive
(
:default_url_options
)
do
{
script_name:
'/gitlab'
}
end
...
...
@@ -220,7 +220,7 @@ describe JiraService do
context
"when a password was previously set"
do
before
do
@jira_service
=
JiraService
.
create!
(
@jira_service
=
described_class
.
create!
(
project:
project
,
properties:
{
url:
'http://jira.example.com/web'
,
...
...
@@ -301,7 +301,7 @@ describe JiraService do
context
'when no password was previously set'
do
before
do
@jira_service
=
JiraService
.
create
(
@jira_service
=
described_class
.
create
(
project:
project
,
properties:
{
url:
'http://jira.example.com/rest/api/2'
,
...
...
spec/models/project_services/pivotaltracker_service_spec.rb
View file @
cddc5cac
...
...
@@ -26,7 +26,7 @@ describe PivotaltrackerService do
describe
'Execute'
do
let
(
:service
)
do
PivotaltrackerService
.
new
.
tap
do
|
service
|
described_class
.
new
.
tap
do
|
service
|
service
.
token
=
'secret_api_token'
end
end
...
...
spec/models/project_services/pushover_service_spec.rb
View file @
cddc5cac
...
...
@@ -29,7 +29,7 @@ describe PushoverService do
end
describe
'Execute'
do
let
(
:pushover
)
{
PushoverService
.
new
}
let
(
:pushover
)
{
described_class
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:sample_data
)
do
...
...
spec/models/project_spec.rb
View file @
cddc5cac
...
...
@@ -77,7 +77,7 @@ describe Project do
context
'after initialized'
do
it
"has a project_feature"
do
expect
(
Project
.
new
.
project_feature
).
to
be_present
expect
(
described_class
.
new
.
project_feature
).
to
be_present
end
end
...
...
@@ -438,7 +438,7 @@ describe Project do
end
it
'returns valid url to repo'
do
project
=
Project
.
new
(
path:
'somewhere'
)
project
=
described_class
.
new
(
path:
'somewhere'
)
expect
(
project
.
url_to_repo
).
to
eq
(
Gitlab
.
config
.
gitlab_shell
.
ssh_path_prefix
+
'somewhere.git'
)
end
...
...
@@ -917,7 +917,7 @@ describe Project do
end
describe
'.with_shared_runners'
do
subject
{
Project
.
with_shared_runners
}
subject
{
described_class
.
with_shared_runners
}
context
'when shared runners are enabled for project'
do
let!
(
:project
)
{
create
(
:empty_project
,
shared_runners_enabled:
true
)
}
...
...
@@ -942,10 +942,10 @@ describe Project do
let!
(
:project2
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
it
'returns total project count'
do
expect
(
Project
).
to
receive
(
:count
).
once
.
and_call_original
expect
(
described_class
).
to
receive
(
:count
).
once
.
and_call_original
3
.
times
do
expect
(
Project
.
cached_count
).
to
eq
(
2
)
expect
(
described_class
.
cached_count
).
to
eq
(
2
)
end
end
end
...
...
@@ -990,7 +990,7 @@ describe Project do
user1
.
toggle_star
(
project1
)
user2
.
toggle_star
(
project2
)
expect
(
Project
.
starred_by
(
user1
)).
to
contain_exactly
(
project1
)
expect
(
described_class
.
starred_by
(
user1
)).
to
contain_exactly
(
project1
)
end
end
...
...
@@ -2012,7 +2012,7 @@ describe Project do
let!
(
:path
)
{
project1
.
namespace
.
full_path
}
it
'returns correct project'
do
expect
(
Project
.
inside_path
(
path
)).
to
eq
([
project1
])
expect
(
described_class
.
inside_path
(
path
)).
to
eq
([
project1
])
end
end
...
...
@@ -2216,7 +2216,7 @@ describe Project do
context
'with a user'
do
let
(
:projects
)
do
Project
.
all
.
public_or_visible_to_user
(
user
)
described_class
.
all
.
public_or_visible_to_user
(
user
)
end
it
'includes projects the user has access to'
do
...
...
@@ -2230,7 +2230,7 @@ describe Project do
context
'without a user'
do
it
'only includes public projects'
do
projects
=
Project
.
all
.
public_or_visible_to_user
projects
=
described_class
.
all
.
public_or_visible_to_user
expect
(
projects
).
to
eq
([
public_project
])
end
...
...
spec/models/project_wiki_spec.rb
View file @
cddc5cac
...
...
@@ -5,7 +5,7 @@ describe ProjectWiki do
let
(
:repository
)
{
project
.
repository
}
let
(
:user
)
{
project
.
owner
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let
(
:project_wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
let
(
:project_wiki
)
{
described_class
.
new
(
project
,
user
)
}
subject
{
project_wiki
}
...
...
spec/models/protected_branch_spec.rb
View file @
cddc5cac
...
...
@@ -101,17 +101,17 @@ describe ProtectedBranch do
production
=
create
(
:protected_branch
,
name:
"production"
)
staging
=
create
(
:protected_branch
,
name:
"staging"
)
expect
(
ProtectedBranch
.
matching
(
"production"
)).
to
include
(
production
)
expect
(
ProtectedBranch
.
matching
(
"production"
)).
not_to
include
(
staging
)
expect
(
described_class
.
matching
(
"production"
)).
to
include
(
production
)
expect
(
described_class
.
matching
(
"production"
)).
not_to
include
(
staging
)
end
it
"accepts a list of protected branches to search from, so as to avoid a DB call"
do
production
=
build
(
:protected_branch
,
name:
"production"
)
staging
=
build
(
:protected_branch
,
name:
"staging"
)
expect
(
ProtectedBranch
.
matching
(
"production"
)).
to
be_empty
expect
(
ProtectedBranch
.
matching
(
"production"
,
protected_refs:
[
production
,
staging
])).
to
include
(
production
)
expect
(
ProtectedBranch
.
matching
(
"production"
,
protected_refs:
[
production
,
staging
])).
not_to
include
(
staging
)
expect
(
described_class
.
matching
(
"production"
)).
to
be_empty
expect
(
described_class
.
matching
(
"production"
,
protected_refs:
[
production
,
staging
])).
to
include
(
production
)
expect
(
described_class
.
matching
(
"production"
,
protected_refs:
[
production
,
staging
])).
not_to
include
(
staging
)
end
end
...
...
@@ -120,17 +120,17 @@ describe ProtectedBranch do
production
=
create
(
:protected_branch
,
name:
"production/*"
)
staging
=
create
(
:protected_branch
,
name:
"staging/*"
)
expect
(
ProtectedBranch
.
matching
(
"production/some-branch"
)).
to
include
(
production
)
expect
(
ProtectedBranch
.
matching
(
"production/some-branch"
)).
not_to
include
(
staging
)
expect
(
described_class
.
matching
(
"production/some-branch"
)).
to
include
(
production
)
expect
(
described_class
.
matching
(
"production/some-branch"
)).
not_to
include
(
staging
)
end
it
"accepts a list of protected branches to search from, so as to avoid a DB call"
do
production
=
build
(
:protected_branch
,
name:
"production/*"
)
staging
=
build
(
:protected_branch
,
name:
"staging/*"
)
expect
(
ProtectedBranch
.
matching
(
"production/some-branch"
)).
to
be_empty
expect
(
ProtectedBranch
.
matching
(
"production/some-branch"
,
protected_refs:
[
production
,
staging
])).
to
include
(
production
)
expect
(
ProtectedBranch
.
matching
(
"production/some-branch"
,
protected_refs:
[
production
,
staging
])).
not_to
include
(
staging
)
expect
(
described_class
.
matching
(
"production/some-branch"
)).
to
be_empty
expect
(
described_class
.
matching
(
"production/some-branch"
,
protected_refs:
[
production
,
staging
])).
to
include
(
production
)
expect
(
described_class
.
matching
(
"production/some-branch"
,
protected_refs:
[
production
,
staging
])).
not_to
include
(
staging
)
end
end
end
...
...
@@ -142,23 +142,23 @@ describe ProtectedBranch do
it
'returns true when the branch matches a protected branch via direct match'
do
create
(
:protected_branch
,
project:
project
,
name:
"foo"
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'foo'
)).
to
eq
(
true
)
expect
(
described_class
.
protected?
(
project
,
'foo'
)).
to
eq
(
true
)
end
it
'returns true when the branch matches a protected branch via wildcard match'
do
create
(
:protected_branch
,
project:
project
,
name:
"production/*"
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'production/some-branch'
)).
to
eq
(
true
)
expect
(
described_class
.
protected?
(
project
,
'production/some-branch'
)).
to
eq
(
true
)
end
it
'returns false when the branch does not match a protected branch via direct match'
do
expect
(
ProtectedBranch
.
protected?
(
project
,
'foo'
)).
to
eq
(
false
)
expect
(
described_class
.
protected?
(
project
,
'foo'
)).
to
eq
(
false
)
end
it
'returns false when the branch does not match a protected branch via wildcard match'
do
create
(
:protected_branch
,
project:
project
,
name:
"production/*"
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'staging/some-branch'
)).
to
eq
(
false
)
expect
(
described_class
.
protected?
(
project
,
'staging/some-branch'
)).
to
eq
(
false
)
end
end
...
...
@@ -168,25 +168,25 @@ describe ProtectedBranch do
it
'returns false when default_protected_branch is unprotected'
do
stub_application_setting
(
default_branch_protection:
Gitlab
::
Access
::
PROTECTION_NONE
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'master'
)).
to
be
false
expect
(
described_class
.
protected?
(
project
,
'master'
)).
to
be
false
end
it
'returns false when default_protected_branch lets developers push'
do
stub_application_setting
(
default_branch_protection:
Gitlab
::
Access
::
PROTECTION_DEV_CAN_PUSH
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'master'
)).
to
be
false
expect
(
described_class
.
protected?
(
project
,
'master'
)).
to
be
false
end
it
'returns true when default_branch_protection does not let developers push but let developer merge branches'
do
stub_application_setting
(
default_branch_protection:
Gitlab
::
Access
::
PROTECTION_DEV_CAN_MERGE
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'master'
)).
to
be
true
expect
(
described_class
.
protected?
(
project
,
'master'
)).
to
be
true
end
it
'returns true when default_branch_protection is in full protection'
do
stub_application_setting
(
default_branch_protection:
Gitlab
::
Access
::
PROTECTION_FULL
)
expect
(
ProtectedBranch
.
protected?
(
project
,
'master'
)).
to
be
true
expect
(
described_class
.
protected?
(
project
,
'master'
)).
to
be
true
end
end
end
...
...
spec/models/redirect_route_spec.rb
View file @
cddc5cac
...
...
@@ -21,7 +21,7 @@ describe RedirectRoute do
let!
(
:redirect5
)
{
group
.
redirect_routes
.
create
(
path:
'gitlabb/test/baz'
)
}
it
'returns correct routes'
do
expect
(
RedirectRoute
.
matching_path_and_descendants
(
'gitlabb/test'
)).
to
match_array
([
redirect2
,
redirect3
,
redirect4
,
redirect5
])
expect
(
described_class
.
matching_path_and_descendants
(
'gitlabb/test'
)).
to
match_array
([
redirect2
,
redirect3
,
redirect4
,
redirect5
])
end
end
end
spec/models/route_spec.rb
View file @
cddc5cac
...
...
@@ -34,7 +34,7 @@ describe Route do
context
'after create'
do
it
'calls #delete_conflicting_redirects'
do
route
.
destroy
new_route
=
Route
.
new
(
source:
group
,
path:
group
.
path
)
new_route
=
described_class
.
new
(
source:
group
,
path:
group
.
path
)
expect
(
new_route
).
to
receive
(
:delete_conflicting_redirects
)
new_route
.
save!
end
...
...
@@ -49,7 +49,7 @@ describe Route do
let!
(
:another_group_nested
)
{
create
(
:group
,
path:
'another'
,
name:
'another'
,
parent:
similar_group
)
}
it
'returns correct routes'
do
expect
(
Route
.
inside_path
(
'git_lab'
)).
to
match_array
([
nested_group
.
route
,
deep_nested_group
.
route
])
expect
(
described_class
.
inside_path
(
'git_lab'
)).
to
match_array
([
nested_group
.
route
,
deep_nested_group
.
route
])
end
end
...
...
spec/models/sent_notification_spec.rb
View file @
cddc5cac
...
...
@@ -38,7 +38,7 @@ describe SentNotification do
let
(
:issue
)
{
create
(
:issue
)
}
it
'creates a new SentNotification'
do
expect
{
described_class
.
record
(
issue
,
user
.
id
)
}.
to
change
{
SentNotification
.
count
}.
by
(
1
)
expect
{
described_class
.
record
(
issue
,
user
.
id
)
}.
to
change
{
described_class
.
count
}.
by
(
1
)
end
end
...
...
@@ -47,7 +47,7 @@ describe SentNotification do
let
(
:note
)
{
create
(
:diff_note_on_merge_request
)
}
it
'creates a new SentNotification'
do
expect
{
described_class
.
record_note
(
note
,
user
.
id
)
}.
to
change
{
SentNotification
.
count
}.
by
(
1
)
expect
{
described_class
.
record_note
(
note
,
user
.
id
)
}.
to
change
{
described_class
.
count
}.
by
(
1
)
end
end
...
...
spec/models/user_spec.rb
View file @
cddc5cac
...
...
@@ -261,7 +261,7 @@ describe User do
it
"returns users with 2fa enabled via OTP"
do
user_with_2fa
=
create
(
:user
,
:two_factor_via_otp
)
user_without_2fa
=
create
(
:user
)
users_with_two_factor
=
User
.
with_two_factor
.
pluck
(
:id
)
users_with_two_factor
=
described_class
.
with_two_factor
.
pluck
(
:id
)
expect
(
users_with_two_factor
).
to
include
(
user_with_2fa
.
id
)
expect
(
users_with_two_factor
).
not_to
include
(
user_without_2fa
.
id
)
...
...
@@ -270,7 +270,7 @@ describe User do
it
"returns users with 2fa enabled via U2F"
do
user_with_2fa
=
create
(
:user
,
:two_factor_via_u2f
)
user_without_2fa
=
create
(
:user
)
users_with_two_factor
=
User
.
with_two_factor
.
pluck
(
:id
)
users_with_two_factor
=
described_class
.
with_two_factor
.
pluck
(
:id
)
expect
(
users_with_two_factor
).
to
include
(
user_with_2fa
.
id
)
expect
(
users_with_two_factor
).
not_to
include
(
user_without_2fa
.
id
)
...
...
@@ -279,7 +279,7 @@ describe User do
it
"returns users with 2fa enabled via OTP and U2F"
do
user_with_2fa
=
create
(
:user
,
:two_factor_via_otp
,
:two_factor_via_u2f
)
user_without_2fa
=
create
(
:user
)
users_with_two_factor
=
User
.
with_two_factor
.
pluck
(
:id
)
users_with_two_factor
=
described_class
.
with_two_factor
.
pluck
(
:id
)
expect
(
users_with_two_factor
).
to
eq
([
user_with_2fa
.
id
])
expect
(
users_with_two_factor
).
not_to
include
(
user_without_2fa
.
id
)
...
...
@@ -290,7 +290,7 @@ describe User do
it
"excludes users with 2fa enabled via OTP"
do
user_with_2fa
=
create
(
:user
,
:two_factor_via_otp
)
user_without_2fa
=
create
(
:user
)
users_without_two_factor
=
User
.
without_two_factor
.
pluck
(
:id
)
users_without_two_factor
=
described_class
.
without_two_factor
.
pluck
(
:id
)
expect
(
users_without_two_factor
).
to
include
(
user_without_2fa
.
id
)
expect
(
users_without_two_factor
).
not_to
include
(
user_with_2fa
.
id
)
...
...
@@ -299,7 +299,7 @@ describe User do
it
"excludes users with 2fa enabled via U2F"
do
user_with_2fa
=
create
(
:user
,
:two_factor_via_u2f
)
user_without_2fa
=
create
(
:user
)
users_without_two_factor
=
User
.
without_two_factor
.
pluck
(
:id
)
users_without_two_factor
=
described_class
.
without_two_factor
.
pluck
(
:id
)
expect
(
users_without_two_factor
).
to
include
(
user_without_2fa
.
id
)
expect
(
users_without_two_factor
).
not_to
include
(
user_with_2fa
.
id
)
...
...
@@ -308,7 +308,7 @@ describe User do
it
"excludes users with 2fa enabled via OTP and U2F"
do
user_with_2fa
=
create
(
:user
,
:two_factor_via_otp
,
:two_factor_via_u2f
)
user_without_2fa
=
create
(
:user
)
users_without_two_factor
=
User
.
without_two_factor
.
pluck
(
:id
)
users_without_two_factor
=
described_class
.
without_two_factor
.
pluck
(
:id
)
expect
(
users_without_two_factor
).
to
include
(
user_without_2fa
.
id
)
expect
(
users_without_two_factor
).
not_to
include
(
user_with_2fa
.
id
)
...
...
@@ -324,8 +324,8 @@ describe User do
create
(
:todo
,
user:
current_user
,
author:
user_2
,
state: :done
)
create
(
:todo
,
user:
current_user
,
author:
user_3
,
state: :pending
)
expect
(
User
.
todo_authors
(
current_user
.
id
,
'pending'
)).
to
eq
[
user_3
]
expect
(
User
.
todo_authors
(
current_user
.
id
,
'done'
)).
to
eq
[
user_2
]
expect
(
described_class
.
todo_authors
(
current_user
.
id
,
'pending'
)).
to
eq
[
user_3
]
expect
(
described_class
.
todo_authors
(
current_user
.
id
,
'done'
)).
to
eq
[
user_2
]
end
end
end
...
...
@@ -609,39 +609,39 @@ describe User do
let
(
:user
)
{
double
}
it
'filters by active users by default'
do
expect
(
User
).
to
receive
(
:active
).
and_return
([
user
])
expect
(
described_class
).
to
receive
(
:active
).
and_return
([
user
])
expect
(
User
.
filter
(
nil
)).
to
include
user
expect
(
described_class
.
filter
(
nil
)).
to
include
user
end
it
'filters by admins'
do
expect
(
User
).
to
receive
(
:admins
).
and_return
([
user
])
expect
(
described_class
).
to
receive
(
:admins
).
and_return
([
user
])
expect
(
User
.
filter
(
'admins'
)).
to
include
user
expect
(
described_class
.
filter
(
'admins'
)).
to
include
user
end
it
'filters by blocked'
do
expect
(
User
).
to
receive
(
:blocked
).
and_return
([
user
])
expect
(
described_class
).
to
receive
(
:blocked
).
and_return
([
user
])
expect
(
User
.
filter
(
'blocked'
)).
to
include
user
expect
(
described_class
.
filter
(
'blocked'
)).
to
include
user
end
it
'filters by two_factor_disabled'
do
expect
(
User
).
to
receive
(
:without_two_factor
).
and_return
([
user
])
expect
(
described_class
).
to
receive
(
:without_two_factor
).
and_return
([
user
])
expect
(
User
.
filter
(
'two_factor_disabled'
)).
to
include
user
expect
(
described_class
.
filter
(
'two_factor_disabled'
)).
to
include
user
end
it
'filters by two_factor_enabled'
do
expect
(
User
).
to
receive
(
:with_two_factor
).
and_return
([
user
])
expect
(
described_class
).
to
receive
(
:with_two_factor
).
and_return
([
user
])
expect
(
User
.
filter
(
'two_factor_enabled'
)).
to
include
user
expect
(
described_class
.
filter
(
'two_factor_enabled'
)).
to
include
user
end
it
'filters by wop'
do
expect
(
User
).
to
receive
(
:without_projects
).
and_return
([
user
])
expect
(
described_class
).
to
receive
(
:without_projects
).
and_return
([
user
])
expect
(
User
.
filter
(
'wop'
)).
to
include
user
expect
(
described_class
.
filter
(
'wop'
)).
to
include
user
end
end
...
...
@@ -662,9 +662,9 @@ describe User do
project
.
request_access
(
user_without_project2
)
end
it
{
expect
(
User
.
without_projects
).
not_to
include
user
}
it
{
expect
(
User
.
without_projects
).
to
include
user_without_project
}
it
{
expect
(
User
.
without_projects
).
to
include
user_without_project2
}
it
{
expect
(
described_class
.
without_projects
).
not_to
include
user
}
it
{
expect
(
described_class
.
without_projects
).
to
include
user_without_project
}
it
{
expect
(
described_class
.
without_projects
).
to
include
user_without_project2
}
end
describe
'user creation'
do
...
...
@@ -680,7 +680,7 @@ describe User do
end
describe
'with defaults'
do
let
(
:user
)
{
User
.
new
}
let
(
:user
)
{
described_class
.
new
}
it
"applies defaults to user"
do
expect
(
user
.
projects_limit
).
to
eq
(
Gitlab
.
config
.
gitlab
.
default_projects_limit
)
...
...
@@ -690,7 +690,7 @@ describe User do
end
describe
'with default overrides'
do
let
(
:user
)
{
User
.
new
(
projects_limit:
123
,
can_create_group:
false
,
can_create_team:
true
)
}
let
(
:user
)
{
described_class
.
new
(
projects_limit:
123
,
can_create_group:
false
,
can_create_team:
true
)
}
it
"applies defaults to user"
do
expect
(
user
.
projects_limit
).
to
eq
(
123
)
...
...
@@ -740,18 +740,18 @@ describe User do
it
'finds by primary email'
do
user
=
create
(
:user
,
email:
'foo@example.com'
)
expect
(
User
.
find_by_any_email
(
user
.
email
)).
to
eq
user
expect
(
described_class
.
find_by_any_email
(
user
.
email
)).
to
eq
user
end
it
'finds by secondary email'
do
email
=
create
(
:email
,
email:
'foo@example.com'
)
user
=
email
.
user
expect
(
User
.
find_by_any_email
(
email
.
email
)).
to
eq
user
expect
(
described_class
.
find_by_any_email
(
email
.
email
)).
to
eq
user
end
it
'returns nil when nothing found'
do
expect
(
User
.
find_by_any_email
(
''
)).
to
be_nil
expect
(
described_class
.
find_by_any_email
(
''
)).
to
be_nil
end
end
...
...
@@ -899,12 +899,12 @@ describe User do
let!
(
:user
)
{
create
(
:user
,
username:
username
)
}
it
'gets the correct user'
do
expect
(
User
.
by_login
(
user
.
email
.
upcase
)).
to
eq
user
expect
(
User
.
by_login
(
user
.
email
)).
to
eq
user
expect
(
User
.
by_login
(
username
.
downcase
)).
to
eq
user
expect
(
User
.
by_login
(
username
)).
to
eq
user
expect
(
User
.
by_login
(
nil
)).
to
be_nil
expect
(
User
.
by_login
(
''
)).
to
be_nil
expect
(
described_class
.
by_login
(
user
.
email
.
upcase
)).
to
eq
user
expect
(
described_class
.
by_login
(
user
.
email
)).
to
eq
user
expect
(
described_class
.
by_login
(
username
.
downcase
)).
to
eq
user
expect
(
described_class
.
by_login
(
username
)).
to
eq
user
expect
(
described_class
.
by_login
(
nil
)).
to
be_nil
expect
(
described_class
.
by_login
(
''
)).
to
be_nil
end
end
...
...
@@ -938,12 +938,12 @@ describe User do
let!
(
:route
)
{
user
.
namespace
.
route
}
it
'returns the user'
do
expect
(
User
.
find_by_full_path
(
route
.
path
)).
to
eq
(
user
)
expect
(
described_class
.
find_by_full_path
(
route
.
path
)).
to
eq
(
user
)
end
it
'is case-insensitive'
do
expect
(
User
.
find_by_full_path
(
route
.
path
.
upcase
)).
to
eq
(
user
)
expect
(
User
.
find_by_full_path
(
route
.
path
.
downcase
)).
to
eq
(
user
)
expect
(
described_class
.
find_by_full_path
(
route
.
path
.
upcase
)).
to
eq
(
user
)
expect
(
described_class
.
find_by_full_path
(
route
.
path
.
downcase
)).
to
eq
(
user
)
end
end
...
...
@@ -952,18 +952,18 @@ describe User do
context
'without the follow_redirects option'
do
it
'returns nil'
do
expect
(
User
.
find_by_full_path
(
redirect_route
.
path
)).
to
eq
(
nil
)
expect
(
described_class
.
find_by_full_path
(
redirect_route
.
path
)).
to
eq
(
nil
)
end
end
context
'with the follow_redirects option set to true'
do
it
'returns the user'
do
expect
(
User
.
find_by_full_path
(
redirect_route
.
path
,
follow_redirects:
true
)).
to
eq
(
user
)
expect
(
described_class
.
find_by_full_path
(
redirect_route
.
path
,
follow_redirects:
true
)).
to
eq
(
user
)
end
it
'is case-insensitive'
do
expect
(
User
.
find_by_full_path
(
redirect_route
.
path
.
upcase
,
follow_redirects:
true
)).
to
eq
(
user
)
expect
(
User
.
find_by_full_path
(
redirect_route
.
path
.
downcase
,
follow_redirects:
true
)).
to
eq
(
user
)
expect
(
described_class
.
find_by_full_path
(
redirect_route
.
path
.
upcase
,
follow_redirects:
true
)).
to
eq
(
user
)
expect
(
described_class
.
find_by_full_path
(
redirect_route
.
path
.
downcase
,
follow_redirects:
true
)).
to
eq
(
user
)
end
end
end
...
...
@@ -971,12 +971,12 @@ describe User do
context
'without a route or a redirect route matching the given path'
do
context
'without the follow_redirects option'
do
it
'returns nil'
do
expect
(
User
.
find_by_full_path
(
'unknown'
)).
to
eq
(
nil
)
expect
(
described_class
.
find_by_full_path
(
'unknown'
)).
to
eq
(
nil
)
end
end
context
'with the follow_redirects option set to true'
do
it
'returns nil'
do
expect
(
User
.
find_by_full_path
(
'unknown'
,
follow_redirects:
true
)).
to
eq
(
nil
)
expect
(
described_class
.
find_by_full_path
(
'unknown'
,
follow_redirects:
true
)).
to
eq
(
nil
)
end
end
end
...
...
@@ -986,7 +986,7 @@ describe User do
let!
(
:group
)
{
create
(
:group
,
path:
'group_path'
,
owner:
user
)
}
it
'returns nil'
do
expect
(
User
.
find_by_full_path
(
'group_path'
)).
to
eq
(
nil
)
expect
(
described_class
.
find_by_full_path
(
'group_path'
)).
to
eq
(
nil
)
end
end
...
...
@@ -994,7 +994,7 @@ describe User do
let!
(
:group
)
{
create
(
:group
,
path:
'group_path'
)
}
it
'returns nil'
do
expect
(
User
.
find_by_full_path
(
'group_path'
)).
to
eq
(
nil
)
expect
(
described_class
.
find_by_full_path
(
'group_path'
)).
to
eq
(
nil
)
end
end
end
...
...
@@ -1044,7 +1044,7 @@ describe User do
end
describe
'#requires_ldap_check?'
do
let
(
:user
)
{
User
.
new
}
let
(
:user
)
{
described_class
.
new
}
it
'is false when LDAP is disabled'
do
# Create a condition which would otherwise cause 'true' to be returned
...
...
@@ -1215,7 +1215,7 @@ describe User do
describe
'#sort'
do
before
do
User
.
delete_all
described_class
.
delete_all
@user
=
create
:user
,
created_at:
Date
.
today
,
last_sign_in_at:
Date
.
today
,
name:
'Alpha'
@user1
=
create
:user
,
created_at:
Date
.
today
-
1
,
last_sign_in_at:
Date
.
today
-
1
,
name:
'Omega'
@user2
=
create
:user
,
created_at:
Date
.
today
-
2
,
last_sign_in_at:
nil
,
name:
'Beta'
...
...
@@ -1223,34 +1223,34 @@ describe User do
context
'when sort by recent_sign_in'
do
it
'sorts users by the recent sign-in time'
do
expect
(
User
.
sort
(
'recent_sign_in'
).
first
).
to
eq
(
@user
)
expect
(
described_class
.
sort
(
'recent_sign_in'
).
first
).
to
eq
(
@user
)
end
it
'pushes users who never signed in to the end'
do
expect
(
User
.
sort
(
'recent_sign_in'
).
third
).
to
eq
(
@user2
)
expect
(
described_class
.
sort
(
'recent_sign_in'
).
third
).
to
eq
(
@user2
)
end
end
context
'when sort by oldest_sign_in'
do
it
'sorts users by the oldest sign-in time'
do
expect
(
User
.
sort
(
'oldest_sign_in'
).
first
).
to
eq
(
@user1
)
expect
(
described_class
.
sort
(
'oldest_sign_in'
).
first
).
to
eq
(
@user1
)
end
it
'pushes users who never signed in to the end'
do
expect
(
User
.
sort
(
'oldest_sign_in'
).
third
).
to
eq
(
@user2
)
expect
(
described_class
.
sort
(
'oldest_sign_in'
).
third
).
to
eq
(
@user2
)
end
end
it
'sorts users in descending order by their creation time'
do
expect
(
User
.
sort
(
'created_desc'
).
first
).
to
eq
(
@user
)
expect
(
described_class
.
sort
(
'created_desc'
).
first
).
to
eq
(
@user
)
end
it
'sorts users in ascending order by their creation time'
do
expect
(
User
.
sort
(
'created_asc'
).
first
).
to
eq
(
@user2
)
expect
(
described_class
.
sort
(
'created_asc'
).
first
).
to
eq
(
@user2
)
end
it
'sorts users by id in descending order when nil is passed'
do
expect
(
User
.
sort
(
nil
).
first
).
to
eq
(
@user2
)
expect
(
described_class
.
sort
(
nil
).
first
).
to
eq
(
@user2
)
end
end
...
...
@@ -1770,7 +1770,7 @@ describe User do
describe
'.ghost'
do
it
"creates a ghost user if one isn't already present"
do
ghost
=
User
.
ghost
ghost
=
described_class
.
ghost
expect
(
ghost
).
to
be_ghost
expect
(
ghost
).
to
be_persisted
...
...
@@ -1778,16 +1778,16 @@ describe User do
it
"does not create a second ghost user if one is already present"
do
expect
do
User
.
ghost
User
.
ghost
end
.
to
change
{
User
.
count
}.
by
(
1
)
expect
(
User
.
ghost
).
to
eq
(
User
.
ghost
)
described_class
.
ghost
described_class
.
ghost
end
.
to
change
{
described_class
.
count
}.
by
(
1
)
expect
(
described_class
.
ghost
).
to
eq
(
described_class
.
ghost
)
end
context
"when a regular user exists with the username 'ghost'"
do
it
"creates a ghost user with a non-conflicting username"
do
create
(
:user
,
username:
'ghost'
)
ghost
=
User
.
ghost
ghost
=
described_class
.
ghost
expect
(
ghost
).
to
be_persisted
expect
(
ghost
.
username
).
to
eq
(
'ghost1'
)
...
...
@@ -1797,7 +1797,7 @@ describe User do
context
"when a regular user exists with the email 'ghost@example.com'"
do
it
"creates a ghost user with a non-conflicting email"
do
create
(
:user
,
email:
'ghost@example.com'
)
ghost
=
User
.
ghost
ghost
=
described_class
.
ghost
expect
(
ghost
).
to
be_persisted
expect
(
ghost
.
email
).
to
eq
(
'ghost1@example.com'
)
...
...
@@ -1810,7 +1810,7 @@ describe User do
end
it
'creates a ghost user'
do
expect
(
User
.
ghost
).
to
be_persisted
expect
(
described_class
.
ghost
).
to
be_persisted
end
end
end
...
...
@@ -1889,13 +1889,13 @@ describe User do
context
'.active'
do
before
do
User
.
ghost
described_class
.
ghost
create
(
:user
,
name:
'user'
,
state:
'active'
)
create
(
:user
,
name:
'user'
,
state:
'blocked'
)
end
it
'only counts active and non internal users'
do
expect
(
User
.
active
.
count
).
to
eq
(
1
)
expect
(
described_class
.
active
.
count
).
to
eq
(
1
)
end
end
...
...
spec/models/wiki_directory_spec.rb
View file @
cddc5cac
...
...
@@ -10,7 +10,7 @@ RSpec.describe WikiDirectory do
describe
'#initialize'
do
context
'when there are pages'
do
let
(
:pages
)
{
[
build
(
:wiki_page
)]
}
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
,
pages
)
}
let
(
:directory
)
{
described_class
.
new
(
'/path_up_to/dir'
,
pages
)
}
it
'sets the slug attribute'
do
expect
(
directory
.
slug
).
to
eq
(
'/path_up_to/dir'
)
...
...
@@ -22,7 +22,7 @@ RSpec.describe WikiDirectory do
end
context
'when there are no pages'
do
let
(
:directory
)
{
WikiDirectory
.
new
(
'/path_up_to/dir'
)
}
let
(
:directory
)
{
described_class
.
new
(
'/path_up_to/dir'
)
}
it
'sets the slug attribute'
do
expect
(
directory
.
slug
).
to
eq
(
'/path_up_to/dir'
)
...
...
spec/models/wiki_page_spec.rb
View file @
cddc5cac
...
...
@@ -5,13 +5,13 @@ describe WikiPage do
let
(
:user
)
{
project
.
owner
}
let
(
:wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
subject
{
WikiPage
.
new
(
wiki
)
}
subject
{
described_class
.
new
(
wiki
)
}
describe
'.group_by_directory'
do
context
'when there are no pages'
do
it
'returns an empty array'
do
expect
(
WikiPage
.
group_by_directory
(
nil
)).
to
eq
([])
expect
(
WikiPage
.
group_by_directory
([])).
to
eq
([])
expect
(
described_class
.
group_by_directory
(
nil
)).
to
eq
([])
expect
(
described_class
.
group_by_directory
([])).
to
eq
([])
end
end
...
...
@@ -39,7 +39,7 @@ describe WikiPage do
it
'returns an array with pages and directories'
do
expected_grouped_entries
=
[
page_1
,
dir_1
,
dir_1_1
,
dir_2
]
grouped_entries
=
WikiPage
.
group_by_directory
(
wiki
.
pages
)
grouped_entries
=
described_class
.
group_by_directory
(
wiki
.
pages
)
grouped_entries
.
each_with_index
do
|
page_or_dir
,
i
|
expected_page_or_dir
=
expected_grouped_entries
[
i
]
...
...
@@ -56,7 +56,7 @@ describe WikiPage do
expected_order
=
[
'page_1'
,
'dir_1/page_2'
,
'dir_1/dir_1_1/page_3'
,
'dir_2/page_4'
,
'dir_2/page_5'
]
grouped_entries
=
WikiPage
.
group_by_directory
(
wiki
.
pages
)
grouped_entries
=
described_class
.
group_by_directory
(
wiki
.
pages
)
actual_order
=
grouped_entries
.
map
do
|
page_or_dir
|
...
...
@@ -72,7 +72,7 @@ describe WikiPage do
it
'removes hyphens from a name'
do
name
=
'a-name--with-hyphens'
expect
(
WikiPage
.
unhyphenize
(
name
)).
to
eq
(
'a name with hyphens'
)
expect
(
described_class
.
unhyphenize
(
name
)).
to
eq
(
'a name with hyphens'
)
end
end
...
...
@@ -81,7 +81,7 @@ describe WikiPage do
before
do
create_page
(
"test page"
,
"test content"
)
@page
=
wiki
.
wiki
.
paged
(
"test page"
)
@wiki_page
=
WikiPage
.
new
(
wiki
,
@page
,
true
)
@wiki_page
=
described_class
.
new
(
wiki
,
@page
,
true
)
end
it
"sets the slug attribute"
do
...
...
spec/policies/global_policy_spec.rb
View file @
cddc5cac
...
...
@@ -4,7 +4,7 @@ describe GlobalPolicy do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
GlobalPolicy
.
new
(
current_user
,
[
user
])
}
subject
{
described_class
.
new
(
current_user
,
[
user
])
}
describe
"reading the list of users"
do
context
"for a logged in user"
do
...
...
spec/policies/user_policy_spec.rb
View file @
cddc5cac
...
...
@@ -4,7 +4,7 @@ describe UserPolicy do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
UserPolicy
.
new
(
current_user
,
user
)
}
subject
{
described_class
.
new
(
current_user
,
user
)
}
describe
"reading a user's information"
do
it
{
is_expected
.
to
be_allowed
(
:read_user
)
}
...
...
spec/services/create_release_service_spec.rb
View file @
cddc5cac
...
...
@@ -5,7 +5,7 @@ describe CreateReleaseService do
let
(
:user
)
{
create
(
:user
)
}
let
(
:tag_name
)
{
project
.
repository
.
tag_names
.
first
}
let
(
:description
)
{
'Awesome release!'
}
let
(
:service
)
{
CreateReleaseService
.
new
(
project
,
user
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
it
'creates a new release'
do
result
=
service
.
execute
(
tag_name
,
description
)
...
...
spec/services/event_create_service_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
EventCreateService
do
include
UserActivitiesHelpers
let
(
:service
)
{
EventCreateService
.
new
}
let
(
:service
)
{
described_class
.
new
}
describe
'Issues'
do
describe
'#open_issue'
do
...
...
spec/services/git_hooks_service_spec.rb
View file @
cddc5cac
...
...
@@ -5,7 +5,7 @@ describe GitHooksService do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:service
)
{
GitHooksService
.
new
}
let
(
:service
)
{
described_class
.
new
}
before
do
@blankrev
=
Gitlab
::
Git
::
BLANK_SHA
...
...
spec/services/git_tag_push_service_spec.rb
View file @
cddc5cac
...
...
@@ -5,7 +5,7 @@ describe GitTagPushService do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:service
)
{
GitTagPushService
.
new
(
project
,
user
,
oldrev:
oldrev
,
newrev:
newrev
,
ref:
ref
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
oldrev:
oldrev
,
newrev:
newrev
,
ref:
ref
)
}
let
(
:oldrev
)
{
Gitlab
::
Git
::
BLANK_SHA
}
let
(
:newrev
)
{
"8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b"
}
# gitlab-test: git rev-parse refs/tags/v1.1.0
...
...
@@ -184,7 +184,7 @@ describe GitTagPushService do
describe
"Webhooks"
do
context
"execute webhooks"
do
let
(
:service
)
{
GitTagPushService
.
new
(
project
,
user
,
oldrev:
'oldrev'
,
newrev:
'newrev'
,
ref:
'refs/tags/v1.0.0'
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
oldrev:
'oldrev'
,
newrev:
'newrev'
,
ref:
'refs/tags/v1.0.0'
)
}
it
"when pushing tags"
do
expect
(
project
).
to
receive
(
:execute_hooks
)
...
...
spec/services/groups/destroy_service_spec.rb
View file @
cddc5cac
...
...
@@ -100,7 +100,7 @@ describe Groups::DestroyService do
# Kick off the initial group destroy in a new thread, so that
# it doesn't share this spec's database transaction.
Thread
.
new
{
Groups
::
DestroyService
.
new
(
group
,
user
).
async_execute
}.
join
(
5
)
Thread
.
new
{
described_class
.
new
(
group
,
user
).
async_execute
}.
join
(
5
)
group_record
=
run_with_new_database_connection
do
|
conn
|
conn
.
execute
(
"SELECT * FROM namespaces WHERE id =
#{
group
.
id
}
"
).
first
...
...
spec/services/issues/update_service_spec.rb
View file @
cddc5cac
...
...
@@ -488,7 +488,7 @@ describe Issues::UpdateService do
context
'updating mentions'
do
let
(
:mentionable
)
{
issue
}
include_examples
'updating mentions'
,
Issues
::
UpdateService
include_examples
'updating mentions'
,
described_class
end
context
'duplicate issue'
do
...
...
spec/services/labels/create_service_spec.rb
View file @
cddc5cac
...
...
@@ -17,7 +17,7 @@ describe Labels::CreateService do
context
'in a project'
do
context
'with color in hex-code'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
hex_color
)).
execute
(
project:
project
)
label
=
described_class
.
new
(
params_with
(
hex_color
)).
execute
(
project:
project
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -26,7 +26,7 @@ describe Labels::CreateService do
context
'with color in allowed name'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
named_color
)).
execute
(
project:
project
)
label
=
described_class
.
new
(
params_with
(
named_color
)).
execute
(
project:
project
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -35,7 +35,7 @@ describe Labels::CreateService do
context
'with color in up-case allowed name'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
upcase_color
)).
execute
(
project:
project
)
label
=
described_class
.
new
(
params_with
(
upcase_color
)).
execute
(
project:
project
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -44,7 +44,7 @@ describe Labels::CreateService do
context
'with color surrounded by spaces'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
spaced_color
)).
execute
(
project:
project
)
label
=
described_class
.
new
(
params_with
(
spaced_color
)).
execute
(
project:
project
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -53,7 +53,7 @@ describe Labels::CreateService do
context
'with unknown color'
do
it
'doesn\'t create a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
unknown_color
)).
execute
(
project:
project
)
label
=
described_class
.
new
(
params_with
(
unknown_color
)).
execute
(
project:
project
)
expect
(
label
).
not_to
be_persisted
end
...
...
@@ -61,7 +61,7 @@ describe Labels::CreateService do
context
'with no color'
do
it
'doesn\'t create a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
no_color
)).
execute
(
project:
project
)
label
=
described_class
.
new
(
params_with
(
no_color
)).
execute
(
project:
project
)
expect
(
label
).
not_to
be_persisted
end
...
...
@@ -71,7 +71,7 @@ describe Labels::CreateService do
context
'in a group'
do
context
'with color in hex-code'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
hex_color
)).
execute
(
group:
group
)
label
=
described_class
.
new
(
params_with
(
hex_color
)).
execute
(
group:
group
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -80,7 +80,7 @@ describe Labels::CreateService do
context
'with color in allowed name'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
named_color
)).
execute
(
group:
group
)
label
=
described_class
.
new
(
params_with
(
named_color
)).
execute
(
group:
group
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -89,7 +89,7 @@ describe Labels::CreateService do
context
'with color in up-case allowed name'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
upcase_color
)).
execute
(
group:
group
)
label
=
described_class
.
new
(
params_with
(
upcase_color
)).
execute
(
group:
group
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -98,7 +98,7 @@ describe Labels::CreateService do
context
'with color surrounded by spaces'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
spaced_color
)).
execute
(
group:
group
)
label
=
described_class
.
new
(
params_with
(
spaced_color
)).
execute
(
group:
group
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -107,7 +107,7 @@ describe Labels::CreateService do
context
'with unknown color'
do
it
'doesn\'t create a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
unknown_color
)).
execute
(
group:
group
)
label
=
described_class
.
new
(
params_with
(
unknown_color
)).
execute
(
group:
group
)
expect
(
label
).
not_to
be_persisted
end
...
...
@@ -115,7 +115,7 @@ describe Labels::CreateService do
context
'with no color'
do
it
'doesn\'t create a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
no_color
)).
execute
(
group:
group
)
label
=
described_class
.
new
(
params_with
(
no_color
)).
execute
(
group:
group
)
expect
(
label
).
not_to
be_persisted
end
...
...
@@ -125,7 +125,7 @@ describe Labels::CreateService do
context
'in admin area'
do
context
'with color in hex-code'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
hex_color
)).
execute
(
template:
true
)
label
=
described_class
.
new
(
params_with
(
hex_color
)).
execute
(
template:
true
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -134,7 +134,7 @@ describe Labels::CreateService do
context
'with color in allowed name'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
named_color
)).
execute
(
template:
true
)
label
=
described_class
.
new
(
params_with
(
named_color
)).
execute
(
template:
true
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -143,7 +143,7 @@ describe Labels::CreateService do
context
'with color in up-case allowed name'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
upcase_color
)).
execute
(
template:
true
)
label
=
described_class
.
new
(
params_with
(
upcase_color
)).
execute
(
template:
true
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -152,7 +152,7 @@ describe Labels::CreateService do
context
'with color surrounded by spaces'
do
it
'creates a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
spaced_color
)).
execute
(
template:
true
)
label
=
described_class
.
new
(
params_with
(
spaced_color
)).
execute
(
template:
true
)
expect
(
label
).
to
be_persisted
expect
(
label
.
color
).
to
eq
expected_saved_color
...
...
@@ -161,7 +161,7 @@ describe Labels::CreateService do
context
'with unknown color'
do
it
'doesn\'t create a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
unknown_color
)).
execute
(
template:
true
)
label
=
described_class
.
new
(
params_with
(
unknown_color
)).
execute
(
template:
true
)
expect
(
label
).
not_to
be_persisted
end
...
...
@@ -169,7 +169,7 @@ describe Labels::CreateService do
context
'with no color'
do
it
'doesn\'t create a label'
do
label
=
Labels
::
CreateService
.
new
(
params_with
(
no_color
)).
execute
(
template:
true
)
label
=
described_class
.
new
(
params_with
(
no_color
)).
execute
(
template:
true
)
expect
(
label
).
not_to
be_persisted
end
...
...
spec/services/labels/update_service_spec.rb
View file @
cddc5cac
...
...
@@ -20,7 +20,7 @@ describe Labels::UpdateService do
context
'with color in hex-code'
do
it
'updates the label'
do
label
=
Labels
::
UpdateService
.
new
(
params_with
(
hex_color
)).
execute
(
@label
)
label
=
described_class
.
new
(
params_with
(
hex_color
)).
execute
(
@label
)
expect
(
label
).
to
be_valid
expect
(
label
.
reload
.
color
).
to
eq
expected_saved_color
...
...
@@ -29,7 +29,7 @@ describe Labels::UpdateService do
context
'with color in allowed name'
do
it
'updates the label'
do
label
=
Labels
::
UpdateService
.
new
(
params_with
(
named_color
)).
execute
(
@label
)
label
=
described_class
.
new
(
params_with
(
named_color
)).
execute
(
@label
)
expect
(
label
).
to
be_valid
expect
(
label
.
reload
.
color
).
to
eq
expected_saved_color
...
...
@@ -38,7 +38,7 @@ describe Labels::UpdateService do
context
'with color in up-case allowed name'
do
it
'updates the label'
do
label
=
Labels
::
UpdateService
.
new
(
params_with
(
upcase_color
)).
execute
(
@label
)
label
=
described_class
.
new
(
params_with
(
upcase_color
)).
execute
(
@label
)
expect
(
label
).
to
be_valid
expect
(
label
.
reload
.
color
).
to
eq
expected_saved_color
...
...
@@ -47,7 +47,7 @@ describe Labels::UpdateService do
context
'with color surrounded by spaces'
do
it
'updates the label'
do
label
=
Labels
::
UpdateService
.
new
(
params_with
(
spaced_color
)).
execute
(
@label
)
label
=
described_class
.
new
(
params_with
(
spaced_color
)).
execute
(
@label
)
expect
(
label
).
to
be_valid
expect
(
label
.
reload
.
color
).
to
eq
expected_saved_color
...
...
@@ -56,7 +56,7 @@ describe Labels::UpdateService do
context
'with unknown color'
do
it
'doesn\'t update the label'
do
label
=
Labels
::
UpdateService
.
new
(
params_with
(
unknown_color
)).
execute
(
@label
)
label
=
described_class
.
new
(
params_with
(
unknown_color
)).
execute
(
@label
)
expect
(
label
).
not_to
be_valid
end
...
...
@@ -64,7 +64,7 @@ describe Labels::UpdateService do
context
'with no color'
do
it
'doesn\'t update the label'
do
label
=
Labels
::
UpdateService
.
new
(
params_with
(
no_color
)).
execute
(
@label
)
label
=
described_class
.
new
(
params_with
(
no_color
)).
execute
(
@label
)
expect
(
label
).
not_to
be_valid
end
...
...
spec/services/merge_requests/build_service_spec.rb
View file @
cddc5cac
...
...
@@ -19,7 +19,7 @@ describe MergeRequests::BuildService do
let
(
:commits
)
{
nil
}
let
(
:service
)
do
MergeRequests
::
BuildService
.
new
(
project
,
user
,
described_class
.
new
(
project
,
user
,
description:
description
,
source_branch:
source_branch
,
target_branch:
target_branch
,
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
cddc5cac
...
...
@@ -13,7 +13,7 @@ describe MergeRequests::MergeService do
describe
'#execute'
do
context
'valid params'
do
let
(
:service
)
{
MergeRequests
::
MergeService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
before
do
allow
(
service
).
to
receive
(
:execute_hooks
)
...
...
@@ -112,7 +112,7 @@ describe MergeRequests::MergeService do
context
'closes related todos'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
assignee:
user
,
author:
user
)
}
let
(
:project
)
{
merge_request
.
project
}
let
(
:service
)
{
MergeRequests
::
MergeService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let!
(
:todo
)
do
create
(
:todo
,
:assigned
,
project:
project
,
...
...
@@ -136,7 +136,7 @@ describe MergeRequests::MergeService do
context
'source branch removal'
do
context
'when the source branch is protected'
do
let
(
:service
)
do
MergeRequests
::
MergeService
.
new
(
project
,
user
,
should_remove_source_branch:
'1'
)
described_class
.
new
(
project
,
user
,
should_remove_source_branch:
'1'
)
end
before
do
...
...
@@ -151,7 +151,7 @@ describe MergeRequests::MergeService do
context
'when the source branch is the default branch'
do
let
(
:service
)
do
MergeRequests
::
MergeService
.
new
(
project
,
user
,
should_remove_source_branch:
'1'
)
described_class
.
new
(
project
,
user
,
should_remove_source_branch:
'1'
)
end
before
do
...
...
@@ -169,7 +169,7 @@ describe MergeRequests::MergeService do
let
(
:service
)
do
merge_request
.
merge_params
[
'force_remove_source_branch'
]
=
'1'
merge_request
.
save!
MergeRequests
::
MergeService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
end
it
'removes the source branch using the author user'
do
...
...
@@ -182,7 +182,7 @@ describe MergeRequests::MergeService do
context
'when MR merger set the source branch to be removed'
do
let
(
:service
)
do
MergeRequests
::
MergeService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
,
should_remove_source_branch:
'1'
)
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
,
should_remove_source_branch:
'1'
)
end
it
'removes the source branch using the current user'
do
...
...
@@ -196,7 +196,7 @@ describe MergeRequests::MergeService do
end
context
"error handling"
do
let
(
:service
)
{
MergeRequests
::
MergeService
.
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/refresh_service_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
MergeRequests
::
RefreshService
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
MergeRequests
::
RefreshService
}
let
(
:service
)
{
described_class
}
describe
'#execute'
do
before
do
...
...
spec/services/merge_requests/update_service_spec.rb
View file @
cddc5cac
...
...
@@ -55,7 +55,7 @@ describe MergeRequests::UpdateService do
}
end
let
(
:service
)
{
MergeRequests
::
UpdateService
.
new
(
project
,
user
,
opts
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
before
do
allow
(
service
).
to
receive
(
:execute_hooks
)
...
...
@@ -145,7 +145,7 @@ describe MergeRequests::UpdateService do
}
end
let
(
:service
)
{
MergeRequests
::
UpdateService
.
new
(
project
,
user
,
opts
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
opts
)
}
context
'without pipeline'
do
before
do
...
...
@@ -205,7 +205,7 @@ describe MergeRequests::UpdateService do
context
'with a non-authorised user'
do
let
(
:visitor
)
{
create
(
:user
)
}
let
(
:service
)
{
MergeRequests
::
UpdateService
.
new
(
project
,
visitor
,
opts
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
visitor
,
opts
)
}
before
do
merge_request
.
update_attribute
(
:merge_error
,
'Error'
)
...
...
@@ -348,7 +348,7 @@ describe MergeRequests::UpdateService do
opts
=
{
label_ids:
[
label
.
id
]
}
perform_enqueued_jobs
do
@merge_request
=
MergeRequests
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
merge_request
)
@merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
(
merge_request
)
end
should_email
(
subscriber
)
...
...
@@ -364,7 +364,7 @@ describe MergeRequests::UpdateService do
opts
=
{
label_ids:
[
label
.
id
,
label2
.
id
]
}
perform_enqueued_jobs
do
@merge_request
=
MergeRequests
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
merge_request
)
@merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
(
merge_request
)
end
should_not_email
(
subscriber
)
...
...
@@ -375,7 +375,7 @@ describe MergeRequests::UpdateService do
opts
=
{
label_ids:
[
label2
.
id
]
}
perform_enqueued_jobs
do
@merge_request
=
MergeRequests
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
merge_request
)
@merge_request
=
described_class
.
new
(
project
,
user
,
opts
).
execute
(
merge_request
)
end
should_not_email
(
subscriber
)
...
...
@@ -386,7 +386,7 @@ describe MergeRequests::UpdateService do
context
'updating mentions'
do
let
(
:mentionable
)
{
merge_request
}
include_examples
'updating mentions'
,
MergeRequests
::
UpdateService
include_examples
'updating mentions'
,
described_class
end
context
'when MergeRequest has tasks'
do
...
...
spec/services/milestones/close_service_spec.rb
View file @
cddc5cac
...
...
@@ -11,7 +11,7 @@ describe Milestones::CloseService do
describe
'#execute'
do
before
do
Milestones
::
CloseService
.
new
(
project
,
user
,
{}).
execute
(
milestone
)
described_class
.
new
(
project
,
user
,
{}).
execute
(
milestone
)
end
it
{
expect
(
milestone
).
to
be_valid
}
...
...
spec/services/milestones/create_service_spec.rb
View file @
cddc5cac
...
...
@@ -14,7 +14,7 @@ describe Milestones::CreateService do
description:
'Patch release to fix security issue'
}
@milestone
=
Milestones
::
CreateService
.
new
(
project
,
user
,
opts
).
execute
@milestone
=
described_class
.
new
(
project
,
user
,
opts
).
execute
end
it
{
expect
(
@milestone
).
to
be_valid
}
...
...
spec/services/notes/post_process_service_spec.rb
View file @
cddc5cac
...
...
@@ -21,7 +21,7 @@ describe Notes::PostProcessService do
expect
(
project
).
to
receive
(
:execute_hooks
)
expect
(
project
).
to
receive
(
:execute_services
)
Notes
::
PostProcessService
.
new
(
@note
).
execute
described_class
.
new
(
@note
).
execute
end
end
end
spec/services/notification_service_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
NotificationService
do
include
EmailHelpers
let
(
:notification
)
{
NotificationService
.
new
}
let
(
:notification
)
{
described_class
.
new
}
let
(
:assignee
)
{
create
(
:user
)
}
around
(
:each
)
do
|
example
|
...
...
spec/services/pages_service_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
PagesService
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Build
.
build
(
build
)
}
let
(
:service
)
{
PagesService
.
new
(
data
)
}
let
(
:service
)
{
described_class
.
new
(
data
)
}
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
...
...
spec/services/projects/destroy_service_spec.rb
View file @
cddc5cac
...
...
@@ -81,7 +81,7 @@ describe Projects::DestroyService do
before
do
new_user
=
create
(
:user
)
project
.
team
.
add_user
(
new_user
,
Gitlab
::
Access
::
DEVELOPER
)
allow_any_instance_of
(
Projects
::
DestroyService
).
to
receive
(
:flush_caches
).
and_raise
(
::
Redis
::
CannotConnectError
)
allow_any_instance_of
(
described_class
).
to
receive
(
:flush_caches
).
and_raise
(
::
Redis
::
CannotConnectError
)
end
it
'keeps project team intact upon an error'
do
...
...
@@ -114,7 +114,7 @@ describe Projects::DestroyService do
context
'errors'
do
context
'when `remove_legacy_registry_tags` fails'
do
before
do
expect_any_instance_of
(
Projects
::
DestroyService
)
expect_any_instance_of
(
described_class
)
.
to
receive
(
:remove_legacy_registry_tags
).
and_return
(
false
)
end
...
...
@@ -123,7 +123,7 @@ describe Projects::DestroyService do
context
'when `remove_repository` fails'
do
before
do
expect_any_instance_of
(
Projects
::
DestroyService
)
expect_any_instance_of
(
described_class
)
.
to
receive
(
:remove_repository
).
and_return
(
false
)
end
...
...
spec/services/projects/transfer_service_spec.rb
View file @
cddc5cac
...
...
@@ -37,7 +37,7 @@ describe Projects::TransferService do
end
it
'executes system hooks'
do
expect_any_instance_of
(
Projects
::
TransferService
).
to
receive
(
:execute_system_hooks
)
expect_any_instance_of
(
described_class
).
to
receive
(
:execute_system_hooks
)
transfer_project
(
project
,
user
,
group
)
end
...
...
@@ -80,7 +80,7 @@ describe Projects::TransferService do
end
it
"doesn't run system hooks"
do
expect_any_instance_of
(
Projects
::
TransferService
).
not_to
receive
(
:execute_system_hooks
)
expect_any_instance_of
(
described_class
).
not_to
receive
(
:execute_system_hooks
)
attempt_project_transfer
end
...
...
spec/services/projects/unlink_fork_service_spec.rb
View file @
cddc5cac
require
'spec_helper'
describe
Projects
::
UnlinkForkService
do
subject
{
Projects
::
UnlinkForkService
.
new
(
fork_project
,
user
)
}
subject
{
described_class
.
new
(
fork_project
,
user
)
}
let
(
:fork_link
)
{
create
(
:forked_project_link
)
}
let
(
:fork_project
)
{
fork_link
.
forked_to_project
}
...
...
spec/services/repair_ldap_blocked_user_service_spec.rb
View file @
cddc5cac
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
RepairLdapBlockedUserService
do
let
(
:user
)
{
create
(
:omniauth_user
,
provider:
'ldapmain'
,
state:
'ldap_blocked'
)
}
let
(
:identity
)
{
user
.
ldap_identity
}
subject
(
:service
)
{
RepairLdapBlockedUserService
.
new
(
user
)
}
subject
(
:service
)
{
described_class
.
new
(
user
)
}
describe
'#execute'
do
it
'changes to normal block after destroying last ldap identity'
do
...
...
spec/services/search/global_service_spec.rb
View file @
cddc5cac
...
...
@@ -16,7 +16,7 @@ describe Search::GlobalService do
describe
'#execute'
do
context
'unauthenticated'
do
it
'returns public projects only'
do
results
=
Search
::
GlobalService
.
new
(
nil
,
search:
"searchable"
).
execute
results
=
described_class
.
new
(
nil
,
search:
"searchable"
).
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
public_project
]
end
...
...
@@ -24,19 +24,19 @@ describe Search::GlobalService do
context
'authenticated'
do
it
'returns public, internal and private projects'
do
results
=
Search
::
GlobalService
.
new
(
user
,
search:
"searchable"
).
execute
results
=
described_class
.
new
(
user
,
search:
"searchable"
).
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
public_project
,
found_project
,
internal_project
]
end
it
'returns only public & internal projects'
do
results
=
Search
::
GlobalService
.
new
(
internal_user
,
search:
"searchable"
).
execute
results
=
described_class
.
new
(
internal_user
,
search:
"searchable"
).
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
internal_project
,
public_project
]
end
it
'namespace name is searchable'
do
results
=
Search
::
GlobalService
.
new
(
user
,
search:
found_project
.
namespace
.
path
).
execute
results
=
described_class
.
new
(
user
,
search:
found_project
.
namespace
.
path
).
execute
expect
(
results
.
objects
(
'projects'
)).
to
match_array
[
found_project
]
end
...
...
spec/services/search/group_service_spec.rb
View file @
cddc5cac
...
...
@@ -17,7 +17,7 @@ describe Search::GroupService do
let!
(
:project2
)
{
create
(
:empty_project
,
:internal
,
namespace:
nested_group
,
name:
"Inner
#{
term
}
2"
)
}
let!
(
:project3
)
{
create
(
:empty_project
,
:internal
,
namespace:
nested_group
.
parent
,
name:
"Outer
#{
term
}
"
)
}
let
(
:results
)
{
Search
::
GroupService
.
new
(
user
,
search_group
,
search:
term
).
execute
}
let
(
:results
)
{
described_class
.
new
(
user
,
search_group
,
search:
term
).
execute
}
subject
{
results
.
objects
(
'projects'
)
}
context
'in parent group'
do
...
...
spec/services/search_service_spec.rb
View file @
cddc5cac
...
...
@@ -22,7 +22,7 @@ describe SearchService do
describe
'#project'
do
context
'when the project is accessible'
do
it
'returns the project'
do
project
=
SearchService
.
new
(
user
,
project_id:
accessible_project
.
id
).
project
project
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
).
project
expect
(
project
).
to
eq
accessible_project
end
...
...
@@ -31,7 +31,7 @@ describe SearchService do
search_project
=
create
:empty_project
search_project
.
add_guest
(
user
)
project
=
SearchService
.
new
(
user
,
project_id:
search_project
.
id
).
project
project
=
described_class
.
new
(
user
,
project_id:
search_project
.
id
).
project
expect
(
project
).
to
eq
search_project
end
...
...
@@ -39,7 +39,7 @@ describe SearchService do
context
'when the project is not accessible'
do
it
'returns nil'
do
project
=
SearchService
.
new
(
user
,
project_id:
inaccessible_project
.
id
).
project
project
=
described_class
.
new
(
user
,
project_id:
inaccessible_project
.
id
).
project
expect
(
project
).
to
be_nil
end
...
...
@@ -47,7 +47,7 @@ describe SearchService do
context
'when there is no project_id'
do
it
'returns nil'
do
project
=
SearchService
.
new
(
user
).
project
project
=
described_class
.
new
(
user
).
project
expect
(
project
).
to
be_nil
end
...
...
@@ -57,7 +57,7 @@ describe SearchService do
describe
'#group'
do
context
'when the group is accessible'
do
it
'returns the group'
do
group
=
SearchService
.
new
(
user
,
group_id:
accessible_group
.
id
).
group
group
=
described_class
.
new
(
user
,
group_id:
accessible_group
.
id
).
group
expect
(
group
).
to
eq
accessible_group
end
...
...
@@ -65,7 +65,7 @@ describe SearchService do
context
'when the group is not accessible'
do
it
'returns nil'
do
group
=
SearchService
.
new
(
user
,
group_id:
inaccessible_group
.
id
).
group
group
=
described_class
.
new
(
user
,
group_id:
inaccessible_group
.
id
).
group
expect
(
group
).
to
be_nil
end
...
...
@@ -73,7 +73,7 @@ describe SearchService do
context
'when there is no group_id'
do
it
'returns nil'
do
group
=
SearchService
.
new
(
user
).
group
group
=
described_class
.
new
(
user
).
group
expect
(
group
).
to
be_nil
end
...
...
@@ -83,7 +83,7 @@ describe SearchService do
describe
'#show_snippets?'
do
context
'when :snippets is \'true\''
do
it
'returns true'
do
show_snippets
=
SearchService
.
new
(
user
,
snippets:
'true'
).
show_snippets?
show_snippets
=
described_class
.
new
(
user
,
snippets:
'true'
).
show_snippets?
expect
(
show_snippets
).
to
be_truthy
end
...
...
@@ -91,7 +91,7 @@ describe SearchService do
context
'when :snippets is not \'true\''
do
it
'returns false'
do
show_snippets
=
SearchService
.
new
(
user
,
snippets:
'tru'
).
show_snippets?
show_snippets
=
described_class
.
new
(
user
,
snippets:
'tru'
).
show_snippets?
expect
(
show_snippets
).
to
be_falsey
end
...
...
@@ -99,7 +99,7 @@ describe SearchService do
context
'when :snippets is missing'
do
it
'returns false'
do
show_snippets
=
SearchService
.
new
(
user
).
show_snippets?
show_snippets
=
described_class
.
new
(
user
).
show_snippets?
expect
(
show_snippets
).
to
be_falsey
end
...
...
@@ -110,7 +110,7 @@ describe SearchService do
context
'with accessible project_id'
do
context
'and allowed scope'
do
it
'returns the specified scope'
do
scope
=
SearchService
.
new
(
user
,
project_id:
accessible_project
.
id
,
scope:
'notes'
).
scope
scope
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
,
scope:
'notes'
).
scope
expect
(
scope
).
to
eq
'notes'
end
...
...
@@ -118,7 +118,7 @@ describe SearchService do
context
'and disallowed scope'
do
it
'returns the default scope'
do
scope
=
SearchService
.
new
(
user
,
project_id:
accessible_project
.
id
,
scope:
'projects'
).
scope
scope
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
,
scope:
'projects'
).
scope
expect
(
scope
).
to
eq
'blobs'
end
...
...
@@ -126,7 +126,7 @@ describe SearchService do
context
'and no scope'
do
it
'returns the default scope'
do
scope
=
SearchService
.
new
(
user
,
project_id:
accessible_project
.
id
).
scope
scope
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
).
scope
expect
(
scope
).
to
eq
'blobs'
end
...
...
@@ -136,7 +136,7 @@ describe SearchService do
context
'with \'true\' snippets'
do
context
'and allowed scope'
do
it
'returns the specified scope'
do
scope
=
SearchService
.
new
(
user
,
snippets:
'true'
,
scope:
'snippet_titles'
).
scope
scope
=
described_class
.
new
(
user
,
snippets:
'true'
,
scope:
'snippet_titles'
).
scope
expect
(
scope
).
to
eq
'snippet_titles'
end
...
...
@@ -144,7 +144,7 @@ describe SearchService do
context
'and disallowed scope'
do
it
'returns the default scope'
do
scope
=
SearchService
.
new
(
user
,
snippets:
'true'
,
scope:
'projects'
).
scope
scope
=
described_class
.
new
(
user
,
snippets:
'true'
,
scope:
'projects'
).
scope
expect
(
scope
).
to
eq
'snippet_blobs'
end
...
...
@@ -152,7 +152,7 @@ describe SearchService do
context
'and no scope'
do
it
'returns the default scope'
do
scope
=
SearchService
.
new
(
user
,
snippets:
'true'
).
scope
scope
=
described_class
.
new
(
user
,
snippets:
'true'
).
scope
expect
(
scope
).
to
eq
'snippet_blobs'
end
...
...
@@ -162,7 +162,7 @@ describe SearchService do
context
'with no project_id, no snippets'
do
context
'and allowed scope'
do
it
'returns the specified scope'
do
scope
=
SearchService
.
new
(
user
,
scope:
'issues'
).
scope
scope
=
described_class
.
new
(
user
,
scope:
'issues'
).
scope
expect
(
scope
).
to
eq
'issues'
end
...
...
@@ -170,7 +170,7 @@ describe SearchService do
context
'and disallowed scope'
do
it
'returns the default scope'
do
scope
=
SearchService
.
new
(
user
,
scope:
'blobs'
).
scope
scope
=
described_class
.
new
(
user
,
scope:
'blobs'
).
scope
expect
(
scope
).
to
eq
'projects'
end
...
...
@@ -178,7 +178,7 @@ describe SearchService do
context
'and no scope'
do
it
'returns the default scope'
do
scope
=
SearchService
.
new
(
user
).
scope
scope
=
described_class
.
new
(
user
).
scope
expect
(
scope
).
to
eq
'projects'
end
...
...
@@ -189,7 +189,7 @@ describe SearchService do
describe
'#search_results'
do
context
'with accessible project_id'
do
it
'returns an instance of Gitlab::ProjectSearchResults'
do
search_results
=
SearchService
.
new
(
search_results
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
,
scope:
'notes'
,
...
...
@@ -201,7 +201,7 @@ describe SearchService do
context
'with accessible project_id and \'true\' snippets'
do
it
'returns an instance of Gitlab::ProjectSearchResults'
do
search_results
=
SearchService
.
new
(
search_results
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
,
snippets:
'true'
,
...
...
@@ -214,7 +214,7 @@ describe SearchService do
context
'with \'true\' snippets'
do
it
'returns an instance of Gitlab::SnippetSearchResults'
do
search_results
=
SearchService
.
new
(
search_results
=
described_class
.
new
(
user
,
snippets:
'true'
,
search:
snippet
.
content
).
search_results
...
...
@@ -225,7 +225,7 @@ describe SearchService do
context
'with no project_id and no snippets'
do
it
'returns an instance of Gitlab::SearchResults'
do
search_results
=
SearchService
.
new
(
search_results
=
described_class
.
new
(
user
,
search:
public_project
.
name
).
search_results
...
...
@@ -237,7 +237,7 @@ describe SearchService do
describe
'#search_objects'
do
context
'with accessible project_id'
do
it
'returns objects in the project'
do
search_objects
=
SearchService
.
new
(
search_objects
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
,
scope:
'notes'
,
...
...
@@ -249,7 +249,7 @@ describe SearchService do
context
'with accessible project_id and \'true\' snippets'
do
it
'returns objects in the project'
do
search_objects
=
SearchService
.
new
(
search_objects
=
described_class
.
new
(
user
,
project_id:
accessible_project
.
id
,
snippets:
'true'
,
...
...
@@ -262,7 +262,7 @@ describe SearchService do
context
'with \'true\' snippets'
do
it
'returns objects in snippets'
do
search_objects
=
SearchService
.
new
(
search_objects
=
described_class
.
new
(
user
,
snippets:
'true'
,
search:
snippet
.
content
).
search_objects
...
...
@@ -273,7 +273,7 @@ describe SearchService do
context
'with accessible group_id'
do
it
'returns objects in the group'
do
search_objects
=
SearchService
.
new
(
search_objects
=
described_class
.
new
(
user
,
group_id:
accessible_group
.
id
,
search:
group_project
.
name
).
search_objects
...
...
@@ -284,7 +284,7 @@ describe SearchService do
context
'with no project_id, group_id or snippets'
do
it
'returns objects in global'
do
search_objects
=
SearchService
.
new
(
search_objects
=
described_class
.
new
(
user
,
search:
public_project
.
name
).
search_objects
...
...
spec/services/todo_service_spec.rb
View file @
cddc5cac
...
...
@@ -873,21 +873,21 @@ describe TodoService do
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
todos
=
TodosFinder
.
new
(
john_doe
,
{}).
execute
expect
{
TodoService
.
new
.
mark_todos_as_done
(
todos
,
john_doe
)
}
expect
{
described_class
.
new
.
mark_todos_as_done
(
todos
,
john_doe
)
}
.
to
change
{
john_doe
.
todos
.
done
.
count
}.
from
(
0
).
to
(
1
)
end
it
'marks an array of todos as done'
do
todo
=
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
expect
{
TodoService
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)
}
expect
{
described_class
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)
}
.
to
change
{
todo
.
reload
.
state
}.
from
(
'pending'
).
to
(
'done'
)
end
it
'returns the ids of updated todos'
do
# Needed on API
todo
=
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
expect
(
TodoService
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)).
to
eq
([
todo
.
id
])
expect
(
described_class
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)).
to
eq
([
todo
.
id
])
end
context
'when some of the todos are done already'
do
...
...
@@ -895,23 +895,23 @@ describe TodoService do
let!
(
:second_todo
)
{
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
another_issue
,
project:
project
)
}
it
'returns the ids of those still pending'
do
TodoService
.
new
.
mark_pending_todos_as_done
(
issue
,
john_doe
)
described_class
.
new
.
mark_pending_todos_as_done
(
issue
,
john_doe
)
expect
(
TodoService
.
new
.
mark_todos_as_done
(
Todo
.
all
,
john_doe
)).
to
eq
([
second_todo
.
id
])
expect
(
described_class
.
new
.
mark_todos_as_done
(
Todo
.
all
,
john_doe
)).
to
eq
([
second_todo
.
id
])
end
it
'returns an empty array if all are done'
do
TodoService
.
new
.
mark_pending_todos_as_done
(
issue
,
john_doe
)
TodoService
.
new
.
mark_pending_todos_as_done
(
another_issue
,
john_doe
)
described_class
.
new
.
mark_pending_todos_as_done
(
issue
,
john_doe
)
described_class
.
new
.
mark_pending_todos_as_done
(
another_issue
,
john_doe
)
expect
(
TodoService
.
new
.
mark_todos_as_done
(
Todo
.
all
,
john_doe
)).
to
eq
([])
expect
(
described_class
.
new
.
mark_todos_as_done
(
Todo
.
all
,
john_doe
)).
to
eq
([])
end
end
it
'caches the number of todos of a user'
,
:use_clean_rails_memory_store_caching
do
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
todo
=
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
TodoService
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)
described_class
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)
expect_any_instance_of
(
TodosFinder
).
not_to
receive
(
:execute
)
...
...
spec/services/update_release_service_spec.rb
View file @
cddc5cac
...
...
@@ -6,7 +6,7 @@ describe UpdateReleaseService do
let
(
:tag_name
)
{
project
.
repository
.
tag_names
.
first
}
let
(
:description
)
{
'Awesome release!'
}
let
(
:new_description
)
{
'The best release!'
}
let
(
:service
)
{
UpdateReleaseService
.
new
(
project
,
user
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
context
'with an existing release'
do
let
(
:create_service
)
{
CreateReleaseService
.
new
(
project
,
user
)
}
...
...
spec/services/web_hook_service_spec.rb
View file @
cddc5cac
...
...
@@ -12,7 +12,7 @@ describe WebHookService do
let
(
:data
)
do
{
before:
'oldrev'
,
after:
'newrev'
,
ref:
'ref'
}
end
let
(
:service_instance
)
{
WebHookService
.
new
(
project_hook
,
data
,
'push_hooks'
)
}
let
(
:service_instance
)
{
described_class
.
new
(
project_hook
,
data
,
'push_hooks'
)
}
describe
'#execute'
do
before
(
:each
)
do
...
...
@@ -114,7 +114,7 @@ describe WebHookService do
context
'should not log ServiceHooks'
do
let
(
:service_hook
)
{
create
(
:service_hook
)
}
let
(
:service_instance
)
{
WebHookService
.
new
(
service_hook
,
data
,
'service_hook'
)
}
let
(
:service_instance
)
{
described_class
.
new
(
service_hook
,
data
,
'service_hook'
)
}
before
do
WebMock
.
stub_request
(
:post
,
service_hook
.
url
).
to_return
(
status:
200
,
body:
'Success'
)
...
...
@@ -131,7 +131,7 @@ describe WebHookService do
it
'enqueue WebHookWorker'
do
expect
(
Sidekiq
::
Client
).
to
receive
(
:enqueue
).
with
(
WebHookWorker
,
project_hook
.
id
,
data
,
'push_hooks'
)
WebHookService
.
new
(
project_hook
,
data
,
'push_hooks'
).
async_execute
described_class
.
new
(
project_hook
,
data
,
'push_hooks'
).
async_execute
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