Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
72b7b10d
Commit
72b7b10d
authored
Oct 24, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add applications controller logic
parent
bba020a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
22 deletions
+42
-22
app/controllers/admin/applications_controller.rb
app/controllers/admin/applications_controller.rb
+5
-10
app/controllers/oauth/applications_controller.rb
app/controllers/oauth/applications_controller.rb
+10
-12
app/services/applications/create_searvice.rb
app/services/applications/create_searvice.rb
+15
-0
spec/services/applications/create_service_spec.rb
spec/services/applications/create_service_spec.rb
+12
-0
No files found.
app/controllers/admin/applications_controller.rb
View file @
72b7b10d
...
...
@@ -19,10 +19,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
end
def
create
@application
=
Doorkeeper
::
Application
.
new
(
application_params
)
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
.
merge
(
ip_address:
request
.
remote_ip
)).
execute
if
@application
.
save
redirect_to_admin_page
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
admin_application_url
(
@application
)
else
render
:new
end
...
...
@@ -41,13 +43,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
redirect_to
admin_applications_url
,
status:
302
,
notice:
'Application was successfully destroyed.'
end
protected
def
redirect_to_admin_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
admin_application_url
(
@application
)
end
private
def
set_application
...
...
app/controllers/oauth/applications_controller.rb
View file @
72b7b10d
...
...
@@ -16,25 +16,16 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
end
def
create
@application
=
Doorkeeper
::
Application
.
new
(
application_params
)
@application
=
Applications
::
CreateService
.
new
(
current_user
,
create_application_params
).
execute
@application
.
owner
=
current_user
if
@application
.
save
redirect_to_oauth_application_page
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
else
set_index_vars
render
:index
end
end
protected
def
redirect_to_oauth_application_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
oauth_application_url
(
@application
)
end
private
def
verify_user_oauth_applications_enabled
...
...
@@ -61,4 +52,11 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
end
def
create_application_params
application_params
.
tap
do
|
params
|
params
[
:owner
]
=
current_user
params
[
:ip_address
]
=
request
.
remote_ip
end
end
end
app/services/applications/create_searvice.rb
0 → 100644
View file @
72b7b10d
module
Applications
class
CreateService
prepend
::
EE
::
Applications
::
CreateService
def
initialize
(
current_user
,
params
)
@current_user
=
current_user
@params
=
params
@ip_address
=
@params
.
delete
(
:ip_address
)
end
def
execute
Doorkeeper
::
Application
.
create
(
@params
)
end
end
end
spec/services/applications/create_service_spec.rb
0 → 100644
View file @
72b7b10d
require
'spec_helper'
describe
::
Applications
::
CreateService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:params
)
{
attributes_for
(
:application
)
}
subject
{
described_class
.
new
(
user
,
params
)
}
it
'creates an application'
do
expect
{
subject
.
execute
}.
to
change
{
Doorkeeper
::
Application
.
count
}.
by
(
1
)
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