moved stream logic into its own controller (StreamsController)
This commit is contained in:
parent
bfe0b7129c
commit
339c47d782
15 changed files with 175 additions and 392 deletions
|
|
@ -127,22 +127,6 @@ class ApplicationController < ActionController::Base
|
|||
@tags ||= current_user.followed_tags
|
||||
end
|
||||
|
||||
# @param stream_klass [Constant]
|
||||
# @return [String] JSON representation of posts given a [Stream] constant.
|
||||
def stream_json(stream_klass)
|
||||
render_for_api :backbone, :json => stream(stream_klass).stream_posts, :root => :posts
|
||||
end
|
||||
|
||||
def stream(stream_klass)
|
||||
authenticate_user!
|
||||
stream_klass.new(current_user, :max_time => max_time)
|
||||
end
|
||||
|
||||
def default_stream_action(stream_klass)
|
||||
@stream = stream(stream_klass)
|
||||
render 'aspects/index'
|
||||
end
|
||||
|
||||
def max_time
|
||||
params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,22 +2,10 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
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 => :public
|
||||
|
||||
before_filter :save_selected_aspects, :only => :aspects
|
||||
before_filter :ensure_page, :only => :aspects
|
||||
|
||||
respond_to :html,
|
||||
:mobile,
|
||||
:json,
|
||||
|
|
@ -71,53 +59,8 @@ class PostsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 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
|
||||
|
|
@ -133,14 +76,4 @@ 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
|
||||
|
|
|
|||
71
app/controllers/streams_controller.rb
Normal file
71
app/controllers/streams_controller.rb
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# 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", "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 StreamsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :save_selected_aspects, :only => :aspects
|
||||
before_filter :redirect_unless_admin, :only => :public
|
||||
|
||||
respond_to :html,
|
||||
:mobile,
|
||||
:json
|
||||
|
||||
def aspects
|
||||
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
|
||||
@stream = Stream::Aspect.new(current_user, aspect_ids,
|
||||
:max_time => max_time)
|
||||
stream_responder
|
||||
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=nil)
|
||||
if stream_klass.present?
|
||||
@stream ||= stream_klass.new(current_user, :max_time => max_time)
|
||||
end
|
||||
|
||||
respond_with do |format|
|
||||
format.html { render 'layouts/main_stream' }
|
||||
format.mobile { render 'layouts/main_stream' }
|
||||
format.json { render_for_api :backbone, :json => @stream.stream_posts, :root => :posts }
|
||||
end
|
||||
end
|
||||
|
||||
def save_selected_aspects
|
||||
if params[:a_ids].present?
|
||||
session[:a_ids] = params[:a_ids]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -13,9 +13,9 @@
|
|||
= link_to image_tag('close_label.png'), getting_started_completed_path, :id => "gs-skip-x"
|
||||
.span-23
|
||||
%h1
|
||||
= t('.welcome_to_diaspora', :name => current_user.first_name)
|
||||
= t('aspects.index.welcome_to_diaspora', :name => current_user.first_name)
|
||||
%h3
|
||||
= t('.introduce_yourself')
|
||||
= t('aspects.index.introduce_yourself')
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
18
app/views/layouts/main_stream.mobile.haml
Normal file
18
app/views/layouts/main_stream.mobile.haml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
%h2{:style => "padding:0 10px;display:none;"}
|
||||
- if @stream.for_all_aspects?
|
||||
= t('all_aspects')
|
||||
- else
|
||||
= @stream.aspect
|
||||
|
||||
#main_stream.stream
|
||||
= render 'shared/stream', :posts => @stream.stream_posts
|
||||
-if @stream.stream_posts.length > 0
|
||||
#pagination
|
||||
%a.more-link.paginate{:href => next_page_path}
|
||||
%h1
|
||||
= t("more")
|
||||
|
||||
|
|
@ -21,13 +21,13 @@ Diaspora::Application.routes.draw do
|
|||
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"
|
||||
get "public" => "streams#public", :as => "public_stream"
|
||||
get "stream" => "streams#multi", :as => "multi_stream"
|
||||
get "followed_tags" => "streams#followed_tags", :as => "followed_tags_stream"
|
||||
get "mentions" => "streams#mentioned", :as => "mentioned_stream"
|
||||
get "liked" => "streams#liked", :as => "liked_stream"
|
||||
get "commented" => "streams#commented", :as => "commented_stream"
|
||||
get "aspects" => "streams#aspects", :as => "aspects_stream"
|
||||
|
||||
resources :aspects do
|
||||
put :toggle_contact_visibility
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ Feature: oembed
|
|||
Given I expand the publisher
|
||||
When I fill in "status_message_fake_text" with "http://mytube.com/watch?v=M3r2XDceM6A&format=json"
|
||||
And I press "Share"
|
||||
And I wait for the ajax to finish
|
||||
|
||||
And I follow "Your Aspects"
|
||||
Then I should not see a video player
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ Feature: viewing the photo lightbox
|
|||
And I fill in "status_message_fake_text" with "Look at this dog"
|
||||
And I press "Share"
|
||||
And I wait for the ajax to finish
|
||||
And I am on the aspects page
|
||||
|
||||
Scenario: viewing a photo
|
||||
Then I should see an image attached to the post
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Feature: posting from the main page
|
|||
Given I expand the publisher
|
||||
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||
And I press "Share"
|
||||
And I wait for the ajax to finish
|
||||
|
||||
And I go to the aspects page
|
||||
Then I should see "I am eating a yogurt" within ".stream_element"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe PostsController do
|
||||
describe StreamsController do
|
||||
describe '#aspects' do
|
||||
before do
|
||||
sign_in :user, alice
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe PostsController do
|
||||
describe StreamsController do
|
||||
describe '#multi' do
|
||||
before do
|
||||
sign_in :user, alice
|
||||
|
|
@ -1,35 +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 MultisController do
|
||||
describe '#index' do
|
||||
before do
|
||||
@old_spotlight_value = AppConfig[:community_spotlight]
|
||||
sign_in :user, alice
|
||||
end
|
||||
|
||||
after do
|
||||
AppConfig[:community_spotlight] = @old_spotlight_value
|
||||
end
|
||||
|
||||
it 'succeeds' do
|
||||
AppConfig[:community_spotlight] = [bob.person.diaspora_handle]
|
||||
get :index
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'succeeds without AppConfig[:community_spotlight]' do
|
||||
AppConfig[:community_spotlight] = nil
|
||||
get :index
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'succeeds on mobile' do
|
||||
get :index, :format => :mobile
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -137,71 +137,4 @@ describe PostsController do
|
|||
StatusMessage.exists?(message.id).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'streams' do
|
||||
before do
|
||||
sign_in alice
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
|
|
|||
72
spec/controllers/streams_controller_spec.rb
Normal file
72
spec/controllers/streams_controller_spec.rb
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# 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 StreamsController do
|
||||
before do
|
||||
sign_in alice
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
|
@ -1,195 +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 TagFollowingsController do
|
||||
|
||||
def valid_attributes
|
||||
{:name => "partytimeexcellent"}
|
||||
end
|
||||
|
||||
before do
|
||||
@tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
|
||||
sign_in :user, bob
|
||||
bob.followed_tags.create(:name => "testing")
|
||||
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::FollowedTag
|
||||
end
|
||||
|
||||
describe 'if empty' do
|
||||
it 'succeeds' do
|
||||
bob.followed_tags.delete_all
|
||||
get :index
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'assigns a stream' do
|
||||
bob.followed_tags.delete_all
|
||||
get :index
|
||||
assigns[:stream].should be_a Stream::FollowedTag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "create" do
|
||||
describe "successfully" do
|
||||
it "creates a new TagFollowing" do
|
||||
expect {
|
||||
post :create, valid_attributes
|
||||
response.should be_redirect
|
||||
}.to change(TagFollowing, :count).by(1)
|
||||
end
|
||||
|
||||
it "associates the tag following with the currently-signed-in user" do
|
||||
expect {
|
||||
post :create, valid_attributes
|
||||
response.should be_redirect
|
||||
}.to change(bob.tag_followings, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created tag_following as @tag_following" do
|
||||
post :create, valid_attributes
|
||||
response.should be_redirect
|
||||
assigns(:tag_following).should be_a(TagFollowing)
|
||||
assigns(:tag_following).should be_persisted
|
||||
end
|
||||
|
||||
it "creates the tag IFF it doesn't already exist" do
|
||||
ActsAsTaggableOn::Tag.find_by_name('tomcruisecontrol').should be_nil
|
||||
expect {
|
||||
post :create, :name => "tomcruisecontrol"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(1)
|
||||
end
|
||||
|
||||
it "flashes success to the tag page" do
|
||||
post :create, valid_attributes
|
||||
flash[:notice].should include(valid_attributes[:name])
|
||||
end
|
||||
|
||||
it "flashes error if you already have a tag" do
|
||||
TagFollowing.any_instance.stub(:save).and_return(false)
|
||||
post :create, valid_attributes
|
||||
flash[:error].should include(valid_attributes[:name])
|
||||
end
|
||||
|
||||
it 'squashes the tag' do
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should be_nil
|
||||
post :create, :name => "some stuff"
|
||||
assigns[:tag].name.should == "somestuff"
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should_not be_nil
|
||||
end
|
||||
|
||||
it 'downcases the tag name' do
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should be_nil
|
||||
post :create, :name => "SOMESTUFF"
|
||||
response.should be_redirect
|
||||
assigns[:tag].name.should == "somestuff"
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should_not be_nil
|
||||
end
|
||||
|
||||
it "normalizes the tag name" do
|
||||
ActsAsTaggableOn::Tag.find_by_name('foobar').should be_nil
|
||||
post :create, :name => "foo:bar"
|
||||
assigns[:tag].name.should == "foobar"
|
||||
ActsAsTaggableOn::Tag.find_by_name('foobar').should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'fails to' do
|
||||
it "create the tag if it already exists" do
|
||||
ActsAsTaggableOn::Tag.find_by_name('tomcruisecontrol').should be_nil
|
||||
expect {
|
||||
post :create, :name => "tomcruisecontrol"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(1)
|
||||
ActsAsTaggableOn::Tag.find_by_name('tomcruisecontrol').should_not be_nil
|
||||
|
||||
expect {
|
||||
post :create, :name => "tomcruisecontrol"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
expect {
|
||||
post :create, :name => "tom cruise control"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
expect {
|
||||
post :create, :name => "TomCruiseControl"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
expect {
|
||||
post :create, :name => "tom:cruise:control"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
end
|
||||
|
||||
it "create a tag following for a user other than the currently signed in user" do
|
||||
expect {
|
||||
expect {
|
||||
post :create, valid_attributes.merge(:user_id => alice.id)
|
||||
}.not_to change(alice.tag_followings, :count).by(1)
|
||||
}.to change(bob.tag_followings, :count).by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE destroy" do
|
||||
before do
|
||||
TagFollowing.create!(:tag => @tag, :user => bob )
|
||||
TagFollowing.create!(:tag => @tag, :user => alice )
|
||||
end
|
||||
|
||||
it "destroys the requested tag_following" do
|
||||
expect {
|
||||
delete :destroy, valid_attributes
|
||||
}.to change(TagFollowing, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects and flashes error if you already don't follow the tag" do
|
||||
delete :destroy, valid_attributes
|
||||
|
||||
response.should redirect_to(tag_path(:name => valid_attributes[:name]))
|
||||
flash[:notice].should include(valid_attributes[:name])
|
||||
end
|
||||
|
||||
it "redirects and flashes error if you already don't follow the tag" do
|
||||
TagFollowing.any_instance.stub(:destroy).and_return(false)
|
||||
delete :destroy, valid_attributes
|
||||
|
||||
response.should redirect_to(tag_path(:name => valid_attributes[:name]))
|
||||
flash[:error].should include(valid_attributes[:name])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create_multiple" do
|
||||
it "redirects" do
|
||||
post :create_multiple, :tags => "#foo,#bar"
|
||||
response.should be_redirect
|
||||
end
|
||||
|
||||
it "handles no tags parameter" do
|
||||
expect { post :create_multiple, :name => 'not tags' }.to_not raise_exception
|
||||
end
|
||||
|
||||
it "adds multiple tags" do
|
||||
expect { post :create_multiple, :tags => "#tags,#cats,#bats," }.to change{ bob.followed_tags.count }.by(3)
|
||||
end
|
||||
|
||||
it "adds non-followed tags" do
|
||||
TagFollowing.create!(:tag => @tag, :user => bob )
|
||||
expect { post :create_multiple, :tags => "#partytimeexcellent,#a,#b," }.to change{ bob.followed_tags.count }.by(2)
|
||||
end
|
||||
|
||||
it "normalizes the tag names" do
|
||||
bob.followed_tags.delete_all
|
||||
post :create_multiple, :tags => "#foo:bar,#bar#foo"
|
||||
bob.followed_tags(true).map(&:name).should =~ ["foobar", "barfoo"]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue