Commit c42916df authored by khall's avatar khall
Browse files

Two tests failing after rspec 2.99 => 3.0.0

parent 027bb9fc
......@@ -192,7 +192,7 @@ group :test do
# RSpec (unit tests, some integration tests)
gem 'fixture_builder', '0.3.6'
gem 'fuubar', '1.3.3'
gem 'fuubar', '2.0.0'
gem 'rspec-instafail', '0.2.5', :require => false
gem 'test_after_commit', '0.2.5'
......@@ -212,7 +212,7 @@ end
group :development, :test do
# RSpec (unit tests, some integration tests)
gem 'rspec-rails', '2.99'
gem 'rspec-rails', '3.0.0'
# Cucumber (integration tests)
gem 'cucumber-rails', '1.4.1', :require => false
......
......@@ -181,8 +181,8 @@ GEM
thor (>= 0.13.6)
formatador (0.2.5)
fssm (0.2.10)
fuubar (1.3.3)
rspec (>= 2.14.0, < 3.1.0)
fuubar (2.0.0)
rspec (~> 3.0)
ruby-progressbar (~> 1.4)
gherkin (2.12.2)
multi_json (~> 1.3)
......@@ -392,27 +392,28 @@ GEM
roxml (3.1.6)
activesupport (>= 2.3.0)
nokogiri (>= 1.3.3)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-collection_matchers (1.0.0)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-instafail (0.2.5)
rspec
rspec-mocks (2.99.2)
rspec-rails (2.99.0)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-rails (3.0.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-collection_matchers
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.4)
ruby-oembed (0.8.10)
ruby-progressbar (1.5.1)
rubyzip (1.1.6)
......@@ -527,7 +528,7 @@ DEPENDENCIES
fog (= 1.23.0)
foreigner (= 1.6.1)
foreman (= 0.62)
fuubar (= 1.3.3)
fuubar (= 2.0.0)
gon (= 5.1.2)
guard-cucumber (= 1.4.1)
guard-rspec (= 4.3.1)
......@@ -571,7 +572,7 @@ DEPENDENCIES
remotipart (= 1.2.1)
roxml (= 3.1.6)
rspec-instafail (= 0.2.5)
rspec-rails (= 2.99)
rspec-rails (= 3.0.0)
ruby-oembed (= 0.8.10)
sass-rails (= 4.0.3)
selenium-webdriver (= 2.42.0)
......
require 'spec_helper'
describe Admin::UsersController do
describe Admin::UsersController, :type => :controller do
before do
@user = FactoryGirl.create :user
Role.add_admin(@user.person)
......@@ -12,8 +12,8 @@ describe Admin::UsersController do
describe '#close_account' do
it 'queues a job to disable the given account' do
other_user = FactoryGirl.create :user
other_user.should_receive(:close_account!)
User.stub(:find).and_return(other_user)
expect(other_user).to receive(:close_account!)
allow(User).to receive(:find).and_return(other_user)
post :close_account, id: other_user.id
end
......
......@@ -4,7 +4,7 @@
require 'spec_helper'
describe AdminsController do
describe AdminsController, :type => :controller do
before do
@user = FactoryGirl.create :user
sign_in :user, @user
......@@ -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 stream_path
expect(response).to redirect_to stream_path
end
end
......@@ -25,23 +25,23 @@ describe AdminsController do
it 'succeeds and renders user_search' do
get :user_search
response.should be_success
response.should render_template(:user_search)
expect(response).to be_success
expect(response).to render_template(:user_search)
end
it 'assigns users to an empty array if nothing is searched for' do
get :user_search
assigns[:users].should == []
expect(assigns[:users]).to eq([])
end
it 'searches on username' do
get :user_search, admins_controller_user_search: { username: @user.username }
assigns[:users].should == [@user]
expect(assigns[:users]).to eq([@user])
end
it 'searches on email' do
get :user_search, admins_controller_user_search: { email: @user.email }
assigns[:users].should == [@user]
expect(assigns[:users]).to eq([@user])
end
it 'searches on age < 13 (COPPA)' do
......@@ -55,8 +55,8 @@ describe AdminsController do
get :user_search, admins_controller_user_search: { under13: '1' }
assigns[:users].should include(u_13)
assigns[:users].should_not include(o_13)
expect(assigns[:users]).to include(u_13)
expect(assigns[:users]).not_to include(o_13)
end
end
end
......@@ -65,7 +65,7 @@ describe AdminsController do
context 'admin not signed in' do
it 'is behind redirect_unless_admin' do
get :admin_inviter
response.should redirect_to stream_path
expect(response).to redirect_to stream_path
end
end
......@@ -77,14 +77,14 @@ describe AdminsController do
it 'does not die if you do it twice' do
get :admin_inviter, :identifier => 'bob@moms.com'
get :admin_inviter, :identifier => 'bob@moms.com'
response.should be_redirect
expect(response).to be_redirect
end
it 'invites a new user' do
EmailInviter.should_receive(:new).and_return(double.as_null_object)
expect(EmailInviter).to receive(:new).and_return(double.as_null_object)
get :admin_inviter, :identifier => 'bob@moms.com'
response.should redirect_to user_search_path
flash.notice.should include("invitation sent")
expect(response).to redirect_to user_search_path
expect(flash.notice).to include("invitation sent")
end
end
end
......@@ -96,8 +96,8 @@ describe AdminsController do
it 'succeeds and renders stats' do
get :stats
response.should be_success
response.should render_template(:stats)
expect(response).to be_success
expect(response).to render_template(:stats)
end
end
end
......@@ -4,7 +4,7 @@
require 'spec_helper'
describe ApplicationController do
describe ApplicationController, :type => :controller do
controller do
def index
head :ok
......@@ -18,20 +18,20 @@ describe ApplicationController do
describe '#set_diaspora_headers' do
it 'sets the version header' do
get :index
response.headers['X-Diaspora-Version'].should include AppConfig.version.number.get
expect(response.headers['X-Diaspora-Version']).to include AppConfig.version.number.get
end
context 'with git info' do
before do
AppConfig.stub(:git_available?).and_return(true)
AppConfig.stub(:git_update).and_return('yesterday')
AppConfig.stub(:git_revision).and_return('02395')
allow(AppConfig).to receive(:git_available?).and_return(true)
allow(AppConfig).to receive(:git_update).and_return('yesterday')
allow(AppConfig).to receive(:git_revision).and_return('02395')
end
it 'sets the git header' do
get :index
response.headers['X-Git-Update'].should == 'yesterday'
response.headers['X-Git-Revision'].should == '02395'
expect(response.headers['X-Git-Update']).to eq('yesterday')
expect(response.headers['X-Git-Revision']).to eq('02395')
end
end
end
......@@ -41,25 +41,25 @@ describe ApplicationController do
request.format = :html
session[:mobile_view] = true
get :index
request.format.mobile?.should be true
expect(request.format.mobile?).to be true
end
it 'uses :html for :tablets' do
request.format = :tablet
session[:tablet_view] = true
get :index
request.format.html?.should be true
expect(request.format.html?).to be true
end
it "doesn't mess up other formats, like json" do
get :index, :format => 'json'
request.format.json?.should be true
expect(request.format.json?).to be true
end
it "doesn't mess up other formats, like xml, even with :mobile session" do
session[:mobile_view] = true
get :index, :format => 'xml'
request.format.xml?.should be true
expect(request.format.xml?).to be true
end
end
......@@ -70,11 +70,11 @@ describe ApplicationController do
end
it 'queries current_users tag if there are tag_followings' do
@controller.send(:tags).should == [@tag]
expect(@controller.send(:tags)).to eq([@tag])
end
it 'does not query twice' do
User.any_instance.should_receive(:followed_tags).once.and_return([@tag])
expect_any_instance_of(User).to receive(:followed_tags).once.and_return([@tag])
@controller.send(:tags)
@controller.send(:tags)
end
......@@ -87,7 +87,7 @@ describe ApplicationController do
end
it "redirects to getting started if the user has getting started set to true" do
@controller.send(:after_sign_in_path_for, alice).should == getting_started_path
expect(@controller.send(:after_sign_in_path_for, alice)).to eq(getting_started_path)
end
end
end
......
......@@ -4,7 +4,7 @@
require 'spec_helper'
describe AspectMembershipsController do
describe AspectMembershipsController, :type => :controller do
before do
@aspect0 = alice.aspects.first
@aspect1 = alice.aspects.create(:name => "another aspect")
......@@ -14,7 +14,7 @@ describe AspectMembershipsController do
alice.getting_started = false
alice.save
sign_in :user, alice
@controller.stub(:current_user).and_return(alice)
allow(@controller).to receive(:current_user).and_return(alice)
request.env["HTTP_REFERER"] = 'http://' + request.host
end
......@@ -28,16 +28,16 @@ describe AspectMembershipsController do
:format => :json,
:person_id => bob.person.id,
:aspect_id => @aspect1.id
response.should be_success
expect(response).to be_success
end
it 'creates an aspect membership' do
lambda {
expect {
post :create,
:format => :json,
:person_id => bob.person.id,
:aspect_id => @aspect1.id
}.should change{
}.to change{
alice.contact_for(bob.person).aspect_memberships.count
}.by(1)
end
......@@ -45,30 +45,30 @@ describe AspectMembershipsController do
it 'creates a contact' do
#argggg why?
alice.contacts.reload
lambda {
expect {
post :create,
:format => :json,
:person_id => @person.id,
:aspect_id => @aspect0.id
}.should change{
}.to change{
alice.contacts.size
}.by(1)
end
it 'failure flashes error' do
alice.should_receive(:share_with).and_return(nil)
expect(alice).to receive(:share_with).and_return(nil)
post :create,
:format => :json,
:person_id => @person.id,
:aspect_id => @aspect0.id
flash[:error].should_not be_blank
expect(flash[:error]).not_to be_blank
end
it 'does not 500 on a duplicate key error' do
params = {:format => :json, :person_id => @person.id, :aspect_id => @aspect0.id}
post :create, params
post :create, params
response.status.should == 400
expect(response.status).to eq(400)
end
context 'json' do
......@@ -79,7 +79,7 @@ describe AspectMembershipsController do
:aspect_id => @aspect0.id
contact = @controller.current_user.contact_for(@person)
response.body.should == contact.aspect_memberships.first.to_json
expect(response.body).to eq(contact.aspect_memberships.first.to_json)
end
end
end
......@@ -88,23 +88,23 @@ describe AspectMembershipsController do
it 'removes contacts from an aspect' do
membership = alice.add_contact_to_aspect(@contact, @aspect1)
delete :destroy, :format => :json, :id => membership.id
response.should be_success
expect(response).to be_success
@aspect1.reload
@aspect1.contacts.to_a.should_not include @contact
expect(@aspect1.contacts.to_a).not_to include @contact
end
it 'does not 500 on an html request' do
membership = alice.add_contact_to_aspect(@contact, @aspect1)
delete :destroy, :id => membership.id
response.should redirect_to :back
expect(response).to redirect_to :back
@aspect1.reload
@aspect1.contacts.to_a.should_not include @contact
expect(@aspect1.contacts.to_a).not_to include @contact
end
it 'aspect membership does not exist' do
delete :destroy, :format => :json, :id => 123
response.should_not be_success
response.body.should include "Could not find the selected person in that aspect"
expect(response).not_to be_success
expect(response.body).to include "Could not find the selected person in that aspect"
end
end
end
......@@ -4,7 +4,7 @@
require 'spec_helper'
describe AspectsController do
describe AspectsController, :type => :controller do
before do
alice.getting_started = false
alice.save
......@@ -12,7 +12,7 @@ describe AspectsController do
@alices_aspect_1 = alice.aspects.where(:name => "generic").first
@alices_aspect_2 = alice.aspects.create(:name => "another aspect")
@controller.stub(:current_user).and_return(alice)
allow(@controller).to receive(:current_user).and_return(alice)
request.env["HTTP_REFERER"] = 'http://' + request.host
end
......@@ -20,74 +20,74 @@ describe AspectsController do
describe "#new" do
it "renders a remote form if remote is true" do
get :new, "remote" => "true"
response.should be_success
response.body.should =~ /#{Regexp.escape('data-remote="true"')}/
expect(response).to be_success
expect(response.body).to match(/#{Regexp.escape('data-remote="true"')}/)
end
it "renders a non-remote form if remote is false" do
get :new, "remote" => "false"
response.should be_success
response.body.should_not =~ /#{Regexp.escape('data-remote="true"')}/
expect(response).to be_success
expect(response.body).not_to match(/#{Regexp.escape('data-remote="true"')}/)
end
it "renders a non-remote form if remote is missing" do
get :new
response.should be_success
response.body.should_not =~ /#{Regexp.escape('data-remote="true"')}/
expect(response).to be_success
expect(response.body).not_to match(/#{Regexp.escape('data-remote="true"')}/)
end
end
describe "#show" do
it "succeeds" do
get :show, 'id' => @alices_aspect_1.id.to_s
response.should be_redirect
expect(response).to be_redirect
end
it 'redirects on an invalid id' do
get :show, 'id' => 4341029835
response.should be_redirect
expect(response).to be_redirect
end
end
describe "#create" do
context "with valid params" do
it "creates an aspect" do
alice.aspects.count.should == 2
expect(alice.aspects.count).to eq(2)
post :create, "aspect" => {"name" => "new aspect"}
alice.reload.aspects.count.should == 3
expect(alice.reload.aspects.count).to eq(3)
end
it "redirects to the aspect's contact page" do
post :create, "aspect" => {"name" => "new aspect"}
response.should redirect_to(contacts_path(:a_id => Aspect.find_by_name("new aspect").id))
expect(response).to redirect_to(contacts_path(:a_id => Aspect.find_by_name("new aspect").id))
end
context "with person_id param" do
it "creates a contact if one does not already exist" do
lambda {
expect {
post :create, :format => 'js', :aspect => {:name => "new", :person_id => eve.person.id}
}.should change {
}.to change {
alice.contacts.count
}.by(1)
end
it "adds a new contact to the new aspect" do
post :create, :format => 'js', :aspect => {:name => "new", :person_id => eve.person.id}
alice.aspects.find_by_name("new").contacts.count.should == 1
expect(alice.aspects.find_by_name("new").contacts.count).to eq(1)
end
it "adds an existing contact to the new aspect" do
post :create, :format => 'js', :aspect => {:name => "new", :person_id => bob.person.id}
alice.aspects.find_by_name("new").contacts.count.should == 1
expect(alice.aspects.find_by_name("new").contacts.count).to eq(1)
end
end
end
context "with invalid params" do
it "does not create an aspect" do
alice.aspects.count.should == 2
expect(alice.aspects.count).to eq(2)
post :create, "aspect" => {"name" => ""}
alice.reload.aspects.count.should == 2
expect(alice.reload.aspects.count).to eq(2)
end
it "goes back to the page you came from" do
post :create, "aspect" => {"name" => ""}
response.should redirect_to(:back)
expect(response).to redirect_to(:back)
end
end
end
......@@ -102,13 +102,13 @@ describe AspectsController do
params = {"name" => "Bruisers"}
params[:user_id] = new_user.id
put('update', :id => @alices_aspect_1.id, "aspect" => params)
Aspect.find(@alices_aspect_1.id).user_id.should == alice.id
expect(Aspect.find(@alices_aspect_1.id).user_id).to eq(alice.id)
end
it "should return the name and id of the updated item" do
params = {"name" => "Bruisers"}
put('update', :id => @alices_aspect_1.id, "aspect" => params)
response.body.should == { :id => @alices_aspect_1.id, :name => "Bruisers" }.to_json
expect(response.body).to eq({ :id => @alices_aspect_1.id, :name => "Bruisers" }.to_json)
end
end
......@@ -134,25 +134,25 @@ describe AspectsController do
it 'renders' do
get :edit, :id => @alices_aspect_1.id
response.should be_success
expect(response).to be_success
end
it 'assigns the contacts in alphabetical order with people in aspects first' do
get :edit, :id => @alices_aspect_2.id
assigns[:contacts].map(&:id).should == [alice.contact_for(eve.person), alice.contact_for(@zed.person), alice.contact_for(bob.person), alice.contact_for(@katz.person)].map(&:id)
expect(assigns[:contacts].map(&:id)).to eq([alice.contact_for(eve.person), alice.contact_for(@zed.person), alice.contact_for(bob.person), alice.contact_for(@katz.person)].map(&:id))
end
it 'assigns all the contacts if noone is there' do
alices_aspect_3 = alice.aspects.create(:name => "aspect 3")
get :edit, :id => alices_aspect_3.id
assigns[:contacts].map(&:id).should == [alice.contact_for(bob.person), alice.contact_for(eve.person), alice.contact_for(@katz.person), alice.contact_for(@zed.person)].map(&:id)
expect(assigns[:contacts].map(&:id)).to eq([alice.contact_for(bob.person), alice.contact_for(eve.person), alice.contact_for(@katz.person), alice.contact_for(@zed.person)].map(&:id))
end
it 'eager loads the aspect memberships for all the contacts' do
get :edit, :id => @alices_aspect_2.id
assigns[:contacts].each do |c|
c.aspect_memberships.loaded?.should be true
expect(c.aspect_memberships.loaded?).to be true
end
end
end
......@@ -163,7 +163,7 @@ describe AspectsController do
@alices_aspect_1.save
xhr :get, :toggle_contact_visibility, :format => 'js', :aspect_id => @alices_aspect_1.id
@alices_aspect_1.reload.contacts_visible.should be true
expect(@alices_aspect_1.reload.contacts_visible).to be true
end
it 'sets contacts hidden' do
......@@ -171,7 +171,7 @@ describe AspectsController do
@alices_aspect_1.save
xhr :get, :toggle_contact_visibility, :format => 'js', :aspect_id => @alices_aspect_1.id
@alices_aspect_1.reload.contacts_visible.should be false
expect(@alices_aspect_1.reload.contacts_visible).to be false
end
end
end
require 'spec_helper'
describe BlocksController do
describe BlocksController, :type => :controller do
before do
sign_in alice
end
......@@ -15,17 +15,17 @@ describe BlocksController do
it "redirects back" do
post :create, :block => { :person_id => 2 }
response.should be_redirect
expect(response).to be_redirect
end