Guest User

Untitled

a guest
Jul 23rd, 2018
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. require File.expand_path(File.dirname(__FILE__) + "/acceptance_helper")
  2.  
  3. feature "Registrations" do
  4. context "classic sign up" do
  5.  
  6. before(:each) do
  7. visit '/user/sign_up'
  8. end
  9.  
  10. scenario "should have an email field" do
  11. page.should have_css('#user_email')
  12. end
  13.  
  14. scenario "should have a password field" do
  15. page.should have_css('#user_password')
  16. end
  17.  
  18. scenario "should have a password confirmation field" do
  19. page.should have_css('#user_password_confirmation')
  20. end
  21.  
  22. scenario "should be able to sign up" do
  23. lambda {
  24. fill_in('user_email', :with => "newuser@email.com")
  25. fill_in('user_password', :with => 'secret')
  26. fill_in('user_password_confirmation', :with => 'secret')
  27. click_button(I18n.t(:"helpers.submit.signup"))
  28. current_path.should == "/bookmarks"
  29. page.should have_content(I18n.t(:"helpers.submit.signout"))
  30. }.should change(User, :count)
  31. end
  32.  
  33. scenario "should not be able to signup with an existing email" do
  34. user = Factory(:user, :email => 'seb@email.com')
  35. lambda {
  36. fill_in('user_email', :with => user.email)
  37. fill_in('user_password', :with => 'secret')
  38. fill_in('user_password_confirmation', :with => 'secret')
  39. click_button(I18n.t(:"helpers.submit.signup"))
  40. current_path.should == "/user"
  41. }.should_not change(User, :count)
  42. end
  43. end
  44.  
  45. context "amoniauth sign up with email" do
  46. stub_omniauth!
  47.  
  48. scenario "should be able to sign up" do
  49. lambda {
  50. lambda {
  51. visit "/user/sign_up"
  52. click_link "facebook_connect"
  53. page.should have_content(I18n.t(:"devise.omniauth_callbacks.success", :kind => 'facebook'))
  54. }.should change(User, :count)
  55. }.should change(UserToken, :count)
  56. end
  57. end
  58.  
  59. context "amoniauth sign up without email" do
  60. stub_omniauth!(nil)
  61.  
  62. before(:each) do
  63. visit "/user/sign_up"
  64. click_link "facebook_connect"
  65.  
  66. current_path.should == "/user/sign_up/facebook/finalize"
  67. page.should have_css('#user_email')
  68. page.should_not have_css('#user_password')
  69. end
  70.  
  71. scenario "should be able to sign up with facebook account if enter a valid email" do
  72. lambda {
  73. lambda {
  74. fill_in('user_email', :with => "user@email.com")
  75.  
  76. click_button(I18n.t(:"helpers.submit.signup"))
  77.  
  78. page.should have_content(I18n.t(:"devise.omniauth_callbacks.success", :kind => 'facebook'))
  79. }.should change(User, :count)
  80. }.should change(UserToken, :count)
  81. end
  82.  
  83. scenario "should not be able to sign up with facebook account with an invalid email" do
  84. lambda {
  85. lambda {
  86. fill_in('user_email', :with => "foo")
  87.  
  88. click_button(I18n.t(:"helpers.submit.signup"))
  89.  
  90. current_path.should == "/user/sign_up/facebook/finalize"
  91. }.should_not change(User, :count)
  92. }.should_not change(UserToken, :count)
  93. end
  94. end
  95. end
Add Comment
Please, Sign In to add comment