features/step_definitions/user_steps.rb in yousty-activeadmin-1.0.4.pre vs features/step_definitions/user_steps.rb in yousty-activeadmin-1.0.5.pre

- old
+ new

@@ -1,16 +1,16 @@ def ensure_user_created(email) - user = AdminUser.where(:email => email).first_or_create(:password => 'password', :password_confirmation => 'password') + 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? + 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' @@ -20,20 +20,26 @@ 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' + 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 /^an admin user "([^"]*)" exists with( expired)? reset password token "(.*?)"$/ do |email, expired, token| - user = ensure_user_created(email) - user.reset_password_token = token - user.reset_password_sent_at = 1.minute.ago unless expired - user.save +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