-class DiaryEntryController < ApplicationController
+class DiaryEntriesController < ApplicationController
layout "site", :except => :rss
before_action :authorize_web
before_action :allow_thirdparty_images, :only => [:new, :edit, :index, :show, :comments]
def new
- @title = t "diary_entry.new.title"
+ @title = t "diary_entries.new.title"
if request.post?
@diary_entry = DiaryEntry.new(entry_params)
end
def edit
- @title = t "diary_entry.edit.title"
+ @title = t "diary_entries.edit.title"
@diary_entry = DiaryEntry.find(params[:id])
if current_user != @diary_entry.user
@user = User.active.find_by(:display_name => params[:display_name])
if @user
- @title = t "diary_entry.index.user_title", :user => @user.display_name
+ @title = t "diary_entries.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.index.title_friends"
+ @title = t "diary_entries.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.index.title_nearby"
+ @title = t "diary_entries.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.index.in_language_title", :language => Language.find(params[:language]).english_name
+ @title = t "diary_entries.index.in_language_title", :language => Language.find(params[:language]).english_name
@entries = @entries.where(:language_code => params[:language])
else
- @title = t "diary_entry.index.title"
+ @title = t "diary_entries.index.title"
end
end
if user
@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 => "index", :display_name => user.display_name, :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+ @title = t("diary_entries.feed.user.title", :user => user.display_name)
+ @description = t("diary_entries.feed.user.description", :user => user.display_name)
+ @link = url_for :action => "index", :display_name => user.display_name, :host => SERVER_URL, :protocol => SERVER_PROTOCOL
else
head :not_found
return
if params[:language]
@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 => "index", :language => params[:language], :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+ @title = t("diary_entries.feed.language.title", :language_name => Language.find(params[:language]).english_name)
+ @description = t("diary_entries.feed.language.description", :language_name => Language.find(params[:language]).english_name)
+ @link = url_for :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 => "index", :host => SERVER_URL, :protocol => SERVER_PROTOCOL
+ @title = t("diary_entries.feed.all.title")
+ @description = t("diary_entries.feed.all.description")
+ @link = url_for :action => "index", :host => SERVER_URL, :protocol => SERVER_PROTOCOL
end
end
def show
@entry = @user.diary_entries.visible.where(:id => params[:id]).first
if @entry
- @title = t "diary_entry.show.title", :user => params[:display_name], :title => @entry.title
+ @title = t "diary_entries.show.title", :user => params[:display_name], :title => @entry.title
else
- @title = t "diary_entry.no_such_entry.title", :id => params[:id]
+ @title = t "diary_entries.no_such_entry.title", :id => params[:id]
render :action => "no_such_entry", :status => :not_found
end
end
<h2><%= link_to h(diary_entry.title), diary_entry_path(diary_entry.user, diary_entry) %></h2>
<small class='deemphasize'>
- <%= raw(t '.posted_by', :link_user => (link_to h(diary_entry.user.display_name), user_path(diary_entry.user)), :created => l(diary_entry.created_at, :format => :blog), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entry', :action => 'index', :display_name => nil, :language => diary_entry.language_code)) %>
+ <%= raw(t '.posted_by', :link_user => (link_to h(diary_entry.user.display_name), user_path(diary_entry.user)), :created => l(diary_entry.created_at, :format => :blog), :language_link => (link_to h(diary_entry.language.name), :controller => 'diary_entries', :action => 'index', :display_name => nil, :language => diary_entry.language_code)) %>
</small>
</div>
</fieldset>
<% if action_name == 'new' %>
- <%= submit_tag t('diary_entry.new.publish_button') %>
+ <%= submit_tag t('diary_entries.new.publish_button') %>
<% else %>
<%= submit_tag t('.save_button') %>
<% end %>
<% if @user %>
<% if @user == current_user %>
<div>
- <li><%= link_to image_tag("new.png", :class => "small_icon", :border=>0) + t('.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('.new_title')} %></li>
+ <li><%= link_to image_tag("new.png", :class => "small_icon", :border=>0) + t('.new'), diary_new_path, {:title => t('.new_title')} %></li>
</div>
<% end %>
<% else %>
<% if current_user %>
<div>
- <li><%= link_to image_tag("new.png", :class => "small_icon", :border=>0) + t('.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('.new_title')} %></li>
+ <li><%= link_to image_tag("new.png", :class => "small_icon", :border=>0) + t('.new'), diary_new_path, {:title => t('.new_title')} %></li>
</div>
<% end %>
<% end %>
<span class='count-number'><%= number_with_delimiter(current_user.traces.size) %></span>
</li>
<li>
- <%= link_to t('.my diary'), :controller => 'diary_entry', :action => 'index', :display_name => current_user.display_name %>
+ <%= link_to t('.my diary'), :controller => 'diary_entries', :action => 'index', :display_name => current_user.display_name %>
<span class='count-number'><%= number_with_delimiter(current_user.diary_entries.size) %></span>
</li>
<li>
- <%= link_to t('.my comments' ), :controller => 'diary_entry', :action => 'comments', :display_name => current_user.display_name %>
+ <%= link_to t('.my comments' ), :controller => 'diary_entries', :action => 'comments', :display_name => current_user.display_name %>
</li>
<li>
<%= link_to t('.my settings'), :controller => 'users', :action => 'account', :display_name => current_user.display_name %>
<%= link_to t('.send message'), new_message_path(@user) %>
</li>
<li>
- <%= link_to t('.diary'), :controller => 'diary_entry', :action => 'index', :display_name => @user.display_name %>
+ <%= link_to t('.diary'), :controller => 'diary_entries', :action => 'index', :display_name => @user.display_name %>
<span class='count-number'><%= number_with_delimiter(@user.diary_entries.size) %></span>
</li>
<li>
- <%= link_to t('.comments'), :controller => 'diary_entry', :action => 'comments', :display_name => @user.display_name %>
+ <%= link_to t('.comments'), :controller => 'diary_entries', :action => 'comments', :display_name => @user.display_name %>
</li>
<li>
<% if current_user and current_user.is_friends_with?(@user) %>
commented_at_html: "Updated %{when} ago"
commented_at_by_html: "Updated %{when} ago by %{user}"
full: Full discussion
- diary_entry:
+ diary_entries:
new:
title: New Diary Entry
publish_button: "Publish"
post "/trace/:id/delete" => "traces#delete", :id => /\d+/
# diary pages
- match "/diary/new" => "diary_entry#new", :via => [:get, :post]
- get "/diary/friends" => "diary_entry#index", :friends => true, :as => "friend_diaries"
- get "/diary/nearby" => "diary_entry#index", :nearby => true, :as => "nearby_diaries"
- get "/user/:display_name/diary/rss" => "diary_entry#rss", :defaults => { :format => :rss }
- get "/diary/:language/rss" => "diary_entry#rss", :defaults => { :format => :rss }
- get "/diary/rss" => "diary_entry#rss", :defaults => { :format => :rss }
- get "/user/:display_name/diary/comments/:page" => "diary_entry#comments", :page => /[1-9][0-9]*/
- get "/user/:display_name/diary/comments/" => "diary_entry#comments"
- get "/user/:display_name/diary" => "diary_entry#index"
- get "/diary/:language" => "diary_entry#index"
- get "/diary" => "diary_entry#index"
- get "/user/:display_name/diary/:id" => "diary_entry#show", :id => /\d+/, :as => :diary_entry
- post "/user/:display_name/diary/:id/newcomment" => "diary_entry#comment", :id => /\d+/
- match "/user/:display_name/diary/:id/edit" => "diary_entry#edit", :via => [:get, :post], :id => /\d+/
- post "/user/:display_name/diary/:id/hide" => "diary_entry#hide", :id => /\d+/, :as => :hide_diary_entry
- post "/user/:display_name/diary/:id/hidecomment/:comment" => "diary_entry#hidecomment", :id => /\d+/, :comment => /\d+/, :as => :hide_diary_comment
- post "/user/:display_name/diary/:id/subscribe" => "diary_entry#subscribe", :as => :diary_entry_subscribe, :id => /\d+/
- post "/user/:display_name/diary/:id/unsubscribe" => "diary_entry#unsubscribe", :as => :diary_entry_unsubscribe, :id => /\d+/
+ match "/diary/new" => "diary_entries#new", :via => [:get, :post]
+ get "/diary/friends" => "diary_entries#index", :friends => true, :as => "friend_diaries"
+ get "/diary/nearby" => "diary_entries#index", :nearby => true, :as => "nearby_diaries"
+ 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 }
+ get "/user/:display_name/diary/comments/:page" => "diary_entries#comments", :page => /[1-9][0-9]*/
+ 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"
+ get "/user/:display_name/diary/:id" => "diary_entries#show", :id => /\d+/, :as => :diary_entry
+ post "/user/:display_name/diary/:id/newcomment" => "diary_entries#comment", :id => /\d+/
+ match "/user/:display_name/diary/:id/edit" => "diary_entries#edit", :via => [:get, :post], :id => /\d+/
+ post "/user/:display_name/diary/:id/hide" => "diary_entries#hide", :id => /\d+/, :as => :hide_diary_entry
+ post "/user/:display_name/diary/:id/hidecomment/:comment" => "diary_entries#hidecomment", :id => /\d+/, :comment => /\d+/, :as => :hide_diary_comment
+ post "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :as => :diary_entry_subscribe, :id => /\d+/
+ post "/user/:display_name/diary/:id/unsubscribe" => "diary_entries#unsubscribe", :as => :diary_entry_unsubscribe, :id => /\d+/
# user pages
get "/user/:display_name" => "users#show", :as => "user"
require "test_helper"
-class DiaryEntryControllerTest < ActionController::TestCase
+class DiaryEntriesControllerTest < ActionController::TestCase
include ActionView::Helpers::NumberHelper
def setup
def test_routes
assert_routing(
{ :path => "/diary", :method => :get },
- { :controller => "diary_entry", :action => "index" }
+ { :controller => "diary_entries", :action => "index" }
)
assert_routing(
{ :path => "/diary/language", :method => :get },
- { :controller => "diary_entry", :action => "index", :language => "language" }
+ { :controller => "diary_entries", :action => "index", :language => "language" }
)
assert_routing(
{ :path => "/user/username/diary", :method => :get },
- { :controller => "diary_entry", :action => "index", :display_name => "username" }
+ { :controller => "diary_entries", :action => "index", :display_name => "username" }
)
assert_routing(
{ :path => "/diary/friends", :method => :get },
- { :controller => "diary_entry", :action => "index", :friends => true }
+ { :controller => "diary_entries", :action => "index", :friends => true }
)
assert_routing(
{ :path => "/diary/nearby", :method => :get },
- { :controller => "diary_entry", :action => "index", :nearby => true }
+ { :controller => "diary_entries", :action => "index", :nearby => true }
)
assert_routing(
{ :path => "/diary/rss", :method => :get },
- { :controller => "diary_entry", :action => "rss", :format => :rss }
+ { :controller => "diary_entries", :action => "rss", :format => :rss }
)
assert_routing(
{ :path => "/diary/language/rss", :method => :get },
- { :controller => "diary_entry", :action => "rss", :language => "language", :format => :rss }
+ { :controller => "diary_entries", :action => "rss", :language => "language", :format => :rss }
)
assert_routing(
{ :path => "/user/username/diary/rss", :method => :get },
- { :controller => "diary_entry", :action => "rss", :display_name => "username", :format => :rss }
+ { :controller => "diary_entries", :action => "rss", :display_name => "username", :format => :rss }
)
assert_routing(
{ :path => "/user/username/diary/comments", :method => :get },
- { :controller => "diary_entry", :action => "comments", :display_name => "username" }
+ { :controller => "diary_entries", :action => "comments", :display_name => "username" }
)
assert_routing(
{ :path => "/user/username/diary/comments/1", :method => :get },
- { :controller => "diary_entry", :action => "comments", :display_name => "username", :page => "1" }
+ { :controller => "diary_entries", :action => "comments", :display_name => "username", :page => "1" }
)
assert_routing(
{ :path => "/diary/new", :method => :get },
- { :controller => "diary_entry", :action => "new" }
+ { :controller => "diary_entries", :action => "new" }
)
assert_routing(
{ :path => "/diary/new", :method => :post },
- { :controller => "diary_entry", :action => "new" }
+ { :controller => "diary_entries", :action => "new" }
)
assert_routing(
{ :path => "/user/username/diary/1", :method => :get },
- { :controller => "diary_entry", :action => "show", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "show", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/diary/1/edit", :method => :get },
- { :controller => "diary_entry", :action => "edit", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "edit", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/diary/1/edit", :method => :post },
- { :controller => "diary_entry", :action => "edit", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "edit", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/diary/1/newcomment", :method => :post },
- { :controller => "diary_entry", :action => "comment", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "comment", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/diary/1/hide", :method => :post },
- { :controller => "diary_entry", :action => "hide", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "hide", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/diary/1/hidecomment/2", :method => :post },
- { :controller => "diary_entry", :action => "hidecomment", :display_name => "username", :id => "1", :comment => "2" }
+ { :controller => "diary_entries", :action => "hidecomment", :display_name => "username", :id => "1", :comment => "2" }
)
assert_routing(
{ :path => "/user/username/diary/1/subscribe", :method => :post },
- { :controller => "diary_entry", :action => "subscribe", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "subscribe", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/diary/1/unsubscribe", :method => :post },
- { :controller => "diary_entry", :action => "unsubscribe", :display_name => "username", :id => "1" }
+ { :controller => "diary_entries", :action => "unsubscribe", :display_name => "username", :id => "1" }
)
end
:params => { :display_name => entry.user.display_name, :id => entry.id },
:session => { :user => entry.user }
assert_response :success
- assert_template "diary_entry/show"
+ assert_template "show"
assert_select "title", :text => /Users' diaries | /, :count => 1
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
:params => { :display_name => entry.user.display_name, :id => entry.id },
:session => { :user => create(:user) }
assert_response :success
- assert_template "diary_entry/show"
+ assert_template "show"
assert_select "title", :text => /Users' diaries | /, :count => 1
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
end
def test_rss_link_to
- link = rss_link_to(:controller => :diary_entry, :action => :rss)
+ link = rss_link_to(:controller => :diary_entries, :action => :rss)
assert_dom_equal "<a class=\"rsssmall\" href=\"/diary/rss\"><img border=\"0\" height=\"16\" src=\"/images/RSS.png\" width=\"16\" /></a>", link
end
follow_redirect!
assert_response :success
- assert_template "diary_entry/edit"
+ assert_template "diary_entries/edit"
# print @response.body
# print @html_document.to_yaml
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content?(@comment.body)
- assert_not page.has_content?(I18n.t("diary_entry.diary_comment.report"))
+ assert_not page.has_content?(I18n.t("diary_entries.diary_comment.report"))
end
def test_it_works
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content? @diary_entry.title
- click_on I18n.t("diary_entry.diary_comment.report")
+ click_on I18n.t("diary_entries.diary_comment.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("reports.new.disclaimer.intro")
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content?(@diary_entry.title)
- assert_not page.has_content?(I18n.t("diary_entry.diary_entry.report"))
+ assert_not page.has_content?(I18n.t("diary_entries.diary_entry.report"))
end
def test_it_works
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content? @diary_entry.title
- click_on I18n.t("diary_entry.diary_entry.report")
+ click_on I18n.t("diary_entries.diary_entry.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("reports.new.disclaimer.intro")
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content? @diary_entry.title
- click_on I18n.t("diary_entry.diary_entry.report")
+ click_on I18n.t("diary_entries.diary_entry.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("reports.new.disclaimer.intro")