Use named paths for messages
This commit is contained in:
parent
52f0ba78ea
commit
011cfa794a
9 changed files with 19 additions and 23 deletions
|
@ -69,10 +69,8 @@ class Notifier < ActionMailer::Base
|
|||
@from_user = message.sender.display_name
|
||||
@text = message.body
|
||||
@title = message.title
|
||||
@readurl = url_for(:controller => "message", :action => "read",
|
||||
:message_id => message.id)
|
||||
@replyurl = url_for(:controller => "message", :action => "reply",
|
||||
:message_id => message.id)
|
||||
@readurl = read_message_url(message)
|
||||
@replyurl = reply_message_url(message)
|
||||
@author = @from_user
|
||||
|
||||
attach_user_avatar(message.sender)
|
||||
|
@ -99,10 +97,7 @@ class Notifier < ActionMailer::Base
|
|||
:display_name => comment.diary_entry.user.display_name,
|
||||
:id => comment.diary_entry.id,
|
||||
:anchor => "newcomment")
|
||||
@replyurl = url_for(:controller => "message",
|
||||
:action => "new",
|
||||
:display_name => comment.user.display_name,
|
||||
:title => "Re: #{comment.diary_entry.title}")
|
||||
@replyurl = new_message_url(comment.user, :message => { :title => "Re: #{comment.diary_entry.title}" })
|
||||
|
||||
@author = @from_user
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<ul class='secondary-actions clearfix'>
|
||||
<% if params[:action] == 'list' %>
|
||||
<li><%= link_to t('.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %></li>
|
||||
<li><%= link_to t('.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :message => { :title => "Re: #{diary_entry.title}" } %></li>
|
||||
<li><%= link_to t('.reply_link'), new_message_path(diary_entry.user, :message => { :title => "Re: #{diary_entry.title}" }) %></li>
|
||||
<li><%= link_to t('.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %></li>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<tr id="inbox-<%= message_summary.id %>" class="inbox-row<%= "-unread" if not message_summary.message_read? %>">
|
||||
<td class="inbox-sender"><%= link_to h(message_summary.sender.display_name), user_path(message_summary.sender) %></td>
|
||||
<td class="inbox-subject"><%= link_to h(message_summary.title), :controller => 'message', :action => 'read', :message_id => message_summary.id %></td>
|
||||
<td class="inbox-subject"><%= link_to h(message_summary.title), read_message_path(message_summary) %></td>
|
||||
<td class="inbox-sent"><%= l message_summary.sent_on, :format => :friendly %></td>
|
||||
<td class="inbox-mark-unread"><%= button_to t('.unread_button'), {:controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'unread'}, { :remote => true } %></td>
|
||||
<td class="inbox-mark-read"><%= button_to t('.read_button'), {:controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read'}, { :remote => true } %></td>
|
||||
<td class="inbox-delete"><%= button_to t('.delete_button'), {:controller => 'message', :action => 'delete', :message_id => message_summary.id, :referer => request.fullpath}, { :remote => true } %></td>
|
||||
<td class="inbox-mark-unread"><%= button_to t('.unread_button'), mark_message_path(message_summary, :mark => 'unread'), { :remote => true } %></td>
|
||||
<td class="inbox-mark-read"><%= button_to t('.read_button'), mark_message_path(message_summary, :mark => 'read'), { :remote => true } %></td>
|
||||
<td class="inbox-delete"><%= button_to t('.delete_button'), delete_message_path(message_summary, :referer => request.fullpath), { :remote => true } %></td>
|
||||
</tr>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<tr class="inbox-row">
|
||||
<td class="inbox-sender"><%= link_to h(sent_message_summary.recipient.display_name), user_path(sent_message_summary.recipient) %></td>
|
||||
<td class="inbox-subject"><%= link_to h(sent_message_summary.title), :controller => 'message', :action => 'read', :message_id => sent_message_summary.id %></td>
|
||||
<td class="inbox-subject"><%= link_to h(sent_message_summary.title), read_message_path(sent_message_summary) %></td>
|
||||
<td class="inbox-sent"><%= l sent_message_summary.sent_on, :format => :friendly %></td>
|
||||
<td class="inbox-delete"><%= button_to t('.delete_button'), :controller => 'message', :action => 'delete', :message_id => sent_message_summary.id, :referer => request.fullpath %></td>
|
||||
<td class="inbox-delete"><%= button_to t('.delete_button'), delete_message_path(sent_message_summary, :referer => request.fullpath) %></td>
|
||||
</tr>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<%= error_messages_for 'message' %>
|
||||
|
||||
<%= form_for :message, :html => { :class => 'standard-form' }, :url => { :action => "new", :display_name => @message.recipient.display_name } do |f| %>
|
||||
<%= form_for :message, :html => { :class => 'standard-form' }, :url => new_message_path(@message.recipient) do |f| %>
|
||||
<fieldset>
|
||||
<div class='form-row'>
|
||||
<label class="standard-label" for="message_title"><%= t '.subject' %></label>
|
||||
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
<div class='buttons'>
|
||||
<%= submit_tag t('.send_button') %>
|
||||
<%= link_to t('.back_to_inbox'), { :controller => 'message', :action => 'inbox', :display_name => current_user.display_name }, :class => 'deemphasize button' %>
|
||||
<%= link_to t('.back_to_inbox'), inbox_path(current_user), :class => 'deemphasize button' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
<div class="richtext"><%= @message.body.to_html %></div>
|
||||
|
||||
<div class='message-buttons buttons'>
|
||||
<%= button_to t('.reply_button'), {:controller => 'message', :action => 'reply', :message_id => @message.id}, :class => 'reply-button' %>
|
||||
<%= button_to t('.unread_button'), {:controller => 'message', :action => 'mark', :message_id => @message.id, :mark => 'unread'}, :class => 'mark-unread-button' %>
|
||||
<%= button_to t('.delete_button'), {:controller => 'message', :action => 'delete', :message_id => @message.id}, :class => 'delete-button' %>
|
||||
<%= button_to t('.reply_button'), reply_message_path(@message), :class => 'reply-button' %>
|
||||
<%= button_to t('.unread_button'), mark_message_path(@message, :mark => 'unread'), :class => 'mark-unread-button' %>
|
||||
<%= button_to t('.delete_button'), delete_message_path(@message), :class => 'delete-button' %>
|
||||
|
||||
<% else %>
|
||||
|
||||
|
@ -36,5 +36,5 @@
|
|||
|
||||
<% end %>
|
||||
|
||||
<%= link_to t('.back'), {:controller => 'message', :action => 'outbox', :display_name => current_user.display_name }, :class => "button deemphasize" %>
|
||||
<%= link_to t('.back'), outbox_path(current_user), :class => "button deemphasize" %>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
</p>
|
||||
|
||||
<ul class='secondary-actions clearfix deemphasize'>
|
||||
<li><%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => contact.display_name %></li>
|
||||
<li><%= link_to t('user.view.send message'), new_message_path(contact) %></li>
|
||||
<li>
|
||||
<% if current_user.is_friends_with?(contact) %>
|
||||
<%= link_to t('user.view.remove as friend'), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<!-- Displaying another user's profile page -->
|
||||
|
||||
<li>
|
||||
<%= link_to t('.send message'), :controller => 'message', :action => 'new', :display_name => @user.display_name %>
|
||||
<%= link_to t('.send message'), new_message_path(@user) %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.diary'), :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
|
||||
|
|
|
@ -178,6 +178,7 @@ class MessageControllerTest < ActionController::TestCase
|
|||
assert_equal "[OpenStreetMap] Test Message", e.subject
|
||||
assert_match /Test message body/, e.text_part.decoded
|
||||
assert_match /Test message body/, e.html_part.decoded
|
||||
assert_match %r{#{SERVER_URL}/message/read/}, e.text_part.decoded
|
||||
ActionMailer::Base.deliveries.clear
|
||||
m = Message.last
|
||||
assert_equal user.id, m.from_user_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue