remove #next and #previous from posts_controller

This commit is contained in:
Fabian Rodriguez 2013-12-01 16:49:18 -02:00
parent 6eed63807d
commit 92db8cb929
2 changed files with 1 additions and 73 deletions

View file

@ -7,7 +7,7 @@ class PostsController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :iframe, :oembed, :interactions]
before_filter :set_format_if_malformed_from_status_net, :only => :show
before_filter :find_post, :only => [:show, :next, :previous, :interactions]
before_filter :find_post, :only => [:show, :interactions]
before_filter -> { @css_framework = :bootstrap }
@ -48,24 +48,6 @@ class PostsController < ApplicationController
end
end
def next
next_post = Post.visible_from_author(@post.author, current_user).newer(@post)
respond_to do |format|
format.html{ redirect_to post_path(next_post) }
format.json{ render :json => PostPresenter.new(next_post, current_user)}
end
end
def previous
previous_post = Post.visible_from_author(@post.author, current_user).older(@post)
respond_to do |format|
format.html{ redirect_to post_path(previous_post) }
format.json{ render :json => PostPresenter.new(previous_post, current_user)}
end
end
def interactions
respond_with(PostInteractionPresenter.new(@post, current_user))
end

View file

@ -167,58 +167,4 @@ describe PostsController do
StatusMessage.exists?(message.id).should be_true
end
end
describe "#next" do
before do
sign_in alice
Post.stub(:find_by_guid_or_id_with_user).and_return(mock_model(Post, :author => 4))
Post.stub_chain(:visible_from_author, :newer).and_return(next_post)
end
let(:next_post){ mock_model(StatusMessage, :id => 34)}
context "GET .json" do
let(:mock_presenter) { mock(:as_json => {:title => "the unbearable lightness of being"}) }
it "should return a show presenter the next post" do
PostPresenter.should_receive(:new).with(next_post, alice).and_return(mock_presenter)
get :next, :id => 14, :format => :json
response.body.should == {:title => "the unbearable lightness of being"}.to_json
end
end
context "GET .html" do
it "should redirect to the next post" do
get :next, :id => 14
response.should redirect_to(post_path(next_post))
end
end
end
describe "previous" do
before do
sign_in alice
Post.stub(:find_by_guid_or_id_with_user).and_return(mock_model(Post, :author => 4))
Post.stub_chain(:visible_from_author, :older).and_return(previous_post)
end
let(:previous_post){ mock_model(StatusMessage, :id => 11)}
context "GET .json" do
let(:mock_presenter) { mock(:as_json => {:title => "existential crises"})}
it "should return a show presenter the next post" do
PostPresenter.should_receive(:new).with(previous_post, alice).and_return(mock_presenter)
get :previous, :id => 14, :format => :json
response.body.should == {:title => "existential crises"}.to_json
end
end
context "GET .html" do
it "should redirect to the next post" do
get :previous, :id => 14
response.should redirect_to(post_path(previous_post))
end
end
end
end