Refactor some diary entry routes to use resources
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 29 May 2019 13:55:27 +0000 (15:55 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 29 May 2019 13:55:27 +0000 (15:55 +0200)
app/views/layouts/_header.html.erb
app/views/site/about.html.erb
app/views/users/show.html.erb
config/routes.rb
test/system/diary_entry_test.rb

index a2a63b406af9e017bd053937de60c679f4679dbf..725000a1364bd2dd0a6ca9fc343f494ce2f2be08 100644 (file)
@@ -49,7 +49,7 @@
         </li>
       <% end %>
       <li class="compact-hide <%= current_page_class(traces_path) %>"><%= link_to t("layouts.gps_traces"), traces_path %></li>
-      <li class="compact-hide <%= current_page_class(diary_path) %>"><%= link_to t("layouts.user_diaries"), diary_path %></li>
+      <li class="compact-hide <%= current_page_class(diary_entries_path) %>"><%= link_to t("layouts.user_diaries"), diary_entries_path %></li>
       <li class="compact-hide <%= current_page_class(copyright_path) %>"><%= link_to t("layouts.copyright"), copyright_path %></li>
       <li class="compact-hide <%= current_page_class(help_path) %>"><%= link_to t("layouts.help"), help_path %></li>
       <li class="compact-hide <%= current_page_class(about_path) %>"><%= link_to t("layouts.about"), about_path %></li>
@@ -65,7 +65,7 @@
             </li>
           <% end %>
           <li class="<%= current_page_class(traces_path) %>"><%= link_to t("layouts.gps_traces"), traces_path %></li>
-          <li class="<%= current_page_class(diary_path) %>"><%= link_to t("layouts.user_diaries"), diary_path %></li>
+          <li class="<%= current_page_class(diary_entries_path) %>"><%= link_to t("layouts.user_diaries"), diary_entries_path %></li>
           <li class="<%= current_page_class(copyright_path) %>"><%= link_to t("layouts.copyright"), copyright_path %></li>
           <li class="<%= current_page_class(help_path) %>"><%= link_to t("layouts.help"), help_path %></li>
           <li class="<%= current_page_class(about_path) %>"><%= link_to t("layouts.about"), about_path %></li>
index 219e0ab6b0df3cf11e5eb9f0cd58f5414e25595a..886aaf006434f9069aee2338a74a5aa9d39a9cd2 100644 (file)
@@ -17,7 +17,7 @@
 
   <div class='section'>
     <h2><div class='icon community'></div><%= t ".community_driven_title" %></h2>
-    <p><%= t ".community_driven_html", :diary_path => diary_path %></p>
+    <p><%= t ".community_driven_html", :diary_path => diary_entries_path %></p>
   </div>
 
   <div class='section' id='open-data'>
index 5090cbee07a2e90284e033221c94a594f8ba3d4a..87eb9b45feb1c44027c7317e679820d79e8334c5 100644 (file)
     <% else %>
       <ul class='secondary-actions clearfix'>
         <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
-        <li><%= link_to t(".friends_diaries"), friend_diaries_path %></li>
+        <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
       </ul>
       <div id="friends-container">
         <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
     <% else %>
       <ul class='secondary-actions clearfix'>
         <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
-        <li><%= link_to t(".nearby_diaries"), nearby_diaries_path %></li>
+        <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
       </ul>
       <div id="nearbyusers">
         <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
index 12a2828184b617045c3d46f152b6926a5c19ac97..63ce061672a559ccdf87622093972ad5eac2800f 100644 (file)
@@ -216,9 +216,12 @@ OpenStreetMap::Application.routes.draw do
   post "/trace/:id/delete" => "traces#delete", :id => /\d+/
 
   # diary pages
-  resources :diary_entries, :path => "diary", :only => [:new, :create]
-  get "/diary/friends" => "diary_entries#index", :friends => true, :as => "friend_diaries"
-  get "/diary/nearby" => "diary_entries#index", :nearby => true, :as => "nearby_diaries"
+  resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
+    collection do
+      get "friends" => "diary_entries#index", :friends => true
+      get "nearby" => "diary_entries#index", :nearby => true
+    end
+  end
   get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
   get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
   get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
@@ -226,7 +229,6 @@ OpenStreetMap::Application.routes.draw do
   get "/user/:display_name/diary/comments/" => "diary_entries#comments"
   get "/user/:display_name/diary" => "diary_entries#index"
   get "/diary/:language" => "diary_entries#index"
-  get "/diary" => "diary_entries#index"
   scope "/user/:display_name" do
     resources :diary_entries, :path => "diary", :only => [:edit, :update, :show]
   end
index 39ccc04b26be946f9689a1011b5b78ec0bb1f513..6b6a51de553f554df76fc68ae305164ea504e084 100644 (file)
@@ -8,7 +8,7 @@ class DiaryEntrySystemTest < ApplicationSystemTestCase
 
   test "reply to diary entry should prefill the message subject" do
     sign_in_as(create(:user))
-    visit diary_path
+    visit diary_entries_path
 
     click_on "Reply to this entry"