moved render_views out of controller specs to spec_helper.

cleaned up indentation and spacing in controller specs.
This commit is contained in:
Arzumy MD 2011-05-07 18:38:40 +08:00
parent 160e01f7bd
commit 3767cce149
29 changed files with 207 additions and 127 deletions

View file

@ -1,29 +1,34 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
describe AdminsController do describe AdminsController do
render_views
before do before do
@user = Factory :user @user = Factory :user
sign_in :user, @user sign_in :user, @user
end end
it 'is behind redirect_unless_admin' do describe '#user_search' do
get :user_search context 'admin not signed in' do
response.should redirect_to root_url it 'is behind redirect_unless_admin' do
get :user_search
response.should redirect_to root_url
end
end end
context 'admin signed in' do context 'admin signed in' do
before do before do
AppConfig[:admins] = [@user.username] AppConfig[:admins] = [@user.username]
end end
describe '#user_search' do
it 'succeeds' do it 'succeeds' do
get :user_search get :user_search
response.should be_success response.should be_success
end end
it 'assings users to an empty array if nothing is searched for' do it 'assigns users to an empty array if nothing is searched for' do
get :user_search get :user_search
assigns[:users].should == [] assigns[:users].should == []
end end
@ -52,13 +57,20 @@ describe AdminsController do
assigns[:users].should == [@user] assigns[:users].should == [@user]
end end
end end
end
describe '#admin_inviter' do
context 'admin signed in' do
before do
AppConfig[:admins] = [@user.username]
end
describe '#admin_inviter' do
it 'invites a new user' do it 'invites a new user' do
Invitation.should_receive(:create_invitee).with(:service => 'email', :identifier => 'bob@moms.com') Invitation.should_receive(:create_invitee).with(:service => 'email', :identifier => 'bob@moms.com')
get :admin_inviter, :identifier => 'bob@moms.com' get :admin_inviter, :identifier => 'bob@moms.com'
response.should be_redirect response.should be_redirect
end end
it 'passes an existing user to create_invitee' do it 'passes an existing user to create_invitee' do
Factory.create(:user, :email => 'bob@moms.com') Factory.create(:user, :email => 'bob@moms.com')
bob = User.where(:email => 'bob@moms.com').first bob = User.where(:email => 'bob@moms.com').first

View file

@ -1,7 +1,11 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
describe ApisController do describe ApisController do
before(:all) do before do
@status_message1 = Factory(:status_message, :text => '#bobby #flay #sux', :public => true, :updated_at => Time.now + 20) @status_message1 = Factory(:status_message, :text => '#bobby #flay #sux', :public => true, :updated_at => Time.now + 20)
@status_message2 = Factory(:status_message, :text => '#aobby', :public => true, :created_at => Time.now + 10) @status_message2 = Factory(:status_message, :text => '#aobby', :public => true, :created_at => Time.now + 10)

View file

@ -1,3 +1,7 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
describe ApplicationController do describe ApplicationController do
@ -5,19 +9,23 @@ describe ApplicationController do
def user_signed_in? def user_signed_in?
nil nil
end end
def current_user def current_user
nil nil
end end
def index def index
render :nothing => true render :nothing => true
end end
end end
describe '#set_git_headers' do describe '#set_git_headers' do
context 'with git info' do context 'with git info' do
before do before do
AppConfig[:git_update] = 'yesterday' AppConfig[:git_update] = 'yesterday'
AppConfig[:git_revision] = '02395' AppConfig[:git_revision] = '02395'
end end
it 'sets the git header if there is git info' do it 'sets the git header if there is git info' do
get :index get :index
response.headers['X-Git-Update'].should == 'yesterday' response.headers['X-Git-Update'].should == 'yesterday'

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe AspectMembershipsController do describe AspectMembershipsController do
render_views
before do before do
@user = alice @user = alice
@user2 = bob @user2 = bob

View file

