fix: Super admin redirect issue [CW-1370] (#6715)
This commit is contained in:
@@ -1,6 +1,18 @@
|
|||||||
class SuperAdmin::UsersController < SuperAdmin::ApplicationController
|
class SuperAdmin::UsersController < SuperAdmin::ApplicationController
|
||||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||||
# For example, you may want to send an email after a foo is updated.
|
# For example, you may want to send an email after a foo is updated.
|
||||||
|
|
||||||
|
def create
|
||||||
|
resource = resource_class.new(resource_params)
|
||||||
|
authorize_resource(resource)
|
||||||
|
|
||||||
|
if resource.save
|
||||||
|
redirect_to super_admin_user_path(resource), notice: translate_with_resource('create.success')
|
||||||
|
else
|
||||||
|
notice = resource.errors.full_messages.first
|
||||||
|
redirect_to new_super_admin_user_path, notice: notice
|
||||||
|
end
|
||||||
|
end
|
||||||
#
|
#
|
||||||
# def update
|
# def update
|
||||||
# super
|
# super
|
||||||
|
|||||||
@@ -13,6 +13,16 @@ RSpec.describe 'Super Admin Users API', type: :request do
|
|||||||
|
|
||||||
context 'when it is an authenticated super admin' do
|
context 'when it is an authenticated super admin' do
|
||||||
let!(:user) { create(:user) }
|
let!(:user) { create(:user) }
|
||||||
|
let!(:params) do
|
||||||
|
{ user: {
|
||||||
|
name: 'admin@example.com',
|
||||||
|
display_name: 'admin@example.com',
|
||||||
|
email: 'admin@example.com',
|
||||||
|
password: 'Password1!',
|
||||||
|
confirmed_at: '2023-03-20 22:32:41',
|
||||||
|
type: 'SuperAdmin'
|
||||||
|
} }
|
||||||
|
end
|
||||||
|
|
||||||
it 'shows the list of users' do
|
it 'shows the list of users' do
|
||||||
sign_in(super_admin, scope: :super_admin)
|
sign_in(super_admin, scope: :super_admin)
|
||||||
@@ -21,6 +31,18 @@ RSpec.describe 'Super Admin Users API', type: :request do
|
|||||||
expect(response.body).to include('New user')
|
expect(response.body).to include('New user')
|
||||||
expect(response.body).to include(CGI.escapeHTML(user.name))
|
expect(response.body).to include(CGI.escapeHTML(user.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates the new super_admin record' do
|
||||||
|
sign_in(super_admin, scope: :super_admin)
|
||||||
|
|
||||||
|
post '/super_admin/users', params: params
|
||||||
|
|
||||||
|
expect(response).to redirect_to("http://www.example.com/super_admin/users/#{User.last.id}")
|
||||||
|
expect(SuperAdmin.last.email).to eq('admin@example.com')
|
||||||
|
|
||||||
|
post '/super_admin/users', params: params
|
||||||
|
expect(response).to redirect_to('http://www.example.com/super_admin/users/new')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user