Guest User

Untitled

a guest
May 19th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 2.07 KB | None | 0 0
  1. describe 'Contacts' do
  2.   it 'add single contact' do
  3.     user = FactoryGirl.create(:user, :user_type => 'worker')
  4.     login(user)
  5.     visit new_contact_path()  
  6.     contact = FactoryGirl.build :contact
  7.     fill_in('First name', :with => contact.first_name)
  8.     fill_in('Last name', :with => contact.last_name)
  9.     fill_in('Email', :with => contact.email)  
  10.     click_on('Create Contact')
  11.     page.should have_content('Contact was successfully created.')
  12.     contact.email.should eq(Contact.last.email)
  13.   end
  14.   it 'adds private contact and checks if is block for other users' do
  15.     user = FactoryGirl.create(:user, :user_type => 'worker')
  16.     login(user)
  17.     visit new_contact_path()
  18.     contact = FactoryGirl.build :contact
  19.     fill_in('First name', :with => contact.first_name)
  20.     fill_in('Last name', :with => contact.last_name)
  21.     fill_in('Email', :with => contact.email)  
  22.     page.select 'Just me', :from => 'Who can see this contact'
  23.     click_on('Create Contact')
  24.     logout
  25.     visit root_path
  26.     user2 = FactoryGirl.create(:user, :user_type => 'worker')
  27.     login(user2)
  28.     visit contact_path(1)
  29.     page.should have_content(I18n.t('errors.not_authorized'))
  30.   end
  31.   it 'list all contacts' do
  32.     user = FactoryGirl.create(:user, :user_type => 'worker')
  33.     login(user)
  34.     visit new_contact_path()  
  35.     contact = FactoryGirl.build :contact
  36.     fill_in('First name', :with => contact.first_name)
  37.     fill_in('Last name', :with => contact.last_name)
  38.     fill_in('Email', :with => contact.email)  
  39.     click_on('Create Contact')
  40.     contact2 = FactoryGirl.build :contact, :first_name => 'Mike', :last_name => 'Smith', :email => 'other@example.com'
  41.     visit new_contact_path()  
  42.     fill_in('First name', :with => contact2.first_name)
  43.     fill_in('Last name', :with => contact2.last_name)
  44.     fill_in('Email', :with => contact2.email)
  45.     click_on('Create Contact')
  46.    
  47.     visit contacts_path
  48.     page.should have_content(contact.first_name)
  49.     page.should have_content(contact2.last_name)
  50.     page.should have_content(contact2.email)
  51.   end
  52.  
  53. end
Add Comment
Please, Sign In to add comment