@ -6,8 +6,6 @@ require 'spec_helper'
require File.join(Rails.root, "spec", "shared_behaviors", "log_override") require File.join(Rails.root, "spec", "shared_behaviors", "log_override")
describe AspectsController do describe AspectsController do
render_views
before do before do
@bob = bob @bob = bob
@alice = alice @alice = alice
@ -241,27 +239,31 @@ describe AspectsController do
get :manage get :manage
response.should be_success response.should be_success
end end
it "performs reasonably", :performance => true do it "performs reasonably", :performance => true do
require 'benchmark' require 'benchmark'
8.times do |n| 8.times do |n|
aspect = @alice.aspects.create(:name => "aspect#{n}") aspect = @alice.aspects.create(:name => "aspect#{n}")
8.times do |o| 8.times do |o|
person = Factory(:person) person = Factory(:person)
@alice.activate_contact(person, aspect) @alice.activate_contact(person, aspect)
end
end end
Benchmark.realtime{ end
get :manage Benchmark.realtime{
}.should < 4.5 get :manage
}.should < 4.5
end end
it "assigns aspect to manage" do it "assigns aspect to manage" do
get :manage get :manage
assigns(:aspect).should == :manage assigns(:aspect).should == :manage
end end
it "assigns remote_requests" do it "assigns remote_requests" do
get :manage get :manage
assigns(:remote_requests).should be_empty assigns(:remote_requests).should be_empty
end end
it "assigns contacts to only non-pending" do it "assigns contacts to only non-pending" do
contact = @alice.contact_for(bob.person) contact = @alice.contact_for(bob.person)
Contact.unscoped.where(:user_id => @alice.id).count.should == 1 Contact.unscoped.where(:user_id => @alice.id).count.should == 1
@ -273,6 +275,7 @@ describe AspectsController do
contacts.count.should == 1 contacts.count.should == 1
contacts.first.should == contact contacts.first.should == contact
end end
context "when the user has pending requests" do context "when the user has pending requests" do
before do before do
requestor = Factory.create(:user) requestor = Factory.create(:user)
@ -283,18 +286,22 @@ describe AspectsController do
requestor_aspect.reload requestor_aspect.reload
@alice.reload @alice.reload
end end
it "succeeds" do it "succeeds" do
get :manage get :manage
response.should be_success response.should be_success
end end
it "assigns aspect to manage" do it "assigns aspect to manage" do
get :manage get :manage
assigns(:aspect).should == :manage assigns(:aspect).should == :manage
end end
it "assigns remote_requests" do it "assigns remote_requests" do
get :manage get :manage
assigns(:remote_requests).count.should == 1 assigns(:remote_requests).count.should == 1
end end
it "generates a jasmine fixture" do it "generates a jasmine fixture" do
get :manage get :manage
save_fixture(html_for("body"), "aspects_manage") save_fixture(html_for("body"), "aspects_manage")
@ -306,6 +313,7 @@ describe AspectsController do
before do before do
@alices_aspect_1 = @alice.aspects.create(:name => "Bruisers") @alices_aspect_1 = @alice.aspects.create(:name => "Bruisers")
end end
it "doesn't overwrite random attributes" do it "doesn't overwrite random attributes" do
new_user = Factory.create :user new_user = Factory.create :user
params = {"name" => "Bruisers"} params = {"name" => "Bruisers"}
@ -336,6 +344,7 @@ describe AspectsController do
connect_users(@alice, @alices_aspect_2, @zed, @zed.aspects.first) connect_users(@alice, @alices_aspect_2, @zed, @zed.aspects.first)
connect_users(@alice, @alices_aspect_1, @katz, @katz.aspects.first) connect_users(@alice, @alices_aspect_1, @katz, @katz.aspects.first)
end end
it 'renders' do it 'renders' do
get :edit, :id => @alices_aspect_1.id get :edit, :id => @alices_aspect_1.id
response.should be_success response.should be_success
@ -371,4 +380,4 @@ describe AspectsController do
@alices_aspect_1.reload.contacts_visible.should be_false @alices_aspect_1.reload.contacts_visible.should be_false
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe CommentsController do describe CommentsController do
render_views
before do before do
@aspect1 = alice.aspects.first @aspect1 = alice.aspects.first
@aspect2 = bob.aspects.first @aspect2 = bob.aspects.first
@ -20,10 +18,12 @@ describe CommentsController do
{:text =>"facebook, is that you?", {:text =>"facebook, is that you?",
:post_id =>"#{@post.id}"} :post_id =>"#{@post.id}"}
} }
context "on my own post" do context "on my own post" do
before do before do
@post = alice.post :status_message, :text => 'GIANTS', :to => @aspect1.id @post = alice.post :status_message, :text => 'GIANTS', :to => @aspect1.id
end end
it 'responds to format js' do it 'responds to format js' do
post :create, comment_hash.merge(:format => 'js') post :create, comment_hash.merge(:format => 'js')
response.code.should == '201' response.code.should == '201'
@ -35,16 +35,19 @@ describe CommentsController do
before do before do
@post = bob.post :status_message, :text => 'GIANTS', :to => @aspect2.id @post = bob.post :status_message, :text => 'GIANTS', :to => @aspect2.id
end end
it 'comments' do it 'comments' do
post :create, comment_hash post :create, comment_hash
response.code.should == '201' response.code.should == '201'
end end
it "doesn't overwrite author_id" do it "doesn't overwrite author_id" do
new_user = Factory.create(:user) new_user = Factory.create(:user)
comment_hash[:author_id] = new_user.person.id.to_s comment_hash[:author_id] = new_user.person.id.to_s
post :create, comment_hash post :create, comment_hash
Comment.find_by_text(comment_hash[:text]).author_id.should == alice.person.id Comment.find_by_text(comment_hash[:text]).author_id.should == alice.person.id
end end
it "doesn't overwrite id" do it "doesn't overwrite id" do
old_comment = alice.comment("hello", :on => @post) old_comment = alice.comment("hello", :on => @post)
comment_hash[:id] = old_comment.id comment_hash[:id] = old_comment.id
@ -52,10 +55,12 @@ describe CommentsController do
old_comment.reload.text.should == 'hello' old_comment.reload.text.should == 'hello'
end end
end end
context 'on a post from a stranger' do context 'on a post from a stranger' do
before do before do
@post = eve.post :status_message, :text => 'GIANTS', :to => eve.aspects.first.id @post = eve.post :status_message, :text => 'GIANTS', :to => eve.aspects.first.id
end end
it 'posts no comment' do it 'posts no comment' do
alice.should_not_receive(:comment) alice.should_not_receive(:comment)
post :create, comment_hash post :create, comment_hash
@ -72,6 +77,7 @@ describe CommentsController do
@comment2 = bob.comment("hey", :on => @message) @comment2 = bob.comment("hey", :on => @message)
@comment3 = eve.comment("hey", :on => @message) @comment3 = eve.comment("hey", :on => @message)
end end
it 'lets the user delete his comment' do it 'lets the user delete his comment' do
alice.should_receive(:retract).with(@comment) alice.should_receive(:retract).with(@comment)
delete :destroy, :format => "js", :id => @comment.id delete :destroy, :format => "js", :id => @comment.id
@ -106,4 +112,4 @@ describe CommentsController do
end end
end end
end end
end end

View file

@ -2,12 +2,9 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
describe ContactsController do describe ContactsController do
render_views
before do before do
@user = alice @user = alice
@user2 = bob @user2 = bob
@ -37,12 +34,12 @@ describe ContactsController do
end end
describe '#create' do describe '#create' do
context 'with an incoming request' do context 'with an incoming request' do
before do before do
@user3 = Factory.create(:user) @user3 = Factory.create(:user)
@user3.send_contact_request_to(@user.person, @user3.aspects.create(:name => "Walruses")) @user3.send_contact_request_to(@user.person, @user3.aspects.create(:name => "Walruses"))
end end
it 'deletes the request' do it 'deletes the request' do
post :create, post :create,
:format => 'js', :format => 'js',
@ -50,6 +47,7 @@ describe ContactsController do
:aspect_id => @aspect1.id :aspect_id => @aspect1.id
Request.where(:sender_id => @user3.person.id, :recipient_id => @user.person.id).first.should be_nil Request.where(:sender_id => @user3.person.id, :recipient_id => @user.person.id).first.should be_nil
end end
it 'does not leave the contact pending' do it 'does not leave the contact pending' do
post :create, post :create,
:format => 'js', :format => 'js',
@ -58,6 +56,7 @@ describe ContactsController do
@user.contact_for(@user3.person).should_not be_pending @user.contact_for(@user3.person).should_not be_pending
end end
end end
context 'with a non-contact' do context 'with a non-contact' do
before do before do
@person = Factory(:person) @person = Factory(:person)
@ -125,4 +124,4 @@ describe ContactsController do
response.should redirect_to(@contact.person) response.should redirect_to(@contact.person)
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe ConversationVisibilitiesController do describe ConversationVisibilitiesController do
render_views
before do before do
@user1 = alice @user1 = alice
sign_in :user, @user1 sign_in :user, @user1
@ -32,4 +30,4 @@ describe ConversationVisibilitiesController do
}.should_not change(ConversationVisibility, :count) }.should_not change(ConversationVisibility, :count)
end end
end end
end end

