136 lines
5.8 KiB
Ruby
136 lines
5.8 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe "Signup" do
|
|
|
|
subject { page }
|
|
|
|
before(:each) do
|
|
UserMailer.deliveries.clear
|
|
end
|
|
|
|
describe "signup page" do
|
|
before { visit signup_path }
|
|
|
|
it { should have_selector('h1', text: 'create a jamkazam account') }
|
|
|
|
describe "with valid information" do
|
|
before do
|
|
fill_in "jam_ruby_user[first_name]", with: "Mike"
|
|
fill_in "jam_ruby_user[last_name]", with: "Jones"
|
|
fill_in "jam_ruby_user[email]", with: "noone@jamkazam.com"
|
|
fill_in "jam_ruby_user[password]", with: "jam123"
|
|
fill_in "jam_ruby_user[password_confirmation]", with: "jam123"
|
|
check("jam_ruby_user[instruments][drums][selected]")
|
|
check("jam_ruby_user[terms_of_service]")
|
|
click_button "CREATE ACCOUNT"
|
|
end
|
|
|
|
# Successful signup with no invitation tells you to go sign up
|
|
it { expect(first('title').native.text).to eq "Jamkazam | Confirmation Email Sent" }
|
|
it { should have_selector('div.alert.alert-success', text: "Please check your email and confirm your signup") }
|
|
it { User.find_by_email('noone@jamkazam.com').musician_instruments.length.should == 1 }
|
|
# an email is sent on no-invite signup
|
|
it { UserMailer.deliveries.length.should == 1 }
|
|
end
|
|
|
|
describe "with service invite" do
|
|
before do
|
|
@invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com")
|
|
visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}"
|
|
|
|
fill_in "jam_ruby_user[first_name]", with: "Mike"
|
|
fill_in "jam_ruby_user[last_name]", with: "Jones"
|
|
fill_in "jam_ruby_user[email]", with: "noone@jamkazam.com"
|
|
fill_in "jam_ruby_user[password]", with: "jam123"
|
|
fill_in "jam_ruby_user[password_confirmation]", with: "jam123"
|
|
check("jam_ruby_user[instruments][drums][selected]")
|
|
check("jam_ruby_user[terms_of_service]")
|
|
click_button "CREATE ACCOUNT"
|
|
end
|
|
|
|
# Successful sign-in goes to the client
|
|
it { expect(first('title').native.text).to eq "Jamkazam" }
|
|
it { should have_selector('h1', text: "Audio Gear Setup") }
|
|
|
|
# there is no email sent though when you signup based on an invite (because you just left your email to get here)
|
|
it { UserMailer.deliveries.length.should == 0 }
|
|
end
|
|
|
|
describe "with user invite and autofriend" do
|
|
before do
|
|
@user = FactoryGirl.create(:user)
|
|
@invited_user = FactoryGirl.create(:invited_user, :sender => @user, :autofriend => true, :email => "noone@jamkazam.com")
|
|
visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}"
|
|
|
|
fill_in "jam_ruby_user[first_name]", with: "Mike"
|
|
fill_in "jam_ruby_user[last_name]", with: "Jones"
|
|
fill_in "jam_ruby_user[email]", with: "noone@jamkazam.com"
|
|
fill_in "jam_ruby_user[password]", with: "jam123"
|
|
fill_in "jam_ruby_user[password_confirmation]", with: "jam123"
|
|
check("jam_ruby_user[instruments][drums][selected]")
|
|
check("jam_ruby_user[terms_of_service]")
|
|
click_button "CREATE ACCOUNT"
|
|
end
|
|
|
|
# Successful sign-in goes to the client
|
|
it { expect(first('title').native.text).to eq "Jamkazam" }
|
|
it { should have_selector('h1', text: "Audio Gear Setup") }
|
|
it { @user.friends?(User.find_by_email("noone@jamkazam.com")) }
|
|
it { User.find_by_email("noone@jamkazam.com").friends?(@user) }
|
|
end
|
|
|
|
describe "can't signup to the same invite twice" do
|
|
before do
|
|
@invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com")
|
|
visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}"
|
|
|
|
fill_in "jam_ruby_user[first_name]", with: "Mike"
|
|
fill_in "jam_ruby_user[last_name]", with: "Jones"
|
|
fill_in "jam_ruby_user[email]", with: "noone@jamkazam.com"
|
|
fill_in "jam_ruby_user[password]", with: "jam123"
|
|
fill_in "jam_ruby_user[password_confirmation]", with: "jam123"
|
|
check("jam_ruby_user[instruments][drums][selected]")
|
|
check("jam_ruby_user[terms_of_service]")
|
|
click_button "CREATE ACCOUNT"
|
|
expect(first('title').native.text).to eq "Jamkazam"
|
|
should have_selector('h1', text: "Audio Gear Setup")
|
|
visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}"
|
|
end
|
|
|
|
it { should have_selector('h1', text: "You have already signed up with this invitation") }
|
|
|
|
end
|
|
|
|
describe "can signup with an email different than the one used to invite" do
|
|
before do
|
|
@invited_user = FactoryGirl.create(:invited_user, :email => "what@jamkazam.com")
|
|
visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}"
|
|
|
|
fill_in "jam_ruby_user[first_name]", with: "Mike"
|
|
fill_in "jam_ruby_user[last_name]", with: "Jones"
|
|
fill_in "jam_ruby_user[email]", with: "noone@jamkazam.com"
|
|
fill_in "jam_ruby_user[password]", with: "jam123"
|
|
fill_in "jam_ruby_user[password_confirmation]", with: "jam123"
|
|
check("jam_ruby_user[instruments][drums][selected]")
|
|
check("jam_ruby_user[terms_of_service]")
|
|
click_button "CREATE ACCOUNT"
|
|
end
|
|
|
|
it { expect(first('title').native.text).to eq "Jamkazam | Confirmation Email Sent" }
|
|
it { should have_selector('div.alert.alert-success', text: "Please check your email and confirm your signup") }
|
|
it { User.find_by_email('noone@jamkazam.com').musician_instruments.length.should == 1 }
|
|
it { User.find_by_email('what@jamkazam.com').should be_nil }
|
|
# an email is sent when you invite but use a different email than the one used to invite
|
|
it { UserMailer.deliveries.length.should == 1 }
|
|
it {
|
|
visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}"
|
|
should have_selector('h1', text: "You have already signed up with this invitation")
|
|
}
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
end
|