Sha256: 8ffc8f2c75b8454cc064d785deb39c769ffaf49987f1021a261c371837dbea90

Contents?: true

Size: 1.32 KB

Versions: 22

Compression:

Stored size: 1.32 KB

Contents

def ensure_user_created(email)
  user = AdminUser.where(email: email).first_or_create(password: 'password', password_confirmation: 'password')

  unless user.persisted?
    raise "Could not create user #{email}: #{user.errors.full_messages}"
  end
  user
end

Given /^(?:I am logged|log) out$/ do
  click_link 'Logout' if page.all(:css, "a", text: 'Logout').any?
end

Given /^I am logged in$/ do
  step 'log out'
  login_as ensure_user_created 'admin@example.com'
end

# only for @requires-reloading scenario
Given /^I am logged in with capybara$/ do
  ensure_user_created 'admin@example.com'
  step 'log out'

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

Given /^an admin user "([^"]*)" exists$/ do |email|
  ensure_user_created(email)
end

Given /^"([^"]*)" requests a password reset with token "([^"]*)"( but it expires)?$/ do |email, token, expired|
  visit new_admin_user_password_path
  fill_in 'Email', with: email
  allow(Devise).to receive(:friendly_token).and_return(token)
  click_button "Reset My Password"

  AdminUser.where(email: email).first.update_attribute :reset_password_sent_at, 1.month.ago if expired
end

When /^I fill in the password field with "([^"]*)"$/ do |password|
  fill_in 'admin_user_password', with: password
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/features/step_definitions/user_steps.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.17.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.16.pre features/step_definitions/user_steps.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/features/step_definitions/user_steps.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/features/step_definitions/user_steps.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.15.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.14.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.13.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.12.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.11.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.10.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.9.pre features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.8.pre features/step_definitions/user_steps.rb
activeadmin-1.0.0.pre4 features/step_definitions/user_steps.rb
activeadmin-1.0.0.pre3 features/step_definitions/user_steps.rb
activeadmin-1.0.0.pre2 features/step_definitions/user_steps.rb
activeadmin-1.0.0.pre1 features/step_definitions/user_steps.rb
yousty-activeadmin-1.0.7.pre features/step_definitions/user_steps.rb