move all stream actions into PostController

This commit is contained in:
danielgrippi 2012-01-16 19:33:47 -08:00
parent e0a63e624f
commit bfe0b7129c
36 changed files with 200 additions and 312 deletions

View file

@ -83,7 +83,7 @@ class ApplicationController < ActionController::Base
def redirect_unless_admin
unless current_user.admin?
redirect_to multi_url, :notice => 'you need to be an admin to do that'
redirect_to multi_stream_url, :notice => 'you need to be an admin to do that'
return
end
end
@ -111,7 +111,7 @@ class ApplicationController < ActionController::Base
end
def after_sign_in_path_for(resource)
stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : multi_path)
stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : multi_stream_path)
end
def tag_followings

View file

@ -2,29 +2,13 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, "lib", 'stream', "aspect")
class AspectsController < ApplicationController
before_filter :authenticate_user!
before_filter :save_selected_aspects, :only => :index
before_filter :ensure_page, :only => :index
respond_to :html,
:js,
:json
def index
stream_klass = Stream::Aspect
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
@stream = Stream::Aspect.new(current_user, aspect_ids,
:max_time => params[:max_time].to_i)
respond_with do |format|
format.html { render 'aspects/index' }
format.json{ render_for_api :backbone, :json => @stream.stream_posts, :root => :posts }
end
end
def create
@aspect = current_user.aspects.create(params[:aspect])
@ -132,16 +116,4 @@ class AspectsController < ApplicationController
end
@aspect.save
end
def ensure_page
params[:max_time] ||= Time.now + 1
end
private
def save_selected_aspects
if params[:a_ids].present?
session[:a_ids] = params[:a_ids]
end
end
end

View file

@ -1,19 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib','stream', 'comments')
class CommentStreamController < ApplicationController
respond_to :html, :json
def index
stream_klass = Stream::Comments
respond_with do |format|
format.html{ default_stream_action(stream_klass) }
format.json{ stream_json(stream_klass) }
end
end
end

View file

@ -6,7 +6,7 @@ class HomeController < ApplicationController
def show
if current_user
redirect_to multi_path if current_user
redirect_to multi_stream_path if current_user
elsif is_mobile_device?
redirect_to user_session_path
else

View file

@ -1,19 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib','stream', 'likes')
class LikeStreamController < ApplicationController
respond_to :html, :json
def index
stream_klass = Stream::Likes
respond_with do |format|
format.html{ default_stream_action(stream_klass) }
format.json{ stream_json(stream_klass) }
end
end
end

View file

@ -1,19 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib','stream', 'mention')
class MentionsController < ApplicationController
respond_to :html, :json
def index
stream_klass = Stream::Mention
respond_with do |format|
format.html{ default_stream_action(stream_klass) }
format.json{ stream_json(stream_klass) }
end
end
end

View file

@ -1,20 +0,0 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib', 'stream', 'multi')
class MultisController < ApplicationController
respond_to :html, :json
def index
stream_klass = Stream::Multi
respond_with do |format|
format.html{ default_stream_action(stream_klass) }
format.mobile{ default_stream_action(stream_klass) }
format.json{ stream_json(stream_klass) }
end
end
end

View file

@ -50,7 +50,7 @@ class NotificationsController < VannaController
post_process :html do
def post_read_all(json)
Response.new(:status => 302, :location => multi_path)
Response.new(:status => 302, :location => multi_stream_path)
end
end

View file

