From 660abc3647c9820aaa6132c1013dcc788d24e8a1 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Tue, 3 Jun 2025 18:38:51 +0300 Subject: [PATCH] Add empty profile links page --- app/controllers/profiles/links_controller.rb | 9 +++++ app/views/profiles/links/show.html.erb | 11 ++++++ .../profile_sections/_navigation.html.erb | 3 ++ config/locales/en.yml | 9 +++++ config/routes.rb | 1 + .../profiles/links_controller_test.rb | 34 +++++++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 app/controllers/profiles/links_controller.rb create mode 100644 app/views/profiles/links/show.html.erb create mode 100644 test/controllers/profiles/links_controller_test.rb diff --git a/app/controllers/profiles/links_controller.rb b/app/controllers/profiles/links_controller.rb new file mode 100644 index 000000000..b82a254fb --- /dev/null +++ b/app/controllers/profiles/links_controller.rb @@ -0,0 +1,9 @@ +module Profiles + class LinksController < ProfileSectionsController + private + + def update_profile + current_user.save + end + end +end diff --git a/app/views/profiles/links/show.html.erb b/app/views/profiles/links/show.html.erb new file mode 100644 index 000000000..a63e38f56 --- /dev/null +++ b/app/views/profiles/links/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 0710577dc..76b102d31 100644 --- a/app/views/profiles/profile_sections/_navigation.html.erb +++ b/app/views/profiles/profile_sections/_navigation.html.erb @@ -2,6 +2,9 @@ + diff --git a/config/locales/en.yml b/config/locales/en.yml index 4d1850085..d1f75a693 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1997,6 +1997,7 @@ en: profile_sections: navigation: description: Description + links: Links image: Image company: Company location: Location @@ -2012,6 +2013,14 @@ en: update: success: Profile updated. failure: Couldn't update profile. + links: + show: + title: Edit Profile + save: Update Profile + cancel: Cancel + update: + success: Profile updated. + failure: Couldn't update profile. images: show: title: Edit Profile diff --git a/config/routes.rb b/config/routes.rb index 6dd1b100d..b58d71244 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 :links, :only => [:show, :update] resource :image, :only => [:show, :update] resource :company, :only => [:show, :update] resource :location, :only => [:show, :update] diff --git a/test/controllers/profiles/links_controller_test.rb b/test/controllers/profiles/links_controller_test.rb new file mode 100644 index 000000000..dfd23db65 --- /dev/null +++ b/test/controllers/profiles/links_controller_test.rb @@ -0,0 +1,34 @@ +require "test_helper" + +module Profiles + class LinksControllerTest < ActionDispatch::IntegrationTest + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/profile/links", :method => :get }, + { :controller => "profiles/links", :action => "show" } + ) + assert_routing( + { :path => "/profile/links", :method => :put }, + { :controller => "profiles/links", :action => "update" } + ) + end + + def test_show + user = create(:user) + session_for(user) + + get profile_links_path + + assert_response :success + assert_template :show + end + + def test_show_unauthorized + get profile_links_path + + assert_redirected_to login_path(:referer => profile_links_path) + end + end +end -- 2.39.5