View file

@ -1,8 +1,10 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
describe ConversationsController do describe ConversationsController do
render_views
before do before do
sign_in :user, alice sign_in :user, alice
end end
@ -11,12 +13,15 @@ describe ConversationsController do
before do before do
get :new get :new
end end
it 'succeeds' do it 'succeeds' do
response.should be_success response.should be_success
end end
it "assigns a json list of contacts" do it "assigns a json list of contacts" do
assigns(:contacts_json).should include(alice.contacts.first.person.name) assigns(:contacts_json).should include(alice.contacts.first.person.name)
end end
it "assigns a contact if passed a contact id" do it "assigns a contact if passed a contact id" do
get :new, :contact_id => alice.contacts.first.id get :new, :contact_id => alice.contacts.first.id
assigns(:contact).should == alice.contacts.first assigns(:contact).should == alice.contacts.first

View file

@ -6,8 +6,6 @@ require 'spec_helper'
require File.join(Rails.root, "spec", "shared_behaviors", "log_override") require File.join(Rails.root, "spec", "shared_behaviors", "log_override")
describe HomeController do describe HomeController do
render_views
before do before do
@user = alice @user = alice
sign_in @user sign_in @user
@ -36,22 +34,24 @@ describe HomeController do
get :show get :show
response.should redirect_to( :controller => 'aspects', :action => 'index', :a_ids => @index_params[:a_ids] ) response.should redirect_to( :controller => 'aspects', :action => 'index', :a_ids => @index_params[:a_ids] )
end end
end
describe "custom logging on success" do describe "custom logging on success" do
before do before do
@action = :show @action = :show
@action_params = {"lasers" => "green"} @action_params = {"lasers" => "green"}
end end
it_should_behave_like "it overrides the logs on success"
end
describe "custom logging on redirect" do it_should_behave_like "it overrides the logs on success"
before do end
sign_in :user, bob
@action = :show describe "custom logging on redirect" do
@action_params = {"lasers" => "green"} before do
sign_in :user, bob
@action = :show
@action_params = {"lasers" => "green"}
end
it_should_behave_like "it overrides the logs on redirect"
end end
it_should_behave_like "it overrides the logs on redirect"
end end
end end

View file

