more test cleanup
This commit is contained in:
parent
abac3cab38
commit
205380d91e
|
|
@ -27,7 +27,8 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
|
||||
@user = UserManager.new.signup(params[:jam_ruby_user][:name],
|
||||
@user = UserManager.new.signup(params[:jam_ruby_user][:first_name],
|
||||
params[:jam_ruby_user][:last_name],
|
||||
params[:jam_ruby_user][:email],
|
||||
params[:jam_ruby_user][:password],
|
||||
params[:jam_ruby_user][:password_confirmation],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
factory :user, :class => "JamRuby::User" do
|
||||
sequence(:name) { |n| "Person #{n}" }
|
||||
sequence(:email) { |n| "person_#{n}@example.com"}
|
||||
password "foobar"
|
||||
password_confirmation "foobar"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe UserManager do
|
|||
|
||||
it "signup successfully with instruments" do
|
||||
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA",
|
||||
[{ :instrument_id => "electric guitar", :proficiency_level => 3, :priority => 0}], "http://localhost:3000/confirm" )
|
||||
[{ :instrument_id => "electric guitar", :proficiency_level => 3, :priority => 0}], "http://localhost:3000/confirm")
|
||||
|
||||
@user.errors.any?.should be_false
|
||||
@user.instruments.length.should == 1
|
||||
|
|
@ -39,32 +39,32 @@ describe UserManager do
|
|||
end
|
||||
|
||||
it "duplicate signup failure" do
|
||||
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
|
||||
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
|
||||
UserMailer.deliveries.length.should == 1
|
||||
@user.errors.any?.should be_false
|
||||
|
||||
# exactly the same parameters; should dup on email, and send no email
|
||||
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
|
||||
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
|
||||
UserMailer.deliveries.length.should == 1
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:email][0].should == "has already been taken"
|
||||
|
||||
# change email so that name appears dupped
|
||||
@user = @user_manager.signup("bob", "smith", "bobbie@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
|
||||
@user = @user_manager.signup("bob", "smith", "bobbie@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
|
||||
UserMailer.deliveries.length.should == 1
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:name][0].should == "has already been taken"
|
||||
end
|
||||
|
||||
it "fail on no username" do
|
||||
@user = @user_manager.signup("", "", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
|
||||
@user = @user_manager.signup("", "", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "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"
|
||||
end
|
||||
|
||||
it "fail on no username" do
|
||||
@user = @user_manager.signup("murp", "", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
|
||||
@user = @user_manager.signup("murp", "last", "", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
|
||||
UserMailer.deliveries.length.should == 0
|
||||
@user.errors.any?.should be_true
|
||||
@user.errors[:email][0].should == "can't be blank"
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ describe "Search API ", :type => :api do
|
|||
it "simple search" do
|
||||
User.delete_search_index # so that the user created before the test and logged in doesn't show up
|
||||
User.create_search_index
|
||||
@musician = FactoryGirl.create(:user, first_name: "Peach", last_name: "Nothing", name: "peach1", email: "user@example.com", musician: true)
|
||||
@fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Grovery", name: "peach2", email: "fan@example.com", musician: false)
|
||||
@musician = FactoryGirl.create(:user, first_name: "Peach", last_name: "Nothing", email: "user@example.com", musician: true)
|
||||
@fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Grovery", email: "fan@example.com", musician: false)
|
||||
@band = Band.save(name: "Peach pit", website: "www.bands.com", biography: "zomg we rock")
|
||||
@band2 = Band.save(name: "Peach", website: "www.bands2.com", biography: "zomg we rock")
|
||||
User.search_index.refresh
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ describe "User pages" do
|
|||
|
||||
before do
|
||||
sign_in FactoryGirl.create(:user)
|
||||
FactoryGirl.create(:user, name: "Bob", email: "bob@example.com")
|
||||
FactoryGirl.create(:user, name: "Ben", email: "ben@example.com")
|
||||
FactoryGirl.create(:user, first_name: "Bob", last_name: "Smith", email: "bob@example.com")
|
||||
FactoryGirl.create(:user, first_name: "Ben", last_name: "Smith", email: "ben@example.com")
|
||||
visit users_path
|
||||
end
|
||||
|
||||
|
|
@ -112,7 +112,8 @@ describe "User pages" do
|
|||
|
||||
describe "with valid information" do
|
||||
before do
|
||||
fill_in "Name", with: "Example User"
|
||||
fill_in "First Name", with: "Example"
|
||||
fill_in "Last Name", with: "User"
|
||||
fill_in "Email", with: "user@example.com"
|
||||
fill_in "City", with: "Austin"
|
||||
fill_in "State", with: "TX"
|
||||
|
|
@ -151,20 +152,24 @@ describe "User pages" do
|
|||
|
||||
|
||||
describe "with valid information" do
|
||||
let(:new_name) { "New Name" }
|
||||
let(:new_first_name) { "New First Name" }
|
||||
let(:new_last_name) { "New Last Name" }
|
||||
let(:new_email) { "new@example.com" }
|
||||
before do
|
||||
fill_in "Name", with: new_name
|
||||
fill_in "First Name", with: new_first_name
|
||||
fill_in "Last Name", with: new_last_name
|
||||
fill_in "Email", with: new_email
|
||||
fill_in "Password", with: user.password
|
||||
fill_in "Confirm Password", with: user.password
|
||||
click_button "Save changes"
|
||||
end
|
||||
|
||||
it { should have_selector('title', text: new_name) }
|
||||
it { should have_selector('title', text: new_first_name) }
|
||||
it { should have_selector('title', text: new_last_name) }
|
||||
it { should have_selector('div.alert.alert-success') }
|
||||
it { should have_link('Sign out', href: signout_path) }
|
||||
specify { user.reload.name.should == new_name }
|
||||
specify { user.reload.first_name.should == new_first_name }
|
||||
specify { user.reload.last_name.should == new_last_name }
|
||||
specify { user.reload.email.should == new_email }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue