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

Instance Method Details

#automatic_loginObject

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 
  @me ||= FactoryGirl.create(:user)
  page.driver.visit(new_integration_sessions_path(user_id: @me.slug))
  click_button "Login"
end

#confirm_loginObject

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 
  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 (user)
  fill_in 'Email', with: "#{user}@volontari.at"
  fill_in 'Password', with: 'password'
  click_button :submit
end

#logoutObject

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.delete_cookie('_session', 'path=/') if $browser
  $browser.delete_all_visible_cookies if $browser
end

#manual_loginObject

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 
  visit 
   @me.name
  visit user_confirmation_path(confirmation_token: @me.confirmation_token)  
end

#submit_forgot_password_formObject

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_formObject

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