diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index e724858f8..76dbe9188 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -75,8 +75,8 @@ class PublicsController < ApplicationController @post = Post.where(:guid => params[:guid], :public => true).includes(:author, :comments => :author).first end - #hax to upgrade logged in users who can comment if @post + #hax to upgrade logged in users who can comment if user_signed_in? && current_user.find_visible_post_by_id(@post.id) redirect_to post_path(@post) else @@ -86,8 +86,8 @@ class PublicsController < ApplicationController I18n.locale = @person.owner.language respond_to do |format| - format.all{ render "#{@post.class.to_s.underscore}", :layout => 'application'} format.xml{ render :xml => @post.to_diaspora_xml } + format.any{ render "#{@post.class.to_s.underscore}", :layout => 'application'} end else flash[:error] = I18n.t('posts.show.not_found') diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index b99c0be69..483206ba6 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -66,7 +66,14 @@ describe PublicsController do status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all') get :post, :guid => status.id - response.status= 200 + response.status.should == 200 + end + + it 'shows a public photo' do + status = Factory(:status_message_with_photo, :public => true, :author => alice.person) + photo = status.photos.first + get :post, :guid => photo.id + response.status.should == 200 end it 'does not show a private post' do diff --git a/spec/factories.rb b/spec/factories.rb index bf6640a67..4e8b4281d 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -78,7 +78,7 @@ end Factory.define(:status_message_with_photo, :parent => :status_message) do |m| m.sequence(:text) { |n| "There are #{n} ninjas in this photo." } m.after_build do |m| - p = Factory(:photo, :author => m.author, :status_message => m, :pending => false) + p = Factory(:photo, :author => m.author, :status_message => m, :pending => false, :public => m.public) end end