Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a /profile/me action that redirects to the profile for the logged-in user #4291

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def show
@extra_rubygems = rubygems
end

def me
redirect_to profile_path(current_user.display_id)
end

def edit
@user = current_user
end
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
end
resource :dashboard, only: :show, constraints: { format: /html|atom/ }
resources :profiles, only: :show
get "profile/me", to: "profiles#me", as: :my_profile
resource :multifactor_auth, only: %i[new create update destroy] do
get 'recovery'
post 'otp_update', to: 'multifactor_auths#otp_update', as: :otp_update
Expand Down
16 changes: 16 additions & 0 deletions test/functional/profiles_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class ProfilesControllerTest < ActionController::TestCase
end
end

context "on GET to me" do
setup { get :me }

should respond_with :redirect
should redirect_to("the sign in path") { sign_in_path }
end

context "on GET to show when hide email" do
setup do
@user.update(public_email: false)
Expand Down Expand Up @@ -75,6 +82,15 @@ class ProfilesControllerTest < ActionController::TestCase
end
end

context "on GET to me" do
setup do
get :me
end

should respond_with :redirect
should redirect_to("the user's profile page") { profile_path(@user.handle) }
end

context "on GET to delete" do
setup do
get :delete
Expand Down