Huge commit I know, but move show and destroy routes into PostsController and PostsController#show into PublicsController
This commit is contained in:
parent
6a165c0e3d
commit
97ca10ddda
36 changed files with 211 additions and 256 deletions
|
|
@ -28,7 +28,7 @@ class ActivityStreams::PhotosController < ApplicationController
|
|||
skip_before_filter :verify_authenticity_token, :only => :create
|
||||
|
||||
respond_to :json
|
||||
respond_to :html, :only => [:show, :destroy]
|
||||
respond_to :html, :only => [:show]
|
||||
|
||||
def create
|
||||
@photo = ActivityStreams::Photo.from_activity(params[:activity])
|
||||
|
|
@ -52,14 +52,6 @@ class ActivityStreams::PhotosController < ApplicationController
|
|||
respond_with @photo
|
||||
end
|
||||
|
||||
def destroy
|
||||
@photo = current_user.posts.where(:id => params[:id]).first
|
||||
if @photo
|
||||
current_user.retract(@photo)
|
||||
end
|
||||
respond_with @photo
|
||||
end
|
||||
|
||||
def fail!
|
||||
render :nothing => true, :status => 401
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ class CommentsController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
|
||||
respond_to :html, :mobile
|
||||
respond_to :json, :only => :show
|
||||
|
||||
rescue_from ActiveRecord::RecordNotFound do
|
||||
render :nothing => true, :status => 404
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class LikesController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.js { render :status => 201 }
|
||||
format.html { render :nothing => true, :status => 201 }
|
||||
format.mobile { redirect_to status_message_path(@like.post_id) }
|
||||
format.mobile { redirect_to post_path(@like.post_id) }
|
||||
end
|
||||
else
|
||||
render :nothing => true, :status => 422
|
||||
|
|
|
|||
|
|
@ -3,32 +3,39 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class PostsController < ApplicationController
|
||||
skip_before_filter :set_invites
|
||||
skip_before_filter :which_action_and_user
|
||||
skip_before_filter :set_grammatical_gender
|
||||
|
||||
before_filter :authenticate_user!
|
||||
respond_to :html
|
||||
respond_to :mobile
|
||||
respond_to :json
|
||||
def show
|
||||
@post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
|
||||
|
||||
#hax to upgrade logged in users who can comment
|
||||
@post = current_user.find_visible_post_by_id params[:id]
|
||||
if @post
|
||||
if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
|
||||
redirect_to "/#{@post.class.to_s.pluralize.underscore}/#{@post.id}"
|
||||
return
|
||||
end
|
||||
|
||||
@landing_page = true
|
||||
@person = @post.author
|
||||
if @person.owner_id
|
||||
I18n.locale = @person.owner.language
|
||||
render "posts/#{@post.class.to_s.underscore}", :layout => true
|
||||
else
|
||||
flash[:error] = I18n.t('posts.doesnt_exist')
|
||||
redirect_to root_url
|
||||
# mark corresponding notification as read
|
||||
if notification = Notification.where(:recipient_id => current_user.id, :target_id => @post.id).first
|
||||
notification.unread = false
|
||||
notification.save
|
||||
end
|
||||
|
||||
respond_with @post
|
||||
else
|
||||
Rails.logger.info(:event => :link_to_nonexistent_post, :ref => request.env['HTTP_REFERER'], :user_id => current_user.id, :post_id => params[:id])
|
||||
flash[:error] = I18n.t('posts.show.not_found')
|
||||
redirect_to :back
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@post = current_user.posts.where(:id => params[:id]).first
|
||||
if @post
|
||||
current_user.retract(@post)
|
||||
respond_to do |format|
|
||||
format.js {render 'destroy'}
|
||||
format.all {redirect_to root_url}
|
||||
end
|
||||
else
|
||||
flash[:error] = I18n.t('posts.doesnt_exist')
|
||||
redirect_to root_url
|
||||
Rails.logger.info "event=post_destroy status=failure user=#{current_user.diaspora_handle} reason='User does not own post'"
|
||||
render :nothing => true, :status => 404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -64,4 +64,29 @@ class PublicsController < ApplicationController
|
|||
|
||||
render :nothing => true, :status => 202
|
||||
end
|
||||
|
||||
def post
|
||||
@post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
|
||||
|
||||
#hax to upgrade logged in users who can comment
|
||||
if @post
|
||||
if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
|
||||
redirect_to post_path(@post)
|
||||
return
|
||||
end
|
||||
|
||||
@landing_page = true
|
||||
@person = @post.author
|
||||
if @person.owner_id
|
||||
I18n.locale = @person.owner.language
|
||||
render "#{@post.class.to_s.underscore}", :layout => 'application'
|
||||
else
|
||||
flash[:error] = I18n.t('posts.show.not_found')
|
||||
redirect_to root_url
|
||||
end
|
||||
else
|
||||
flash[:error] = I18n.t('posts.show.not_found')
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ class StatusMessagesController < ApplicationController
|
|||
|
||||
respond_to :html
|
||||
respond_to :mobile
|
||||
respond_to :json, :only => :show
|
||||
|
||||
|
||||
# Called when a user clicks "Mention" on a profile page
|
||||
# @option [Integer] person_id The id of the person to be mentioned
|
||||
|
|
@ -91,20 +89,6 @@ class StatusMessagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@status_message = current_user.posts.where(:id => params[:id]).first
|
||||
if @status_message
|
||||
current_user.retract(@status_message)
|
||||
respond_to do |format|
|
||||
format.js {render 'destroy'}
|
||||
format.all {redirect_to root_url}
|
||||
end
|
||||
else
|
||||
Rails.logger.info "event=post_destroy status=failure user=#{current_user.diaspora_handle} reason='User does not own post'"
|
||||
render :nothing => true, :status => 404
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@status_message = current_user.find_visible_post_by_id params[:id]
|
||||
if @status_message
|
||||
|
|
|
|||
|
|
@ -16,19 +16,6 @@ module ApplicationHelper
|
|||
"javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
|
||||
end
|
||||
|
||||
def object_path(object, opts={})
|
||||
return "" if object.nil?
|
||||
object = object.person if object.instance_of? User
|
||||
object = object.model if object.instance_of? PostsFake::Fake
|
||||
if object.respond_to?(:activity_streams?) && object.activity_streams?
|
||||
class_name = object.class.name.underscore.split('/')
|
||||
method_sym = "#{class_name.first}_#{class_name.last}_path".to_sym
|
||||
else
|
||||
method_sym = "#{object.class.name.underscore}_path".to_sym
|
||||
end
|
||||
self.send(method_sym, object, opts)
|
||||
end
|
||||
|
||||
def object_fields(object)
|
||||
object.attributes.keys
|
||||
end
|
||||
|
|
@ -109,7 +96,7 @@ module ApplicationHelper
|
|||
@rtl ||= RTL_LANGUAGES.include? I18n.locale
|
||||
end
|
||||
|
||||
def controller_index_path
|
||||
def controller_index_path
|
||||
self.send((request.filtered_parameters["controller"] + "_path").to_sym)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,21 +9,21 @@ module NotificationsHelper
|
|||
if note.instance_of?(Notifications::Mentioned)
|
||||
post = Mention.find(note.target_id).post
|
||||
if post
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post)).html_safe)
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), post_path(post)).html_safe)
|
||||
else
|
||||
t('notifications.mentioned_deleted', :actors => actors, :count => actors_count).html_safe
|
||||
end
|
||||
elsif note.instance_of?(Notifications::CommentOnPost)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
|
||||
else
|
||||
t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe
|
||||
end
|
||||
elsif note.instance_of?(Notifications::AlsoCommented)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
|
||||
else
|
||||
t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe
|
||||
end
|
||||
|
|
@ -31,7 +31,7 @@ module NotificationsHelper
|
|||
post = note.target
|
||||
post = post.post if post.is_a? Like
|
||||
if post
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
|
||||
else
|
||||
t('notifications.liked_post_deleted', :actors => actors, :count => actors_count).html_safe
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
#show_content{:data=>{:guid=>@photo.id}}
|
||||
= render 'shared/author_info', :person => @photo.author, :post => @photo
|
||||
|
||||
= image_tag @photo.image_url
|
||||
|
||||
.info
|
||||
%span.time
|
||||
= t('ago', :time => time_ago_in_words(@photo.created_at))
|
||||
|
||||
%br
|
||||
- if current_user.owns? @photo
|
||||
= link_to t('delete'), @photo, :confirm => t('are_you_sure'), :method => :delete
|
||||
- else
|
||||
= link_to t('hide'), post_visibility_path(:id => "42", :post_id => @photo.id), :confirm => t('are_you_sure'), :method => :put, :remote => true
|
||||
|
||||
.stream.show{:data=>{:guid=>@photo.id}}
|
||||
= render "comments/comments", :post => @photo, :comments => @photo.comments, :always_expanded => true
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
- for post in @posts
|
||||
.image-element.stream_element
|
||||
.hold-me
|
||||
= link_to(image_tag(post.image_url), object_path(post))
|
||||
= link_to(image_tag(post.image_url), post_path(post))
|
||||
.via
|
||||
= post.author.name
|
||||
.time{:integer => post.created_at.to_i}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
%br
|
||||
%br
|
||||
= link_to t('.sign_in'), status_message_url(@comment.post)
|
||||
= link_to t('.sign_in'), post_url(@comment.post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
= @comment.text
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), status_message_url(@comment.post)
|
||||
= link_to t('.sign_in'), post_url(@comment.post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
!= @comment.text
|
||||
|
||||
!= status_message_url(@comment.post)
|
||||
!= post_url(@comment.post)
|
||||
|
||||
!= "#{t('notifier.love')} \n"
|
||||
!= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
%p
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), status_message_url(@like.post)
|
||||
= link_to t('.sign_in'), post_url(@like.post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
%p
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), status_message_url(@post)
|
||||
= link_to t('.sign_in'), post_url(@post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
= link_to (image_tag post.url(:thumb_large)), object_path(post), :class => 'stream_photo'
|
||||
= link_to (image_tag post.url(:thumb_large)), photo_path(post), :class => 'stream_photo'
|
||||
|
||||
%h1
|
||||
= post.pending
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@
|
|||
%p
|
||||
= markdownify(photo.status_message.text)
|
||||
%span{:style=>'font-size:smaller'}
|
||||
=link_to t('.collection_permalink'), photo.status_message
|
||||
=link_to t('.collection_permalink'), post_path(photo.status_message)
|
||||
%br
|
||||
%br
|
||||
|
||||
.span-7.prepend-1
|
||||
.show_photo_attachments
|
||||
- for photo in additional_photos
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), object_path(photo)
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo)
|
||||
|
||||
|
||||
#photo_edit_options
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
var target = $(".stream_element[data-guid=<%= escape_javascript(@status_message.id.to_s) %>]")
|
||||
var target = $(".stream_element[data-guid=<%= escape_javascript(@post.id.to_s) %>]")
|
||||
target.hide('blind', { direction: 'vertical' }, 300, function(){ target.remove() });
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
.span-16.append-4.prepend-4.last
|
||||
.span-20.append-2.prepend-2.last
|
||||
#main_stream.stream.status_message_show
|
||||
= render 'shared/stream_element', :post => @photo, :all_aspects => @photo.aspects
|
||||
= render 'shared/stream_element', :post => @post, :all_aspects => @post.aspects
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
28
app/views/posts/show.mobile.haml
Normal file
28
app/views/posts/show.mobile.haml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
#show_content{:data=>{:guid=>@post.id}}
|
||||
= render 'shared/author_info', :person => @post.author, :post => @post
|
||||
|
||||
- if @post.activity_streams?
|
||||
= image_tag @photo.image_url
|
||||
- else
|
||||
%p
|
||||
= markdownify(@post.text, :youtube_maps => @post[:youtube_titles])
|
||||
|
||||
- for photo in @post.photos
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo.url(:thumb_medium)
|
||||
|
||||
.info
|
||||
%span.time
|
||||
= t('ago', :time => time_ago_in_words(@post.created_at))
|
||||
|
||||
%br
|
||||
- if current_user.owns? @post
|
||||
= link_to t('delete'), @post, :confirm => t('are_you_sure'), :method => :delete
|
||||
- else
|
||||
= link_to t('hide'), post_visibility_path(:id => "42", :post_id => @post.id), :confirm => t('are_you_sure'), :method => :put, :remote => true
|
||||
|
||||
.stream.show{:data=>{:guid=>@post.id}}
|
||||
= render "comments/comments", :post => @post, :comments => @post.comments, :always_expanded => true
|
||||
|
|
@ -24,13 +24,13 @@
|
|||
#original_post_info
|
||||
%h4{:style=>"position:relative;"}
|
||||
= t('photos.show.original_post')
|
||||
= link_to t('photos.show.view'), post_path(@post.status_message)
|
||||
= link_to t('photos.show.view'), public_post_path(@post.status_message)
|
||||
|
||||
%p
|
||||
= @post.status_message.text
|
||||
|
||||
%p
|
||||
- for photo in @post.status_message.photos
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), post_path(photo)
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), public_post_path(photo)
|
||||
%p
|
||||
= link_to t('photos.show.permalink'), post_path(@post)
|
||||
= link_to t('posts.show.permalink'), public_post_path(@post)
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
= markdownify(@post.text, :youtube_maps => @post[:youtube_titles])
|
||||
|
||||
- for photo in @post.photos
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), post_path(photo)
|
||||
.thumb_small= link_to (image_tag photo.url(:thumb_small)), public_post_path(photo)
|
||||
|
||||
.time
|
||||
= how_long_ago(@post)
|
||||
= link_to t('status_messages.show.permalink'), post_path(@post)
|
||||
= link_to t('posts.show.permalink'), public_post_path(@post)
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
.stream_element{:data=>{:guid=>post.id}}
|
||||
- if current_user && post.author.owner_id == current_user.id
|
||||
.right.controls
|
||||
= link_to image_tag('deletelabel.png'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
|
||||
= link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
|
||||
- else
|
||||
.right.controls
|
||||
= link_to image_tag('deletelabel.png'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete", :title => t('hide')
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
%span.details
|
||||
–
|
||||
%span.timeago
|
||||
= link_to(how_long_ago(post), object_path(post))
|
||||
= link_to(how_long_ago(post), post_path(post))
|
||||
|
||||
- if post.activity_streams?
|
||||
= link_to image_tag(post.image_url), post.object_url
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@
|
|||
- if post.activity_streams?
|
||||
= t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe
|
||||
|
||||
= link_to "#{t('comments', :count => post.comments.length)} →", post_path(post), :class => 'comment_link right'
|
||||
- if post.activity_streams?
|
||||
= link_to "#{t('comments', :count => post.comments.length)} →", activity_streams_photo_path(post), :class => 'comment_link right'
|
||||
%br
|
||||
- else
|
||||
= link_to "#{t('comments', :count => post.comments.length)} →", status_message_path(post), :class => 'comment_link right'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
.span-20.append-2.prepend-2.last
|
||||
.stream_container
|
||||
#main_stream.stream.status_message_show
|
||||
= render 'shared/stream_element', :post => @status_message, :all_aspects => @status_message.aspects
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
#show_content{:data=>{:guid=>@status_message.id}}
|
||||
= render 'shared/author_info', :person => @status_message.author, :post => @status_message
|
||||
|
||||
%p
|
||||
= markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
|
||||
|
||||
- for photo in @status_message.photos
|
||||
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo.url(:thumb_medium)
|
||||
|
||||
.info
|
||||
%span.time
|
||||
= t('ago', :time => time_ago_in_words(@status_message.created_at))
|
||||
|
||||
%br
|
||||
- if current_user.owns? @status_message
|
||||
= link_to t('delete'), @status_message, :confirm => t('are_you_sure'), :method => :delete
|
||||
- else
|
||||
= link_to t('hide'), post_visibility_path(:id => "42", :post_id => @status_message.id), :confirm => t('are_you_sure'), :method => :put, :remote => true
|
||||
|
||||
.stream.show{:data=>{:guid=>@status_message.id}}
|
||||
= render "comments/comments", :post => @status_message, :comments => @status_message.comments, :always_expanded => true
|
||||
|
|
@ -490,7 +490,6 @@ en:
|
|||
view: "view"
|
||||
edit: "edit"
|
||||
edit_delete_photo: "Edit photo description / delete photo"
|
||||
permalink: "permalink"
|
||||
collection_permalink: "collection permalink"
|
||||
original_post: "Original Post"
|
||||
edit:
|
||||
|
|
@ -519,7 +518,10 @@ en:
|
|||
or_select_one: "or select one from your already existing"
|
||||
|
||||
posts:
|
||||
doesnt_exist: "that post does not exist!"
|
||||
show:
|
||||
destroy: "Delete"
|
||||
permalink: "permalink"
|
||||
not_found: "Sorry, we couldn't find that post."
|
||||
|
||||
post_visibilites:
|
||||
update:
|
||||
|
|
@ -675,10 +677,6 @@ en:
|
|||
mentioning: "Mentioning: %{person}"
|
||||
create:
|
||||
success: "Successfully mentioned: %{names}"
|
||||
show:
|
||||
destroy: "Delete"
|
||||
permalink: "permalink"
|
||||
not_found: "Sorry, we couldn't find that post."
|
||||
helper:
|
||||
no_message_to_display: "No message to display."
|
||||
destroy:
|
||||
|
|
|
|||
|
|
@ -11,19 +11,24 @@ Diaspora::Application.routes.draw do
|
|||
put 'toggle_contact_visibility' => :toggle_contact_visibility
|
||||
end
|
||||
|
||||
resources :status_messages, :only => [:new, :create, :destroy, :show] do
|
||||
resources :status_messages, :only => [:new, :create] do
|
||||
resources :likes, :only => [:create, :destroy, :index]
|
||||
end
|
||||
|
||||
resources :comments, :only => [:create, :destroy, :index]
|
||||
resources :posts, :only => [:show, :destroy]
|
||||
|
||||
get 'bookmarklet' => 'status_messages#bookmarklet'
|
||||
get 'p/:id' => 'posts#show', :as => 'post'
|
||||
get 'p/:id' => 'publics#post', :as => 'public_post'
|
||||
|
||||
resources :photos, :except => [:index] do
|
||||
put 'make_profile_photo' => :make_profile_photo
|
||||
end
|
||||
|
||||
resources :comments, :only => [:create, :destroy]
|
||||
|
||||
# ActivityStreams routes
|
||||
scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
|
||||
resources :photos, :controller => "photos", :only => [:create]
|
||||
end
|
||||
|
||||
resources :conversations do
|
||||
resources :messages, :only => [:create, :show]
|
||||
|
|
@ -66,15 +71,7 @@ Diaspora::Application.routes.draw do
|
|||
get 'invitations/resend/:id' => 'invitations#resend', :as => 'invitation_resend'
|
||||
end
|
||||
|
||||
# generating a new user token (for devise)
|
||||
|
||||
# ActivityStreams routes
|
||||
scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
|
||||
resources :photos, :controller => "photos", :only => [:create, :show, :destroy]
|
||||
end
|
||||
|
||||
|
||||
#Temporary token_authenticable route
|
||||
#Cubbies info page
|
||||
resource :token, :only => :show
|
||||
|
||||
get 'login' => redirect('/users/sign_in')
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ Feature: commenting
|
|||
When I follow "less than a minute ago"
|
||||
Then I should see "Look at this dog"
|
||||
When I open the comment box
|
||||
And I focus the comment field
|
||||
And I fill in "text" with "I think thats a cat"
|
||||
And I press "Comment"
|
||||
And I wait for the ajax to finish
|
||||
|
|
|
|||
|
|
@ -1,15 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ActivityStreams::PhotosController do
|
||||
describe '#show' do
|
||||
before do
|
||||
@photo = Factory(:activity_streams_photo, :author => bob.person)
|
||||
sign_in :user, alice
|
||||
end
|
||||
it 'succeeds' do
|
||||
get :show, :id => @photo.id
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,28 +6,72 @@ require 'spec_helper'
|
|||
|
||||
describe PostsController do
|
||||
before do
|
||||
alice
|
||||
sign_in alice
|
||||
aspect = alice.aspects.first
|
||||
@message = alice.build_post :status_message, :text => "ohai", :to => aspect.id
|
||||
@message.save!
|
||||
|
||||
alice.add_to_streams(@message, [aspect])
|
||||
alice.dispatch_post @message, :to => aspect.id
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
it 'shows a public post' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||
|
||||
get :show, :id => status.id
|
||||
response.status= 200
|
||||
|
||||
it 'succeeds' do
|
||||
get :show, "id" => @message.id.to_s
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'does not show a private post' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => false, :to => 'all')
|
||||
get :show, :id => status.id
|
||||
response.status = 302
|
||||
it 'marks a corresponding notification as read' do
|
||||
alice.comment("comment after me", :post => @message)
|
||||
bob.comment("here you go", :post => @message)
|
||||
note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
|
||||
lambda{
|
||||
get :show, :id => @message.id
|
||||
note.reload
|
||||
}.should change(note, :unread).from(true).to(false)
|
||||
end
|
||||
|
||||
it 'redirects to the proper show page if the user has visibility of the post' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||
sign_in bob
|
||||
get :show, :id => status.id
|
||||
response.should be_redirect
|
||||
it 'redirects to back if there is no status message' do
|
||||
get :show, :id => 2345
|
||||
response.status.should == 302
|
||||
end
|
||||
|
||||
it 'succeeds with a AS/photo' do
|
||||
photo = Factory(:activity_streams_photo, :author => bob.person)
|
||||
get :show, :id => photo.id
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
describe '#destroy' do
|
||||
|
||||
it 'let a user delete his message' do
|
||||
message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
|
||||
delete :destroy, :format => :js, :id => message.id
|
||||
response.should be_success
|
||||
StatusMessage.find_by_id(message.id).should be_nil
|
||||
end
|
||||
|
||||
it 'sends a retraction on delete' do
|
||||
controller.stub!(:current_user).and_return alice
|
||||
message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
|
||||
alice.should_receive(:retract).with(message)
|
||||
delete :destroy, :format => :js, :id => message.id
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'will not let you destroy posts visible to you' do
|
||||
message = bob.post(:status_message, :text => "hey", :to => bob.aspects.first.id)
|
||||
delete :destroy, :format => :js, :id => message.id
|
||||
response.should_not be_success
|
||||
StatusMessage.exists?(message.id).should be_true
|
||||
end
|
||||
|
||||
it 'will not let you destory posts you do not own' do
|
||||
message = eve.post(:status_message, :text => "hey", :to => eve.aspects.first.id)
|
||||
delete :destroy, :format => :js, :id => message.id
|
||||
response.should_not be_success
|
||||
StatusMessage.exists?(message.id).should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -61,6 +61,28 @@ describe PublicsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#post' do
|
||||
it 'shows a public post' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||
|
||||
get :post, :id => status.id
|
||||
response.status= 200
|
||||
end
|
||||
|
||||
it 'does not show a private post' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => false, :to => 'all')
|
||||
get :post, :id => status.id
|
||||
response.status = 302
|
||||
end
|
||||
|
||||
it 'redirects to the proper show page if the user has visibility of the post' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||
sign_in bob
|
||||
get :post, :id => status.id
|
||||
response.should be_redirect
|
||||
end
|
||||
end
|
||||
|
||||
describe '#hcard' do
|
||||
it "succeeds", :fixture => true do
|
||||
post :hcard, "guid" => @user.person.guid.to_s
|
||||
|
|
|
|||
|
|
@ -39,36 +39,6 @@ describe StatusMessagesController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before do
|
||||
@message = alice.build_post :status_message, :text => "ohai", :to => @aspect1.id
|
||||
@message.save!
|
||||
|
||||
alice.add_to_streams(@message, [@aspect1])
|
||||
alice.dispatch_post @message, :to => @aspect1.id
|
||||
end
|
||||
|
||||
it 'succeeds' do
|
||||
get :show, "id" => @message.id.to_s
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'marks a corresponding notification as read' do
|
||||
alice.comment("comment after me", :post => @message)
|
||||
bob.comment("here you go", :post => @message)
|
||||
note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
|
||||
lambda{
|
||||
get :show, :id => @message.id
|
||||
note.reload
|
||||
}.should change(note, :unread).from(true).to(false)
|
||||
end
|
||||
|
||||
it 'redirects to back if there is no status message' do
|
||||
get :show, :id => 2345
|
||||
response.status.should == 302
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
let(:status_message_hash) {
|
||||
{ :status_message => {
|
||||
|
|
@ -164,32 +134,4 @@ describe StatusMessagesController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#destroy' do
|
||||
before do
|
||||
@message = alice.post(:status_message, :text => "hey", :to => @aspect1.id)
|
||||
@message2 = bob.post(:status_message, :text => "hey", :to => @aspect2.id)
|
||||
@message3 = eve.post(:status_message, :text => "hey", :to => eve.aspects.first.id)
|
||||
end
|
||||
|
||||
it 'let a user delete his message' do
|
||||
delete :destroy, :format => :js, :id => @message.id
|
||||
StatusMessage.find_by_id(@message.id).should be_nil
|
||||
end
|
||||
|
||||
it 'sends a retraction on delete' do
|
||||
alice.should_receive(:retract).with(@message)
|
||||
delete :destroy, :format => :js, :id => @message.id
|
||||
end
|
||||
|
||||
it 'will not let you destroy posts visible to you' do
|
||||
delete :destroy, :format => :js, :id => @message2.id
|
||||
StatusMessage.find_by_id(@message2.id).should be_true
|
||||
end
|
||||
|
||||
it 'will not let you destory posts you do not own' do
|
||||
delete :destroy, :format => :js, :id => @message3.id
|
||||
StatusMessage.find_by_id(@message3.id).should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe NotificationsHelper do
|
|||
@person2 = Factory(:person)
|
||||
@notification = Notification.notify(@user, Factory(:like, :author => @person, :post => @post), @person)
|
||||
@notification = Notification.notify(@user, Factory(:like, :author => @person2, :post => @post), @person2)
|
||||
|
||||
|
||||
end
|
||||
describe '#notification_people_link' do
|
||||
context 'formatting' do
|
||||
|
|
@ -68,14 +68,14 @@ describe NotificationsHelper do
|
|||
describe 'for a like' do
|
||||
it 'should include a link to the post' do
|
||||
output = object_link(@notification, notification_people_link(@notification))
|
||||
output.should include status_message_path(@post)
|
||||
output.should include post_path(@post)
|
||||
end
|
||||
|
||||
it 'includes the boilerplate translation' do
|
||||
output = object_link(@notification, notification_people_link(@notification))
|
||||
output.should include t("#{@notification.popup_translation_key}.one",
|
||||
:actors => notification_people_link(@notification),
|
||||
:post_link => "<a href=\"#{status_message_path(@post)}\" class=\"hard_object_link\" data-ref=\"#{@post.id}\">#{t('notifications.post')}</a>")
|
||||
:post_link => "<a href=\"#{post_path(@post)}\" class=\"hard_object_link\" data-ref=\"#{@post.id}\">#{t('notifications.post')}</a>")
|
||||
end
|
||||
|
||||
context 'when post is deleted' do
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ describe PostsFake do
|
|||
sm = Factory(:status_message)
|
||||
fake = PostsFake::Fake.new(sm, @fakes)
|
||||
|
||||
status_message_path(fake).should == status_message_path(sm)
|
||||
post_path(fake).should == post_path(sm)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module I18n
|
||||
def self.just_raise_that_exception(*args)
|
||||
raise args.first
|
||||
raise "Translation not found: #{args.first.key}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue