From f144ec969a0008bc4dda46d2dee0c42e5cfc92df Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Tue, 3 Jun 2025 05:50:58 +0300 Subject: [PATCH] Add empty profile location page --- .../profiles/locations_controller.rb | 9 +++++ app/views/profiles/locations/show.html.erb | 11 ++++++ .../profile_sections/_navigation.html.erb | 3 ++ config/locales/en.yml | 9 +++++ config/routes.rb | 1 + .../profiles/locations_controller_test.rb | 34 +++++++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 app/controllers/profiles/locations_controller.rb create mode 100644 app/views/profiles/locations/show.html.erb create mode 100644 test/controllers/profiles/locations_controller_test.rb diff --git a/app/controllers/profiles/locations_controller.rb b/app/controllers/profiles/locations_controller.rb new file mode 100644 index 000000000..a4e6e997c --- /dev/null +++ b/app/controllers/profiles/locations_controller.rb @@ -0,0 +1,9 @@ +module Profiles + class LocationsController < ProfileSectionsController + private + + def update_profile + current_user.save + end + end +end diff --git a/app/views/profiles/locations/show.html.erb b/app/views/profiles/locations/show.html.erb new file mode 100644 index 000000000..a63e38f56 --- /dev/null +++ b/app/views/profiles/locations/show.html.erb @@ -0,0 +1,11 @@ +<% content_for :heading_class, "pb-0" %> + +<% content_for :heading do %> +

<%= t ".title" %>

+ <%= render :partial => "navigation" %> +<% end %> + +<%= bootstrap_form_for current_user, :url => { :action => :update } do |f| %> + <%= f.primary t(".save") %> + <%= link_to t(".cancel"), current_user, :class => "btn btn-link" %> +<% end %> diff --git a/app/views/profiles/profile_sections/_navigation.html.erb b/app/views/profiles/profile_sections/_navigation.html.erb index 4c6bd645c..a86e0c7a0 100644 --- a/app/views/profiles/profile_sections/_navigation.html.erb +++ b/app/views/profiles/profile_sections/_navigation.html.erb @@ -2,4 +2,7 @@ + diff --git a/config/locales/en.yml b/config/locales/en.yml index a5522099d..5dcabb3c0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1997,6 +1997,7 @@ en: profile_sections: navigation: description: Description + location: Location descriptions: show: title: Edit Profile @@ -2025,6 +2026,14 @@ en: update: success: Profile updated. failure: Couldn't update profile. + locations: + show: + title: Edit Profile + save: Update Profile + cancel: Cancel + update: + success: Profile updated. + failure: Couldn't update profile. sessions: new: tab_title: "Log In" diff --git a/config/routes.rb b/config/routes.rb index 413cdd180..7910d2ea5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -320,6 +320,7 @@ OpenStreetMap::Application.routes.draw do namespace :profile, :module => :profiles do resource :description, :only => [:show, :update] + resource :location, :only => [:show, :update] end get "/profile", :to => redirect(:path => "/profile/description"), :as => nil get "/profile/edit", :to => redirect(:path => "/profile/description"), :as => nil diff --git a/test/controllers/profiles/locations_controller_test.rb b/test/controllers/profiles/locations_controller_test.rb new file mode 100644 index 000000000..b1bbf141f --- /dev/null +++ b/test/controllers/profiles/locations_controller_test.rb @@ -0,0 +1,34 @@ +require "test_helper" + +module Profiles + class LocationsControllerTest < ActionDispatch::IntegrationTest + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/profile/location", :method => :get }, + { :controller => "profiles/locations", :action => "show" } + ) + assert_routing( + { :path => "/profile/location", :method => :put }, + { :controller => "profiles/locations", :action => "update" } + ) + end + + def test_show + user = create(:user) + session_for(user) + + get profile_location_path + + assert_response :success + assert_template :show + end + + def test_show_unauthorized + get profile_location_path + + assert_redirected_to login_path(:referer => profile_location_path) + end + end +end -- 2.39.5