@ -2,12 +2,21 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib', 'stream', 'public')
require File.join(Rails.root, "lib", "stream", "aspect")
require File.join(Rails.root, "lib", "stream", "multi")
require File.join(Rails.root, "lib", "stream", "comments")
require File.join(Rails.root, "lib", "stream", "likes")
require File.join(Rails.root, "lib", "stream", "mention")
require File.join(Rails.root, "lib", "stream", "followed_tag")
class PostsController < ApplicationController
before_filter :authenticate_user!, :except => :show
before_filter :set_format_if_malformed_from_status_net, :only => :show
before_filter :redirect_unless_admin, :only => :index
before_filter :redirect_unless_admin, :only => :public
before_filter :save_selected_aspects, :only => :aspects
before_filter :ensure_page, :only => :aspects
respond_to :html,
:mobile,
@ -54,7 +63,7 @@ class PostsController < ApplicationController
respond_to do |format|
format.js {render 'destroy'}
format.json { render :nothing => true, :status => 204 }
format.all {redirect_to multi_path}
format.all {redirect_to multi_stream_path}
end
else
Rails.logger.info "event=post_destroy status=failure user=#{current_user.diaspora_handle} reason='User does not own post'"
@ -62,16 +71,57 @@ class PostsController < ApplicationController
end
end
def index
default_stream_action(Stream::Public)
# streams
def aspects
stream_klass = Stream::Aspect
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
@stream = Stream::Aspect.new(current_user, aspect_ids,
:max_time => params[:max_time].to_i)
respond_with do |format|
format.html { render 'aspects/index' }
format.json{ render_for_api :backbone, :json => @stream.stream_posts, :root => :posts }
end
end
def public
stream_responder(Stream::Public)
end
def multi
stream_responder(Stream::Multi)
end
def commented
stream_responder(Stream::Comments)
end
def liked
stream_responder(Stream::Likes)
end
def mentioned
stream_responder(Stream::Mention)
end
def followed_tags
stream_responder(Stream::FollowedTag)
end
private
def stream_responder(stream_klass)
respond_with do |format|
format.html{ default_stream_action(stream_klass) }
format.mobile{ default_stream_action(stream_klass) }
format.json{ stream_json(stream_klass) }
end
end
def set_format_if_malformed_from_status_net
request.format = :html if request.format == 'application/html+xml'
end
private
def user_can_not_comment_on_post?
if @post.public && @post.author.local?
false
@ -83,4 +133,14 @@ class PostsController < ApplicationController
true
end
end
def save_selected_aspects
if params[:a_ids].present?
session[:a_ids] = params[:a_ids]
end
end
def ensure_page
params[:max_time] ||= Time.now + 1
end
end

View file

@ -70,7 +70,7 @@ class StatusMessagesController < ApplicationController
respond_to do |format|
format.html { redirect_to :back}
format.mobile{ redirect_to multi_path}
format.mobile{ redirect_to multi_stream_path}
format.json{ render :json => @status_message.as_api_response(:backbone), :status => 201 }
end
else

View file

@ -2,22 +2,12 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
require File.join(Rails.root, 'lib', 'stream', 'followed_tag')
class TagFollowingsController < ApplicationController
before_filter :authenticate_user!
respond_to :html, :json
def index
stream_klass = Stream::FollowedTag
respond_with do |format|
format.html{ default_stream_action(stream_klass) }
format.json{ stream_json(stream_klass) }
end
end
# POST /tag_followings
# POST /tag_followings.xml
def create
@ -73,6 +63,6 @@ class TagFollowingsController < ApplicationController
@tag_following = current_user.tag_followings.create(:tag_id => @tag.id)
end
end
redirect_to multi_path
redirect_to multi_stream_path
end
end

View file