@ -7,8 +7,6 @@ require 'spec_helper'
describe InvitationsController do describe InvitationsController do
include Devise::TestHelpers include Devise::TestHelpers
render_views
before do before do
@user = alice @user = alice
@aspect = @user.aspects.first @aspect = @user.aspects.first
@ -77,8 +75,10 @@ describe InvitationsController do
:invitation_token => @invited_user.invitation_token}} :invitation_token => @invited_user.invitation_token}}
end end
context 'success' do context 'success' do
let(:invited) {User.find_by_username(@accept_params[:user][:username])} let(:invited) {User.find_by_username(@accept_params[:user][:username])}
it 'creates a user' do it 'creates a user' do
put :update, @accept_params put :update, @accept_params
invited.should_not be_nil invited.should_not be_nil
@ -95,15 +95,18 @@ describe InvitationsController do
end end
end end
context 'failure' do context 'failure' do
before do before do
@fail_params = @accept_params @fail_params = @accept_params
@fail_params[:user][:username] = @user.username @fail_params[:user][:username] = @user.username
end end
it 'stays on the invitation accept form' do it 'stays on the invitation accept form' do
put :update, @fail_params put :update, @fail_params
response.location.include?(accept_user_invitation_path).should be_true response.location.include?(accept_user_invitation_path).should be_true
end end
it 'keeps the invitation token' do it 'keeps the invitation token' do
put :update, @fail_params put :update, @fail_params
response.location.include?("invitation_token=#{@invited_user.invitation_token}").should be_true response.location.include?("invitation_token=#{@invited_user.invitation_token}").should be_true
@ -145,5 +148,4 @@ describe InvitationsController do
put :resend, :id => invitation2.id put :resend, :id => invitation2.id
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe LikesController do describe LikesController do
render_views
before do before do
@user1 = alice @user1 = alice
@user2 = bob @user2 = bob
@ -26,10 +24,12 @@ describe LikesController do
{:positive => 0, {:positive => 0,
:post_id => "#{@post.id}"} :post_id => "#{@post.id}"}
} }
context "on my own post" do context "on my own post" do
before do before do
@post = @user1.post :status_message, :text => "AWESOME", :to => @aspect1.id @post = @user1.post :status_message, :text => "AWESOME", :to => @aspect1.id
end end
it 'responds to format js' do it 'responds to format js' do
post :create, like_hash.merge(:format => 'js') post :create, like_hash.merge(:format => 'js')
response.code.should == '201' response.code.should == '201'
@ -40,24 +40,29 @@ describe LikesController do
before do before do
@post = @user2.post :status_message, :text => "AWESOME", :to => @aspect2.id @post = @user2.post :status_message, :text => "AWESOME", :to => @aspect2.id
end end
it 'likes' do it 'likes' do
post :create, like_hash post :create, like_hash
response.code.should == '201' response.code.should == '201'
end end
it 'dislikes' do it 'dislikes' do
post :create, dislike_hash post :create, dislike_hash
response.code.should == '201' response.code.should == '201'
end end
it "doesn't post multiple times" do it "doesn't post multiple times" do
@user1.like(1, :on => @post) @user1.like(1, :on => @post)
post :create, dislike_hash post :create, dislike_hash
response.code.should == '422' response.code.should == '422'
end end
end end
context "on a post from a stranger" do context "on a post from a stranger" do
before do before do
@post = eve.post :status_message, :text => "AWESOME", :to => eve.aspects.first.id @post = eve.post :status_message, :text => "AWESOME", :to => eve.aspects.first.id
end end
it "doesn't post" do it "doesn't post" do
@user1.should_not_receive(:like) @user1.should_not_receive(:like)
post :create, like_hash post :create, like_hash
@ -65,4 +70,4 @@ describe LikesController do
end end
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe MessagesController do describe MessagesController do
render_views
before do before do
@user1 = alice @user1 = alice
@user2 = bob @user2 = bob
@ -22,11 +20,13 @@ describe MessagesController do
@create_hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id], @create_hash = { :author => @user1.person, :participant_ids => [@user1.contacts.first.person.id, @user1.person.id],
:subject => "cool stuff", :text => "stuff"} :subject => "cool stuff", :text => "stuff"}
end end
context "on my own post" do context "on my own post" do
before do before do
@cnv = Conversation.create(@create_hash) @cnv = Conversation.create(@create_hash)
@message_hash = {:conversation_id => @cnv.id, :message => {:text => "here is something else"}} @message_hash = {:conversation_id => @cnv.id, :message => {:text => "here is something else"}}
end end
it 'redirects to conversation' do it 'redirects to conversation' do
lambda{ lambda{
post :create, @message_hash post :create, @message_hash
@ -42,17 +42,20 @@ describe MessagesController do
@cnv = Conversation.create(@create_hash) @cnv = Conversation.create(@create_hash)
@message_hash = {:conversation_id => @cnv.id, :message => {:text => "here is something else"}} @message_hash = {:conversation_id => @cnv.id, :message => {:text => "here is something else"}}
end end
it 'comments' do it 'comments' do
post :create, @message_hash post :create, @message_hash
response.code.should == '302' response.code.should == '302'
response.should redirect_to(conversations_path(:conversation_id => @cnv)) response.should redirect_to(conversations_path(:conversation_id => @cnv))
end end
it "doesn't overwrite author_id" do it "doesn't overwrite author_id" do
new_user = Factory.create(:user) new_user = Factory.create(:user)
@message_hash[:author_id] = new_user.person.id.to_s @message_hash[:author_id] = new_user.person.id.to_s
post :create, @message_hash post :create, @message_hash
Message.find_by_text(@message_hash[:message][:text]).author_id.should == @user1.person.id Message.find_by_text(@message_hash[:message][:text]).author_id.should == @user1.person.id
end end
it "doesn't overwrite id" do it "doesn't overwrite id" do
old_message = Message.create(:text => "hello", :author_id => @user1.person.id, :conversation_id => @cnv.id) old_message = Message.create(:text => "hello", :author_id => @user1.person.id, :conversation_id => @cnv.id)
@message_hash[:id] = old_message.id @message_hash[:id] = old_message.id
@ -60,6 +63,7 @@ describe MessagesController do
old_message.reload.text.should == 'hello' old_message.reload.text.should == 'hello'
end end
end end
context 'on a post from a stranger' do context 'on a post from a stranger' do
before do before do
@create_hash[:author] = eve.person @create_hash[:author] = eve.person
@ -67,10 +71,11 @@ describe MessagesController do
@cnv = Conversation.create(@create_hash) @cnv = Conversation.create(@create_hash)
@message_hash = {:conversation_id => @cnv.id, :message => {:text => "here is something else"}} @message_hash = {:conversation_id => @cnv.id, :message => {:text => "here is something else"}}
end end
it 'posts no comment' do it 'posts no comment' do
post :create, @message_hash post :create, @message_hash
response.code.should == '422' response.code.should == '422'
end end
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe NotificationsController do describe NotificationsController do
before do before do
@user = alice @user = alice
@aspect = @user.aspects.first @aspect = @user.aspects.first
@ -57,4 +55,4 @@ describe NotificationsController do
assigns[:notifications].count.should == 1 assigns[:notifications].count.should == 1
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe PeopleController do describe PeopleController do
render_views
before do before do
@user = alice @user = alice
@aspect = @user.aspects.first @aspect = @user.aspects.first
@ -25,14 +23,17 @@ describe PeopleController do
get :index, :q => "Korth", :format => 'json' get :index, :q => "Korth", :format => 'json'
response.body.should == [@korth].to_json response.body.should == [@korth].to_json
end end
it 'does not set @hashes in a json request' do it 'does not set @hashes in a json request' do
get :index, :q => "Korth", :format => 'json' get :index, :q => "Korth", :format => 'json'
assigns[:hashes].should be_nil assigns[:hashes].should be_nil
end end
it 'sets @hashes in an html request' do it 'sets @hashes in an html request' do
get :index, :q => "Korth" get :index, :q => "Korth"
assigns[:hashes].should_not be_nil assigns[:hashes].should_not be_nil
end end
it "assigns people" do it "assigns people" do
eugene2 = Factory.create(:person, eugene2 = Factory.create(:person,
:profile => Factory.build(:profile, :first_name => "Eugene", :profile => Factory.build(:profile, :first_name => "Eugene",
@ -144,6 +145,7 @@ describe PeopleController do
sign_out :user sign_out :user
@person = bob.person @person = bob.person
end end
it "succeeds" do it "succeeds" do
get :show, :id => @person.id get :show, :id => @person.id
response.status.should == 200 response.status.should == 200
@ -183,6 +185,7 @@ describe PeopleController do
response.status.should == 404 response.status.should == 404
end end
end end
context "when the person is a contact of the current user" do context "when the person is a contact of the current user" do
before do before do
@person = bob.person @person = bob.person
@ -249,6 +252,7 @@ describe PeopleController do
end end
end end
end end
describe '#contacts' do describe '#contacts' do
it 'assigns the contacts of a person' do it 'assigns the contacts of a person' do
contact = alice.contact_for(bob.person) contact = alice.contact_for(bob.person)
@ -264,4 +268,4 @@ describe PeopleController do
get :retrieve_remote, :diaspora_handle => @user.diaspora_handle get :retrieve_remote, :diaspora_handle => @user.diaspora_handle
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe PhotosController do describe PhotosController do
render_views
before do before do
@alices_photo = alice.post(:photo, :user_file => uploaded_photo, :to => alice.aspects.first.id) @alices_photo = alice.post(:photo, :user_file => uploaded_photo, :to => alice.aspects.first.id)
@bobs_photo = bob.post(:photo, :user_file => uploaded_photo, :to => bob.aspects.first.id, :public => true) @bobs_photo = bob.post(:photo, :user_file => uploaded_photo, :to => bob.aspects.first.id, :public => true)
@ -55,51 +53,62 @@ describe PhotosController do
before do before do
get :show, :id => @alices_photo.id get :show, :id => @alices_photo.id
end end
it "succeeds" do it "succeeds" do
response.should be_success response.should be_success
end end
it "assigns the photo" do it "assigns the photo" do
assigns[:photo].should == @alices_photo assigns[:photo].should == @alices_photo
assigns[:ownership].should be_true assigns[:ownership].should be_true
end end
end end
context "private photo user can see" do context "private photo user can see" do
before do before do
get :show, :id => @bobs_photo.id get :show, :id => @bobs_photo.id
end end
it "succeeds" do it "succeeds" do
response.should be_success response.should be_success
end end
it "assigns the photo" do it "assigns the photo" do
assigns[:photo].should == @bobs_photo assigns[:photo].should == @bobs_photo
assigns[:ownership].should be_false assigns[:ownership].should be_false
end end
end end
context "private photo user cannot see" do context "private photo user cannot see" do
before do before do
user3 = Factory(:user_with_aspect) user3 = Factory(:user_with_aspect)
@photo = user3.post(:photo, :user_file => uploaded_photo, :to => user3.aspects.first.id) @photo = user3.post(:photo, :user_file => uploaded_photo, :to => user3.aspects.first.id)
end end
it "redirects to the referrer" do it "redirects to the referrer" do
request.env["HTTP_REFERER"] = "http://google.com" request.env["HTTP_REFERER"] = "http://google.com"
get :show, :id => @photo.to_param get :show, :id => @photo.to_param
response.should redirect_to("http://google.com") response.should redirect_to("http://google.com")
end end
it "redirects to the aspects page if there's no referrer" do it "redirects to the aspects page if there's no referrer" do
request.env.delete("HTTP_REFERER") request.env.delete("HTTP_REFERER")
get :show, :id => @photo.to_param get :show, :id => @photo.to_param
response.should redirect_to(aspects_path) response.should redirect_to(aspects_path)
end end
end end
context "public photo" do context "public photo" do
before do before do
user3 = Factory(:user_with_aspect) user3 = Factory(:user_with_aspect)
@photo = user3.post(:photo, :user_file => uploaded_photo, :to => user3.aspects.first.id, :public => true) @photo = user3.post(:photo, :user_file => uploaded_photo, :to => user3.aspects.first.id, :public => true)
get :show, :id => @photo.to_param get :show, :id => @photo.to_param
end end
it "succeeds" do it "succeeds" do
response.should be_success response.should be_success
end end
it "assigns the photo" do it "assigns the photo" do
assigns[:photo].should == @photo assigns[:photo].should == @photo
assigns[:ownership].should be_false assigns[:ownership].should be_false
@ -164,7 +173,6 @@ describe PhotosController do
end end
describe "#make_profile_photo" do describe "#make_profile_photo" do
it 'should return a 201 on a js success' do it 'should return a 201 on a js success' do
get :make_profile_photo, :photo_id => @alices_photo.id, :format => 'js' get :make_profile_photo, :photo_id => @alices_photo.id, :format => 'js'
response.code.should == "201" response.code.should == "201"
@ -174,7 +182,5 @@ describe PhotosController do
get :make_profile_photo, :photo_id => @bobs_photo.id get :make_profile_photo, :photo_id => @bobs_photo.id
response.code.should == "422" response.code.should == "422"
end end
end end
end
end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe PostVisibilitiesController do describe PostVisibilitiesController do
render_views
before do before do
@user1 = alice @user1 = alice
@bob = bob @bob = bob
@ -16,7 +14,6 @@ describe PostVisibilitiesController do
a2.contacts << bob.contact_for(alice.person) a2.contacts << bob.contact_for(alice.person)
a2.save a2.save
@status = bob.post(:status_message, :text => "hello", :public => true, :to => a2) @status = bob.post(:status_message, :text => "hello", :public => true, :to => a2)
@vis = @status.post_visibilities.first @vis = @status.post_visibilities.first
@vis.reload.hidden.should == false @vis.reload.hidden.should == false
@ -47,15 +44,17 @@ describe PostVisibilitiesController do
user2 = eve user2 = eve
sign_in :user, user2 sign_in :user, user2
end end
it 'does not let a user destroy a visibility that is not theirs' do it 'does not let a user destroy a visibility that is not theirs' do
lambda { lambda {
put :update, :format => :js, :id => 42, :post_id => @status.id put :update, :format => :js, :id => 42, :post_id => @status.id
}.should_not change(@vis.reload, :hidden).to(true) }.should_not change(@vis.reload, :hidden).to(true)
end end
it 'does not succceed' do
it 'does not succeed' do
put :update, :format => :js, :id => 42, :post_id => @status.id put :update, :format => :js, :id => 42, :post_id => @status.id
response.should_not be_success response.should_not be_success
end end
end end
end end
end end

View file

@ -5,11 +5,10 @@
require 'spec_helper' require 'spec_helper'
describe PostsController do describe PostsController do
render_views
before do before do
@user = alice @user = alice
end end
describe '#show' do describe '#show' do
it 'shows a public post' do it 'shows a public post' do
status = @user.post(:status_message, :text => "hello", :public => true, :to => 'all') status = @user.post(:status_message, :text => "hello", :public => true, :to => 'all')

View file

@ -2,11 +2,9 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
require 'spec_helper' require 'spec_helper'
describe ProfilesController do describe ProfilesController do
render_views
before do before do
@user = eve @user = eve
sign_in :user, @user sign_in :user, @user
@ -63,6 +61,7 @@ describe ProfilesController do
@user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" @user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
@user.person.profile.save @user.person.profile.save
end end
it "doesn't overwrite the profile photo when an empty string is passed in" do it "doesn't overwrite the profile photo when an empty string is passed in" do
image_url = @user.person.profile.image_url image_url = @user.person.profile.image_url
put :update, @params put :update, @params
@ -77,6 +76,7 @@ describe ProfilesController do
@profile_params = {:profile =>{ :person_id => new_person.id, @profile_params = {:profile =>{ :person_id => new_person.id,
:diaspora_handle => 'abc@a.com'}} :diaspora_handle => 'abc@a.com'}}
end end
it 'person_id' do it 'person_id' do
person = @user.person person = @user.person
profile = person.profile profile = person.profile
@ -90,4 +90,4 @@ describe ProfilesController do
end end
end end
end end
end end

View file

@ -5,7 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe PublicsController do describe PublicsController do
render_views
let(:fixture_path) { File.join(Rails.root, 'spec', 'fixtures')} let(:fixture_path) { File.join(Rails.root, 'spec', 'fixtures')}
before do before do
@user = alice @user = alice
@ -20,6 +19,7 @@ describe PublicsController do
save_fixture(response.body, "host-meta", fixture_path) save_fixture(response.body, "host-meta", fixture_path)
end end
end end
describe '#receive' do describe '#receive' do
let(:xml) { "<walruses></walruses>" } let(:xml) { "<walruses></walruses>" }
@ -111,4 +111,4 @@ describe PublicsController do
response.should be_success response.should be_success
end end
end end
end end

View file

@ -7,8 +7,6 @@ require 'spec_helper'
describe RegistrationsController do describe RegistrationsController do
include Devise::TestHelpers include Devise::TestHelpers
render_views
before do before do
request.env["devise.mapping"] = Devise.mappings[:user] request.env["devise.mapping"] = Devise.mappings[:user]
@valid_params = {:user => { @valid_params = {:user => {
@ -24,14 +22,17 @@ describe RegistrationsController do
before do before do
AppConfig[:registrations_closed] = true AppConfig[:registrations_closed] = true
end end
after do after do
AppConfig[:registrations_closed] = false AppConfig[:registrations_closed] = false
end end
it 'redirects #new to the login page' do it 'redirects #new to the login page' do
get :new get :new
flash[:error].should == I18n.t('registrations.closed') flash[:error].should == I18n.t('registrations.closed')
response.should redirect_to new_user_session_path response.should redirect_to new_user_session_path
end end
it 'redirects #create to the login page' do it 'redirects #create to the login page' do
post :create, @valid_params post :create, @valid_params
flash[:error].should == I18n.t('registrations.closed') flash[:error].should == I18n.t('registrations.closed')
@ -45,47 +46,57 @@ describe RegistrationsController do
user = Factory.build(:user) user = Factory.build(:user)
User.stub!(:build).and_return(user) User.stub!(:build).and_return(user)
end end
it "creates a user" do it "creates a user" do
lambda { lambda {
get :create, @valid_params get :create, @valid_params
}.should change(User, :count).by(1) }.should change(User, :count).by(1)
end end
it "assigns @user" do it "assigns @user" do
get :create, @valid_params get :create, @valid_params
assigns(:user).should be_true assigns(:user).should be_true
end end
it "sets the flash" do it "sets the flash" do
get :create, @valid_params get :create, @valid_params
flash[:notice].should_not be_empty flash[:notice].should_not be_empty
end end
it "redirects to the root path" do it "redirects to the root path" do
get :create, @valid_params get :create, @valid_params
response.should redirect_to root_path response.should redirect_to root_path
end end
end end
context "with invalid parameters" do context "with invalid parameters" do
before do before do
@invalid_params = @valid_params @invalid_params = @valid_params
@invalid_params[:user][:password_confirmation] = "baddword" @invalid_params[:user][:password_confirmation] = "baddword"
end end
it "does not create a user" do it "does not create a user" do
lambda { get :create, @invalid_params }.should_not change(User, :count) lambda { get :create, @invalid_params }.should_not change(User, :count)
end end
it "does not create a person" do it "does not create a person" do
lambda { get :create, @invalid_params }.should_not change(Person, :count) lambda { get :create, @invalid_params }.should_not change(Person, :count)
end end
it "assigns @user" do it "assigns @user" do
get :create, @invalid_params get :create, @invalid_params
assigns(:user).should_not be_nil assigns(:user).should_not be_nil
end end
it "sets the flash error" do it "sets the flash error" do
get :create, @invalid_params get :create, @invalid_params
flash[:error].should_not be_blank flash[:error].should_not be_blank
end end
it "re-renders the form" do it "re-renders the form" do
get :create, @invalid_params get :create, @invalid_params
response.should render_template("registrations/new") response.should render_template("registrations/new")
end end
end end
end end
end end

View file

@ -5,7 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe RequestsController do describe RequestsController do
render_views
before do before do
@user = alice @user = alice
@other_user = eve @other_user = eve
@ -20,6 +19,7 @@ describe RequestsController do
@other_user.send_contact_request_to(@user.person, @other_user.aspects.first) @other_user.send_contact_request_to(@user.person, @other_user.aspects.first)
@friend_request = Request.where(:recipient_id => @user.person.id).first @friend_request = Request.where(:recipient_id => @user.person.id).first
end end
describe 'when accepting a contact request' do describe 'when accepting a contact request' do
it "succeeds" do it "succeeds" do
xhr :delete, :destroy, xhr :delete, :destroy,
@ -28,6 +28,7 @@ describe RequestsController do
:id => @friend_request.id.to_s :id => @friend_request.id.to_s
response.should redirect_to(requests_path) response.should redirect_to(requests_path)
end end
it "marks the notification as read" do it "marks the notification as read" do
notification = Notification.where(:recipient_id => @user.id, :target_id=> @friend_request.id).first notification = Notification.where(:recipient_id => @user.id, :target_id=> @friend_request.id).first
notification.unread = true notification.unread = true
@ -39,12 +40,14 @@ describe RequestsController do
notification.reload.unread.should == false notification.reload.unread.should == false
end end
end end
describe 'when ignoring a contact request' do describe 'when ignoring a contact request' do
it "succeeds" do it "succeeds" do
xhr :delete, :destroy, xhr :delete, :destroy,
:id => @friend_request.id.to_s :id => @friend_request.id.to_s
response.should be_success response.should be_success
end end
it "removes the request object" do it "removes the request object" do
lambda { lambda {
xhr :delete, :destroy, xhr :delete, :destroy,
@ -71,6 +74,7 @@ describe RequestsController do
:into => @user.aspects[0].id :into => @user.aspects[0].id
}} }}
end end
it 'creates a contact' do it 'creates a contact' do
@user.contact_for(@other_user).should be_nil @user.contact_for(@other_user).should be_nil
lambda { lambda {
@ -80,12 +84,14 @@ describe RequestsController do
new_contact.should_not be_nil new_contact.should_not be_nil
new_contact.should be_pending new_contact.should be_pending
end end
it 'does not persist a Request' do it 'does not persist a Request' do
lambda { lambda {
post :create, @params post :create, @params
}.should_not change(Request, :count) }.should_not change(Request, :count)
end end
end end
it 'autoaccepts and when sending a request to someone who sent me a request' do it 'autoaccepts and when sending a request to someone who sent me a request' do
@other_user.send_contact_request_to(@user.person, @other_user.aspects[0]) @other_user.send_contact_request_to(@user.person, @other_user.aspects[0])
@ -138,4 +144,4 @@ describe RequestsController do
response.should redirect_to :back response.should redirect_to :back
end end
end end
end end

View file

@ -5,7 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe ServicesController do describe ServicesController do
render_views
let(:mock_access_token) { Object.new } let(:mock_access_token) { Object.new }
let(:omniauth_auth) { let(:omniauth_auth) {
@ -60,7 +59,6 @@ describe ServicesController do
response.should redirect_to services_url response.should redirect_to services_url
end end
it 'creates a twitter service' do it 'creates a twitter service' do
Service.delete_all Service.delete_all
@user.getting_started = false @user.getting_started = false
@ -74,6 +72,7 @@ describe ServicesController do
before do before do
@service1 = Factory.create(:service, :user => @user) @service1 = Factory.create(:service, :user => @user)
end end
it 'destroys a service selected by id' do it 'destroys a service selected by id' do
lambda{ lambda{
delete :destroy, :id => @service1.id delete :destroy, :id => @service1.id
@ -97,6 +96,7 @@ describe ServicesController do
get :finder, :provider => @service1.provider get :finder, :provider => @service1.provider
response.should be_success response.should be_success
end end
it 'has no translations missing' do it 'has no translations missing' do
get :finder, :provider => @service1.provider get :finder, :provider => @service1.provider
response.body.match(/translation/).should be_nil response.body.match(/translation/).should be_nil
@ -104,7 +104,6 @@ describe ServicesController do
end end
describe '#invite' do describe '#invite' do
before do before do
@uid = "abc" @uid = "abc"
@invite_params = {:provider => 'facebook', :uid => @uid, :aspect_id => @user.aspects.first.id} @invite_params = {:provider => 'facebook', :uid => @uid, :aspect_id => @user.aspects.first.id}
@ -140,5 +139,4 @@ describe ServicesController do
}.should_not change(Invitation, :count) }.should_not change(Invitation, :count)
end end
end end
end end

View file

@ -12,8 +12,6 @@ end
describe SessionsController do describe SessionsController do
include Devise::TestHelpers include Devise::TestHelpers
render_views
let(:mock_access_token) { Object.new } let(:mock_access_token) { Object.new }
@ -34,4 +32,4 @@ describe SessionsController do
"password"=>"evankorth"}} "password"=>"evankorth"}}
end end
end end
end end

View file

@ -11,7 +11,6 @@ SocketsController.class_eval <<-EOT
EOT EOT
describe SocketsController do describe SocketsController do
render_views
before do before do
@user = alice @user = alice
@controller = SocketsController.new @controller = SocketsController.new
@ -33,6 +32,7 @@ describe SocketsController do
json.include?("html\":null").should be_true json.include?("html\":null").should be_true
end end
end end
describe '#outgoing' do describe '#outgoing' do
it 'calls queue_to_user' do it 'calls queue_to_user' do
Diaspora::WebSocket.should_receive(:is_connected?).with(@user.id).and_return(true) Diaspora::WebSocket.should_receive(:is_connected?).with(@user.id).and_return(true)
@ -45,10 +45,11 @@ describe SocketsController do
Diaspora::WebSocket.should_not_receive(:queue_to_user) Diaspora::WebSocket.should_not_receive(:queue_to_user)
@controller.outgoing(@user.id, @message) @controller.outgoing(@user.id, @message)
end end
it 'takes a user or an id' do it 'takes a user or an id' do
Diaspora::WebSocket.should_receive(:is_connected?).with(@user.id).and_return(false) Diaspora::WebSocket.should_receive(:is_connected?).with(@user.id).and_return(false)
Diaspora::WebSocket.should_not_receive(:queue_to_user) Diaspora::WebSocket.should_not_receive(:queue_to_user)
@controller.outgoing(@user, @message) @controller.outgoing(@user, @message)
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe StatusMessagesController do describe StatusMessagesController do
render_views
before do before do
@aspect1 = alice.aspects.first @aspect1 = alice.aspects.first
@aspect2 = bob.aspects.first @aspect2 = bob.aspects.first
@ -31,14 +29,14 @@ describe StatusMessagesController do
response.should be_success response.should be_success
end end
it 'generates a jasmine fixture' do it 'generates a jasmine fixture' do
contact = alice.contact_for(bob.person) contact = alice.contact_for(bob.person)
aspect = alice.aspects.create(:name => 'people') aspect = alice.aspects.create(:name => 'people')
contact.aspects << aspect contact.aspects << aspect
contact.save contact.save
get :new, :person_id => bob.person.id, :layout => true get :new, :person_id => bob.person.id, :layout => true
save_fixture(html_for("body"), "status_message_new") save_fixture(html_for("body"), "status_message_new")
end end
end end
describe '#show' do describe '#show' do
@ -65,7 +63,6 @@ describe StatusMessagesController do
}.should change(note, :unread).from(true).to(false) }.should change(note, :unread).from(true).to(false)
end end
it 'redirects to back if there is no status message' do it 'redirects to back if there is no status message' do
get :show, :id => 2345 get :show, :id => 2345
response.status.should == 302 response.status.should == 302
@ -80,17 +77,20 @@ describe StatusMessagesController do
}, },
:aspect_ids => [@aspect1.id.to_s] } :aspect_ids => [@aspect1.id.to_s] }
} }
context 'js requests' do context 'js requests' do
it 'responds' do it 'responds' do
post :create, status_message_hash.merge(:format => 'js') post :create, status_message_hash.merge(:format => 'js')
response.status.should == 201 response.status.should == 201
end end
it 'responds with json' do it 'responds with json' do
post :create, status_message_hash.merge(:format => 'js') post :create, status_message_hash.merge(:format => 'js')
json = JSON.parse(response.body) json = JSON.parse(response.body)
json['post_id'].should_not be_nil json['post_id'].should_not be_nil
json['html'].should_not be_nil json['html'].should_not be_nil
end end
it 'escapes XSS' do it 'escapes XSS' do
xss = "<script> alert('hi browser') </script>" xss = "<script> alert('hi browser') </script>"
post :create, status_message_hash.merge(:format => 'js', :text => xss) post :create, status_message_hash.merge(:format => 'js', :text => xss)
@ -128,12 +128,12 @@ describe StatusMessagesController do
} }
post :create, status_message_hash post :create, status_message_hash
end end
it 'sends the errors in the body on js' do it 'sends the errors in the body on js' do
post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''}) post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''})
response.body.should include('Status message requires a message or at least one photo') response.body.should include('Status message requires a message or at least one photo')
end end
context 'with photos' do context 'with photos' do
before do before do
fixture_filename = 'button.png' fixture_filename = 'button.png'

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe TagsController do describe TagsController do
render_views
describe '#index (search)' do describe '#index (search)' do
before do before do
sign_in :user, alice sign_in :user, alice
@ -26,10 +24,12 @@ describe TagsController do
get :index, :q => "c", :format => 'json' get :index, :q => "c", :format => 'json'
response.body.should_not include("#cats") response.body.should_not include("#cats")
end end
it 'redirects the aimless to excellent parties' do it 'redirects the aimless to excellent parties' do
get :index get :index
response.should redirect_to tag_path('partytimeexcellent') response.should redirect_to tag_path('partytimeexcellent')
end end
it 'does not allow json requestors to party' do it 'does not allow json requestors to party' do
get :index, :format => :json get :index, :format => :json
response.status.should == 422 response.status.should == 422
@ -37,24 +37,25 @@ describe TagsController do
end end
describe '#show' do describe '#show' do
context 'signed in' do context 'signed in' do
before do before do
sign_in :user, alice sign_in :user, alice
end end
it 'displays your own post' do it 'displays your own post' do
my_post = alice.post(:status_message, :text => "#what", :to => 'all') my_post = alice.post(:status_message, :text => "#what", :to => 'all')
get :show, :name => 'what' get :show, :name => 'what'
assigns(:posts).models.should == [my_post] assigns(:posts).models.should == [my_post]
response.status.should == 200 response.status.should == 200
end end
it "displays a friend's post" do it "displays a friend's post" do
other_post = bob.post(:status_message, :text => "#hello", :to => 'all') other_post = bob.post(:status_message, :text => "#hello", :to => 'all')
get :show, :name => 'hello' get :show, :name => 'hello'
assigns(:posts).models.should == [other_post] assigns(:posts).models.should == [other_post]
response.status.should == 200 response.status.should == 200
end end
it 'displays a public post' do it 'displays a public post' do
other_post = eve.post(:status_message, :text => "#hello", :public => true, :to => 'all') other_post = eve.post(:status_message, :text => "#hello", :public => true, :to => 'all')
get :show, :name => 'hello' get :show, :name => 'hello'
@ -71,26 +72,32 @@ describe TagsController do
alice.profile.save! alice.profile.save!
get :show, :name => "whatevs" get :show, :name => "whatevs"
end end
it "succeeds" do it "succeeds" do
response.should be_success response.should be_success
end end
it "assigns the right set of people" do it "assigns the right set of people" do
assigns(:people).should == [alice.person] assigns(:people).should == [alice.person]
end end
end end
context "when there are posts to display" do context "when there are posts to display" do
before do before do
@post = alice.post(:status_message, :text => "#what", :public => true, :to => 'all') @post = alice.post(:status_message, :text => "#what", :public => true, :to => 'all')
alice.post(:status_message, :text => "#hello", :public => true, :to => 'all') alice.post(:status_message, :text => "#hello", :public => true, :to => 'all')
end end
it "succeeds" do it "succeeds" do
get :show, :name => 'what' get :show, :name => 'what'
response.should be_success response.should be_success
end end
it "assigns the right set of posts" do it "assigns the right set of posts" do
get :show, :name => 'what' get :show, :name => 'what'
assigns[:posts].models.should == [@post] assigns[:posts].models.should == [@post]
end end
it 'succeeds with comments' do it 'succeeds with comments' do
alice.comment('what WHAT!', :on => @post) alice.comment('what WHAT!', :on => @post)
get :show, :name => 'what' get :show, :name => 'what'
@ -99,4 +106,4 @@ describe TagsController do
end end
end end
end end
end end

View file

@ -5,8 +5,6 @@
require 'spec_helper' require 'spec_helper'
describe UsersController do describe UsersController do
render_views
before do before do
@user = alice @user = alice
@aspect = @user.aspects.first @aspect = @user.aspects.first
@ -48,6 +46,7 @@ describe UsersController do
:user => { :diaspora_handle => "notreal@stuff.com" } } :user => { :diaspora_handle => "notreal@stuff.com" } }
end end
it "doesn't overwrite random attributes" do it "doesn't overwrite random attributes" do
lambda { lambda {
put :update, @params put :update, @params
@ -123,7 +122,6 @@ describe UsersController do
proc{ proc{
put :update, par put :update, par
}.should change(@user.user_preferences, :count).by(-1) }.should change(@user.user_preferences, :count).by(-1)
end end
end end
end end
@ -140,4 +138,4 @@ describe UsersController do
assigns[:email_prefs]['mentioned'].should be_false assigns[:email_prefs]['mentioned'].should be_false
end end
end end
end end

View file

@ -40,6 +40,10 @@ RSpec.configure do |config|
$process_queue = false $process_queue = false
end end
config.before(:each, :type => :controller) do
self.class.render_views
end
end end
disable_typhoeus disable_typhoeus