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
948fabc2
Commit
948fabc2
authored
Jun 10, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
aff559c4
895519a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
2 deletions
+49
-2
app/controllers/import/fogbugz_controller.rb
app/controllers/import/fogbugz_controller.rb
+6
-2
changelogs/unreleased/sh-fix-fogbugz-import.yml
changelogs/unreleased/sh-fix-fogbugz-import.yml
+5
-0
spec/controllers/import/fogbugz_controller_spec.rb
spec/controllers/import/fogbugz_controller_spec.rb
+38
-0
No files found.
app/controllers/import/fogbugz_controller.rb
View file @
948fabc2
...
@@ -11,7 +11,7 @@ class Import::FogbugzController < Import::BaseController
...
@@ -11,7 +11,7 @@ class Import::FogbugzController < Import::BaseController
def
callback
def
callback
begin
begin
res
=
Gitlab
::
FogbugzImport
::
Client
.
new
(
import_params
.
symbolize_keys
)
res
=
Gitlab
::
FogbugzImport
::
Client
.
new
(
import_params
.
to_h
.
symbolize_keys
)
rescue
rescue
# If the URI is invalid various errors can occur
# If the URI is invalid various errors can occur
return
redirect_to
new_import_fogbugz_path
,
alert:
_
(
'Could not connect to FogBugz, check your URL'
)
return
redirect_to
new_import_fogbugz_path
,
alert:
_
(
'Could not connect to FogBugz, check your URL'
)
...
@@ -26,7 +26,7 @@ class Import::FogbugzController < Import::BaseController
...
@@ -26,7 +26,7 @@ class Import::FogbugzController < Import::BaseController
end
end
def
create_user_map
def
create_user_map
user_map
=
params
[
:users
]
user_map
=
user_map_params
.
to_h
[
:users
]
unless
user_map
.
is_a?
(
Hash
)
&&
user_map
.
all?
{
|
k
,
v
|
!
v
[
:name
].
blank?
}
unless
user_map
.
is_a?
(
Hash
)
&&
user_map
.
all?
{
|
k
,
v
|
!
v
[
:name
].
blank?
}
flash
.
now
[
:alert
]
=
_
(
'All users must have a name.'
)
flash
.
now
[
:alert
]
=
_
(
'All users must have a name.'
)
...
@@ -99,6 +99,10 @@ class Import::FogbugzController < Import::BaseController
...
@@ -99,6 +99,10 @@ class Import::FogbugzController < Import::BaseController
params
.
permit
(
:uri
,
:email
,
:password
)
params
.
permit
(
:uri
,
:email
,
:password
)
end
end
def
user_map_params
params
.
permit
(
users:
%w(name email gitlab_user)
)
end
def
verify_fogbugz_import_enabled
def
verify_fogbugz_import_enabled
render_404
unless
fogbugz_import_enabled?
render_404
unless
fogbugz_import_enabled?
end
end
...
...
changelogs/unreleased/sh-fix-fogbugz-import.yml
0 → 100644
View file @
948fabc2
---
title
:
Fix Fogbugz Importer not working
merge_request
:
29383
author
:
type
:
fixed
spec/controllers/import/fogbugz_controller_spec.rb
View file @
948fabc2
...
@@ -11,6 +11,44 @@ describe Import::FogbugzController do
...
@@ -11,6 +11,44 @@ describe Import::FogbugzController do
sign_in
(
user
)
sign_in
(
user
)
end
end
describe
'POST #callback'
do
let
(
:token
)
{
FFaker
::
Lorem
.
characters
(
8
)
}
let
(
:uri
)
{
'https://example.com'
}
let
(
:xml_response
)
{
%Q(<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?><response><token><![CDATA[
#{
token
}
]]></token></response>)
}
it
'attempts to contact Fogbugz server'
do
stub_request
(
:post
,
"https://example.com/api.asp"
).
to_return
(
status:
200
,
body:
xml_response
,
headers:
{})
post
:callback
,
params:
{
uri:
uri
,
email:
'test@example.com'
,
password:
'mypassword'
}
expect
(
session
[
:fogbugz_token
]).
to
eq
(
token
)
expect
(
session
[
:fogbugz_uri
]).
to
eq
(
uri
)
expect
(
response
).
to
redirect_to
(
new_user_map_import_fogbugz_path
)
end
end
describe
'POST #create_user_map'
do
let
(
:user_map
)
do
{
"2"
=>
{
"name"
=>
"Test User"
,
"email"
=>
"testuser@example.com"
,
"gitlab_user"
=>
"3"
}
}
end
it
'stores the user map in the session'
do
client
=
double
(
user_map:
{})
expect
(
controller
).
to
receive
(
:client
).
and_return
(
client
)
post
:create_user_map
,
params:
{
users:
user_map
}
expect
(
session
[
:fogbugz_user_map
]).
to
eq
(
user_map
)
expect
(
response
).
to
redirect_to
(
status_import_fogbugz_path
)
end
end
describe
'GET status'
do
describe
'GET status'
do
before
do
before
do
@repo
=
OpenStruct
.
new
(
name:
'vim'
)
@repo
=
OpenStruct
.
new
(
name:
'vim'
)
...
...
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