@ -87,7 +87,7 @@ class UsersController < ApplicationController
if params[:user] && params[:user][:current_password] && current_user.valid_password?(params[:user][:current_password])
current_user.close_account!
sign_out current_user
redirect_to(multi_path, :notice => I18n.t('users.destroy.success'))
redirect_to(multi_stream_path, :notice => I18n.t('users.destroy.success'))
else
if params[:user].present? && params[:user][:current_password].present?
flash[:error] = t 'users.destroy.wrong_password'
@ -111,7 +111,7 @@ class UsersController < ApplicationController
format.any { redirect_to person_path(user.person.id) }
end
else
redirect_to multi_path, :error => I18n.t('users.public.does_not_exist', :username => params[:username])
redirect_to multi_stream_path, :error => I18n.t('users.public.does_not_exist', :username => params[:username])
end
end
@ -127,14 +127,14 @@ class UsersController < ApplicationController
def logged_out
@page = :logged_out
if user_signed_in?
redirect_to multi_path
redirect_to multi_stream_path
end
end
def getting_started_completed
user = current_user
user.update_attributes(:getting_started => false)
redirect_to multi_path
redirect_to multi_stream_path
end
def export
@ -150,7 +150,7 @@ class UsersController < ApplicationController
def user_photo
username = params[:username].split('@')[0]
user = User.find_by_username(username)
if user.present?
if user.present?
redirect_to user.profile.image_url
else
render :nothing => true, :status => 404

View file

@ -83,7 +83,7 @@ class VannaController < Vanna::Base
def redirect_unless_admin
unless current_user.admin?
redirect_to multi_path, :notice => 'you need to be an admin to do that'
redirect_to multi_stream_path, :notice => 'you need to be an admin to do that'
return
end
end

View file

@ -10,25 +10,19 @@ module StreamHelper
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
elsif controller.instance_of?(PeopleController)
local_or_remote_person_path(@person, :max_time => time_for_scroll(@stream))
elsif controller.instance_of?(TagFollowingsController)
tag_followings_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(MentionsController)
mentions_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(MultisController)
multi_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(PostsController)
public_stream_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(AspectsController)
aspects_path(:max_time => time_for_scroll(@stream), :a_ids => @stream.aspect_ids)
elsif controller.instance_of?(LikeStreamController)
like_stream_path(:max_time => time_for_scroll(@stream))
elsif controller.instance_of?(CommentStreamController)
comment_stream_path(:max_time => time_for_scroll(@stream))
else
raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
end
end
def reshare?(post)
post.instance_of?(Reshare)
end
private
def time_for_scroll(stream)
if stream.stream_posts.empty?
(Time.now() + 1).to_i
@ -36,8 +30,4 @@ module StreamHelper
stream.stream_posts.last.send(stream.order.to_sym).to_i
end
end
def reshare?(post)
post.instance_of?(Reshare)
end
end

View file

@ -31,21 +31,21 @@
.section
%ul.left_nav
%li
= link_to t("streams.multi.title"), multi_path, :class => 'home_selector', :rel => 'backbone'
= link_to t("streams.multi.title"), multi_stream_path, :class => 'home_selector', :rel => 'backbone'
= render 'aspects/aspect_listings', :stream => @stream
%ul.left_nav
%li
= link_to t('streams.mentions.title'), mentions_path, :class => 'home_selector', :rel => 'backbone'
= link_to t('streams.mentions.title'), mentioned_stream_path, :class => 'home_selector', :rel => 'backbone'
%ul.left_nav
%li
= link_to t('streams.comment_stream.title'), comment_stream_path, :class => 'home_selector', :rel => 'backbone'
= link_to t('streams.comment_stream.title'), commented_stream_path, :class => 'home_selector', :rel => 'backbone'
%ul.left_nav
%li
= link_to t('streams.like_stream.title'), like_stream_path, :class => 'home_selector', :rel => 'backbone'
= link_to t('streams.like_stream.title'), liked_stream_path, :class => 'home_selector', :rel => 'backbone'
#followed_tags_listing
= render 'tags/followed_tags_listings'

View file

@ -50,7 +50,7 @@
= yield
%header
= link_to(image_tag('white@2x.png', :height => 20, :width => 127, :id => 'header_title'), multi_path)
= link_to(image_tag('white@2x.png', :height => 20, :width => 127, :id => 'header_title'), multi_stream_path)
- if user_signed_in?
- if yield(:header_action).present?
= yield(:header_action)

View file

