Sha256: 5b1d93f4d85ca36ea887da62ca89024521f6e153a8527463869650a9c48aee99

Contents?: true

Size: 1.73 KB

Versions: 50

Compression:

Stored size: 1.73 KB

Contents

Given /^I am logged out$/ do
  if page.all(:css, "a", :text => "Logout").size > 0
    click_link "Logout"
  end
end

Given /^I am logged in$/ do
  create_admin_user_and_logout_if_needed
  user = AdminUser.find_by_email "admin@example.com"
  login_as(user)
end

# only for @requires-reloading scenario
Given /^I am logged in with capybara$/ do
  create_admin_user_and_logout_if_needed

  visit new_admin_user_session_path
  fill_in "Email", :with => "admin@example.com"
  fill_in "Password", :with => "password"
  click_button "Login"
end

def create_admin_user_and_logout_if_needed
  step 'an admin user "admin@example.com" exists'

  if page.all(:css, "a", :text => "Logout").size > 0
    click_link "Logout"
  end
end

Given /^an admin user "([^"]*)" exists$/ do |admin_email|
  user = AdminUser.find_or_create_by_email :email => admin_email,
                                           :password => "password",
                                           :password_confirmation => "password"

  unless user.persisted?
    puts "Coult not create an admin user #{admin_email}: #{user.errors.full_messages}"
    raise "Could not create an admin user"
  end
end

Given /^an admin user "([^"]*)" exists with (expired )?reset password token "(.*?)"$/ do |admin_email, expired, token|
  user = AdminUser.find_or_create_by_email :email => admin_email,
                                           :password => "password",
                                           :password_confirmation => "password"

  unless user.persisted?
    puts "Coult not create an admin user #{admin_email}: #{user.errors.full_messages}"
    raise "Could not create an admin user"
  end

  user.reset_password_token = token
  user.reset_password_sent_at = 1.minute.ago unless expired
  user.save
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
lalala-4.0.0.dev.94 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.92 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.90 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.84 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.80 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.79 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.78 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.77 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.74 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.73 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.72 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.71 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.66 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.65 vendor/deps/active_admin/features/step_definitions/user_steps.rb
activeadmin-0.6.0 features/step_definitions/user_steps.rb
lalala-4.0.0.dev.64 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.63 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.62 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.61 vendor/deps/active_admin/features/step_definitions/user_steps.rb
lalala-4.0.0.dev.60 vendor/deps/active_admin/features/step_definitions/user_steps.rb