Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe 'Contacts' do
- it 'add single contact' do
- user = FactoryGirl.create(:user, :user_type => 'worker')
- login(user)
- visit new_contact_path()
- contact = FactoryGirl.build :contact
- fill_in('First name', :with => contact.first_name)
- fill_in('Last name', :with => contact.last_name)
- fill_in('Email', :with => contact.email)
- click_on('Create Contact')
- page.should have_content('Contact was successfully created.')
- contact.email.should eq(Contact.last.email)
- end
- it 'adds private contact and checks if is block for other users' do
- user = FactoryGirl.create(:user, :user_type => 'worker')
- login(user)
- visit new_contact_path()
- contact = FactoryGirl.build :contact
- fill_in('First name', :with => contact.first_name)
- fill_in('Last name', :with => contact.last_name)
- fill_in('Email', :with => contact.email)
- page.select 'Just me', :from => 'Who can see this contact'
- click_on('Create Contact')
- logout
- visit root_path
- user2 = FactoryGirl.create(:user, :user_type => 'worker')
- login(user2)
- visit contact_path(1)
- page.should have_content(I18n.t('errors.not_authorized'))
- end
- it 'list all contacts' do
- user = FactoryGirl.create(:user, :user_type => 'worker')
- login(user)
- visit new_contact_path()
- contact = FactoryGirl.build :contact
- fill_in('First name', :with => contact.first_name)
- fill_in('Last name', :with => contact.last_name)
- fill_in('Email', :with => contact.email)
- click_on('Create Contact')
- contact2 = FactoryGirl.build :contact, :first_name => 'Mike', :last_name => 'Smith', :email => 'other@example.com'
- visit new_contact_path()
- fill_in('First name', :with => contact2.first_name)
- fill_in('Last name', :with => contact2.last_name)
- fill_in('Email', :with => contact2.email)
- click_on('Create Contact')
- visit contacts_path
- page.should have_content(contact.first_name)
- page.should have_content(contact2.last_name)
- page.should have_content(contact2.email)
- end
- end
Add Comment
Please, Sign In to add comment