@ -5,7 +5,7 @@
- if user_signed_in?
%ul.left_nav
%li
%b=link_to t('streams.followed_tag.title'), tag_followings_path, :class => 'home_selector'
%b=link_to t('streams.followed_tag.title'), followed_tags_stream_path, :class => 'home_selector'
- if @stream.is_a?(Stream::FollowedTag)
%ul.sub_nav

View file

@ -4,10 +4,7 @@
- content_for :head do
:css
body {
margin-top: 220px;
}
body { margin-top: 220px; }
#grey_header
.row
@ -25,7 +22,7 @@
%h4
= t('.simply_visit')
%strong
= link_to AppConfig[:pod_url], multi_path
= link_to AppConfig[:pod_url], multi_stream_path
= t('.on_your_mobile_device')
%p.dull

View file

@ -4,15 +4,10 @@
Diaspora::Application.routes.draw do
# Posting and Reading
resources :reshares
resources :aspects do
put :toggle_contact_visibility
end
resources :status_messages, :only => [:new, :create]
resources :posts, :only => [:show, :destroy] do
@ -20,12 +15,23 @@ Diaspora::Application.routes.draw do
resources :comments, :only => [:new, :create, :destroy, :index]
end
get 'p/:id' => 'posts#show', :as => 'short_post'
get 'public_stream' => 'posts#index', :as => 'public_stream'
# roll up likes into a nested resource above
resources :comments, :only => [:create, :destroy] do
resources :likes, :only => [:create, :destroy, :index]
end
# Streams
get "public" => "posts#public", :as => "public_stream"
get "stream" => "posts#multi", :as => "multi_stream"
get "followed_tags" => "posts#followed_tags", :as => "followed_tags_stream"
get "mentions" => "posts#mentioned", :as => "mentioned_stream"
get "liked" => "posts#liked", :as => "liked_stream"
get "commented" => "posts#commented", :as => "commented_stream"
get "aspects" => "posts#aspects", :as => "aspects_stream"
resources :aspects do
put :toggle_contact_visibility
end
get 'bookmarklet' => 'status_messages#bookmarklet'
@ -50,26 +56,19 @@ Diaspora::Application.routes.draw do
resources :tags, :only => [:index]
scope "tags/:name" do
post "tag_followings" => "tag_followings#create", :as => 'tag_tag_followings'
delete "tag_followings" => "tag_followings#destroy"
delete "tag_followings" => "tag_followings#destroy", :as => 'tag_tag_followings'
end
post "multiple_tag_followings" => "tag_followings#create_multiple", :as => 'multiple_tag_followings'
get "tag_followings" => "tag_followings#index", :as => 'tag_followings'
resources :mentions, :only => [:index]
resources "tag_followings", :only => [:create]
get 'comment_stream' => 'comment_stream#index', :as => 'comment_stream'
get 'like_stream' => 'like_stream#index', :as => 'like_stream'
get 'tags/:name' => 'tags#show', :as => 'tag'
resources :apps, :only => [:show]
#Cubbies info page
resource :token, :only => :show
resource :token, :only => :show
# Users and people
@ -120,8 +119,6 @@ Diaspora::Application.routes.draw do
get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
get 'stream' => "multis#index", :as => 'multi'
resources :people, :except => [:edit, :update] do
resources :status_messages
resources :photos

View file

@ -16,7 +16,7 @@ Feature: invitation acceptance
And I preemptively confirm the alert
And I follow "awesome_button"
Then I should be on the multi page
Then I should be on the multi stream page
Scenario: accept invitation from user
Given I have been invited by a user
@ -34,7 +34,7 @@ Feature: invitation acceptance
And I preemptively confirm the alert
And I follow "awesome_button"
Then I should be on the multi page
Then I should be on the multi stream page
Scenario: sends an invitation
Given a user with email "bob@bob.bob"

View file

