tests for last jam location setting and some cleanup of user manager and user location spec
This commit is contained in:
parent
43d1c9cbbd
commit
00e177311d
|
|
@ -10,13 +10,13 @@ X If no profile location is provided, and the user creates/joins a music session
|
|||
=end
|
||||
|
||||
before do
|
||||
@geocode1 = FactoryGirl.create(:geocoder)
|
||||
@geocode2 = FactoryGirl.create(:geocoder)
|
||||
@user = User.new(first_name: "Example", last_name: "User", email: "user@example.com",
|
||||
password: "foobar", password_confirmation: "foobar",
|
||||
city: "Apex", state: "NC", country: "US",
|
||||
terms_of_service: true, musician: true)
|
||||
@user.save!
|
||||
# @geocode1 = FactoryGirl.create(:geocoder)
|
||||
# @geocode2 = FactoryGirl.create(:geocoder)
|
||||
# @user = User.new(first_name: "Example", last_name: "User", email: "user@example.com",
|
||||
# password: "foobar", password_confirmation: "foobar",
|
||||
# city: "Apex", state: "NC", country: "US",
|
||||
# terms_of_service: true, musician: true)
|
||||
# @user.save!
|
||||
end
|
||||
|
||||
describe "with profile location data" do
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class UserManager < BaseManager
|
|||
signup_confirm_url = options[:signup_confirm_url]
|
||||
affiliate_referral_id = options[:affiliate_referral_id]
|
||||
|
||||
@user = User.new
|
||||
user = User.new
|
||||
|
||||
# check if we have disabled open signup for this site. open == invited users can still get in
|
||||
if !SampleApp::Application.config.signup_enabled && invited_user.nil?
|
||||
|
|
@ -40,7 +40,7 @@ class UserManager < BaseManager
|
|||
# the ip address; if location is present, empty or not empty, we'll set the city, etc. from
|
||||
# what is present in location. we should NOT normally default city, etc. for the user, they
|
||||
# own it, they may want it to be unspecified, that is their right.
|
||||
if location
|
||||
unless location.nil?
|
||||
loc[:city] = location[:city]
|
||||
loc[:state] = location[:state]
|
||||
loc[:country] = location[:country]
|
||||
|
|
@ -50,11 +50,11 @@ class UserManager < BaseManager
|
|||
# ALSO: make sure we dont do the recaptcha stuff if used facebook.
|
||||
|
||||
# check recaptcha; if any errors seen, contribute it to the model
|
||||
#unless verify_recaptcha(:model => @user, :message => "recaptcha")
|
||||
# return @user # @user.errors.any? is true now
|
||||
#unless verify_recaptcha(:model => user, :message => "recaptcha")
|
||||
# return user # user.errors.any? is true now
|
||||
#else
|
||||
# sends email to email account for confirmation
|
||||
@user = User.signup(first_name: first_name,
|
||||
user = User.signup(first_name: first_name,
|
||||
last_name: last_name,
|
||||
email: email,
|
||||
password: password,
|
||||
|
|
@ -70,19 +70,19 @@ class UserManager < BaseManager
|
|||
signup_confirm_url: signup_confirm_url,
|
||||
affiliate_referral_id: affiliate_referral_id)
|
||||
|
||||
return @user
|
||||
return user
|
||||
#end
|
||||
end
|
||||
|
||||
def signup_confirm(signup_token, remote_ip=nil)
|
||||
begin
|
||||
@user = User.signup_confirm(signup_token)
|
||||
@user.location = MaxMindManager.lookup(remote_ip) if remote_ip
|
||||
user = User.signup_confirm(signup_token)
|
||||
user.location = MaxMindManager.lookup(remote_ip) if remote_ip
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
@user = nil
|
||||
user = nil
|
||||
end
|
||||
|
||||
return @user
|
||||
return user
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,9 +7,177 @@ describe UserManager do
|
|||
@user_manager = UserManager.new(:conn => @conn)
|
||||
UserMailer.deliveries.clear
|
||||
@location = { :country => "US", :state => "Arkansas", :city => "Little Rock" }
|
||||
@loca = { :country => "US", :state => "Arkansas", :city => "Texarkana" }
|
||||
@locb = { :country => "US", :state => "Texas", :city => "Longview" }
|
||||
@locc = { }
|
||||
@instruments = [ { :instrument_id=>"electric guitar", :proficiency_level => '1', :priority=>0 }]
|
||||
end
|
||||
|
||||
describe 'better signup' do
|
||||
it 'signup sets last_jam_blah of musician' do
|
||||
|
||||
# puts "user manager spec loca = #{@loca.to_s}"
|
||||
|
||||
user = @user_manager.signup(remote_ip: "1.2.3.4",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman15@jamkazam.com",
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
location: @loca,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
user.errors.any?.should be_false
|
||||
user.city.should == @loca[:city]
|
||||
user.state.should == @loca[:state]
|
||||
user.country.should == @loca[:country]
|
||||
user.last_jam_addr.should == 0x01020304
|
||||
user.last_jam_locidispid.should == 17192000002
|
||||
user.last_jam_updated_reason.should == 'r'
|
||||
# d = Time.now - user.last_jam_updated_at # guessing this is seconds
|
||||
# puts "d = #{d}"
|
||||
(Time.now - user.last_jam_updated_at).should be_between(0, 10)
|
||||
end
|
||||
|
||||
it 'signup does not set last_jam_blah of fan' do
|
||||
|
||||
# puts "user manager spec loca = #{@loca.to_s}"
|
||||
|
||||
user = @user_manager.signup(remote_ip: "1.2.3.4",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman16@jamkazam.com",
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: false,
|
||||
location: @locb,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
puts "user.errors #{user.errors.first}" if user.errors.any?
|
||||
user.errors.any?.should be_false
|
||||
user.city.should == @locb[:city]
|
||||
user.state.should == @locb[:state]
|
||||
user.country.should == @locb[:country]
|
||||
user.last_jam_addr.should be_nil
|
||||
user.last_jam_locidispid.should be_nil
|
||||
user.last_jam_updated_reason.should be_nil
|
||||
user.last_jam_updated_at.should be_nil
|
||||
end
|
||||
|
||||
it 'signup does not set fan location if location blank' do
|
||||
|
||||
# puts "user manager spec loca = #{@loca.to_s}"
|
||||
|
||||
user = @user_manager.signup(remote_ip: "1.2.3.4",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman17@jamkazam.com",
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: false,
|
||||
location: @locc,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
puts "user.errors #{user.errors.first}" if user.errors.any?
|
||||
user.errors.any?.should be_false
|
||||
user.city.should be_nil
|
||||
user.state.should be_nil
|
||||
user.country.should be_nil
|
||||
user.last_jam_addr.should be_nil
|
||||
user.last_jam_locidispid.should be_nil
|
||||
user.last_jam_updated_reason.should be_nil
|
||||
user.last_jam_updated_at.should be_nil
|
||||
end
|
||||
|
||||
it 'signup does not set musician location if location blank' do
|
||||
|
||||
# puts "user manager spec loca = #{@loca.to_s}"
|
||||
|
||||
user = @user_manager.signup(remote_ip: "1.2.3.4",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman18@jamkazam.com",
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
location: @locc,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
puts "user.errors #{user.errors.first}" if user.errors.any?
|
||||
user.errors.any?.should be_false
|
||||
user.city.should be_nil
|
||||
user.state.should be_nil
|
||||
user.country.should be_nil
|
||||
user.last_jam_addr.should == 0x01020304
|
||||
user.last_jam_locidispid.should == 17192000002
|
||||
user.last_jam_updated_reason.should == 'r'
|
||||
(Time.now - user.last_jam_updated_at).should be_between(0, 10)
|
||||
end
|
||||
|
||||
it 'signup sets fan location from remote_ip if location nil' do
|
||||
|
||||
# puts "user manager spec loca = #{@loca.to_s}"
|
||||
|
||||
user = @user_manager.signup(remote_ip: "1.2.3.4",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman19@jamkazam.com",
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: false,
|
||||
location: nil,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
puts "user.errors #{user.errors.first}" if user.errors.any?
|
||||
user.errors.any?.should be_false
|
||||
user.city.should == 'Austin'
|
||||
user.state.should == 'TX'
|
||||
user.country.should == 'US'
|
||||
user.last_jam_addr.should be_nil
|
||||
user.last_jam_locidispid.should be_nil
|
||||
user.last_jam_updated_reason.should be_nil
|
||||
user.last_jam_updated_at.should be_nil
|
||||
end
|
||||
|
||||
it 'signup sets musician location from remote_ip if location nil' do
|
||||
|
||||
# puts "user manager spec loca = #{@loca.to_s}"
|
||||
|
||||
user = @user_manager.signup(remote_ip: "1.2.3.4",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman20@jamkazam.com",
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
location: nil,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
puts "user.errors #{user.errors.first}" if user.errors.any?
|
||||
user.errors.any?.should be_false
|
||||
user.city.should == 'Austin'
|
||||
user.state.should == 'TX'
|
||||
user.country.should == 'US'
|
||||
user.last_jam_addr.should == 0x01020304
|
||||
user.last_jam_locidispid.should == 17192000002
|
||||
user.last_jam_updated_reason.should == 'r'
|
||||
(Time.now - user.last_jam_updated_at).should be_between(0, 10)
|
||||
end
|
||||
end
|
||||
|
||||
describe "signup" do
|
||||
let!(:user) { FactoryGirl.create(:user) }
|
||||
let!(:partner) {
|
||||
|
|
@ -22,7 +190,7 @@ describe UserManager do
|
|||
MaxMindIsp.delete_all # prove that city/state/country will remain nil if no maxmind data
|
||||
MaxMindGeo.delete_all
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman1@jamkazam.com",
|
||||
|
|
@ -34,26 +202,26 @@ describe UserManager do
|
|||
signup_confirm_url: "http://localhost:3000/confirm",
|
||||
affiliate_referral_id: AffiliatePartner.coded_id(partner.partner_code))
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.first_name.should == "bob"
|
||||
@user.last_name.should == "smith"
|
||||
@user.email.should == "userman1@jamkazam.com"
|
||||
@user.email_confirmed.should be_false
|
||||
@user.city.should == 'Boston'
|
||||
@user.state.should == 'MA'
|
||||
@user.country.should == 'US'
|
||||
@user.instruments.length.should == 1
|
||||
@user.subscribe_email.should be_true
|
||||
@user.signup_token.should_not be_nil
|
||||
user.errors.any?.should be_false
|
||||
user.first_name.should == "bob"
|
||||
user.last_name.should == "smith"
|
||||
user.email.should == "userman1@jamkazam.com"
|
||||
user.email_confirmed.should be_false
|
||||
user.city.should == 'Boston'
|
||||
user.state.should == 'MA'
|
||||
user.country.should == 'US'
|
||||
user.instruments.length.should == 1
|
||||
user.subscribe_email.should be_true
|
||||
user.signup_token.should_not be_nil
|
||||
|
||||
@user.reload
|
||||
expect(@user.affiliate_referral).to eq(partner)
|
||||
user.reload
|
||||
expect(user.affiliate_referral).to eq(partner)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
||||
it "signup successfully with instruments" do
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman2@jamkazam.com",
|
||||
|
|
@ -64,15 +232,15 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.instruments.length.should == 1
|
||||
musician_instrument = @user.musician_instruments[0]
|
||||
user.errors.any?.should be_false
|
||||
user.instruments.length.should == 1
|
||||
musician_instrument = user.musician_instruments[0]
|
||||
musician_instrument.instrument.should == Instrument.find("electric guitar")
|
||||
musician_instrument.proficiency_level.should == 1
|
||||
end
|
||||
|
||||
it "doesnt fail if ip address is nil" do
|
||||
@user = @user_manager.signup(first_name: "bob",
|
||||
user = @user_manager.signup(first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman3@jamkazam.com",
|
||||
password: "foobar",
|
||||
|
|
@ -82,17 +250,17 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm" )
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.city.should be_nil
|
||||
@user.state.should be_nil
|
||||
@user.country.should be_nil
|
||||
user.errors.any?.should be_false
|
||||
user.city.should be_nil
|
||||
user.state.should be_nil
|
||||
user.country.should be_nil
|
||||
end
|
||||
|
||||
it "sets the location properly from maxmind" do
|
||||
MaxMindManager.active_record_transaction do |manager|
|
||||
manager.create_phony_database()
|
||||
end
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman4@jamkazam.com",
|
||||
|
|
@ -103,17 +271,17 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm" )
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.city.should == 'Boston'
|
||||
@user.state.should == 'MA'
|
||||
@user.country.should == 'US'
|
||||
user.errors.any?.should be_false
|
||||
user.city.should == 'Boston'
|
||||
user.state.should == 'MA'
|
||||
user.country.should == 'US'
|
||||
end
|
||||
|
||||
it "accepts location if specified" do
|
||||
MaxMindManager.active_record_transaction do |manager|
|
||||
manager.create_phony_database()
|
||||
end
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman5@jamkazam.com",
|
||||
|
|
@ -125,17 +293,17 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm" )
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.city.should == 'Little Rock'
|
||||
@user.state.should == 'Arkansas'
|
||||
@user.country.should == 'US'
|
||||
user.errors.any?.should be_false
|
||||
user.city.should == 'Little Rock'
|
||||
user.state.should == 'Arkansas'
|
||||
user.country.should == 'US'
|
||||
end
|
||||
|
||||
it "accepts a nil location, if specified" do
|
||||
MaxMindManager.active_record_transaction do |manager|
|
||||
manager.create_phony_database()
|
||||
end
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman6@jamkazam.com",
|
||||
|
|
@ -147,10 +315,10 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm" )
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.city.should be_nil
|
||||
@user.state.should be_nil
|
||||
@user.country.should be_nil
|
||||
user.errors.any?.should be_false
|
||||
user.city.should be_nil
|
||||
user.state.should be_nil
|
||||
user.country.should be_nil
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -158,7 +326,7 @@ describe UserManager do
|
|||
MaxMindManager.active_record_transaction do |manager|
|
||||
manager.create_phony_database()
|
||||
end
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman7@jamkazam.com",
|
||||
|
|
@ -170,13 +338,13 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm" )
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.birth_date.should == Date.new(2001, 1, 1)
|
||||
user.errors.any?.should be_false
|
||||
user.birth_date.should == Date.new(2001, 1, 1)
|
||||
end
|
||||
|
||||
|
||||
it "duplicate signup failure" do
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman8@jamkazam.com",
|
||||
|
|
@ -188,10 +356,10 @@ describe UserManager do
|
|||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
@user.errors.any?.should be_false
|
||||
user.errors.any?.should be_false
|
||||
|
||||
# exactly the same parameters; should dup on email, and send no email
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman8@jamkazam.com",
|
||||
|
|
@ -202,12 +370,12 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
UserMailer.deliveries.length.should == 1
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:email][0].should == "has already been taken"
|
||||
user.errors.any?.should be_true
|
||||
user.errors[:email][0].should == "has already been taken"
|
||||
end
|
||||
|
||||
it "fail on no first_name/last_name" do
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "",
|
||||
last_name: "",
|
||||
email: "userman10@jamkazam.com",
|
||||
|
|
@ -218,12 +386,12 @@ describe UserManager do
|
|||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
UserMailer.deliveries.length.should == 0
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:first_name][0].should == "can't be blank"
|
||||
user.errors.any?.should be_true
|
||||
user.errors[:first_name][0].should == "can't be blank"
|
||||
end
|
||||
|
||||
it "fail on no email" do
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "murp",
|
||||
last_name: "blurp",
|
||||
email: "",
|
||||
|
|
@ -235,15 +403,15 @@ describe UserManager do
|
|||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:email][0].should == "can't be blank"
|
||||
user.errors.any?.should be_true
|
||||
user.errors[:email][0].should == "can't be blank"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "signup_confirm" do
|
||||
it "fail on no username" do
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman11@jamkazam.com",
|
||||
|
|
@ -253,8 +421,8 @@ describe UserManager do
|
|||
instruments: @instruments,
|
||||
musician: true,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
@user = @user_manager.signup_confirm(@user.signup_token)
|
||||
@user.email_confirmed.should be_true
|
||||
user = @user_manager.signup_confirm(user.signup_token)
|
||||
user.email_confirmed.should be_true
|
||||
end
|
||||
|
||||
it "fail to confirm bogus signup_confirmnup token" do
|
||||
|
|
@ -272,29 +440,29 @@ describe UserManager do
|
|||
|
||||
it "signup successfully with due to service (not from any particular user) invitation" do
|
||||
|
||||
@invitation = FactoryGirl.create(:invited_user)
|
||||
invitation = FactoryGirl.create(:invited_user)
|
||||
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
@invitation.accepted.should be_false
|
||||
invitation.accepted.should be_false
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: @invitation.email,
|
||||
email: invitation.email,
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
invited_user: @invitation,
|
||||
invited_user: invitation,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.email_confirmed.should be_true
|
||||
@user.signup_token.should be_nil
|
||||
@invitation.errors.any?.should be_false
|
||||
@invitation.accepted.should be_true
|
||||
user.errors.any?.should be_false
|
||||
user.email_confirmed.should be_true
|
||||
user.signup_token.should be_nil
|
||||
invitation.errors.any?.should be_false
|
||||
invitation.accepted.should be_true
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
|
@ -302,28 +470,28 @@ describe UserManager do
|
|||
it "signup successfully with due to user invitation with no autofriend" do
|
||||
|
||||
@some_user = FactoryGirl.create(:user)
|
||||
@invitation = FactoryGirl.create(:invited_user, :sender => @some_user)
|
||||
@invitation.accepted.should be_false
|
||||
invitation = FactoryGirl.create(:invited_user, :sender => @some_user)
|
||||
invitation.accepted.should be_false
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: @invitation.email,
|
||||
email: invitation.email,
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
invited_user: @invitation,
|
||||
invited_user: invitation,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.email_confirmed.should be_true
|
||||
@user.signup_token.should be_nil
|
||||
@invitation.errors.any?.should be_false
|
||||
@invitation.accepted.should be_true
|
||||
user.errors.any?.should be_false
|
||||
user.email_confirmed.should be_true
|
||||
user.signup_token.should be_nil
|
||||
invitation.errors.any?.should be_false
|
||||
invitation.accepted.should be_true
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
|
@ -331,30 +499,30 @@ describe UserManager do
|
|||
it "signup successfully with due to user invitation with autofriend" do
|
||||
|
||||
@some_user = FactoryGirl.create(:user)
|
||||
@invitation = FactoryGirl.create(:invited_user, :sender => @some_user, :autofriend => true)
|
||||
@invitation.accepted.should be_false
|
||||
invitation = FactoryGirl.create(:invited_user, :sender => @some_user, :autofriend => true)
|
||||
invitation.accepted.should be_false
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: @invitation.email,
|
||||
email: invitation.email,
|
||||
password: "foobar",
|
||||
password_confirmation: "foobar",
|
||||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
invited_user: @invitation,
|
||||
invited_user: invitation,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.email_confirmed.should be_true
|
||||
@user.signup_token.should be_nil
|
||||
@invitation.errors.any?.should be_false
|
||||
@invitation.accepted.should be_true
|
||||
@user.friends?(@some_user).should be_true
|
||||
@user.friends?(@some_user).should be_true
|
||||
user.errors.any?.should be_false
|
||||
user.email_confirmed.should be_true
|
||||
user.signup_token.should be_nil
|
||||
invitation.errors.any?.should be_false
|
||||
invitation.accepted.should be_true
|
||||
user.friends?(@some_user).should be_true
|
||||
user.friends?(@some_user).should be_true
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
|
@ -362,12 +530,12 @@ describe UserManager do
|
|||
it "signup successfully with due to user invitation with autofriend, but uses another email" do
|
||||
|
||||
@some_user = FactoryGirl.create(:user)
|
||||
@invitation = FactoryGirl.create(:invited_user, :sender => @some_user, :autofriend => true)
|
||||
@invitation.accepted.should be_false
|
||||
invitation = FactoryGirl.create(:invited_user, :sender => @some_user, :autofriend => true)
|
||||
invitation.accepted.should be_false
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman12@jamkazam.com",
|
||||
|
|
@ -376,16 +544,16 @@ describe UserManager do
|
|||
terms_of_service: true,
|
||||
instruments: @instruments,
|
||||
musician: true,
|
||||
invited_user: @invitation,
|
||||
invited_user: invitation,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.email_confirmed.should be_false
|
||||
@user.signup_token.should_not be_nil
|
||||
@invitation.errors.any?.should be_false
|
||||
@invitation.accepted.should be_true
|
||||
@user.friends?(@some_user).should be_true
|
||||
@user.friends?(@some_user).should be_true
|
||||
user.errors.any?.should be_false
|
||||
user.email_confirmed.should be_false
|
||||
user.signup_token.should_not be_nil
|
||||
invitation.errors.any?.should be_false
|
||||
invitation.accepted.should be_true
|
||||
user.friends?(@some_user).should be_true
|
||||
user.friends?(@some_user).should be_true
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
|
@ -396,7 +564,7 @@ describe UserManager do
|
|||
UserMailer.deliveries.clear
|
||||
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: fb_signup.email,
|
||||
|
|
@ -408,13 +576,13 @@ describe UserManager do
|
|||
fb_signup: fb_signup,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.email_confirmed.should be_true
|
||||
@user.signup_token.should be_nil
|
||||
@user.user_authorizations.length.should == 1
|
||||
@user.user_authorizations[0].uid = fb_signup.uid
|
||||
@user.user_authorizations[0].token = fb_signup.token
|
||||
@user.user_authorizations[0].token_expiration = fb_signup.token_expires_at
|
||||
user.errors.any?.should be_false
|
||||
user.email_confirmed.should be_true
|
||||
user.signup_token.should be_nil
|
||||
user.user_authorizations.length.should == 1
|
||||
user.user_authorizations[0].uid = fb_signup.uid
|
||||
user.user_authorizations[0].token = fb_signup.token
|
||||
user.user_authorizations[0].token_expiration = fb_signup.token_expires_at
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
|
@ -425,7 +593,7 @@ describe UserManager do
|
|||
UserMailer.deliveries.clear
|
||||
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman13@jamkazam.com",
|
||||
|
|
@ -437,13 +605,13 @@ describe UserManager do
|
|||
fb_signup: fb_signup,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.email_confirmed.should be_false
|
||||
@user.signup_token.should_not be_nil
|
||||
@user.user_authorizations.length.should == 1
|
||||
@user.user_authorizations[0].uid = fb_signup.uid
|
||||
@user.user_authorizations[0].token = fb_signup.token
|
||||
@user.user_authorizations[0].token_expiration = fb_signup.token_expires_at
|
||||
user.errors.any?.should be_false
|
||||
user.email_confirmed.should be_false
|
||||
user.signup_token.should_not be_nil
|
||||
user.user_authorizations.length.should == 1
|
||||
user.user_authorizations[0].uid = fb_signup.uid
|
||||
user.user_authorizations[0].token = fb_signup.token
|
||||
user.user_authorizations[0].token_expiration = fb_signup.token_expires_at
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
end
|
||||
|
|
@ -457,7 +625,7 @@ describe UserManager do
|
|||
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
@user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
user = @user_manager.signup(remote_ip: "127.0.0.1",
|
||||
first_name: "bob",
|
||||
last_name: "smith",
|
||||
email: "userman13@jamkazam.com",
|
||||
|
|
@ -469,8 +637,8 @@ describe UserManager do
|
|||
fb_signup: fb_signup,
|
||||
signup_confirm_url: "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:user_authorizations].should == ['is invalid']
|
||||
user.errors.any?.should be_true
|
||||
user.errors[:user_authorizations].should == ['is invalid']
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue