Module: UserCukeHelpers
- Defined in:
- lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb,
lib/generators/voluntary/product_dummy/templates/features/support/user_cuke_helpers.rb
Instance Method Summary collapse
-
#automatic_login ⇒ Object
create a new @me user, if not present, and log in using the integration_sessions controller (automatic).
-
#confirm_login ⇒ Object
checks the page content to see, if the login was successful.
-
#create_user(overrides = {}) ⇒ Object
creates a new user object from the factory with some default attributes and the given override attributes, adds the standard aspects to it and returns it.
-
#fill_change_password_section(cur_pass, new_pass, confirm_pass) ⇒ Object
fill change password section on the user edit page.
-
#fill_forgot_password_form(email) ⇒ Object
fill forgot password form to get reset password link.
-
#fill_reset_password_form(new_pass, confirm_pass) ⇒ Object
fill the reset password form.
-
#login_as(user) ⇒ Object
fill out the fields on the sign_in page and press submit.
-
#logout ⇒ Object
delete all cookies, destroying the current session.
-
#manual_login ⇒ Object
use the @me user to perform a manual login via the sign_in page.
-
#submit_forgot_password_form ⇒ Object
submit forgot password form to get reset password link.
-
#submit_reset_password_form ⇒ Object
submit reset password form.
Instance Method Details
#automatic_login ⇒ Object
create a new @me user, if not present, and log in using the integration_sessions controller (automatic)
24 25 26 27 28 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 24 def automatic_login @me ||= FactoryGirl.create(:user) page.driver.visit(new_integration_sessions_path(user_id: @me.slug)) "Login" end |
#confirm_login ⇒ Object
checks the page content to see, if the login was successful
38 39 40 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 38 def confirm_login wait_until { page.has_content?("Sign out") } end |
#create_user(overrides = {}) ⇒ Object
creates a new user object from the factory with some default attributes and the given override attributes, adds the standard aspects to it and returns it
6 7 8 9 10 11 12 13 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 6 def create_user(overrides={}) FactoryGirl.create( :user, { password: 'password', password_confirmation: 'password' }.merge(overrides) ) end |
#fill_change_password_section(cur_pass, new_pass, confirm_pass) ⇒ Object
fill change password section on the user edit page
49 50 51 52 53 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 49 def fill_change_password_section(cur_pass, new_pass, confirm_pass) fill_in 'user_current_password', with: cur_pass fill_in 'user_password', with: new_pass fill_in 'user_password_confirmation', with: confirm_pass end |
#fill_forgot_password_form(email) ⇒ Object
fill forgot password form to get reset password link
56 57 58 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 56 def fill_forgot_password_form(email) fill_in 'user_email', with: email end |
#fill_reset_password_form(new_pass, confirm_pass) ⇒ Object
fill the reset password form
66 67 68 69 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 66 def fill_reset_password_form(new_pass, confirm_pass) fill_in 'user_password', with: new_pass fill_in 'user_password_confirmation', with: confirm_pass end |
#login_as(user) ⇒ Object
fill out the fields on the sign_in page and press submit
16 17 18 19 20 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 16 def login_as(user) fill_in 'Email', with: "#{user}@volontari.at" fill_in 'Password', with: 'password' :submit end |
#logout ⇒ Object
delete all cookies, destroying the current session
43 44 45 46 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 43 def logout $browser.('_session', 'path=/') if $browser $browser. if $browser end |
#manual_login ⇒ Object
use the @me user to perform a manual login via the sign_in page
31 32 33 34 35 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 31 def manual_login visit login_page login_as @me.name visit user_confirmation_path(confirmation_token: @me.confirmation_token) end |
#submit_forgot_password_form ⇒ Object
submit forgot password form to get reset password link
61 62 63 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 61 def submit_forgot_password_form find("#new_user input.button").click end |
#submit_reset_password_form ⇒ Object
submit reset password form
72 73 74 |
# File 'lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb', line 72 def submit_reset_password_form find(".button").click end |