@ -11,7 +11,7 @@ Feature: Change password
Then I should see "Password changed"
Then I should be on the new user session page
When I sign in with password "newsecret"
Then I should be on the multi page
Then I should be on the multi stream page
Scenario: Reset my password
Given a user with email "forgetful@users.net"

View file

@ -29,11 +29,11 @@ Feature: posting
Scenario: can stop following a tag from the tag page
When I press "Following #boss"
And I go to the tag_followings page
And I go to the followed tags stream page
Then I should not see "#boss" within ".left_nav"
Scenario: can stop following a tag from the homepage
When I go to the tag_followings page
When I go to the followed tags stream page
And I preemptively confirm the alert
And I hover over the "li.unfollow#tag-following-boss"
And I follow "unfollow_boss"

View file

@ -6,7 +6,7 @@ Feature: user authentication
And I fill in "Username" with "ohai"
And I fill in "Password" with "secret"
And I press "Sign in"
Then I should be on the multi page
Then I should be on the multi stream page
@javascript
Scenario: user logs out
@ -19,5 +19,5 @@ Feature: user authentication
Scenario: user uses token auth
Given a user with username "ohai" and password "secret"
When I post a photo with a token
And I go to the multi page
And I go to the multi stream page
Then I should be on the new user session page

View file

@ -19,18 +19,18 @@ Feature: new user registration
And I preemptively confirm the alert
And I follow "awesome_button"
Then I should be on the multi page
Then I should be on the multi stream page
And I should not see "awesome_button"
Scenario: new user skips the setup wizard
When I preemptively confirm the alert
And I follow "awesome_button"
Then I should be on the multi page
Then I should be on the multi stream page
Scenario: closing a popover clears getting started
When I preemptively confirm the alert
And I follow "awesome_button"
Then I should be on the multi page
Then I should be on the multi stream page
And I have turned off jQuery effects
And I wait for the popovers to appear
And I click close on all the popovers

View file

@ -2,7 +2,7 @@ module NavigationHelpers
def path_to(page_name)
case page_name
when /^the home(?: )?page$/
multi_path
multi_stream_path
when /^step (\d)$/
if $1.to_i == 1
getting_started_path

View file

@ -2,7 +2,7 @@ class Stream::Multi < Stream::Base
# @return [String] URL
def link(opts)
Rails.application.routes.url_helpers.multi_path(opts)
Rails.application.routes.url_helpers.multi_stream_path(opts)
end
# @return [String]

View file

