before_action :check_database_readable
before_action :check_database_writable, :only => [:new, :edit, :comment, :hide, :hidecomment, :subscribe, :unsubscribe]
before_action :require_administrator, :only => [:hide, :hidecomment]
- before_action :allow_thirdparty_images, :only => [:new, :edit, :list, :show, :comments]
+ before_action :allow_thirdparty_images, :only => [:new, :edit, :index, :show, :comments]
def new
@title = t "diary_entry.new.title"
# Subscribe user to diary comments
@diary_entry.subscriptions.create(:user => current_user)
- redirect_to :action => "list", :display_name => current_user.display_name
+ redirect_to :action => "index", :display_name => current_user.display_name
else
render :action => "edit"
end
render :action => "no_such_entry", :status => :not_found
end
- def list
+ def index
if params[:display_name]
@user = User.active.find_by(:display_name => params[:display_name])
if @user
- @title = t "diary_entry.list.user_title", :user => @user.display_name
+ @title = t "diary_entry.index.user_title", :user => @user.display_name
@entries = @user.diary_entries
else
render_unknown_user params[:display_name]
end
elsif params[:friends]
if current_user
- @title = t "diary_entry.list.title_friends"
+ @title = t "diary_entry.index.title_friends"
@entries = DiaryEntry.where(:user_id => current_user.friend_users)
else
require_user
end
elsif params[:nearby]
if current_user
- @title = t "diary_entry.list.title_nearby"
+ @title = t "diary_entry.index.title_nearby"
@entries = DiaryEntry.where(:user_id => current_user.nearby)
else
require_user
@entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] })
if params[:language]
- @title = t "diary_entry.list.in_language_title", :language => Language.find(params[:language]).english_name
+ @title = t "diary_entry.index.in_language_title", :language => Language.find(params[:language]).english_name
@entries = @entries.where(:language_code => params[:language])
else
- @title = t "diary_entry.list.title"
+ @title = t "diary_entry.index.title"
end
end
@entries = user.diary_entries
@title = t("diary_entry.feed.user.title", :user => user.display_name)
@description = t("diary_entry.feed.user.description", :user => user.display_name)
- @link = url_for :controller => "diary_entry", :action => "list", :display_name => user.display_name, :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+ @link = url_for :controller => "diary_entry", :action => "index", :display_name => user.display_name, :host => SERVER_URL, :protocol => SERVER_PROTOCOL
else
head :not_found
return
@entries = @entries.where(:language_code => params[:language])
@title = t("diary_entry.feed.language.title", :language_name => Language.find(params[:language]).english_name)
@description = t("diary_entry.feed.language.description", :language_name => Language.find(params[:language]).english_name)
- @link = url_for :controller => "diary_entry", :action => "list", :language => params[:language], :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+ @link = url_for :controller => "diary_entry", :action => "index", :language => params[:language], :host => SERVER_URL, :protocol => SERVER_PROTOCOL
else
@title = t("diary_entry.feed.all.title")
@description = t("diary_entry.feed.all.description")
- @link = url_for :controller => "diary_entry", :action => "list", :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+ @link = url_for :controller => "diary_entry", :action => "index", :host => SERVER_URL, :protocol => SERVER_PROTOCOL
end
end
def hide
entry = DiaryEntry.find(params[:id])
entry.update(:visible => false)
- redirect_to :action => "list", :display_name => entry.user.display_name
+ redirect_to :action => "index", :display_name => entry.user.display_name
end
def hidecomment
def test_routes
assert_routing(
{ :path => "/diary", :method => :get },
- { :controller => "diary_entry", :action => "list" }
+ { :controller => "diary_entry", :action => "index" }
)
assert_routing(
{ :path => "/diary/language", :method => :get },
- { :controller => "diary_entry", :action => "list", :language => "language" }
+ { :controller => "diary_entry", :action => "index", :language => "language" }
)
assert_routing(
{ :path => "/user/username/diary", :method => :get },
- { :controller => "diary_entry", :action => "list", :display_name => "username" }
+ { :controller => "diary_entry", :action => "index", :display_name => "username" }
)
assert_routing(
{ :path => "/diary/friends", :method => :get },
- { :controller => "diary_entry", :action => "list", :friends => true }
+ { :controller => "diary_entry", :action => "index", :friends => true }
)
assert_routing(
{ :path => "/diary/nearby", :method => :get },
- { :controller => "diary_entry", :action => "list", :nearby => true }
+ { :controller => "diary_entry", :action => "index", :nearby => true }
)
assert_routing(
:session => { :user => user.id }
end
assert_response :redirect
- assert_redirected_to :action => :list, :display_name => user.display_name
+ assert_redirected_to :action => :index, :display_name => user.display_name
entry = DiaryEntry.order(:id).last
assert_equal user.id, entry.user_id
assert_equal "New Title", entry.title
:session => { :user => user.id }
end
assert_response :redirect
- assert_redirected_to :action => :list, :display_name => user.display_name
+ assert_redirected_to :action => :index, :display_name => user.display_name
entry = DiaryEntry.order(:id).last
assert_equal user.id, entry.user_id
assert_equal "New Title", entry.title
:session => { :user => user.id }
end
assert_response :redirect
- assert_redirected_to :action => :list, :display_name => user.display_name
+ assert_redirected_to :action => :index, :display_name => user.display_name
entry = DiaryEntry.order(:id).last
assert_equal user.id, entry.user_id
assert_equal spammy_title, entry.title
assert_equal "suspended", User.find(user.id).status
# Follow the redirect
- get :list,
+ get :index,
:params => { :display_name => user.display_name },
:session => { :user => user }
assert_response :redirect
assert_equal "suspended", User.find(other_user.id).status
# Follow the redirect
- get :list,
+ get :index,
:params => { :display_name => user.display_name },
:session => { :user => other_user }
assert_response :redirect
assert_select ".diary-comment", :count => 0
end
- def test_list_all
+ def test_index_all
diary_entry = create(:diary_entry)
geo_entry = create(:diary_entry, :latitude => 51.50763, :longitude => -0.10781)
public_entry = create(:diary_entry, :user => create(:user))
# Try a list of all diary entries
- get :list
- check_diary_list diary_entry, geo_entry, public_entry
+ get :index
+ check_diary_index diary_entry, geo_entry, public_entry
end
- def test_list_user
+ def test_index_user
user = create(:user)
other_user = create(:user)
_other_entry = create(:diary_entry, :user => other_user)
# Try a list of diary entries for a valid user
- get :list, :params => { :display_name => user.display_name }
- check_diary_list diary_entry, geo_entry
+ get :index, :params => { :display_name => user.display_name }
+ check_diary_index diary_entry, geo_entry
# Try a list of diary entries for an invalid user
- get :list, :params => { :display_name => "No Such User" }
+ get :index, :params => { :display_name => "No Such User" }
assert_response :not_found
assert_template "user/no_such_user"
end
- def test_list_friends
+ def test_index_friends
user = create(:user)
other_user = create(:user)
friend = create(:friend, :befriender => user)
_other_entry = create(:diary_entry, :user => other_user)
# Try a list of diary entries for your friends when not logged in
- get :list, :params => { :friends => true }
+ get :index, :params => { :friends => true }
assert_response :redirect
assert_redirected_to :controller => :user, :action => :login, :referer => "/diary/friends"
# Try a list of diary entries for your friends when logged in
- get :list, :params => { :friends => true }, :session => { :user => user }
- check_diary_list diary_entry
- get :list, :params => { :friends => true }, :session => { :user => other_user }
- check_diary_list
+ get :index, :params => { :friends => true }, :session => { :user => user }
+ check_diary_index diary_entry
+ get :index, :params => { :friends => true }, :session => { :user => other_user }
+ check_diary_index
end
- def test_list_nearby
+ def test_index_nearby
user = create(:user, :home_lat => 12, :home_lon => 12)
nearby_user = create(:user, :home_lat => 11.9, :home_lon => 12.1)
diary_entry = create(:diary_entry, :user => user)
# Try a list of diary entries for nearby users when not logged in
- get :list, :params => { :nearby => true }
+ get :index, :params => { :nearby => true }
assert_response :redirect
assert_redirected_to :controller => :user, :action => :login, :referer => "/diary/nearby"
# Try a list of diary entries for nearby users when logged in
- get :list, :params => { :nearby => true }, :session => { :user => nearby_user }
- check_diary_list diary_entry
- get :list, :params => { :nearby => true }, :session => { :user => user }
- check_diary_list
+ get :index, :params => { :nearby => true }, :session => { :user => nearby_user }
+ check_diary_index diary_entry
+ get :index, :params => { :nearby => true }, :session => { :user => user }
+ check_diary_index
end
- def test_list_language
+ def test_index_language
create(:language, :code => "de")
create(:language, :code => "sl")
diary_entry_en = create(:diary_entry, :language_code => "en")
diary_entry_de = create(:diary_entry, :language_code => "de")
# Try a list of diary entries in english
- get :list, :params => { :language => "en" }
- check_diary_list diary_entry_en, diary_entry_en2
+ get :index, :params => { :language => "en" }
+ check_diary_index diary_entry_en, diary_entry_en2
# Try a list of diary entries in german
- get :list, :params => { :language => "de" }
- check_diary_list diary_entry_de
+ get :index, :params => { :language => "de" }
+ check_diary_index diary_entry_de
# Try a list of diary entries in slovenian
- get :list, :params => { :language => "sl" }
- check_diary_list
+ get :index, :params => { :language => "sl" }
+ check_diary_index
end
- def test_list_paged
+ def test_index_paged
# Create several pages worth of diary entries
create_list(:diary_entry, 50)
- # Try and get the list
- get :list
+ # Try and get the index
+ get :index
assert_response :success
assert_select "div.diary_post", :count => 20
# Try and get the second page
- get :list, :params => { :page => 2 }
+ get :index, :params => { :page => 2 }
assert_response :success
assert_select "div.diary_post", :count => 20
end
:params => { :display_name => user.display_name, :id => diary_entry.id },
:session => { :user => create(:administrator_user) }
assert_response :redirect
- assert_redirected_to :action => :list, :display_name => user.display_name
+ assert_redirected_to :action => :index, :display_name => user.display_name
assert_equal false, DiaryEntry.find(diary_entry.id).visible
end
private
- def check_diary_list(*entries)
+ def check_diary_index(*entries)
assert_response :success
- assert_template "list"
+ assert_template "index"
assert_no_missing_translations
assert_select "div.diary_post", entries.count