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
d3c816a5
Commit
d3c816a5
authored
Nov 04, 2021
by
Peter Hegman
Committed by
Dmitry Gruzd
Nov 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `Continue` button to view shown after creating an OAuth application
parent
19d45d03
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
142 additions
and
5 deletions
+142
-5
app/controllers/admin/applications_controller.rb
app/controllers/admin/applications_controller.rb
+3
-0
app/controllers/concerns/oauth_applications.rb
app/controllers/concerns/oauth_applications.rb
+10
-0
app/controllers/groups/settings/applications_controller.rb
app/controllers/groups/settings/applications_controller.rb
+3
-0
app/controllers/oauth/applications_controller.rb
app/controllers/oauth/applications_controller.rb
+6
-0
app/views/admin/applications/show.html.haml
app/views/admin/applications/show.html.haml
+1
-0
app/views/doorkeeper/applications/show.html.haml
app/views/doorkeeper/applications/show.html.haml
+4
-1
app/views/groups/settings/applications/show.html.haml
app/views/groups/settings/applications/show.html.haml
+4
-1
app/views/shared/doorkeeper/applications/_show.html.haml
app/views/shared/doorkeeper/applications/_show.html.haml
+6
-3
spec/features/admin/admin_manage_applications_spec.rb
spec/features/admin/admin_manage_applications_spec.rb
+1
-0
spec/features/groups/settings/manage_applications_spec.rb
spec/features/groups/settings/manage_applications_spec.rb
+1
-0
spec/features/profiles/user_manages_applications_spec.rb
spec/features/profiles/user_manages_applications_spec.rb
+1
-0
spec/requests/admin/applications_controller_spec.rb
spec/requests/admin/applications_controller_spec.rb
+18
-0
spec/requests/groups/settings/applications_controller_spec.rb
.../requests/groups/settings/applications_controller_spec.rb
+20
-0
spec/requests/oauth/applications_controller_spec.rb
spec/requests/oauth/applications_controller_spec.rb
+18
-0
spec/support/shared_examples/features/manage_applications_shared_examples.rb
..._examples/features/manage_applications_shared_examples.rb
+2
-0
spec/support/shared_examples/requests/applications_controller_shared_examples.rb
...mples/requests/applications_controller_shared_examples.rb
+44
-0
No files found.
app/controllers/admin/applications_controller.rb
View file @
d3c816a5
...
...
@@ -15,6 +15,7 @@ class Admin::ApplicationsController < Admin::ApplicationController
end
def
show
@created
=
get_created_session
end
def
new
...
...
@@ -33,6 +34,8 @@ class Admin::ApplicationsController < Admin::ApplicationController
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
set_created_session
redirect_to
admin_application_url
(
@application
)
else
render
:new
...
...
app/controllers/concerns/oauth_applications.rb
View file @
d3c816a5
...
...
@@ -3,6 +3,8 @@
module
OauthApplications
extend
ActiveSupport
::
Concern
CREATED_SESSION_KEY
=
:oauth_applications_created
included
do
before_action
:prepare_scopes
,
only:
[
:create
,
:update
]
end
...
...
@@ -15,6 +17,14 @@ module OauthApplications
end
end
def
set_created_session
session
[
CREATED_SESSION_KEY
]
=
true
end
def
get_created_session
session
.
delete
(
CREATED_SESSION_KEY
)
||
false
end
def
load_scopes
@scopes
||=
Doorkeeper
.
configuration
.
scopes
end
...
...
app/controllers/groups/settings/applications_controller.rb
View file @
d3c816a5
...
...
@@ -16,6 +16,7 @@ module Groups
end
def
show
@created
=
get_created_session
end
def
edit
...
...
@@ -27,6 +28,8 @@ module Groups
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
set_created_session
redirect_to
group_settings_application_url
(
@group
,
@application
)
else
set_index_vars
...
...
app/controllers/oauth/applications_controller.rb
View file @
d3c816a5
...
...
@@ -24,12 +24,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
set_index_vars
end
def
show
@created
=
get_created_session
end
def
create
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
).
execute
(
request
)
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
set_created_session
redirect_to
oauth_application_url
(
@application
)
else
set_index_vars
...
...
app/views/admin/applications/show.html.haml
View file @
d3c816a5
...
...
@@ -6,4 +6,5 @@
=
render
'shared/doorkeeper/applications/show'
,
edit_path:
edit_admin_application_path
(
@application
),
delete_path:
admin_application_path
(
@application
),
index_path:
admin_applications_path
,
show_trusted_row:
true
app/views/doorkeeper/applications/show.html.haml
View file @
d3c816a5
...
...
@@ -6,4 +6,7 @@
%h3
.page-title
=
_
(
"Application: %{name}"
)
%
{
name:
@application
.
name
}
=
render
'shared/doorkeeper/applications/show'
,
edit_path:
edit_oauth_application_path
(
@application
),
delete_path:
oauth_application_path
(
@application
)
=
render
'shared/doorkeeper/applications/show'
,
edit_path:
edit_oauth_application_path
(
@application
),
delete_path:
oauth_application_path
(
@application
),
index_path:
oauth_applications_path
app/views/groups/settings/applications/show.html.haml
View file @
d3c816a5
...
...
@@ -6,4 +6,7 @@
%h3
.page-title
=
_
(
"Group application: %{name}"
)
%
{
name:
@application
.
name
}
=
render
'shared/doorkeeper/applications/show'
,
edit_path:
edit_group_settings_application_path
(
@group
,
@application
),
delete_path:
group_settings_application_path
(
@group
,
@application
)
=
render
'shared/doorkeeper/applications/show'
,
edit_path:
edit_group_settings_application_path
(
@group
,
@application
),
delete_path:
group_settings_application_path
(
@group
,
@application
),
index_path:
group_settings_applications_path
app/views/shared/doorkeeper/applications/_show.html.haml
View file @
d3c816a5
...
...
@@ -39,6 +39,9 @@
=
render
"shared/tokens/scopes_list"
,
token:
@application
.form-actions
=
link_to
_
(
'Edit'
),
edit_path
,
class:
'gl-button btn btn-confirm wide float-left'
=
render
'shared/doorkeeper/applications/delete_form'
,
path:
delete_path
,
submit_btn_css:
'gl-button btn btn-danger gl-ml-3'
.form-actions.gl-display-flex.gl-justify-content-space-between
%div
-
if
@created
=
link_to
_
(
'Continue'
),
index_path
,
class:
'btn btn-confirm btn-md gl-button gl-mr-3'
=
link_to
_
(
'Edit'
),
edit_path
,
class:
'btn btn-default btn-md gl-button'
=
render
'shared/doorkeeper/applications/delete_form'
,
path:
delete_path
,
submit_btn_css:
'btn btn-danger btn-md gl-button btn-danger-secondary'
spec/features/admin/admin_manage_applications_spec.rb
View file @
d3c816a5
...
...
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec
.
describe
'admin manage applications'
do
let_it_be
(
:new_application_path
)
{
new_admin_application_path
}
let_it_be
(
:applications_path
)
{
admin_applications_path
}
let_it_be
(
:index_path
)
{
admin_applications_path
}
before
do
admin
=
create
(
:admin
)
...
...
spec/features/groups/settings/manage_applications_spec.rb
View file @
d3c816a5
...
...
@@ -6,6 +6,7 @@ RSpec.describe 'User manages applications' do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:new_application_path
)
{
group_settings_applications_path
(
group
)
}
let_it_be
(
:index_path
)
{
group_settings_applications_path
(
group
)
}
before
do
group
.
add_owner
(
user
)
...
...
spec/features/profiles/user_manages_applications_spec.rb
View file @
d3c816a5
...
...
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec
.
describe
'User manages applications'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:new_application_path
)
{
applications_profile_path
}
let_it_be
(
:index_path
)
{
oauth_applications_path
}
before
do
sign_in
(
user
)
...
...
spec/requests/admin/applications_controller_spec.rb
0 → 100644
View file @
d3c816a5
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Admin
::
ApplicationsController
,
:enable_admin_mode
do
let_it_be
(
:admin
)
{
create
(
:admin
)
}
let_it_be
(
:application
)
{
create
(
:oauth_application
,
owner_id:
nil
,
owner_type:
nil
)
}
let_it_be
(
:show_path
)
{
admin_application_path
(
application
)
}
let_it_be
(
:create_path
)
{
admin_applications_path
}
before
do
sign_in
(
admin
)
end
include_examples
'applications controller - GET #show'
include_examples
'applications controller - POST #create'
end
spec/requests/groups/settings/applications_controller_spec.rb
0 → 100644
View file @
d3c816a5
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Groups
::
Settings
::
ApplicationsController
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:application
)
{
create
(
:oauth_application
,
owner_id:
group
.
id
,
owner_type:
'Namespace'
)
}
let_it_be
(
:show_path
)
{
group_settings_application_path
(
group
,
application
)
}
let_it_be
(
:create_path
)
{
group_settings_applications_path
(
group
)
}
before
do
sign_in
(
user
)
group
.
add_owner
(
user
)
end
include_examples
'applications controller - GET #show'
include_examples
'applications controller - POST #create'
end
spec/requests/oauth/applications_controller_spec.rb
0 → 100644
View file @
d3c816a5
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Oauth
::
ApplicationsController
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:application
)
{
create
(
:oauth_application
,
owner:
user
)
}
let_it_be
(
:show_path
)
{
oauth_application_path
(
application
)
}
let_it_be
(
:create_path
)
{
oauth_applications_path
}
before
do
sign_in
(
user
)
end
include_examples
'applications controller - GET #show'
include_examples
'applications controller - POST #create'
end
spec/support/shared_examples/features/manage_applications_shared_examples.rb
View file @
d3c816a5
...
...
@@ -18,6 +18,7 @@ RSpec.shared_examples 'manage applications' do
click_on
'Save application'
validate_application
(
application_name
,
'Yes'
)
expect
(
page
).
to
have_link
(
'Continue'
,
href:
index_path
)
application
=
Doorkeeper
::
Application
.
find_by
(
name:
application_name
)
expect
(
page
).
to
have_css
(
"button[title=
\"
Copy secret
\"
][data-clipboard-text=
\"
#{
application
.
secret
}
\"
]"
,
text:
'Copy'
)
...
...
@@ -33,6 +34,7 @@ RSpec.shared_examples 'manage applications' do
click_on
'Save application'
validate_application
(
application_name_changed
,
'No'
)
expect
(
page
).
not_to
have_link
(
'Continue'
)
visit_applications_path
...
...
spec/support/shared_examples/requests/applications_controller_shared_examples.rb
0 → 100644
View file @
d3c816a5
# frozen_string_literal: true
RSpec
.
shared_examples
'applications controller - GET #show'
do
describe
'GET #show'
do
it
'renders template'
do
get
show_path
expect
(
response
).
to
render_template
:show
end
context
'when application is viewed after being created'
do
before
do
create_application
end
it
'sets `@created` instance variable to `true`'
do
get
show_path
expect
(
assigns
[
:created
]).
to
eq
(
true
)
end
end
context
'when application is reviewed'
do
it
'sets `@created` instance variable to `false`'
do
get
show_path
expect
(
assigns
[
:created
]).
to
eq
(
false
)
end
end
end
end
RSpec
.
shared_examples
'applications controller - POST #create'
do
it
"sets `
#{
OauthApplications
::
CREATED_SESSION_KEY
}
` session key to `true`"
do
create_application
expect
(
session
[
OauthApplications
::
CREATED_SESSION_KEY
]).
to
eq
(
true
)
end
end
def
create_application
create_params
=
attributes_for
(
:application
,
trusted:
true
,
confidential:
false
,
scopes:
[
'api'
])
post
create_path
,
params:
{
doorkeeper_application:
create_params
}
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