@ -2,12 +2,12 @@ app.Router = Backbone.Router.extend({
routes: {
"stream": "stream",
"aspects:query": "stream",
"comment_stream": "stream",
"like_stream": "stream",
"commented": "stream",
"liked": "stream",
"mentions": "stream",
"people/:id": "stream",
"u/:name": "stream",
"tag_followings": "stream",
"followed_tags": "stream",
"tags/:name": "stream",
"posts/:id": "stream"
},

View file

@ -14,7 +14,7 @@ describe AdminsController do
context 'admin not signed in' do
it 'is behind redirect_unless_admin' do
get :user_search
response.should redirect_to multi_path
response.should redirect_to multi_stream_path
end
end
@ -64,7 +64,7 @@ describe AdminsController do
context 'admin not signed in' do
it 'is behind redirect_unless_admin' do
get :admin_inviter
response.should redirect_to multi_path
response.should redirect_to multi_stream_path
end
end

View file

@ -35,52 +35,6 @@ describe AspectsController do
end
end
describe "#index" do
it 'assigns an Stream::Aspect' do
get :index
assigns(:stream).class.should == Stream::Aspect
end
describe 'filtering by aspect' do
before do
@aspect1 = alice.aspects.create(:name => "test aspect")
@stream = Stream::Aspect.new(alice, [])
@stream.stub(:posts).and_return([])
end
it 'respects a single aspect' do
Stream::Aspect.should_receive(:new).with(alice, [@aspect1.id], anything).and_return(@stream)
get :index, :a_ids => [@aspect1.id]
end
it 'respects multiple aspects' do
aspect2 = alice.aspects.create(:name => "test aspect two")
Stream::Aspect.should_receive(:new).with(alice, [@aspect1.id, aspect2.id], anything).and_return(@stream)
get :index, :a_ids => [@aspect1.id, aspect2.id]
end
end
describe 'performance', :performance => true do
before do
require 'benchmark'
8.times do |n|
user = Factory.create(:user)
aspect = user.aspects.create(:name => 'people')
connect_users(alice, @alices_aspect_1, user, aspect)
post = alice.post(:status_message, :text => "hello#{n}", :to => @alices_aspect_2.id)
8.times do |n|
user.comment "yo#{post.text}", :post => post
end
end
end
it 'takes time' do
Benchmark.realtime {
get :index
}.should < 1.5
end
end
end
describe "#show" do
it "succeeds" do
get :show, 'id' => @alices_aspect_1.id.to_s
@ -124,6 +78,7 @@ describe AspectsController do
end
end
end
context "with invalid params" do
it "does not create an aspect" do
alice.aspects.count.should == 2
@ -232,25 +187,4 @@ describe AspectsController do
end
end
end
describe "mobile site" do
before do
ap = alice.person
posts = []
posts << alice.post(:reshare, :root_guid => Factory(:status_message, :public => true).guid, :to => 'all')
posts << alice.post(:status_message, :text => 'foo', :to => alice.aspects)
photo = Factory(:activity_streams_photo, :public => true, :author => ap)
posts << photo
posts.each do |p|
alice.build_like(:positive => true, :target => p).save
end
alice.add_to_streams(photo, alice.aspects)
sign_in alice
end
it 'should not 500' do
get :index, :format => :mobile
response.should be_success
end
end
end

View file

@ -14,7 +14,7 @@ describe HomeController do
it 'redirects to multis index if user is logged in' do
sign_in alice
get :show, :home => true
response.should redirect_to(multi_path)
response.should redirect_to(multi_stream_path)
end
end
end

View file

@ -4,8 +4,8 @@
require 'spec_helper'
describe AspectsController do
describe '#index' do
describe PostsController do
describe '#aspects' do
before do
sign_in :user, alice
@alices_aspect_2 = alice.aspects.create(:name => "another aspect")
@ -19,19 +19,19 @@ describe AspectsController do
end
it "generates a jasmine fixture", :fixture => true do
get :index
get :aspects
save_fixture(html_for("body"), "aspects_index")
end
it "generates a jasmine fixture with a prefill", :fixture => true do
get :index, :prefill => "reshare things"
get :aspects, :prefill => "reshare things"
save_fixture(html_for("body"), "aspects_index_prefill")
end
it 'generates a jasmine fixture with services', :fixture => true do
alice.services << Services::Facebook.create(:user_id => alice.id)
alice.services << Services::Twitter.create(:user_id => alice.id)
get :index, :prefill => "reshare things"
get :aspects, :prefill => "reshare things"
save_fixture(html_for("body"), "aspects_index_services")
end
@ -39,14 +39,14 @@ describe AspectsController do
bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id)
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
5.times { bob.comment("what", :post => message) }
get :index
get :aspects
save_fixture(html_for("body"), "aspects_index_with_posts")
end
it 'generates a jasmine fixture with only posts', :fixture => true do
2.times { bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) }
get :index, :only_posts => true
get :aspects, :only_posts => true
save_fixture(response.body, "aspects_index_only_posts")
end
@ -54,14 +54,14 @@ describe AspectsController do
it "generates a jasmine fixture with a post with comments", :fixture => true do
message = bob.post(:status_message, :text => "HALO WHIRLED", :to => @bob.aspects.where(:name => "generic").first.id)
5.times { bob.comment("what", :post => message) }
get :index
get :aspects
save_fixture(html_for("body"), "aspects_index_post_with_comments")
end
it 'generates a jasmine fixture with a followed tag', :fixture => true do
@tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
TagFollowing.create!(:tag => @tag, :user => alice)
get :index
get :aspects
save_fixture(html_for("body"), "aspects_index_with_one_followed_tag")
end
@ -89,7 +89,7 @@ describe AspectsController do
)
alice.post(:status_message, :text => "http://www.youtube.com/watch?v=UYrkQL1bX4A", :to => @alices_aspect_2.id)
get :index
get :aspects
save_fixture(html_for("body"), "aspects_index_with_video_post")
end
@ -98,7 +98,7 @@ describe AspectsController do
alice.build_like(:positive => true, :target => message).save
bob.build_like(:positive => true, :target => message).save
get :index
get :aspects
save_fixture(html_for("body"), "aspects_index_with_a_post_with_likes")
end
end

