Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ce5bc4f8
Commit
ce5bc4f8
authored
Jul 02, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RSpec 3 updates for EE
parent
41e64d3c
Changes
49
Show whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
241 additions
and
250 deletions
+241
-250
features/steps/admin/appearance.rb
features/steps/admin/appearance.rb
+11
-11
features/steps/admin/email.rb
features/steps/admin/email.rb
+1
-1
features/steps/admin/groups.rb
features/steps/admin/groups.rb
+2
-2
features/steps/admin/settings.rb
features/steps/admin/settings.rb
+1
-1
features/steps/admin/users.rb
features/steps/admin/users.rb
+1
-1
features/steps/group_hooks.rb
features/steps/group_hooks.rb
+7
-7
features/steps/groups.rb
features/steps/groups.rb
+6
-6
features/steps/groups_management.rb
features/steps/groups_management.rb
+6
-6
features/steps/project/audit_event.rb
features/steps/project/audit_event.rb
+2
-2
features/steps/project/git_hooks.rb
features/steps/project/git_hooks.rb
+3
-3
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+12
-14
features/steps/project/network_graph.rb
features/steps/project/network_graph.rb
+1
-1
features/steps/project/project.rb
features/steps/project/project.rb
+6
-6
features/steps/project/project_group_links.rb
features/steps/project/project_group_links.rb
+3
-3
features/steps/project/redirects.rb
features/steps/project/redirects.rb
+1
-1
features/steps/project/services.rb
features/steps/project/services.rb
+4
-4
features/steps/project/team_management.rb
features/steps/project/team_management.rb
+3
-3
features/steps/project/wiki.rb
features/steps/project/wiki.rb
+2
-2
features/steps/search.rb
features/steps/search.rb
+3
-3
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+1
-1
features/steps/user.rb
features/steps/user.rb
+2
-2
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+1
-1
spec/helpers/merge_request_helper_spec.rb
spec/helpers/merge_request_helper_spec.rb
+6
-6
spec/helpers/oauth_helper_spec.rb
spec/helpers/oauth_helper_spec.rb
+2
-2
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+6
-4
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+10
-10
spec/lib/gitlab/kerberos/authentication_spec.rb
spec/lib/gitlab/kerberos/authentication_spec.rb
+3
-5
spec/lib/gitlab/ldap/access_spec.rb
spec/lib/gitlab/ldap/access_spec.rb
+31
-32
spec/lib/gitlab/ldap/person_spec.rb
spec/lib/gitlab/ldap/person_spec.rb
+1
-1
spec/lib/gitlab/satellite/merge_action_spec.rb
spec/lib/gitlab/satellite/merge_action_spec.rb
+22
-26
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+2
-2
spec/models/concerns/mentionable_spec.rb
spec/models/concerns/mentionable_spec.rb
+2
-2
spec/models/ldap_group_link_spec.rb
spec/models/ldap_group_link_spec.rb
+1
-1
spec/models/license_spec.rb
spec/models/license_spec.rb
+5
-5
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+2
-2
spec/models/project_services/jenkins_service_spec.rb
spec/models/project_services/jenkins_service_spec.rb
+1
-1
spec/models/project_services/jira_service_spec.rb
spec/models/project_services/jira_service_spec.rb
+3
-3
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-2
spec/requests/api/ldap_group_links_spec.rb
spec/requests/api/ldap_group_links_spec.rb
+3
-3
spec/requests/api/ldap_spec.rb
spec/requests/api/ldap_spec.rb
+11
-13
spec/requests/api/project_git_hook_spec.rb
spec/requests/api/project_git_hook_spec.rb
+22
-22
spec/requests/api/project_members_spec.rb
spec/requests/api/project_members_spec.rb
+2
-2
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+7
-7
spec/requests/api/system_hooks_spec.rb
spec/requests/api/system_hooks_spec.rb
+1
-1
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+3
-3
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+4
-4
spec/services/ldap_group_reset_service_spec.rb
spec/services/ldap_group_reset_service_spec.rb
+6
-6
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+1
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+3
-3
No files found.
features/steps/admin/appearance.rb
View file @
ce5bc4f8
...
@@ -9,14 +9,14 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
...
@@ -9,14 +9,14 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
end
step
'I should be redirected to admin appearance page'
do
step
'I should be redirected to admin appearance page'
do
current_path
.
should
==
admin_appearances_path
expect
(
current_path
).
to
eq
admin_appearances_path
page
.
should
have_content
'Appearance settings'
expect
(
page
).
to
have_content
'Appearance settings'
end
end
step
'I should see newly created appearance'
do
step
'I should see newly created appearance'
do
page
.
should
have_field
(
'appearance_title'
,
with:
'MyCompany'
)
expect
(
page
).
to
have_field
(
'appearance_title'
,
with:
'MyCompany'
)
page
.
should
have_field
(
'appearance_description'
,
with:
'dev server'
)
expect
(
page
).
to
have_field
(
'appearance_description'
,
with:
'dev server'
)
page
.
should
have_content
'Last edit'
expect
(
page
).
to
have_content
'Last edit'
end
end
step
'I click preview button'
do
step
'I click preview button'
do
...
@@ -28,8 +28,8 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
...
@@ -28,8 +28,8 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
end
step
'I should see a customized appearance'
do
step
'I should see a customized appearance'
do
page
.
should
have_content
appearance
.
title
expect
(
page
).
to
have_content
appearance
.
title
page
.
should
have_content
appearance
.
description
expect
(
page
).
to
have_content
appearance
.
description
end
end
step
'I attach a logo'
do
step
'I attach a logo'
do
...
@@ -43,11 +43,11 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
...
@@ -43,11 +43,11 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
end
step
'I should see a logo'
do
step
'I should see a logo'
do
page
.
should
have_xpath
(
'//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]'
)
expect
(
page
).
to
have_xpath
(
'//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]'
)
end
end
step
'I should see header logos'
do
step
'I should see header logos'
do
page
.
should
have_xpath
(
'//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]'
)
expect
(
page
).
to
have_xpath
(
'//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]'
)
end
end
step
'I remove the logo'
do
step
'I remove the logo'
do
...
@@ -59,11 +59,11 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
...
@@ -59,11 +59,11 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
end
step
'I should see logo removed'
do
step
'I should see logo removed'
do
page
.
should_not
have_xpath
(
'//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]'
)
expect
(
page
).
not_to
have_xpath
(
'//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]'
)
end
end
step
'I should see header logos removed'
do
step
'I should see header logos removed'
do
page
.
should_not
have_xpath
(
'//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]'
)
expect
(
page
).
not_to
have_xpath
(
'//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]'
)
end
end
def
appearance
def
appearance
...
...
features/steps/admin/email.rb
View file @
ce5bc4f8
...
@@ -50,7 +50,7 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps
...
@@ -50,7 +50,7 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps
end
end
step
'I get redirected to the sign in path'
do
step
'I get redirected to the sign in path'
do
current_path
.
should
==
root_path
expect
(
current_path
).
to
eq
root_path
end
end
step
'unsubscribed email is sent'
do
step
'unsubscribed email is sent'
do
...
...
features/steps/admin/groups.rb
View file @
ce5bc4f8
...
@@ -68,8 +68,8 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
...
@@ -68,8 +68,8 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
end
end
step
'I should see project shared with group'
do
step
'I should see project shared with group'
do
page
.
should
have_content
(
shared_project
.
name_with_namespace
)
expect
(
page
).
to
have_content
(
shared_project
.
name_with_namespace
)
page
.
should
have_content
"Projects shared with"
expect
(
page
).
to
have_content
"Projects shared with"
end
end
step
'we have user "John Doe" in group'
do
step
'we have user "John Doe" in group'
do
...
...
features/steps/admin/settings.rb
View file @
ce5bc4f8
...
@@ -22,7 +22,7 @@ class Spinach::Features::AdminSettings < Spinach::FeatureSteps
...
@@ -22,7 +22,7 @@ class Spinach::Features::AdminSettings < Spinach::FeatureSteps
end
end
step
'I should see the help text'
do
step
'I should see the help text'
do
page
.
should
have_content
help_text
expect
(
page
).
to
have_content
help_text
end
end
step
'I go to help page'
do
step
'I go to help page'
do
...
...
features/steps/admin/users.rb
View file @
ce5bc4f8
...
@@ -149,7 +149,7 @@ class Spinach::Features::AdminUsers < Spinach::FeatureSteps
...
@@ -149,7 +149,7 @@ class Spinach::Features::AdminUsers < Spinach::FeatureSteps
step
'I should not see twitter details'
do
step
'I should not see twitter details'
do
expect
(
page
).
to
have_content
'Pete'
expect
(
page
).
to
have_content
'Pete'
expect
(
page
).
to_not
have_content
'twitter'
expect
(
page
).
not_to
have_content
'twitter'
end
end
step
'click on ssh keys tab'
do
step
'click on ssh keys tab'
do
...
...
features/steps/group_hooks.rb
View file @
ce5bc4f8
...
@@ -28,7 +28,7 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
...
@@ -28,7 +28,7 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
end
end
step
'I should see group hook'
do
step
'I should see group hook'
do
page
.
should
have_content
@hook
.
url
expect
(
page
).
to
have_content
@hook
.
url
end
end
step
'I submit new hook'
do
step
'I submit new hook'
do
...
@@ -38,8 +38,8 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
...
@@ -38,8 +38,8 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
end
end
step
'I should see newly created hook'
do
step
'I should see newly created hook'
do
current_path
.
should
==
group_hooks_path
(
@group
)
expect
(
current_path
).
to
eq
group_hooks_path
(
@group
)
page
.
should
have_content
(
@url
)
expect
(
page
).
to
have_content
(
@url
)
end
end
step
'I click test hook button'
do
step
'I click test hook button'
do
...
@@ -53,18 +53,18 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
...
@@ -53,18 +53,18 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
end
end
step
'hook should be triggered'
do
step
'hook should be triggered'
do
current_path
.
should
==
group_hooks_path
(
@group
)
expect
(
current_path
).
to
eq
group_hooks_path
(
@group
)
page
.
should
have_selector
'.flash-notice'
,
expect
(
page
).
to
have_selector
'.flash-notice'
,
text:
'Hook successfully executed.'
text:
'Hook successfully executed.'
end
end
step
'I should see hook error message'
do
step
'I should see hook error message'
do
page
.
should
have_selector
'.flash-alert'
,
expect
(
page
).
to
have_selector
'.flash-alert'
,
text:
'Hook execution failed. Ensure the group has a project with commits.'
text:
'Hook execution failed. Ensure the group has a project with commits.'
end
end
step
'I should see hook service down error message'
do
step
'I should see hook service down error message'
do
page
.
should
have_selector
'.flash-alert'
,
expect
(
page
).
to
have_selector
'.flash-alert'
,
text:
'Hook execution failed. '
\
text:
'Hook execution failed. '
\
'Ensure hook URL is correct and '
\
'Ensure hook URL is correct and '
\
'service is up.'
'service is up.'
...
...
features/steps/groups.rb
View file @
ce5bc4f8
...
@@ -119,11 +119,11 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
...
@@ -119,11 +119,11 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step
'I should see the audit event listed'
do
step
'I should see the audit event listed'
do
within
(
'table#audits'
)
do
within
(
'table#audits'
)
do
page
.
should
have_content
'Add user access as reporter'
expect
(
page
).
to
have_content
'Add user access as reporter'
page
.
should
have_content
'Change access level from reporter to developer'
expect
(
page
).
to
have_content
'Change access level from reporter to developer'
page
.
should
have_content
'Remove user access'
expect
(
page
).
to
have_content
'Remove user access'
page
.
should
have_content
(
'John Doe'
,
count:
3
)
expect
(
page
).
to
have_content
(
'John Doe'
,
count:
3
)
page
.
should
have_content
(
'Mary Jane'
,
count:
3
)
expect
(
page
).
to
have_content
(
'Mary Jane'
,
count:
3
)
end
end
end
end
...
@@ -143,7 +143,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
...
@@ -143,7 +143,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end
end
Then
'I should be redirected to group page'
do
Then
'I should be redirected to group page'
do
current_path
.
should
==
group_path
(
Group
.
last
)
expect
(
current_path
).
to
eq
group_path
(
Group
.
last
)
end
end
And
'I change group name'
do
And
'I change group name'
do
...
...
features/steps/groups_management.rb
View file @
ce5bc4f8
...
@@ -28,9 +28,9 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
...
@@ -28,9 +28,9 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
end
end
step
'I can control user membership'
do
step
'I can control user membership'
do
page
.
should
have_button
'Add members'
expect
(
page
).
to
have_button
'Add members'
page
.
should
have_link
'Import members'
expect
(
page
).
to
have_link
'Import members'
page
.
should
have_selector
'#project_member_access_level'
expect
(
page
).
to
have_selector
'#project_member_access_level'
end
end
step
'I reload "Open" project members page'
do
step
'I reload "Open" project members page'
do
...
@@ -57,8 +57,8 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
...
@@ -57,8 +57,8 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
end
end
step
'I cannot control user membership from project page'
do
step
'I cannot control user membership from project page'
do
page
.
should_not
have_button
'Add members'
expect
(
page
).
not_to
have_button
'Add members'
page
.
should_not
have_link
'Import members'
expect
(
page
).
not_to
have_link
'Import members'
page
.
should
have_selector
'#project_member_access_level'
expect
(
page
).
to
have_selector
'#project_member_access_level'
end
end
end
end
features/steps/project/audit_event.rb
View file @
ce5bc4f8
...
@@ -18,10 +18,10 @@ class Spinach::Features::AuditEvent < Spinach::FeatureSteps
...
@@ -18,10 +18,10 @@ class Spinach::Features::AuditEvent < Spinach::FeatureSteps
end
end
step
'I see remove deploy key event'
do
step
'I see remove deploy key event'
do
page
.
should
have_content
(
"Remove deploy key"
)
expect
(
page
).
to
have_content
(
"Remove deploy key"
)
end
end
step
'I see deploy key event'
do
step
'I see deploy key event'
do
page
.
should
have_content
(
"Add deploy key"
)
expect
(
page
).
to
have_content
(
"Add deploy key"
)
end
end
end
end
features/steps/project/git_hooks.rb
View file @
ce5bc4f8
...
@@ -10,9 +10,9 @@ class Spinach::Features::GitHooks < Spinach::FeatureSteps
...
@@ -10,9 +10,9 @@ class Spinach::Features::GitHooks < Spinach::FeatureSteps
step
'I should see git hook form'
do
step
'I should see git hook form'
do
page
.
should
have_selector
(
'input#git_hook_commit_message_regex'
)
expect
(
page
).
to
have_selector
(
'input#git_hook_commit_message_regex'
)
page
.
should
have_content
"Commit message"
expect
(
page
).
to
have_content
"Commit message"
page
.
should
have_content
"Commit author's email"
expect
(
page
).
to
have_content
"Commit author's email"
end
end
...
...
features/steps/project/merge_requests.rb
View file @
ce5bc4f8
...
@@ -167,24 +167,24 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -167,24 +167,24 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step
'I should see a discussion has started on diff'
do
step
'I should see a discussion has started on diff'
do
page
.
within
(
".notes .discussion"
)
do
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
current_user
.
name
}
started a discussion"
expect
(
page
).
to
have_content
"
#{
current_user
.
name
}
started a discussion"
page
.
should
have_content
sample_commit
.
line_code_path
expect
(
page
).
to
have_content
sample_commit
.
line_code_path
page
.
should
have_content
"Line is wrong"
expect
(
page
).
to
have_content
"Line is wrong"
end
end
end
end
step
'I should see a discussion has started on commit diff'
do
step
'I should see a discussion has started on commit diff'
do
page
.
within
(
".notes .discussion"
)
do
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
current_user
.
name
}
started a discussion on commit"
expect
(
page
).
to
have_content
"
#{
current_user
.
name
}
started a discussion on commit"
page
.
should
have_content
sample_commit
.
line_code_path
expect
(
page
).
to
have_content
sample_commit
.
line_code_path
page
.
should
have_content
"Line is wrong"
expect
(
page
).
to
have_content
"Line is wrong"
end
end
end
end
step
'I should see a discussion has started on commit'
do
step
'I should see a discussion has started on commit'
do
page
.
within
(
".notes .discussion"
)
do
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
current_user
.
name
}
started a discussion on commit"
expect
(
page
).
to
have_content
"
#{
current_user
.
name
}
started a discussion on commit"
page
.
should
have_content
"One comment to rule them all"
expect
(
page
).
to
have_content
"One comment to rule them all"
end
end
end
end
...
@@ -203,9 +203,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -203,9 +203,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
end
step
'I accept this merge request'
do
step
'I accept this merge request'
do
Gitlab
::
Satellite
::
MergeAction
.
any_instance
.
stub
(
allow_any_instance_of
(
Gitlab
::
Satellite
::
MergeAction
).
to
receive
(
:merge!
).
and_return
(
true
)
merge!:
true
,
)
page
.
within
'.mr-state-widget'
do
page
.
within
'.mr-state-widget'
do
click_button
"Accept Merge Request"
click_button
"Accept Merge Request"
...
@@ -299,7 +297,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -299,7 +297,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
end
step
'I should see description field pre-filled'
do
step
'I should see description field pre-filled'
do
find_field
(
'merge_request_description'
).
value
.
should
==
'This merge request should contain the following.'
expect
(
find_field
(
'merge_request_description'
).
value
).
to
eq
'This merge request should contain the following.'
end
end
step
'I unfold diff'
do
step
'I unfold diff'
do
...
@@ -356,13 +354,13 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -356,13 +354,13 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step
'I should not see merge button'
do
step
'I should not see merge button'
do
within
'.mr-state-widget'
do
within
'.mr-state-widget'
do
page
.
should_not
have_button
(
"Accept Merge Request"
)
expect
(
page
).
not_to
have_button
(
"Accept Merge Request"
)
end
end
end
end
step
'I should see approved merge request "Bug NS-04"'
do
step
'I should see approved merge request "Bug NS-04"'
do
within
'.mr-state-widget'
do
within
'.mr-state-widget'
do
page
.
should
have_button
(
"Accept Merge Request"
)
expect
(
page
).
to
have_button
(
"Accept Merge Request"
)
end
end
end
end
...
...
features/steps/project/network_graph.rb
View file @
ce5bc4f8
...
@@ -9,7 +9,7 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
...
@@ -9,7 +9,7 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
When
'I visit project "Shop" network page'
do
When
'I visit project "Shop" network page'
do
# Stub Graph max_size to speed up test (10 commits vs. 650)
# Stub Graph max_size to speed up test (10 commits vs. 650)
Network
::
Graph
.
stub
(
max_count:
10
)
allow
(
Network
::
Graph
).
to
receive
(
:max_count
).
and_return
(
10
)
project
=
Project
.
find_by
(
name:
"Shop"
)
project
=
Project
.
find_by
(
name:
"Shop"
)
visit
namespace_project_network_path
(
project
.
namespace
,
project
,
"master"
)
visit
namespace_project_network_path
(
project
.
namespace
,
project
,
"master"
)
...
...
features/steps/project/project.rb
View file @
ce5bc4f8
...
@@ -15,7 +15,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
...
@@ -15,7 +15,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step
'I should see project with new settings'
do
step
'I should see project with new settings'
do
expect
(
find_field
(
'project_name'
).
value
).
to
eq
'NewName'
expect
(
find_field
(
'project_name'
).
value
).
to
eq
'NewName'
expect
(
find
(
'#project_issues_enabled'
)).
to_not
be_checked
expect
(
find
(
'#project_issues_enabled'
)).
not_to
be_checked
expect
(
find
(
'#project_merge_requests_enabled'
)).
to
be_checked
expect
(
find
(
'#project_merge_requests_enabled'
)).
to
be_checked
end
end
...
@@ -74,12 +74,12 @@ class Spinach::Features::Project < Spinach::FeatureSteps
...
@@ -74,12 +74,12 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
end
step
'I should see project with merge request template saved'
do
step
'I should see project with merge request template saved'
do
find_field
(
'project_merge_requests_template'
).
value
.
should
==
'This merge request should contain the following.'
expect
(
find_field
(
'project_merge_requests_template'
).
value
).
to
eq
'This merge request should contain the following.'
end
end
step
'I should see project "Shop" README link'
do
step
'I should see project "Shop" README link'
do
within
'.project-side'
do
within
'.project-side'
do
page
.
should
have_content
"README.md"
expect
(
page
).
to
have_content
"README.md"
end
end
end
end
...
@@ -149,9 +149,9 @@ class Spinach::Features::Project < Spinach::FeatureSteps
...
@@ -149,9 +149,9 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step
'I should see the audit event listed'
do
step
'I should see the audit event listed'
do
within
(
'table#audits'
)
do
within
(
'table#audits'
)
do
page
.
should
have_content
"Change access level from developer to master"
expect
(
page
).
to
have_content
"Change access level from developer to master"
page
.
should
have_content
(
project
.
owner
.
name
)
expect
(
page
).
to
have_content
(
project
.
owner
.
name
)
page
.
should
have_content
(
'Pete'
)
expect
(
page
).
to
have_content
(
'Pete'
)
end
end
end
end
...
...
features/steps/project/project_group_links.rb
View file @
ce5bc4f8
...
@@ -6,13 +6,13 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
...
@@ -6,13 +6,13 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
step
'I should see project already shared with group "Ops"'
do
step
'I should see project already shared with group "Ops"'
do
within
'.enabled-groups'
do
within
'.enabled-groups'
do
page
.
should
have_content
"Ops"
expect
(
page
).
to
have_content
"Ops"
end
end
end
end
step
'I should see project is not shared with group "Market"'
do
step
'I should see project is not shared with group "Market"'
do
within
'.enabled-groups'
do
within
'.enabled-groups'
do
page
.
should_not
have_content
"Market"
expect
(
page
).
not_to
have_content
"Market"
end
end
end
end
...
@@ -25,7 +25,7 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
...
@@ -25,7 +25,7 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
step
'I should see project is shared with group "Market"'
do
step
'I should see project is shared with group "Market"'
do
within
'.enabled-groups'
do
within
'.enabled-groups'
do
page
.
should
have_content
"Market"
expect
(
page
).
to
have_content
"Market"
end
end
end
end
...
...
features/steps/project/redirects.rb
View file @
ce5bc4f8
...
@@ -17,7 +17,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
...
@@ -17,7 +17,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
end
end
step
'I should see project "Community" home page'
do
step
'I should see project "Community" home page'
do
Gitlab
.
config
.
gitlab
.
should_
receive
(
:host
).
and_return
(
"www.example.com"
)
expect
(
Gitlab
.
config
.
gitlab
).
to
receive
(
:host
).
and_return
(
"www.example.com"
)
page
.
within
'.navbar-gitlab .title'
do
page
.
within
'.navbar-gitlab .title'
do
expect
(
page
).
to
have_content
'Community'
expect
(
page
).
to
have_content
'Community'
end
end
...
...
features/steps/project/services.rb
View file @
ce5bc4f8
...
@@ -198,10 +198,10 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -198,10 +198,10 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
end
end
step
'I should see jira service settings saved'
do
step
'I should see jira service settings saved'
do
find_field
(
'Project url'
).
value
.
should
==
'http://jira.example'
expect
(
find_field
(
'Project url'
).
value
).
to
eq
'http://jira.example'
find_field
(
'Username'
).
value
.
should
==
'gitlab'
expect
(
find_field
(
'Username'
).
value
).
to
eq
'gitlab'
find_field
(
'Password'
).
value
.
should_not
==
'gitlab'
expect
(
find_field
(
'Password'
).
value
).
not_to
eq
'gitlab'
find_field
(
'Api version'
).
value
.
should
==
'2'
expect
(
find_field
(
'Api version'
).
value
).
to
eq
'2'
end
end
step
'I click Atlassian Bamboo CI service link'
do
step
'I click Atlassian Bamboo CI service link'
do
...
...
features/steps/project/team_management.rb
View file @
ce5bc4f8
...
@@ -142,8 +142,8 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
...
@@ -142,8 +142,8 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
end
end
step
'I should see "Opensource" group user listing'
do
step
'I should see "Opensource" group user listing'
do
page
.
should
have_content
(
"Shared with OpenSource group, members with Master role (2)"
)
expect
(
page
).
to
have_content
(
"Shared with OpenSource group, members with Master role (2)"
)
page
.
should
have_content
(
@os_user1
.
name
)
expect
(
page
).
to
have_content
(
@os_user1
.
name
)
page
.
should
have_content
(
@os_user2
.
name
)
expect
(
page
).
to
have_content
(
@os_user2
.
name
)
end
end
end
end
features/steps/project/wiki.rb
View file @
ce5bc4f8
...
@@ -96,8 +96,8 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
...
@@ -96,8 +96,8 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
step
'I click on existing image link'
do
step
'I click on existing image link'
do
file
=
Gollum
::
File
.
new
(
wiki
.
wiki
)
file
=
Gollum
::
File
.
new
(
wiki
.
wiki
)
Gollum
::
Wiki
.
any_instance
.
stub
(
:file
).
with
(
"image.jpg"
,
"master"
,
true
).
and_return
(
file
)
allow_any_instance_of
(
Gollum
::
Wiki
).
to
receive
(
:file
).
with
(
"image.jpg"
,
"master"
,
true
).
and_return
(
file
)
Gollum
::
File
.
any_instance
.
stub
(
:mime_type
).
and_return
(
"image/jpeg"
)
allow_any_instance_of
(
Gollum
::
File
).
to
receive
(
:mime_type
).
and_return
(
"image/jpeg"
)
expect
(
page
).
to
have_link
(
'image'
,
href:
"image.jpg"
)
expect
(
page
).
to
have_link
(
'image'
,
href:
"image.jpg"
)
click_on
"image"
click_on
"image"
end
end
...
...
features/steps/search.rb
View file @
ce5bc4f8
...
@@ -53,7 +53,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
...
@@ -53,7 +53,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
step
'I should see code results for project "Shop"'
do
step
'I should see code results for project "Shop"'
do
page
.
within
(
'.results'
)
do
page
.
within
(
'.results'
)
do
page
.
should
have_content
'Update capybara, rspec-rails, poltergeist to recent versions'
expect
(
page
).
to
have_content
'Update capybara, rspec-rails, poltergeist to recent versions'
end
end
end
end
...
@@ -74,7 +74,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
...
@@ -74,7 +74,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
step
'I should see "Foo" link in the search results'
do
step
'I should see "Foo" link in the search results'
do
page
.
within
(
'.results'
)
do
page
.
within
(
'.results'
)
do
find
(
:css
,
'.search-results'
).
should
have_link
'Foo'
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
'Foo'
end
end
end
end
...
@@ -84,7 +84,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
...
@@ -84,7 +84,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
step
'I should see "test_wiki" link in the search results'
do
step
'I should see "test_wiki" link in the search results'
do
page
.
within
(
'.results'
)
do
page
.
within
(
'.results'
)
do
find
(
:css
,
'.search-results'
).
should
have_link
'test_wiki.md'
expect
(
find
(
:css
,
'.search-results'
)).
to
have_link
'test_wiki.md'
end
end
end
end
...
...
features/steps/shared/paths.rb
View file @
ce5bc4f8
...
@@ -242,7 +242,7 @@ module SharedPaths
...
@@ -242,7 +242,7 @@ module SharedPaths
step
"I visit my project's network page"
do
step
"I visit my project's network page"
do
# Stub Graph max_size to speed up test (10 commits vs. 650)
# Stub Graph max_size to speed up test (10 commits vs. 650)
Network
::
Graph
.
stub
(
max_count:
10
)
allow
(
Network
::
Graph
).
to
receive
(
:max_count
).
and_return
(
10
)
visit
namespace_project_network_path
(
@project
.
namespace
,
@project
,
root_ref
)
visit
namespace_project_network_path
(
@project
.
namespace
,
@project
,
root_ref
)
end
end
...
...
features/steps/user.rb
View file @
ce5bc4f8
...
@@ -14,7 +14,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
...
@@ -14,7 +14,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
end
end
step
'I should see unsubscribe text and button'
do
step
'I should see unsubscribe text and button'
do
page
.
should
have_content
"Unsubscribe from Admin notifications Yes, I want to unsubscribe joh@doe.org from any further admin emails."
expect
(
page
).
to
have_content
"Unsubscribe from Admin notifications Yes, I want to unsubscribe joh@doe.org from any further admin emails."
end
end
step
'I press the unsubscribe button'
do
step
'I press the unsubscribe button'
do
...
@@ -22,7 +22,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
...
@@ -22,7 +22,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
end
end
step
'I should be unsubscribed'
do
step
'I should be unsubscribed'
do
current_path
.
should
==
root_path
expect
(
current_path
).
to
eq
root_path
end
end
step
'"John Doe" has contributions'
do
step
'"John Doe" has contributions'
do
...
...
spec/features/issues_spec.rb
View file @
ce5bc4f8
...
@@ -36,7 +36,7 @@ describe 'Issues', feature: true do
...
@@ -36,7 +36,7 @@ describe 'Issues', feature: true do
end
end
it
'does not change issue count'
do
it
'does not change issue count'
do
expect
{
click_button
'Save changes'
}.
to_not
change
{
Issue
.
count
}
expect
{
click_button
'Save changes'
}.
not_to
change
{
Issue
.
count
}
end
end
it
'should update issue fields'
do
it
'should update issue fields'
do
...
...
spec/helpers/merge_request_helper_spec.rb
View file @
ce5bc4f8
...
@@ -7,16 +7,16 @@ describe MergeRequestsHelper do
...
@@ -7,16 +7,16 @@ describe MergeRequestsHelper do
let
(
:last_commit
)
{
Commit
.
new
({},
project
)
}
let
(
:last_commit
)
{
Commit
.
new
({},
project
)
}
before
do
before
do
merge_request
.
stub
(
:source_project
)
{
project
}
allow
(
merge_request
).
to
receive
(
:source_project
)
{
project
}
merge_request
.
stub
(
:last_commit
)
{
last_commit
}
allow
(
merge_request
).
to
receive
(
:last_commit
)
{
last_commit
}
project
.
stub
(
:ci_service
)
{
ci_service
}
allow
(
project
).
to
receive
(
:ci_service
)
{
ci_service
}
last_commit
.
stub
(
:sha
)
{
'12d65c'
}
allow
(
last_commit
).
to
receive
(
:sha
)
{
'12d65c'
}
end
end
describe
'ci_build_details_path'
do
describe
'ci_build_details_path'
do
it
'does not include api credentials in a link'
do
it
'does not include api credentials in a link'
do
ci_service
.
stub
(
:build_page
)
{
"http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c"
}
allow
(
ci_service
).
to
receive
(
:build_page
)
{
"http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c"
}
expect
(
ci_build_details_path
(
merge_request
)).
to_not
match
(
"secret"
)
expect
(
ci_build_details_path
(
merge_request
)).
not_to
match
(
"secret"
)
end
end
end
end
...
...
spec/helpers/oauth_helper_spec.rb
View file @
ce5bc4f8
...
@@ -21,12 +21,12 @@ describe OauthHelper do
...
@@ -21,12 +21,12 @@ describe OauthHelper do
describe
"kerberos_enabled?"
do
describe
"kerberos_enabled?"
do
it
'returns true'
do
it
'returns true'
do
allow
(
helper
).
to
receive
(
:enabled_oauth_providers
)
{
[
:twitter
,
:github
,
:kerberos
]
}
allow
(
helper
).
to
receive
(
:enabled_oauth_providers
)
{
[
:twitter
,
:github
,
:kerberos
]
}
helper
.
kerberos_enabled?
.
should
be_truthy
expect
(
helper
).
to
be_kerberos_enabled
end
end
it
'returns false'
do
it
'returns false'
do
allow
(
helper
).
to
receive
(
:enabled_oauth_providers
)
{
[
:twitter
,
:ldapmain
]
}
allow
(
helper
).
to
receive
(
:enabled_oauth_providers
)
{
[
:twitter
,
:ldapmain
]
}
helper
.
kerberos_enabled?
.
should
be_falsey
expect
(
helper
).
not_to
be_kerberos_enabled
end
end
end
end
end
end
spec/lib/gitlab/auth_spec.rb
View file @
ce5bc4f8
...
@@ -36,11 +36,13 @@ describe Gitlab::Auth do
...
@@ -36,11 +36,13 @@ describe Gitlab::Auth do
end
end
context
"with kerberos"
do
context
"with kerberos"
do
before
{
Devise
.
stub
(
omniauth_providers:
[
:kerberos
])
}
before
do
allow
(
Devise
).
to
receive_messages
(
omniauth_providers:
[
:kerberos
])
end
it
"finds user"
do
it
"finds user"
do
Gitlab
::
Kerberos
::
Authentication
.
stub
(
valid?:
true
)
allow
(
Gitlab
::
Kerberos
::
Authentication
).
to
receive_messages
(
valid?:
true
)
Gitlab
::
Kerberos
::
Authentication
.
stub
(
email:
user
.
email
)
allow
(
Gitlab
::
Kerberos
::
Authentication
).
to
receive_messages
(
email:
user
.
email
)
expect
(
gl_auth
.
find
(
username
,
password
)
).
to
eql
user
expect
(
gl_auth
.
find
(
username
,
password
)
).
to
eql
user
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
ce5bc4f8
...
@@ -249,19 +249,19 @@ describe Gitlab::GitAccess do
...
@@ -249,19 +249,19 @@ describe Gitlab::GitAccess do
describe
"git_hook_check"
do
describe
"git_hook_check"
do
describe
"author email check"
do
describe
"author email check"
do
it
'returns true'
do
it
'returns true'
do
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
).
should
be_truthy
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
)).
to
be_truthy
end
end
it
'returns false'
do
it
'returns false'
do
project
.
create_git_hook
project
.
create_git_hook
project
.
git_hook
.
update
(
commit_message_regex:
"@only.com"
)
project
.
git_hook
.
update
(
commit_message_regex:
"@only.com"
)
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
).
allowed?
.
should
be_falsey
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
)).
not_to
be_allowed
end
end
it
'returns true for tags'
do
it
'returns true for tags'
do
project
.
create_git_hook
project
.
create_git_hook
project
.
git_hook
.
update
(
commit_message_regex:
"@only.com"
)
project
.
git_hook
.
update
(
commit_message_regex:
"@only.com"
)
access
.
git_hook_check
(
user
,
project
,
'refs/tags/v1'
,
'6f6d7e7ed'
,
'570e7b2ab'
).
allowed?
.
should
be_truthy
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/tags/v1'
,
'6f6d7e7ed'
,
'570e7b2ab'
)).
to
be_allowed
end
end
end
end
...
@@ -272,12 +272,12 @@ describe Gitlab::GitAccess do
...
@@ -272,12 +272,12 @@ describe Gitlab::GitAccess do
end
end
it
'returns false for non-member user'
do
it
'returns false for non-member user'
do
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
).
allowed?
.
should
be_falsey
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
)).
not_to
be_allowed
end
end
it
'returns true if committer is a gitlab member'
do
it
'returns true if committer is a gitlab member'
do
create
(
:user
,
email:
'dmitriy.zaporozhets@gmail.com'
)
create
(
:user
,
email:
'dmitriy.zaporozhets@gmail.com'
)
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
).
allowed?
.
should
be_truthy
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'6f6d7e7ed'
,
'570e7b2ab'
)).
to
be_allowed
end
end
end
end
...
@@ -285,13 +285,13 @@ describe Gitlab::GitAccess do
...
@@ -285,13 +285,13 @@ describe Gitlab::GitAccess do
it
'returns false when filename is prohibited'
do
it
'returns false when filename is prohibited'
do
project
.
create_git_hook
project
.
create_git_hook
project
.
git_hook
.
update
(
file_name_regex:
"jpg$"
)
project
.
git_hook
.
update
(
file_name_regex:
"jpg$"
)
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'913c66a37'
,
'33f3729a4'
).
allowed?
.
should
be_falsey
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'913c66a37'
,
'33f3729a4'
)).
not_to
be_allowed
end
end
it
'returns true if file name is allowed'
do
it
'returns true if file name is allowed'
do
project
.
create_git_hook
project
.
create_git_hook
project
.
git_hook
.
update
(
file_name_regex:
"exe$"
)
project
.
git_hook
.
update
(
file_name_regex:
"exe$"
)
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'913c66a37'
,
'33f3729a4'
).
allowed?
.
should
be_truthy
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'913c66a37'
,
'33f3729a4'
)).
to
be_allowed
end
end
end
end
...
@@ -303,13 +303,13 @@ describe Gitlab::GitAccess do
...
@@ -303,13 +303,13 @@ describe Gitlab::GitAccess do
it
"returns false when size is too large"
do
it
"returns false when size is too large"
do
project
.
create_git_hook
project
.
create_git_hook
project
.
git_hook
.
update
(
max_file_size:
1
)
project
.
git_hook
.
update
(
max_file_size:
1
)
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'cfe32cf6'
,
'913c66a37'
).
allowed?
.
should
be_falsey
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'cfe32cf6'
,
'913c66a37'
)).
not_to
be_allowed
end
end
it
"returns true when size is allowed"
do
it
"returns true when size is allowed"
do
project
.
create_git_hook
project
.
create_git_hook
project
.
git_hook
.
update
(
max_file_size:
2
)
project
.
git_hook
.
update
(
max_file_size:
2
)
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'cfe32cf6'
,
'913c66a37'
).
allowed?
.
should
be_truthy
expect
(
access
.
git_hook_check
(
user
,
project
,
'refs/heads/master'
,
'cfe32cf6'
,
'913c66a37'
)).
to
be_allowed
end
end
end
end
end
end
...
...
spec/lib/gitlab/kerberos/authentication_spec.rb
View file @
ce5bc4f8
...
@@ -8,13 +8,12 @@ describe Gitlab::Kerberos::Authentication do
...
@@ -8,13 +8,12 @@ describe Gitlab::Kerberos::Authentication do
describe
:login
do
describe
:login
do
before
do
before
do
Devise
.
stub
(
omniauth_providers:
[
:kerberos
])
allow
(
Devise
).
to
receive_messages
(
omniauth_providers:
[
:kerberos
])
end
end
it
"finds the user if authentication is successful"
do
it
"finds the user if authentication is successful"
do
kerberos_realm
=
user
.
email
.
sub
(
/.*@/
,
''
)
kerberos_realm
=
user
.
email
.
sub
(
/.*@/
,
''
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_init_creds_password:
true
)
allow_any_instance_of
(
::
Krb5Auth
::
Krb5
).
to
receive_messages
(
get_init_creds_password:
true
,
get_default_realm:
kerberos_realm
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_default_realm:
kerberos_realm
)
expect
(
klass
.
login
(
'gitlab'
,
password
)).
to
be_truthy
expect
(
klass
.
login
(
'gitlab'
,
password
)).
to
be_truthy
end
end
...
@@ -22,8 +21,7 @@ describe Gitlab::Kerberos::Authentication do
...
@@ -22,8 +21,7 @@ describe Gitlab::Kerberos::Authentication do
it
"returns false if there is no such user in kerberos"
do
it
"returns false if there is no such user in kerberos"
do
kerberos_login
=
"some-login"
kerberos_login
=
"some-login"
kerberos_realm
=
user
.
email
.
sub
(
/.*@/
,
''
)
kerberos_realm
=
user
.
email
.
sub
(
/.*@/
,
''
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_init_creds_password:
true
)
allow_any_instance_of
(
::
Krb5Auth
::
Krb5
).
to
receive_messages
(
get_init_creds_password:
true
,
get_default_realm:
kerberos_realm
)
::
Krb5Auth
::
Krb5
.
any_instance
.
stub
(
get_default_realm:
kerberos_realm
)
expect
(
klass
.
login
(
kerberos_login
,
password
)).
to
be_falsy
expect
(
klass
.
login
(
kerberos_login
,
password
)).
to
be_falsy
end
end
...
...
spec/lib/gitlab/ldap/access_spec.rb
View file @
ce5bc4f8
...
@@ -88,29 +88,28 @@ describe Gitlab::LDAP::Access do
...
@@ -88,29 +88,28 @@ describe Gitlab::LDAP::Access do
subject
{
access
.
update_permissions
}
subject
{
access
.
update_permissions
}
it
"syncs ssh keys if enabled by configuration"
do
it
"syncs ssh keys if enabled by configuration"
do
a
ccess
.
stub
sync_ssh_keys?:
'sshpublickey'
a
llow
(
access
).
to
receive_messages
(
sync_ssh_keys?:
'sshpublickey'
)
expect
(
access
).
to
receive
(
:update_ssh_keys
).
once
expect
(
access
).
to
receive
(
:update_ssh_keys
).
once
subject
subject
end
end
it
"does update group permissions with a group base configured"
do
it
"does update group permissions with a group base configured"
do
a
ccess
.
stub
group_base:
'my-group-base'
a
llow
(
access
).
to
receive_messages
(
group_base:
'my-group-base'
)
expect
(
access
).
to
receive
(
:update_ldap_group_links
)
expect
(
access
).
to
receive
(
:update_ldap_group_links
)
subject
subject
end
end
it
"does not update group permissions without a group base configured"
do
it
"does not update group permissions without a group base configured"
do
a
ccess
.
stub
group_base:
''
a
llow
(
access
).
to
receive_messages
(
group_base:
''
)
expect
(
access
).
not_to
receive
(
:update_ldap_group_links
)
expect
(
access
).
not_to
receive
(
:update_ldap_group_links
)
subject
subject
end
end
it
"does update admin group permissions if admin group is configured"
do
it
"does update admin group permissions if admin group is configured"
do
access
.
stub
admin_group:
'my-admin-group'
allow
(
access
).
to
receive_messages
(
admin_group:
'my-admin-group'
,
update_ldap_group_links:
nil
)
access
.
stub
:update_ldap_group_links
expect
(
access
).
to
receive
(
:update_admin_status
)
expect
(
access
).
to
receive
(
:update_admin_status
)
subject
subject
...
@@ -125,18 +124,18 @@ describe Gitlab::LDAP::Access do
...
@@ -125,18 +124,18 @@ describe Gitlab::LDAP::Access do
end
end
before
do
before
do
Gitlab
::
LDAP
::
Config
.
any_instance
.
stub
(
sync_ssh_keys:
ssh_key_attribute_name
)
allow_any_instance_of
(
Gitlab
::
LDAP
::
Config
).
to
receive_messages
(
sync_ssh_keys:
ssh_key_attribute_name
)
a
ccess
.
stub
sync_ssh_keys?:
true
a
llow
(
access
).
to
receive_messages
(
sync_ssh_keys?:
true
)
end
end
it
"should add a SSH key if it is in LDAP but not in gitlab"
do
it
"should add a SSH key if it is in LDAP but not in gitlab"
do
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
expect
{
access
.
update_ssh_keys
}.
to
change
(
user
.
keys
,
:count
).
from
(
0
).
to
(
1
)
expect
{
access
.
update_ssh_keys
}.
to
change
(
user
.
keys
,
:count
).
from
(
0
).
to
(
1
)
end
end
it
"should add a SSH key and give it a proper name"
do
it
"should add a SSH key and give it a proper name"
do
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
access
.
update_ssh_keys
access
.
update_ssh_keys
expect
(
user
.
keys
.
last
.
title
).
to
match
(
/LDAP/
)
expect
(
user
.
keys
.
last
.
title
).
to
match
(
/LDAP/
)
...
@@ -145,9 +144,9 @@ describe Gitlab::LDAP::Access do
...
@@ -145,9 +144,9 @@ describe Gitlab::LDAP::Access do
it
"should not add a SSH key if it is invalid"
do
it
"should not add a SSH key if it is invalid"
do
entry
=
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com
\n
#{
ssh_key_attribute_name
}
: I am not a valid key"
)
entry
=
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com
\n
#{
ssh_key_attribute_name
}
: I am not a valid key"
)
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
expect
{
access
.
update_ssh_keys
}.
to_not
change
(
user
.
keys
,
:count
)
expect
{
access
.
update_ssh_keys
}.
not_to
change
(
user
.
keys
,
:count
)
end
end
context
'user has at least one LDAPKey'
do
context
'user has at least one LDAPKey'
do
...
@@ -155,14 +154,14 @@ describe Gitlab::LDAP::Access do
...
@@ -155,14 +154,14 @@ describe Gitlab::LDAP::Access do
it
"should remove a SSH key if it is no longer in LDAP"
do
it
"should remove a SSH key if it is no longer in LDAP"
do
entry
=
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com
\n
#{
ssh_key_attribute_name
}
:
\n
"
)
entry
=
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com
\n
#{
ssh_key_attribute_name
}
:
\n
"
)
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
expect
{
access
.
update_ssh_keys
}.
to
change
(
user
.
keys
,
:count
).
from
(
1
).
to
(
0
)
expect
{
access
.
update_ssh_keys
}.
to
change
(
user
.
keys
,
:count
).
from
(
1
).
to
(
0
)
end
end
it
"should remove a SSH key if the ldap attribute was removed"
do
it
"should remove a SSH key if the ldap attribute was removed"
do
entry
=
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com"
)
entry
=
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
"dn: cn=foo, dc=bar, dc=com"
)
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
expect
{
access
.
update_ssh_keys
}.
to
change
(
user
.
keys
,
:count
).
from
(
1
).
to
(
0
)
expect
{
access
.
update_ssh_keys
}.
to
change
(
user
.
keys
,
:count
).
from
(
1
).
to
(
0
)
end
end
...
@@ -173,21 +172,21 @@ describe Gitlab::LDAP::Access do
...
@@ -173,21 +172,21 @@ describe Gitlab::LDAP::Access do
let
(
:entry
)
{
Net
::
LDAP
::
Entry
.
new
}
let
(
:entry
)
{
Net
::
LDAP
::
Entry
.
new
}
before
do
before
do
a
ccess
.
stub
ldap_user:
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
user
.
ldap_identity
.
provider
)
a
llow
(
access
).
to
receive_messages
(
ldap_user:
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
user
.
ldap_identity
.
provider
)
)
end
end
it
"should not update email if email attribute is not set"
do
it
"should not update email if email attribute is not set"
do
expect
{
access
.
update_email
}.
to_not
change
(
user
,
:email
)
expect
{
access
.
update_email
}.
not_to
change
(
user
,
:email
)
end
end
it
"should not update the email if the user has the same email in GitLab and in LDAP"
do
it
"should not update the email if the user has the same email in GitLab and in LDAP"
do
entry
[
'mail'
]
=
[
user
.
email
]
entry
[
'mail'
]
=
[
user
.
email
]
expect
{
access
.
update_email
}.
to_not
change
(
user
,
:email
)
expect
{
access
.
update_email
}.
not_to
change
(
user
,
:email
)
end
end
it
"should not update the email if the user has the same email GitLab and in LDAP, but with upper case in LDAP"
do
it
"should not update the email if the user has the same email GitLab and in LDAP, but with upper case in LDAP"
do
entry
[
'mail'
]
=
[
user
.
email
.
upcase
]
entry
[
'mail'
]
=
[
user
.
email
.
upcase
]
expect
{
access
.
update_email
}.
to_not
change
(
user
,
:email
)
expect
{
access
.
update_email
}.
not_to
change
(
user
,
:email
)
end
end
it
"should update the email if the user email is different"
do
it
"should update the email if the user email is different"
do
...
@@ -199,10 +198,10 @@ describe Gitlab::LDAP::Access do
...
@@ -199,10 +198,10 @@ describe Gitlab::LDAP::Access do
describe
:update_admin_status
do
describe
:update_admin_status
do
before
do
before
do
a
ccess
.
stub
(
admin_group:
"GLAdmins"
)
a
llow
(
access
).
to
receive_messages
(
admin_group:
"GLAdmins"
)
ldap_user_entry
=
Net
::
LDAP
::
Entry
.
new
ldap_user_entry
=
Net
::
LDAP
::
Entry
.
new
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
ldap_user_entry
,
user
.
ldap_identity
.
provider
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
ldap_user_entry
,
user
.
ldap_identity
.
provider
)
}
Gitlab
::
LDAP
::
Person
.
any_instance
.
stub
(
:uid
)
{
'admin2'
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Person
).
to
receive
(
:uid
)
{
'admin2'
}
end
end
it
"should give admin privileges to an User"
do
it
"should give admin privileges to an User"
do
...
@@ -217,7 +216,7 @@ memberuid: admin3
...
@@ -217,7 +216,7 @@ memberuid: admin3
objectclass: top
objectclass: top
objectclass: posixGroup
objectclass: posixGroup
}
)
}
)
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:group
)
{
Gitlab
::
LDAP
::
Group
.
new
(
admin_group
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:group
)
{
Gitlab
::
LDAP
::
Group
.
new
(
admin_group
)
}
expect
{
access
.
update_admin_status
}.
to
change
(
user
,
:admin?
).
to
(
true
)
expect
{
access
.
update_admin_status
}.
to
change
(
user
,
:admin?
).
to
(
true
)
end
end
...
@@ -234,7 +233,7 @@ memberuid: admin3
...
@@ -234,7 +233,7 @@ memberuid: admin3
objectclass: top
objectclass: top
objectclass: posixGroup
objectclass: posixGroup
}
)
}
)
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:group
)
{
Gitlab
::
LDAP
::
Group
.
new
(
admin_group
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:group
)
{
Gitlab
::
LDAP
::
Group
.
new
(
admin_group
)
}
expect
{
access
.
update_admin_status
}.
to
change
(
user
,
:admin?
).
to
(
false
)
expect
{
access
.
update_admin_status
}.
to
change
(
user
,
:admin?
).
to
(
false
)
end
end
end
end
...
@@ -246,7 +245,7 @@ objectclass: posixGroup
...
@@ -246,7 +245,7 @@ objectclass: posixGroup
let
(
:gitlab_group_2
)
{
create
:group
}
let
(
:gitlab_group_2
)
{
create
:group
}
before
do
before
do
a
ccess
.
stub
(
cns_with_access:
cns_with_access
)
a
llow
(
access
).
to
receive_messages
(
cns_with_access:
cns_with_access
)
end
end
context
"non existing access for group-1, allowed via ldap-group1 as MASTER"
do
context
"non existing access for group-1, allowed via ldap-group1 as MASTER"
do
...
@@ -291,7 +290,7 @@ objectclass: posixGroup
...
@@ -291,7 +290,7 @@ objectclass: posixGroup
before
do
before
do
gitlab_group_1
.
group_members
.
masters
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
group_members
.
masters
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
ldap_group_links
.
create
(
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
MASTER
,
provider:
'ldapmain'
)
gitlab_group_1
.
ldap_group_links
.
create
(
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
MASTER
,
provider:
'ldapmain'
)
a
ccess
.
stub
(
cns_with_access:
[
'ldap-group2'
])
a
llow
(
access
).
to
receive_messages
(
cns_with_access:
[
'ldap-group2'
])
end
end
it
"removes user from gitlab_group_1"
do
it
"removes user from gitlab_group_1"
do
...
@@ -304,7 +303,7 @@ objectclass: posixGroup
...
@@ -304,7 +303,7 @@ objectclass: posixGroup
before
do
before
do
gitlab_group_1
.
group_members
.
owners
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
group_members
.
owners
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
ldap_group_links
.
create
(
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
OWNER
,
provider:
'ldapmain'
)
gitlab_group_1
.
ldap_group_links
.
create
(
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
OWNER
,
provider:
'ldapmain'
)
a
ccess
.
stub
(
cns_with_access:
[
'ldap-group2'
])
a
llow
(
access
).
to
receive_messages
(
cns_with_access:
[
'ldap-group2'
])
end
end
it
"does not remove the user from gitlab_group_1 since it's the last owner"
do
it
"does not remove the user from gitlab_group_1 since it's the last owner"
do
...
@@ -318,7 +317,7 @@ objectclass: posixGroup
...
@@ -318,7 +317,7 @@ objectclass: posixGroup
owner2
=
create
(
:user
)
# a 2nd owner
owner2
=
create
(
:user
)
# a 2nd owner
gitlab_group_1
.
group_members
.
owners
.
create
([{
user_id:
user
.
id
},
{
user_id:
owner2
.
id
}])
gitlab_group_1
.
group_members
.
owners
.
create
([{
user_id:
user
.
id
},
{
user_id:
owner2
.
id
}])
gitlab_group_1
.
ldap_group_links
.
create
(
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
OWNER
,
provider:
'ldapmain'
)
gitlab_group_1
.
ldap_group_links
.
create
(
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
OWNER
,
provider:
'ldapmain'
)
a
ccess
.
stub
(
cns_with_access:
[
'ldap-group2'
])
a
llow
(
access
).
to
receive_messages
(
cns_with_access:
[
'ldap-group2'
])
end
end
it
"removes user from gitlab_group_1"
do
it
"removes user from gitlab_group_1"
do
...
@@ -345,14 +344,14 @@ objectclass: posixGroup
...
@@ -345,14 +344,14 @@ objectclass: posixGroup
it
"returns an interator of LDAP Groups"
do
it
"returns an interator of LDAP Groups"
do
::
LdapGroupLink
.
create
({
::
LdapGroupLink
.
create
({
cn:
'example'
,
group_access:
Gitlab
::
Access
::
DEVELOPER
,
group_id:
42
,
provider:
'ldapmain'
})
cn:
'example'
,
group_access:
Gitlab
::
Access
::
DEVELOPER
,
group_id:
42
,
provider:
'ldapmain'
})
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
:group
)
{
Gitlab
::
LDAP
::
Group
.
new
(
ldap_group_1
)
}
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:group
)
{
Gitlab
::
LDAP
::
Group
.
new
(
ldap_group_1
)
}
expect
(
access
.
ldap_groups
.
first
).
to
be_a
Gitlab
::
LDAP
::
Group
expect
(
access
.
ldap_groups
.
first
).
to
be_a
Gitlab
::
LDAP
::
Group
end
end
it
"only returns found ldap groups"
do
it
"only returns found ldap groups"
do
::
LdapGroupLink
.
create
cn:
'example'
,
group_access:
Gitlab
::
Access
::
DEVELOPER
,
group_id:
42
::
LdapGroupLink
.
create
cn:
'example'
,
group_access:
Gitlab
::
Access
::
DEVELOPER
,
group_id:
42
Gitlab
::
LDAP
::
Group
.
stub
(
find_by_cn:
nil
)
# group not found
allow
(
Gitlab
::
LDAP
::
Group
).
to
receive_messages
(
find_by_cn:
nil
)
# group not found
expect
(
access
.
ldap_groups
).
to
be_empty
expect
(
access
.
ldap_groups
).
to
be_empty
end
end
...
@@ -392,13 +391,13 @@ objectclass: posixGroup
...
@@ -392,13 +391,13 @@ objectclass: posixGroup
let
(
:ldap_user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
Net
::
LDAP
::
Entry
.
new
,
user
.
ldap_identity
.
provider
)
}
let
(
:ldap_user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
Net
::
LDAP
::
Entry
.
new
,
user
.
ldap_identity
.
provider
)
}
before
do
before
do
a
ccess
.
stub
(
ldap_user:
ldap_user
)
a
llow
(
access
).
to
receive_messages
(
ldap_user:
ldap_user
)
ldap_user
.
stub
(
:uid
)
{
'user1'
}
allow
(
ldap_user
).
to
receive
(
:uid
)
{
'user1'
}
ldap_user
.
stub
(
:dn
)
{
'uid=user1,ou=People,dc=example'
}
allow
(
ldap_user
).
to
receive
(
:dn
)
{
'uid=user1,ou=People,dc=example'
}
end
end
it
"only returns ldap cns to which the user has access"
do
it
"only returns ldap cns to which the user has access"
do
a
ccess
.
stub
(
ldap_groups:
ldap_groups
)
a
llow
(
access
).
to
receive_messages
(
ldap_groups:
ldap_groups
)
expect
(
access
.
cns_with_access
).
to
eql
[
'group1'
]
expect
(
access
.
cns_with_access
).
to
eql
[
'group1'
]
end
end
end
end
...
...
spec/lib/gitlab/ldap/person_spec.rb
View file @
ce5bc4f8
...
@@ -13,7 +13,7 @@ describe Gitlab::LDAP::Person do
...
@@ -13,7 +13,7 @@ describe Gitlab::LDAP::Person do
subject
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
subject
{
Gitlab
::
LDAP
::
Person
.
new
(
entry
,
'ldapmain'
)
}
before
do
before
do
Gitlab
::
LDAP
::
Config
.
any_instance
.
stub
(
sync_ssh_keys:
ssh_key_attribute_name
)
allow_any_instance_of
(
Gitlab
::
LDAP
::
Config
).
to
receive_messages
(
sync_ssh_keys:
ssh_key_attribute_name
)
end
end
context
"when the SSH key is literal"
do
context
"when the SSH key is literal"
do
...
...
spec/lib/gitlab/satellite/merge_action_spec.rb
View file @
ce5bc4f8
require
'spec_helper'
require
'spec_helper'
describe
'Gitlab::Satellite::MergeAction'
do
describe
Gitlab
::
Satellite
::
MergeAction
do
include
RepoHelpers
include
RepoHelpers
let
(
:project
)
{
create
(
:project
,
namespace:
create
(
:group
))
}
let
(
:project
)
{
create
(
:project
,
namespace:
create
(
:group
))
}
...
@@ -20,14 +20,14 @@ describe 'Gitlab::Satellite::MergeAction' do
...
@@ -20,14 +20,14 @@ describe 'Gitlab::Satellite::MergeAction' do
context
'on fork'
do
context
'on fork'
do
it
'should get proper commits between'
do
it
'should get proper commits between'
do
commits
=
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
commits_between
commits
=
described_class
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
commits_between
verify_commits
(
commits
,
sample_compare
.
commits
.
first
,
sample_compare
.
commits
.
last
)
verify_commits
(
commits
,
sample_compare
.
commits
.
first
,
sample_compare
.
commits
.
last
)
end
end
end
end
context
'between branches'
do
context
'between branches'
do
it
'should raise exception -- not expected to be used by non forks'
do
it
'should raise exception -- not expected to be used by non forks'
do
expect
{
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request
.
author
,
merge_request
).
commits_between
}.
to
raise_error
(
RuntimeError
)
expect
{
described_class
.
new
(
merge_request
.
author
,
merge_request
).
commits_between
}.
to
raise_error
(
RuntimeError
)
end
end
end
end
end
end
...
@@ -41,14 +41,14 @@ describe 'Gitlab::Satellite::MergeAction' do
...
@@ -41,14 +41,14 @@ describe 'Gitlab::Satellite::MergeAction' do
context
'on fork'
do
context
'on fork'
do
it
'should build a format patch'
do
it
'should build a format patch'
do
patch
=
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
format_patch
patch
=
described_class
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
format_patch
verify_content
(
patch
)
verify_content
(
patch
)
end
end
end
end
context
'between branches'
do
context
'between branches'
do
it
'should build a format patch'
do
it
'should build a format patch'
do
patch
=
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_fork
.
author
,
merge_request
).
format_patch
patch
=
described_class
.
new
(
merge_request_fork
.
author
,
merge_request
).
format_patch
verify_content
(
patch
)
verify_content
(
patch
)
end
end
end
end
...
@@ -67,15 +67,15 @@ describe 'Gitlab::Satellite::MergeAction' do
...
@@ -67,15 +67,15 @@ describe 'Gitlab::Satellite::MergeAction' do
context
'on fork'
do
context
'on fork'
do
it
'should get proper diffs'
do
it
'should get proper diffs'
do
diffs
=
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
diffs_between_satellite
diffs
=
described_class
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
diffs_between_satellite
diff
=
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request
.
author
,
merge_request_fork
).
diff_in_satellite
diff
=
described_class
.
new
(
merge_request
.
author
,
merge_request_fork
).
diff_in_satellite
is_a_matching_diff
(
diff
,
diffs
)
is_a_matching_diff
(
diff
,
diffs
)
end
end
end
end
context
'between branches'
do
context
'between branches'
do
it
'should get proper diffs'
do
it
'should get proper diffs'
do
expect
{
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request
.
author
,
merge_request
).
diffs_between_satellite
}.
to
raise_error
(
RuntimeError
)
expect
{
described_class
.
new
(
merge_request
.
author
,
merge_request
).
diffs_between_satellite
}.
to
raise_error
(
RuntimeError
)
end
end
end
end
end
end
...
@@ -83,21 +83,21 @@ describe 'Gitlab::Satellite::MergeAction' do
...
@@ -83,21 +83,21 @@ describe 'Gitlab::Satellite::MergeAction' do
describe
'#can_be_merged?'
do
describe
'#can_be_merged?'
do
context
'on fork'
do
context
'on fork'
do
it
do
it
do
expect
(
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
can_be_merged?
).
to
be_truthy
expect
(
described_class
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
can_be_merged?
).
to
be_truthy
end
end
it
do
it
do
expect
(
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_fork_with_conflict
.
author
,
merge_request_fork_with_conflict
).
can_be_merged?
).
to
be_falsey
expect
(
described_class
.
new
(
merge_request_fork_with_conflict
.
author
,
merge_request_fork_with_conflict
).
can_be_merged?
).
to
be_falsey
end
end
end
end
context
'between branches'
do
context
'between branches'
do
it
do
it
do
expect
(
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request
.
author
,
merge_request
).
can_be_merged?
).
to
be_truthy
expect
(
described_class
.
new
(
merge_request
.
author
,
merge_request
).
can_be_merged?
).
to
be_truthy
end
end
it
do
it
do
expect
(
Gitlab
::
Satellite
::
MergeAction
.
new
(
merge_request_with_conflict
.
author
,
merge_request_with_conflict
).
can_be_merged?
).
to
be_falsey
expect
(
described_class
.
new
(
merge_request_with_conflict
.
author
,
merge_request_with_conflict
).
can_be_merged?
).
to
be_falsey
end
end
end
end
end
end
...
@@ -106,37 +106,33 @@ describe 'Gitlab::Satellite::MergeAction' do
...
@@ -106,37 +106,33 @@ describe 'Gitlab::Satellite::MergeAction' do
describe
'#can_be_rebased?'
do
describe
'#can_be_rebased?'
do
context
'on fork'
do
context
'on fork'
do
before
(
:each
)
do
before
(
:each
)
do
merge_request
.
stub
(
:should_rebase
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:should_rebase
).
and_return
(
true
)
end
end
it
do
it
do
Gitlab
::
Satellite
::
MergeAction
.
new
(
result
=
described_class
.
new
(
merge_request_fork
.
author
,
merge_request_fork
).
merge!
merge_request_fork
.
author
,
expect
(
result
).
to
be_truthy
merge_request_fork
).
merge!
.
should
be_truthy
end
end
it
do
it
do
Gitlab
::
Satellite
::
MergeAction
.
new
(
result
=
described_class
.
new
(
merge_request_fork_with_conflict
.
author
,
merge_request_fork_with_conflict
).
merge!
merge_request_fork_with_conflict
.
author
,
expect
(
result
).
to
be_falsey
merge_request_fork_with_conflict
).
merge!
.
should
be_falsey
end
end
end
end
context
'between branches'
do
context
'between branches'
do
before
(
:each
)
do
before
(
:each
)
do
merge_request
.
stub
(
:should_rebase
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:should_rebase
).
and_return
(
true
)
end
end
it
do
it
do
Gitlab
::
Satellite
::
MergeAction
.
new
(
result
=
described_class
.
new
(
merge_request
.
author
,
merge_request
).
merge!
merge_request
.
author
,
expect
(
result
).
to
be_truthy
merge_request
).
merge!
.
should
be_truthy
end
end
it
do
it
do
Gitlab
::
Satellite
::
MergeAction
.
new
(
result
=
described_class
.
new
(
merge_request_with_conflict
.
author
,
merge_request_with_conflict
).
merge!
merge_request_with_conflict
.
author
,
expect
(
result
).
to
be_falsey
merge_request_with_conflict
).
merge!
.
should
be_falsey
end
end
end
end
end
end
...
...
spec/mailers/notify_spec.rb
View file @
ce5bc4f8
...
@@ -808,8 +808,8 @@ describe Notify do
...
@@ -808,8 +808,8 @@ describe Notify do
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
.
display_name
.
should
eq
(
"GitLab"
)
expect
(
sender
.
display_name
).
to
eq
(
"GitLab"
)
sender
.
address
.
should
eq
(
gitlab_sender
)
expect
(
sender
.
address
).
to
eq
(
gitlab_sender
)
end
end
it
'is sent to recipient'
do
it
'is sent to recipient'
do
...
...
spec/models/concerns/mentionable_spec.rb
View file @
ce5bc4f8
...
@@ -7,8 +7,8 @@ describe Mentionable do
...
@@ -7,8 +7,8 @@ describe Mentionable do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
it
'excludes JIRA references'
do
it
'excludes JIRA references'
do
project
.
stub
(
jira_tracker?:
true
)
allow
(
project
).
to
receive_messages
(
jira_tracker?:
true
)
references
(
project
,
'JIRA-123'
).
should
be_empty
expect
(
references
(
project
,
'JIRA-123'
)).
to
be_empty
end
end
end
end
end
end
...
...
spec/models/ldap_group_link_spec.rb
View file @
ce5bc4f8
...
@@ -11,7 +11,7 @@ describe LdapGroupLink do
...
@@ -11,7 +11,7 @@ describe LdapGroupLink do
group_link
=
build
(
:ldap_group_link
,
group_link
=
build
(
:ldap_group_link
,
cn:
'group1'
,
group_id:
1
,
provider:
'ldapmain'
)
cn:
'group1'
,
group_id:
1
,
provider:
'ldapmain'
)
expect
(
group_link
).
to_not
be_valid
expect
(
group_link
).
not_to
be_valid
group_link
.
group_id
=
2
group_link
.
group_id
=
2
expect
(
group_link
).
to
be_valid
expect
(
group_link
).
to
be_valid
...
...
spec/models/license_spec.rb
View file @
ce5bc4f8
...
@@ -18,7 +18,7 @@ describe License do
...
@@ -18,7 +18,7 @@ describe License do
end
end
it
"is invalid"
do
it
"is invalid"
do
expect
(
license
).
to_not
be_valid
expect
(
license
).
not_to
be_valid
end
end
end
end
end
end
...
@@ -41,7 +41,7 @@ describe License do
...
@@ -41,7 +41,7 @@ describe License do
context
"when the license started"
do
context
"when the license started"
do
it
"is invalid"
do
it
"is invalid"
do
expect
(
license
).
to_not
be_valid
expect
(
license
).
not_to
be_valid
end
end
end
end
...
@@ -57,7 +57,7 @@ describe License do
...
@@ -57,7 +57,7 @@ describe License do
let
(
:date
)
{
License
.
current
.
starts_at
-
6
.
months
}
let
(
:date
)
{
License
.
current
.
starts_at
-
6
.
months
}
it
"is invalid"
do
it
"is invalid"
do
expect
(
license
).
to_not
be_valid
expect
(
license
).
not_to
be_valid
end
end
end
end
...
@@ -94,7 +94,7 @@ describe License do
...
@@ -94,7 +94,7 @@ describe License do
end
end
it
"is valid"
do
it
"is valid"
do
expect
(
license
).
to_not
be_valid
expect
(
license
).
not_to
be_valid
end
end
end
end
...
@@ -197,7 +197,7 @@ describe License do
...
@@ -197,7 +197,7 @@ describe License do
context
"when valid license data is provided"
do
context
"when valid license data is provided"
do
it
"returns the license"
do
it
"returns the license"
do
expect
(
license
.
license
).
to_not
be_nil
expect
(
license
.
license
).
not_to
be_nil
end
end
end
end
end
end
...
...
spec/models/merge_request_spec.rb
View file @
ce5bc4f8
...
@@ -142,9 +142,9 @@ describe MergeRequest do
...
@@ -142,9 +142,9 @@ describe MergeRequest do
let
(
:issue1
)
{
JiraIssue
.
new
(
'FOOBAR-4567'
,
subject
.
project
)
}
let
(
:issue1
)
{
JiraIssue
.
new
(
'FOOBAR-4567'
,
subject
.
project
)
}
it
'returns sorted JiraIssues'
do
it
'returns sorted JiraIssues'
do
subject
.
project
.
stub
(
default_branch:
subject
.
target_branch
)
allow
(
subject
.
project
).
to
receive_messages
(
default_branch:
subject
.
target_branch
)
subject
.
closes_issues
.
should
eq
([
issue1
,
issue0
])
expect
(
subject
.
closes_issues
).
to
eq
([
issue1
,
issue0
])
end
end
end
end
end
end
...
...
spec/models/project_services/jenkins_service_spec.rb
View file @
ce5bc4f8
...
@@ -28,7 +28,7 @@ describe JenkinsService do
...
@@ -28,7 +28,7 @@ describe JenkinsService do
describe
'commits methods'
do
describe
'commits methods'
do
before
do
before
do
@service
=
JenkinsService
.
new
@service
=
JenkinsService
.
new
@service
.
stub
(
allow
(
@service
).
to
receive_messages
(
service_hook:
true
,
service_hook:
true
,
project_url:
'http://jenkins.gitlab.org/projects/2'
,
project_url:
'http://jenkins.gitlab.org/projects/2'
,
token:
'verySecret'
token:
'verySecret'
...
...
spec/models/project_services/jira_service_spec.rb
View file @
ce5bc4f8
...
@@ -34,7 +34,7 @@ describe JiraService do
...
@@ -34,7 +34,7 @@ describe JiraService do
before
do
before
do
@jira_service
=
JiraService
.
new
@jira_service
=
JiraService
.
new
@jira_service
.
stub
(
allow
(
@jira_service
).
to
receive_messages
(
project_id:
project
.
id
,
project_id:
project
.
id
,
project:
project
,
project:
project
,
service_hook:
true
,
service_hook:
true
,
...
@@ -52,7 +52,7 @@ describe JiraService do
...
@@ -52,7 +52,7 @@ describe JiraService do
it
"should call JIRA API"
do
it
"should call JIRA API"
do
@jira_service
.
execute
(
sample_commit
,
JiraIssue
.
new
(
"JIRA-123"
,
project
))
@jira_service
.
execute
(
sample_commit
,
JiraIssue
.
new
(
"JIRA-123"
,
project
))
WebMock
.
should
have_requested
(
:post
,
@api_url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
@api_url
).
with
(
body:
/Issue solved with/
body:
/Issue solved with/
).
once
).
once
end
end
...
@@ -60,7 +60,7 @@ describe JiraService do
...
@@ -60,7 +60,7 @@ describe JiraService do
it
"calls the api with jira_issue_transition_id"
do
it
"calls the api with jira_issue_transition_id"
do
@jira_service
.
jira_issue_transition_id
=
'this-is-a-custom-id'
@jira_service
.
jira_issue_transition_id
=
'this-is-a-custom-id'
@jira_service
.
execute
(
sample_commit
,
JiraIssue
.
new
(
"JIRA-123"
,
project
))
@jira_service
.
execute
(
sample_commit
,
JiraIssue
.
new
(
"JIRA-123"
,
project
))
WebMock
.
should
have_requested
(
:post
,
@api_url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
@api_url
).
with
(
body:
/this-is-a-custom-id/
body:
/this-is-a-custom-id/
).
once
).
once
end
end
...
...
spec/models/user_spec.rb
View file @
ce5bc4f8
...
@@ -185,8 +185,8 @@ describe User do
...
@@ -185,8 +185,8 @@ describe User do
create
:omniauth_user
,
provider:
"gitlub"
create
:omniauth_user
,
provider:
"gitlub"
users
=
User
.
non_ldap
users
=
User
.
non_ldap
users
.
count
.
should
==
2
expect
(
users
.
count
).
to
eq
2
users
.
detect
{
|
user
|
user
.
username
==
ldap_user
.
username
}.
should
be_nil
expect
(
users
.
detect
{
|
user
|
user
.
username
==
ldap_user
.
username
}).
to
be_nil
end
end
end
end
...
...
spec/requests/api/ldap_group_links_spec.rb
View file @
ce5bc4f8
...
@@ -23,7 +23,7 @@ describe API::API, api: true do
...
@@ -23,7 +23,7 @@ describe API::API, api: true do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
post
api
(
"/groups/
#{
group_with_ldap_links
.
id
}
/ldap_group_links"
)
post
api
(
"/groups/
#{
group_with_ldap_links
.
id
}
/ldap_group_links"
)
response
.
status
.
should
==
401
expect
(
response
.
status
).
to
eq
401
end
end
end
end
...
@@ -89,7 +89,7 @@ describe API::API, api: true do
...
@@ -89,7 +89,7 @@ describe API::API, api: true do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
delete
api
(
"/groups/
#{
group_with_ldap_links
.
id
}
/ldap_group_links/ldap-group1"
)
delete
api
(
"/groups/
#{
group_with_ldap_links
.
id
}
/ldap_group_links/ldap-group1"
)
response
.
status
.
should
==
401
expect
(
response
.
status
).
to
eq
401
end
end
end
end
...
@@ -126,7 +126,7 @@ describe API::API, api: true do
...
@@ -126,7 +126,7 @@ describe API::API, api: true do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
delete
api
(
"/groups/
#{
group_with_ldap_links
.
id
}
/ldap_group_links/ldap2/ldap-group2"
)
delete
api
(
"/groups/
#{
group_with_ldap_links
.
id
}
/ldap_group_links/ldap2/ldap-group2"
)
response
.
status
.
should
==
401
expect
(
response
.
status
).
to
eq
401
end
end
end
end
...
...
spec/requests/api/ldap_spec.rb
View file @
ce5bc4f8
...
@@ -10,26 +10,24 @@ describe API::API do
...
@@ -10,26 +10,24 @@ describe API::API do
OpenStruct
.
new
(
cn:
'students'
)
OpenStruct
.
new
(
cn:
'students'
)
]
]
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive_messages
(
groups:
groups
)
groups:
groups
)
end
end
describe
"GET /ldap/groups"
do
describe
"GET /ldap/groups"
do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
get
api
(
"/ldap/groups"
)
get
api
(
"/ldap/groups"
)
response
.
status
.
should
==
401
expect
(
response
.
status
).
to
eq
401
end
end
end
end
context
"when authenticated as user"
do
context
"when authenticated as user"
do
it
"should return an array of ldap groups"
do
it
"should return an array of ldap groups"
do
get
api
(
"/ldap/groups"
,
user
)
get
api
(
"/ldap/groups"
,
user
)
response
.
status
.
should
==
200
expect
(
response
.
status
).
to
eq
200
json_response
.
should
be_an
Array
expect
(
json_response
).
to
be_an
Array
json_response
.
length
.
should
==
2
expect
(
json_response
.
length
).
to
eq
2
json_response
.
first
[
'cn'
].
should
==
'developers'
expect
(
json_response
.
first
[
'cn'
]).
to
eq
'developers'
end
end
end
end
end
end
...
@@ -38,17 +36,17 @@ describe API::API do
...
@@ -38,17 +36,17 @@ describe API::API do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
get
api
(
"/ldap/ldapmain/groups"
)
get
api
(
"/ldap/ldapmain/groups"
)
response
.
status
.
should
==
401
expect
(
response
.
status
).
to
eq
401
end
end
end
end
context
"when authenticated as user"
do
context
"when authenticated as user"
do
it
"should return an array of ldap groups"
do
it
"should return an array of ldap groups"
do
get
api
(
"/ldap/ldapmain/groups"
,
user
)
get
api
(
"/ldap/ldapmain/groups"
,
user
)
response
.
status
.
should
==
200
expect
(
response
.
status
).
to
eq
200
json_response
.
should
be_an
Array
expect
(
json_response
).
to
be_an
Array
json_response
.
length
.
should
==
2
expect
(
json_response
.
length
).
to
eq
2
json_response
.
first
[
'cn'
].
should
==
'developers'
expect
(
json_response
.
first
[
'cn'
]).
to
eq
'developers'
end
end
end
end
end
end
...
...
spec/requests/api/project_git_hook_spec.rb
View file @
ce5bc4f8
...
@@ -19,17 +19,17 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -19,17 +19,17 @@ describe API::API, 'ProjectGitHook', api: true do
context
"authorized user"
do
context
"authorized user"
do
it
"should return project git hook"
do
it
"should return project git hook"
do
get
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
response
.
status
.
should
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
json_response
.
should
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
json_response
[
'project_id'
].
should
eq
(
project
.
id
)
expect
(
json_response
[
'project_id'
]).
to
eq
(
project
.
id
)
end
end
end
end
context
"unauthorized user"
do
context
"unauthorized user"
do
it
"should not access project git hooks"
do
it
"should not access project git hooks"
do
get
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
get
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
response
.
status
.
should
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
end
end
end
...
@@ -40,11 +40,11 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -40,11 +40,11 @@ describe API::API, 'ProjectGitHook', api: true do
it
"should add git hook to project"
do
it
"should add git hook to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
true
deny_delete_tag:
true
response
.
status
.
should
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
json_response
.
should
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
json_response
[
'project_id'
].
should
eq
(
project
.
id
)
expect
(
json_response
[
'project_id'
]).
to
eq
(
project
.
id
)
json_response
[
'deny_delete_tag'
].
should
eq
(
true
)
expect
(
json_response
[
'deny_delete_tag'
]).
to
eq
(
true
)
end
end
end
end
...
@@ -52,7 +52,7 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -52,7 +52,7 @@ describe API::API, 'ProjectGitHook', api: true do
it
"should not add git hook to project"
do
it
"should not add git hook to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
),
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
),
deny_delete_tag:
true
deny_delete_tag:
true
response
.
status
.
should
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
end
end
end
...
@@ -66,7 +66,7 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -66,7 +66,7 @@ describe API::API, 'ProjectGitHook', api: true do
it
"should not add git hook to project"
do
it
"should not add git hook to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
true
deny_delete_tag:
true
response
.
status
.
should
eq
(
422
)
expect
(
response
.
status
).
to
eq
(
422
)
end
end
end
end
end
end
...
@@ -79,10 +79,10 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -79,10 +79,10 @@ describe API::API, 'ProjectGitHook', api: true do
it
"should update an existing project git hook"
do
it
"should update an existing project git hook"
do
put
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
false
,
commit_message_regex:
'Fixes \d+\..*'
deny_delete_tag:
false
,
commit_message_regex:
'Fixes \d+\..*'
response
.
status
.
should
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
json_response
[
'deny_delete_tag'
].
should
eq
(
false
)
expect
(
json_response
[
'deny_delete_tag'
]).
to
eq
(
false
)
json_response
[
'commit_message_regex'
].
should
eq
(
'Fixes \d+\..*'
)
expect
(
json_response
[
'commit_message_regex'
]).
to
eq
(
'Fixes \d+\..*'
)
end
end
end
end
...
@@ -90,13 +90,13 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -90,13 +90,13 @@ describe API::API, 'ProjectGitHook', api: true do
it
"should error on non existing project git hook"
do
it
"should error on non existing project git hook"
do
put
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
put
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
false
,
commit_message_regex:
'Fixes \d+\..*'
deny_delete_tag:
false
,
commit_message_regex:
'Fixes \d+\..*'
response
.
status
.
should
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
it
"should not update git hook for unauthorized user"
do
it
"should not update git hook for unauthorized user"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
),
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
),
deny_delete_tag:
true
deny_delete_tag:
true
response
.
status
.
should
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
end
...
@@ -108,16 +108,16 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -108,16 +108,16 @@ describe API::API, 'ProjectGitHook', api: true do
context
"authorized user"
do
context
"authorized user"
do
it
"should delete git hook from project"
do
it
"should delete git hook from project"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
response
.
status
.
should
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
json_response
.
should
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
end
end
end
end
context
"unauthorized user"
do
context
"unauthorized user"
do
it
"should return a 403 error"
do
it
"should return a 403 error"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
response
.
status
.
should
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
end
end
end
...
@@ -126,15 +126,15 @@ describe API::API, 'ProjectGitHook', api: true do
...
@@ -126,15 +126,15 @@ describe API::API, 'ProjectGitHook', api: true do
context
"for non existing git hook"
do
context
"for non existing git hook"
do
it
"should delete git hook from project"
do
it
"should delete git hook from project"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
response
.
status
.
should
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
json_response
.
should
be_an
Hash
expect
(
json_response
).
to
be_an
Hash
json_response
[
'message'
].
should
eq
(
"404 Not Found"
)
expect
(
json_response
[
'message'
]).
to
eq
(
"404 Not Found"
)
end
end
it
"should return a 403 error if not authorized"
do
it
"should return a 403 error if not authorized"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
response
.
status
.
should
eq
(
403
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
end
end
end
...
...
spec/requests/api/project_members_spec.rb
View file @
ce5bc4f8
...
@@ -98,7 +98,7 @@ describe API::API, api: true do
...
@@ -98,7 +98,7 @@ describe API::API, api: true do
end
end
it
'should return a 405 method not allowed error when group membership lock is enabled'
do
it
'should return a 405 method not allowed error when group membership lock is enabled'
do
response
.
status
.
should
==
405
expect
(
response
.
status
).
to
eq
405
end
end
end
end
end
end
...
@@ -143,7 +143,7 @@ describe API::API, api: true do
...
@@ -143,7 +143,7 @@ describe API::API, api: true do
delete
api
(
"/projects/
#{
project
.
id
}
/members/
#{
user3
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/members/
#{
user3
.
id
}
"
,
user
)
expect
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/members/
#{
user3
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/members/
#{
user3
.
id
}
"
,
user
)
end
.
to_not
change
{
ProjectMember
.
count
}
end
.
not_to
change
{
ProjectMember
.
count
}
end
end
it
"should return 200 if team member already removed"
do
it
"should return 200 if team member already removed"
do
...
...
spec/requests/api/projects_spec.rb
View file @
ce5bc4f8
...
@@ -642,25 +642,25 @@ describe API::API, api: true do
...
@@ -642,25 +642,25 @@ describe API::API, api: true do
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
,
group_access:
Gitlab
::
Access
::
DEVELOPER
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
,
group_access:
Gitlab
::
Access
::
DEVELOPER
end
.
to
change
{
ProjectGroupLink
.
count
}.
by
(
1
)
end
.
to
change
{
ProjectGroupLink
.
count
}.
by
(
1
)
response
.
status
.
should
==
201
expect
(
response
.
status
).
to
eq
201
json_response
[
'group_id'
].
should
==
group
.
id
expect
(
json_response
[
'group_id'
]).
to
eq
group
.
id
json_response
[
'group_access'
].
should
==
Gitlab
::
Access
::
DEVELOPER
expect
(
json_response
[
'group_access'
]).
to
eq
Gitlab
::
Access
::
DEVELOPER
end
end
it
"should return a 400 error when group id is not given"
do
it
"should return a 400 error when group id is not given"
do
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_access:
Gitlab
::
Access
::
DEVELOPER
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_access:
Gitlab
::
Access
::
DEVELOPER
response
.
status
.
should
==
400
expect
(
response
.
status
).
to
eq
400
end
end
it
"should return a 400 error when access level is not given"
do
it
"should return a 400 error when access level is not given"
do
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
response
.
status
.
should
==
400
expect
(
response
.
status
).
to
eq
400
end
end
it
"should return a 409 error when wrong params passed"
do
it
"should return a 409 error when wrong params passed"
do
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
,
group_access:
1234
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
,
group_access:
1234
response
.
status
.
should
==
409
expect
(
response
.
status
).
to
eq
409
json_response
[
'message'
].
should
==
'Group access is not included in the list'
expect
(
json_response
[
'message'
]).
to
eq
'Group access is not included in the list'
end
end
end
end
...
...
spec/requests/api/system_hooks_spec.rb
View file @
ce5bc4f8
...
@@ -49,7 +49,7 @@ describe API::API, api: true do
...
@@ -49,7 +49,7 @@ describe API::API, api: true do
it
"should not create new hook without url"
do
it
"should not create new hook without url"
do
expect
do
expect
do
post
api
(
"/hooks"
,
admin
)
post
api
(
"/hooks"
,
admin
)
end
.
to_not
change
{
SystemHook
.
count
}
end
.
not_to
change
{
SystemHook
.
count
}
end
end
end
end
...
...
spec/requests/api/users_spec.rb
View file @
ce5bc4f8
...
@@ -44,10 +44,10 @@ describe API::API, api: true do
...
@@ -44,10 +44,10 @@ describe API::API, api: true do
User
.
delete_all
User
.
delete_all
create
:omniauth_user
,
provider:
"ldapserver1"
create
:omniauth_user
,
provider:
"ldapserver1"
get
api
(
"/users"
,
user
),
skip_ldap:
"true"
get
api
(
"/users"
,
user
),
skip_ldap:
"true"
response
.
status
.
should
==
200
expect
(
response
.
status
).
to
eq
200
json_response
.
should
be_an
Array
expect
(
json_response
).
to
be_an
Array
username
=
user
.
username
username
=
user
.
username
json_response
.
first
[
"username"
].
should
==
username
expect
(
json_response
.
first
[
"username"
]).
to
eq
username
end
end
end
end
end
end
...
...
spec/services/git_push_service_spec.rb
View file @
ce5bc4f8
...
@@ -265,14 +265,14 @@ describe GitPushService do
...
@@ -265,14 +265,14 @@ describe GitPushService do
WebMock
.
stub_request
(
:get
,
jira_api_comment_url
).
to_return
(
body:
jira_issue_comments
)
WebMock
.
stub_request
(
:get
,
jira_api_comment_url
).
to_return
(
body:
jira_issue_comments
)
WebMock
.
stub_request
(
:get
,
jira_api_project_url
)
WebMock
.
stub_request
(
:get
,
jira_api_project_url
)
closing_commit
.
stub
({
allow
(
closing_commit
).
to
receive_messages
({
issue_closing_regex:
Regexp
.
new
(
Gitlab
.
config
.
gitlab
.
issue_closing_pattern
),
issue_closing_regex:
Regexp
.
new
(
Gitlab
.
config
.
gitlab
.
issue_closing_pattern
),
safe_message:
"this is some work.
\n\n
closes JIRA-1"
,
safe_message:
"this is some work.
\n\n
closes JIRA-1"
,
author_name:
commit_author
.
name
,
author_name:
commit_author
.
name
,
author_email:
commit_author
.
email
author_email:
commit_author
.
email
})
})
project
.
repository
.
stub
(
commits_between:
[
closing_commit
])
allow
(
project
.
repository
).
to
receive_messages
(
commits_between:
[
closing_commit
])
end
end
after
do
after
do
...
@@ -294,7 +294,7 @@ describe GitPushService do
...
@@ -294,7 +294,7 @@ describe GitPushService do
}.
to_json
}.
to_json
service
.
execute
(
project
,
user
,
@oldrev
,
@newrev
,
@ref
)
service
.
execute
(
project
,
user
,
@oldrev
,
@newrev
,
@ref
)
WebMock
.
should
have_requested
(
:post
,
jira_api_transition_url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
jira_api_transition_url
).
with
(
body:
message
body:
message
).
once
).
once
end
end
...
@@ -302,7 +302,7 @@ describe GitPushService do
...
@@ -302,7 +302,7 @@ describe GitPushService do
it
"should initiate one api call to jira server to mention the issue"
do
it
"should initiate one api call to jira server to mention the issue"
do
service
.
execute
(
project
,
user
,
@oldrev
,
@newrev
,
@ref
)
service
.
execute
(
project
,
user
,
@oldrev
,
@newrev
,
@ref
)
WebMock
.
should
have_requested
(
:post
,
jira_api_comment_url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
jira_api_comment_url
).
with
(
body:
/mentioned this issue in/
body:
/mentioned this issue in/
).
once
).
once
end
end
...
...
spec/services/ldap_group_reset_service_spec.rb
View file @
ce5bc4f8
...
@@ -18,9 +18,9 @@ describe LdapGroupResetService do
...
@@ -18,9 +18,9 @@ describe LdapGroupResetService do
context
'initiated by ldap user'
do
context
'initiated by ldap user'
do
before
{
LdapGroupResetService
.
new
.
execute
(
group
,
ldap_user
)
}
before
{
LdapGroupResetService
.
new
.
execute
(
group
,
ldap_user
)
}
it
{
member_access
(
ldap_user
).
should
==
Gitlab
::
Access
::
OWNER
}
it
{
expect
(
member_access
(
ldap_user
)).
to
eq
Gitlab
::
Access
::
OWNER
}
it
{
member_access
(
ldap_user_2
).
should
==
Gitlab
::
Access
::
GUEST
}
it
{
expect
(
member_access
(
ldap_user_2
)).
to
eq
Gitlab
::
Access
::
GUEST
}
it
{
member_access
(
user
).
should
==
Gitlab
::
Access
::
OWNER
}
it
{
expect
(
member_access
(
user
)).
to
eq
Gitlab
::
Access
::
OWNER
}
it
{
expect
(
ldap_user
.
reload
.
last_credential_check_at
).
to
be_nil
}
it
{
expect
(
ldap_user
.
reload
.
last_credential_check_at
).
to
be_nil
}
it
{
expect
(
ldap_user_2
.
reload
.
last_credential_check_at
).
to
be_nil
}
it
{
expect
(
ldap_user_2
.
reload
.
last_credential_check_at
).
to
be_nil
}
end
end
...
@@ -28,9 +28,9 @@ describe LdapGroupResetService do
...
@@ -28,9 +28,9 @@ describe LdapGroupResetService do
context
'initiated by regular user'
do
context
'initiated by regular user'
do
before
{
LdapGroupResetService
.
new
.
execute
(
group
,
user
)
}
before
{
LdapGroupResetService
.
new
.
execute
(
group
,
user
)
}
it
{
member_access
(
ldap_user
).
should
==
Gitlab
::
Access
::
GUEST
}
it
{
expect
(
member_access
(
ldap_user
)).
to
eq
Gitlab
::
Access
::
GUEST
}
it
{
member_access
(
ldap_user_2
).
should
==
Gitlab
::
Access
::
GUEST
}
it
{
expect
(
member_access
(
ldap_user_2
)).
to
eq
Gitlab
::
Access
::
GUEST
}
it
{
member_access
(
user
).
should
==
Gitlab
::
Access
::
OWNER
}
it
{
expect
(
member_access
(
user
)).
to
eq
Gitlab
::
Access
::
OWNER
}
it
{
expect
(
ldap_user
.
reload
.
last_credential_check_at
).
to
be_nil
}
it
{
expect
(
ldap_user
.
reload
.
last_credential_check_at
).
to
be_nil
}
it
{
expect
(
ldap_user_2
.
reload
.
last_credential_check_at
).
to
be_nil
}
it
{
expect
(
ldap_user_2
.
reload
.
last_credential_check_at
).
to
be_nil
}
end
end
...
...
spec/services/projects/create_service_spec.rb
View file @
ce5bc4f8
...
@@ -91,7 +91,7 @@ describe Projects::CreateService do
...
@@ -91,7 +91,7 @@ describe Projects::CreateService do
it
"creates git hook from sample"
do
it
"creates git hook from sample"
do
git_hook
=
create_project
(
@user
,
@opts
).
git_hook
git_hook
=
create_project
(
@user
,
@opts
).
git_hook
[
:force_push_regex
,
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
].
each
do
|
attr_name
|
[
:force_push_regex
,
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
].
each
do
|
attr_name
|
git_hook
.
send
(
attr_name
).
should
==
@git_hook_sample
.
send
(
attr_name
)
expect
(
git_hook
.
send
(
attr_name
)).
to
eq
@git_hook_sample
.
send
(
attr_name
)
end
end
end
end
end
end
...
...
spec/services/system_note_service_spec.rb
View file @
ce5bc4f8
...
@@ -414,7 +414,7 @@ describe SystemNoteService do
...
@@ -414,7 +414,7 @@ describe SystemNoteService do
WebMock
.
stub_request
(
:get
,
jira_api_comment_url
).
to_return
(
body:
jira_issue_comments
)
WebMock
.
stub_request
(
:get
,
jira_api_comment_url
).
to_return
(
body:
jira_issue_comments
)
end
end
subject
{
Note
.
create_cross_reference_not
e
(
jira_issue
,
commit
,
author
)
}
subject
{
described_class
.
cross_referenc
e
(
jira_issue
,
commit
,
author
)
}
it
{
is_expected
.
to
eq
(
jira_status_message
)
}
it
{
is_expected
.
to
eq
(
jira_status_message
)
}
end
end
...
@@ -425,7 +425,7 @@ describe SystemNoteService do
...
@@ -425,7 +425,7 @@ describe SystemNoteService do
WebMock
.
stub_request
(
:get
,
jira_api_comment_url
).
to_return
(
body:
"{
\"
comments
\"
:[{
\"
body
\"
:
\"
#{
message
}
\"
}]}"
)
WebMock
.
stub_request
(
:get
,
jira_api_comment_url
).
to_return
(
body:
"{
\"
comments
\"
:[{
\"
body
\"
:
\"
#{
message
}
\"
}]}"
)
end
end
subject
{
Note
.
create_cross_reference_not
e
(
jira_issue
,
commit
,
author
)
}
subject
{
described_class
.
cross_referenc
e
(
jira_issue
,
commit
,
author
)
}
it
{
is_expected
.
not_to
eq
(
jira_status_message
)
}
it
{
is_expected
.
not_to
eq
(
jira_status_message
)
}
end
end
end
end
...
@@ -442,7 +442,7 @@ describe SystemNoteService do
...
@@ -442,7 +442,7 @@ describe SystemNoteService do
jira_tracker
.
destroy!
jira_tracker
.
destroy!
end
end
subject
{
Note
.
create_cross_reference_not
e
(
jira_issue
,
issue
,
author
)
}
subject
{
described_class
.
cross_referenc
e
(
jira_issue
,
issue
,
author
)
}
it
{
is_expected
.
to
eq
(
jira_status_message
)
}
it
{
is_expected
.
to
eq
(
jira_status_message
)
}
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