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
76e53184
Commit
76e53184
authored
Nov 20, 2021
by
Siddharth Asthana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Style/OpenStructUse offenses
Changelog: other
parent
6695bf1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
.rubocop_manual_todo.yml
.rubocop_manual_todo.yml
+0
-1
spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb
...ontrollers/githubish_import_controller_shared_examples.rb
+15
-15
No files found.
.rubocop_manual_todo.yml
View file @
76e53184
...
...
@@ -2600,7 +2600,6 @@ Style/OpenStructUse:
-
'
spec/support/helpers/import_spec_helper.rb'
-
'
spec/support/helpers/login_helpers.rb'
-
'
spec/support/helpers/repo_helpers.rb'
-
'
spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb'
-
'
spec/tooling/rspec_flaky/flaky_example_spec.rb'
-
'
tooling/rspec_flaky/flaky_example.rb'
...
...
spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb
View file @
76e53184
...
...
@@ -58,11 +58,12 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET new' do
end
RSpec
.
shared_examples
'a GitHub-ish import controller: GET status'
do
let
(
:repo_fake
)
{
Struct
.
new
(
:id
,
:login
,
:full_name
,
:name
,
:owner
,
keyword_init:
true
)
}
let
(
:new_import_url
)
{
public_send
(
"new_import_
#{
provider
}
_url"
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:repo
)
{
OpenStruct
.
new
(
login:
'vim'
,
full_name:
'asd/vim'
,
name:
'vim'
,
owner:
{
login:
'owner'
})
}
let
(
:org
)
{
OpenStruct
.
new
(
login:
'company'
)
}
let
(
:org_repo
)
{
OpenStruct
.
new
(
login:
'company'
,
full_name:
'company/repo'
,
name:
'repo'
,
owner:
{
login:
'owner'
})
}
let
(
:repo
)
{
repo_fake
.
new
(
login:
'vim'
,
full_name:
'asd/vim'
,
name:
'vim'
,
owner:
{
login:
'owner'
})
}
let
(
:org
)
{
double
(
'org'
,
login:
'company'
)
}
let
(
:org_repo
)
{
repo_fake
.
new
(
login:
'company'
,
full_name:
'company/repo'
,
name:
'repo'
,
owner:
{
login:
'owner'
})
}
before
do
assign_session_token
(
provider
)
...
...
@@ -72,7 +73,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do
project
=
create
(
:project
,
import_type:
provider
,
namespace:
user
.
namespace
,
import_status: :finished
,
import_source:
'example/repo'
)
group
=
create
(
:group
)
group
.
add_owner
(
user
)
stub_client
(
repos:
[
repo
,
org_repo
],
orgs:
[
org
],
org_repos:
[
org_repo
],
each_page:
[
OpenStruct
.
new
(
objects:
[
repo
,
org_repo
])].
to_enum
)
stub_client
(
repos:
[
repo
,
org_repo
],
orgs:
[
org
],
org_repos:
[
org_repo
],
each_page:
[
double
(
'client'
,
objects:
[
repo
,
org_repo
])].
to_enum
)
get
:status
,
format: :json
...
...
@@ -125,7 +126,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do
end
context
'when filtering'
do
let
(
:repo_2
)
{
OpenStruct
.
new
(
login:
'emacs'
,
full_name:
'asd/emacs'
,
name:
'emacs'
,
owner:
{
login:
'owner'
})
}
let
(
:repo_2
)
{
repo_fake
.
new
(
login:
'emacs'
,
full_name:
'asd/emacs'
,
name:
'emacs'
,
owner:
{
login:
'owner'
})
}
let
(
:project
)
{
create
(
:project
,
import_type:
provider
,
namespace:
user
.
namespace
,
import_status: :finished
,
import_source:
'example/repo'
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:repos
)
{
[
repo
,
repo_2
,
org_repo
]
}
...
...
@@ -133,7 +134,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do
before
do
group
.
add_owner
(
user
)
client
=
stub_client
(
repos:
repos
,
orgs:
[
org
],
org_repos:
[
org_repo
])
allow
(
client
).
to
receive
(
:each_page
).
and_return
([
OpenStruct
.
new
(
objects:
repos
)].
to_enum
)
allow
(
client
).
to
receive
(
:each_page
).
and_return
([
double
(
'client'
,
objects:
repos
)].
to_enum
)
# GitHub controller has filtering done using GitHub Search API
stub_feature_flags
(
remove_legacy_github_client:
false
)
end
...
...
@@ -172,7 +173,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do
repos
=
[
build
(
:project
,
name:
2
,
path:
'test'
)]
client
=
stub_client
(
repos:
repos
)
allow
(
client
).
to
receive
(
:each_page
).
and_return
([
OpenStruct
.
new
(
objects:
repos
)].
to_enum
)
allow
(
client
).
to
receive
(
:each_page
).
and_return
([
double
(
'client'
,
objects:
repos
)].
to_enum
)
end
it
'does not raise an error'
do
...
...
@@ -189,13 +190,14 @@ end
RSpec
.
shared_examples
'a GitHub-ish import controller: POST create'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:provider_username
)
{
user
.
username
}
let
(
:provider_user
)
{
OpenStruct
.
new
(
login:
provider_username
)
}
let
(
:provider_user
)
{
double
(
'user'
,
login:
provider_username
)
}
let
(
:project
)
{
create
(
:project
,
import_type:
provider
,
import_status: :finished
,
import_source:
"
#{
provider_username
}
/vim"
)
}
let
(
:provider_repo
)
do
OpenStruct
.
new
(
double
(
'provider'
,
name:
'vim'
,
full_name:
"
#{
provider_username
}
/vim"
,
owner:
OpenStruct
.
new
(
login:
provider_username
)
owner:
double
(
'owner'
,
login:
provider_username
)
)
end
...
...
@@ -265,10 +267,9 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do
end
context
"when the repository owner is not the provider user"
do
let
(
:
oth
er_username
)
{
"someone_else"
}
let
(
:
provid
er_username
)
{
"someone_else"
}
before
do
provider_repo
.
owner
=
OpenStruct
.
new
(
login:
other_username
)
assign_session_token
(
provider
)
end
...
...
@@ -277,8 +278,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do
context
"when the namespace is owned by the GitLab user"
do
before
do
user
.
username
=
other_username
user
.
save!
user
.
update!
(
username:
provider_username
)
end
it
"takes the existing namespace"
do
...
...
@@ -292,7 +292,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: POST create' do
context
"when the namespace is not owned by the GitLab user"
do
it
"creates a project using user's namespace"
do
create
(
:user
,
username:
oth
er_username
)
create
(
:user
,
username:
provid
er_username
)
expect
(
Gitlab
::
LegacyGithubImport
::
ProjectCreator
)
.
to
receive
(
:new
).
with
(
provider_repo
,
provider_repo
.
name
,
user
.
namespace
,
user
,
type:
provider
,
**
access_params
)
...
...
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