View file

@ -4,8 +4,8 @@
require 'spec_helper'
describe MultisController do
describe '#index' do
describe PostsController do
describe '#multi' do
before do
sign_in :user, alice
end
@ -27,7 +27,7 @@ describe MultisController do
end
end
get :index, :format => :json
get :multi, :format => :json
response.should be_success
save_fixture(response.body, "multi_stream_json")

View file

@ -1,23 +0,0 @@
# Copyright (c) 2010-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 LikeStreamController do
before do
sign_in :user, alice
end
describe 'index' do
it 'succeeds' do
get :index
response.should be_success
end
it 'assigns a stream' do
get :index
assigns[:stream].should be_a Stream::Likes
end
end
end

View file

@ -138,22 +138,70 @@ describe PostsController do
end
end
describe '#index' do
context 'streams' do
before do
sign_in alice
end
it 'will succeed if admin' do
AppConfig[:admins] = [alice.username]
get :index
response.should be_success
describe "#public" do
it 'will succeed if admin' do
AppConfig[:admins] = [alice.username]
get :public
response.should be_success
end
it 'will redirect if not' do
AppConfig[:admins] = []
get :public
response.should be_redirect
end
end
it 'will redirect if not' do
AppConfig[:admins] = []
get :index
response.should be_redirect
describe '#multi' do
before do
@old_spotlight_value = AppConfig[:community_spotlight]
end
after do
AppConfig[:community_spotlight] = @old_spotlight_value
end
it 'succeeds' do
AppConfig[:community_spotlight] = [bob.person.diaspora_handle]
get :multi
response.should be_success
end
it 'succeeds without AppConfig[:community_spotlight]' do
AppConfig[:community_spotlight] = nil
get :multi
response.should be_success
end
it 'succeeds on mobile' do
get :multi, :format => :mobile
response.should be_success
end
end
streams = [
{:path => :liked, :type => Stream::Likes},
{:path => :mentioned, :type => Stream::Mention},
{:path => :followed_tags, :type => Stream::FollowedTag}
]
streams.each do |s|
describe "##{s[:path]}" do
it 'succeeds' do
get s[:path]
response.should be_success
end
it 'assigns a stream' do
get s[:path]
assigns[:stream].should be_a s[:type]
end
end
end
end
end

View file

@ -67,7 +67,7 @@ describe RegistrationsController do
it "redirects to the home path" do
get :create, @valid_params
response.should be_redirect
response.location.should match /^#{multi_url}\??$/
response.location.should match /^#{multi_stream_url}\??$/
end
end

View file

@ -27,14 +27,14 @@ describe SessionsController do
it "redirects to /stream for a non-mobile user" do
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
response.should be_redirect
response.location.should match /^#{multi_url}\??$/
response.location.should match /^#{multi_stream_url}\??$/
end
it "redirects to /stream for a mobile user" do
@request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7'
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
response.should be_redirect
response.location.should match /^#{multi_url}\??$/
response.location.should match /^#{multi_stream_url}\??$/
end
it 'queues up an update job' do