Revert to including all helpers everywhere, because the rest of the team prefers it that way

This commit is contained in:
Raphael Sofaer 2011-05-12 13:54:55 -07:00
parent efd5c4f500
commit 71e77d59b3
18 changed files with 51 additions and 41 deletions

View file

@ -3,8 +3,6 @@
# the COPYRIGHT file.
class ApplicationController < ActionController::Base
clear_helpers
helper :layout, :error_messages, :markdownify, :aspect_global
has_mobile_fu
protect_from_forgery :except => :receive

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class AspectsController < ApplicationController
helper :comments, :aspect_memberships, :likes
before_filter :authenticate_user!
before_filter :save_sort_order, :only => :index
before_filter :ensure_page, :only => :index

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class ContactsController < ApplicationController
helper :aspect_memberships
before_filter :authenticate_user!
def new

View file

@ -4,11 +4,10 @@
class LikesController < ApplicationController
include ApplicationHelper
helper :likes
before_filter :authenticate_user!
respond_to :html, :mobile, :json
def create
target = current_user.find_visible_post_by_id params[:post_id]
positive = (params[:positive] == 'true') ? true : false

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class PeopleController < ApplicationController
helper :comments, :likes
before_filter :authenticate_user!, :except => [:show]
respond_to :html

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class PhotosController < ApplicationController
helper :comments, :people
before_filter :authenticate_user!
respond_to :html, :json

View file

@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file.
class ServicesController < ApplicationController
helper :aspect_memberships
before_filter :authenticate_user!
def index

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class SocketsController < ApplicationController
helper :comments, :likes
include ApplicationHelper
include SocketsHelper
include Rails.application.routes.url_helpers

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class StatusMessagesController < ApplicationController
helper :comments, :likes
before_filter :authenticate_user!
respond_to :html

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class TagsController < ApplicationController
helper :comments, :likes
skip_before_filter :count_requests
skip_before_filter :set_invites
skip_before_filter :which_action_and_user
@ -41,6 +40,7 @@ class TagsController < ApplicationController
end
def show
@aspect = :tag
if current_user
@posts = StatusMessage.joins(:contacts).where(:pending => false).where(
Contact.arel_table[:user_id].eq(current_user.id).or(

View file

@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class UsersController < ApplicationController
helper :language
require File.join(Rails.root, 'lib/diaspora/ostatus_builder')
require File.join(Rails.root, 'lib/diaspora/exporter')
require File.join(Rails.root, 'lib/collect_user_photos')

View file

@ -7,10 +7,6 @@ module ApplicationHelper
timeago(obj.created_at)
end
def time_for_sort(post)
post.created_at
end
def timeago(time, options={})
options[:class] ||= "timeago"
content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time

View file

@ -3,14 +3,6 @@
# the COPYRIGHT file.
module AspectsHelper
def next_page_path
aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids])
end
def time_for_sort post
post.send(session[:sort_order].to_sym)
end
def remove_link(aspect)
if aspect.contacts.size == 0
link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')

View file

@ -27,8 +27,4 @@ module PeopleHelper
I18n.l bday, :format => I18n.t('date.formats.birthday_with_year')
end
end
def next_page_path
person_path(@person, :max_time => @posts.last.created_at.to_i)
end
end

View file

@ -0,0 +1,23 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module StreamHelper
def next_page_path
if controller.instance_of?(TagsController)
tag_path(@tag, :max_time => @posts.last.created_at.to_i)
elsif controller.instance_of?(PeopleController)
person_path(@person, :max_time => @posts.last.created_at.to_i)
elsif controller.instance_of?(AspectsController)
aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids])
end
end
def time_for_sort post
if controller.instance_of?(AspectsController)
post.send(session[:sort_order].to_sym)
else
post.created_at
end
end
end

View file

@ -3,7 +3,4 @@
# the COPYRIGHT file.
module TagsHelper
def next_page_path
tag_path(@tag, :max_time => @posts.last.created_at.to_i)
end
end

View file

@ -71,11 +71,4 @@ describe ApplicationHelper do
person_link(@person).should_not include("<h1>")
end
end
describe "#time_for_sort" do
it "returns created_at" do
post = @user.post(:status_message, :text => "hello", :public => true, :to => 'all')
time_for_sort(post).should == post.created_at
end
end
end
end

View file

@ -0,0 +1,24 @@
# Copyright (c) 2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe StreamHelper do
before do
@post = Factory(:status_message)
end
describe "#time_for_sort" do
it "returns sort_order for an aspectscontroller" do
sort_order = :stored_in_session
stub!(:controller).and_return(AspectsController.new)
stub!(:session).and_return({:sort_order => sort_order})
@post.should_receive(sort_order)
time_for_sort(@post)
end
it "returns post.created_at otherwise" do
stub!(:controller).and_return(mock())
time_for_sort(@post).should == @post.created_at
end
end
end