can [:index, :feed], Changeset
can :index, ChangesetComment
can [:index, :rss, :show, :comments], DiaryEntry
- can [:mine], Note
+ can [:index], Note
can [:index, :show], Redaction
can [:index, :show, :data, :georss, :picture, :icon], Trace
can [:terms, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :auth_success, :auth_failure], User
class NotesController < ApplicationController
- layout "site", :only => [:mine]
+ layout "site"
before_action :check_api_readable
before_action :authorize_web
##
# Display a list of notes by a specified user
- def mine
+ def index
if params[:display_name]
if @user = User.active.find_by(:display_name => params[:display_name])
@params = params.permit(:display_name)
- @title = t "notes.mine.title", :user => @user.display_name
+ @title = t ".title", :user => @user.display_name
@page = (params[:page] || 1).to_i
@page_size = 10
@notes = @user.notes
<% content_for :heading do %>
- <h2><%= t "notes.mine.heading", :user => @user.display_name %></h2>
- <p><%= t "notes.mine.subheading_html", :user => link_to(@user.display_name, user_path(@user)) %></p>
+ <h2><%= t ".heading", :user => @user.display_name %></h2>
+ <p><%= t ".subheading_html", :user => link_to(@user.display_name, user_path(@user)) %></p>
<% end %>
<%= render :partial => "notes_paging_nav" %>
<span class='count-number'><%= number_with_delimiter(current_user.changesets.size) %></span>
</li>
<li>
- <%= link_to t(".my notes"), :controller => "notes", :action => "mine" %>
+ <%= link_to t(".my notes"), user_notes_path(@user) %>
</li>
<li>
<%= link_to t(".my traces"), :controller => "traces", :action => "mine" %>
<span class='count-number'><%= number_with_delimiter(@user.changesets.size) %></span>
</li>
<li>
- <%= link_to t(".notes"), :controller => "notes", :action => "mine" %>
+ <%= link_to t(".notes"), user_notes_path(@user) %>
</li>
<li>
<%= link_to t(".traces"), :controller => "traces", :action => "index", :display_name => @user.display_name %>
next: "Next »"
previous: "« Previous"
notes:
- mine:
+ index:
title: "Notes submitted or commented on by %{user}"
heading: "%{user}'s notes"
subheading_html: "Notes submitted or commented on by %{user}"
get "/note/new" => "browse#new_note"
get "/user/:display_name/history" => "changesets#index"
get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
- get "/user/:display_name/notes" => "notes#mine", :as => :my_notes
+ get "/user/:display_name/notes" => "notes#index", :as => :user_notes
get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
test "note permissions for a guest" do
ability = Ability.new nil
- [:mine].each do |action|
+ [:index].each do |action|
assert ability.can?(action, Note), "should be able to #{action} Notes"
end
end
def test_routes
assert_routing(
{ :path => "/user/username/notes", :method => :get },
- { :controller => "notes", :action => "mine", :display_name => "username" }
+ { :controller => "notes", :action => "index", :display_name => "username" }
)
end
- def test_mine_success
+ def test_index_success
first_user = create(:user)
second_user = create(:user)
moderator_user = create(:moderator_user)
end
# Note that the table rows include a header row
- get my_notes_path(:display_name => first_user.display_name)
+ get user_notes_path(:display_name => first_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 2
- get my_notes_path(:display_name => second_user.display_name)
+ get user_notes_path(:display_name => second_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 2
- get my_notes_path(:display_name => "non-existent")
+ get user_notes_path(:display_name => "non-existent")
assert_response :not_found
session_for(moderator_user)
- get my_notes_path(:display_name => first_user.display_name)
+ get user_notes_path(:display_name => first_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 2
- get my_notes_path(:display_name => second_user.display_name)
+ get user_notes_path(:display_name => second_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 3
- get my_notes_path(:display_name => "non-existent")
+ get user_notes_path(:display_name => "non-existent")
assert_response :not_found
end
- def test_mine_paged
+ def test_index_paged
user = create(:user)
create_list(:note, 50) do |note|
create(:note_comment, :note => note, :author => user)
end
- get my_notes_path(:display_name => user.display_name)
+ get user_notes_path(:display_name => user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 11
- get my_notes_path(:display_name => user.display_name, :page => 2)
+ get user_notes_path(:display_name => user.display_name, :page => 2)
assert_response :success
assert_select "table.note_list tr", :count => 11
end