Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.dirname(__FILE__) + "/common_dsl"
- module AccountStoriesDSL
- include CommonDSL
- def goes_to_login
- get login_path
- assert_response :success
- assert_template "account/login"
- end
- def goes_to_admin_login
- get admin_login_path
- assert_response :success
- assert_template "account/admin"
- end
- def goes_to_trial_signup
- get signup_trial_path
- assert_response :success
- assert_template "account/signup"
- end
- def goes_to_full_signup
- get signup_full_path
- assert_response :success
- assert_template "account/signup"
- end
- def goes_to_search
- get search_path
- assert_redirected_to login_path
- follow_redirect_and_assert_success!
- assert_template "account/login"
- end
- def logs_into_search(email,pwd)
- post login_path, :email => email, :password => pwd
- assert_redirected_to search_path
- end
- def logs_out
- get logout_path
- assert_redirected_to root_path
- assert_match(/you have been logged out/i, flash[:notice])
- assert_nil session[:user]
- end
- def goes_to_company_information_area
- get company_information_path
- assert_response :success
- assert_template "company_information/index"
- end
- def updates_company_information_with_info
- user = { :company_name => "company name", :company_url => "url", :description => "description", :fax => "fax", :phone => "phone", :street => "street", :street2 => "street2", :city => "city", :state => "MI", :zip => "zip" }
- put company_information_path, :user => user
- assert_redirected_to dashboard_path
- end
- def goes_to_settings_area
- get settings_path
- assert_response :success
- assert_template "settings/index"
- end
- def updates_settings_with(options)
- if logged_in?
- put settings_path(:action => "update_user"), :user => options
- updated_model = current_user(true)
- model_class = User
- elsif admin_logged_in?
- put settings_path(:action => "update_admin"), :user => options
- updated_model = current_admin(true)
- model_class = Admin
- else
- flunk "Admin or Normal user has to be logged in"
- end
- assert_response :success
- assert_template "settings/index"
- options.each do |k,v|
- unless [:password, :password_confirmation].include?(k)
- assert_equal v, updated_model[k]
- end
- end
- assert_equal updated_model, model_class.authenticate(updated_model.email, options[:password])
- end
- def signs_up_for_trial_with(params)
- post signup_path, :user => params.update(:upgrading => "false")
- assert_redirected_to dashboard_path
- follow_redirect_and_assert_success!
- assert_equal 2, emails_sent.size # one confirmation, one to admin
- the_user = find_last(User)
- assert_equal the_user.id, session[:user]
- assert the_user.trial?
- end
- def signs_up_for_full_account_with(params)
- post signup_path, :user => params.update(:upgrading => "true")
- assert_redirected_to dashboard_path
- follow_redirect_and_assert_success!
- assert_equal 4, emails_sent.size # one confirmation, one to admin, another for user invoice, and one more to admin for upgrade
- the_user = find_last(User)
- assert_equal the_user.id, session[:user]
- assert the_user.full?
- assert_not_nil the_user.billing_profile
- end
- ##
- # Forgot/Reset Password
- ##
- def goes_to_forgotten_password
- get forgot_path
- assert_response :success
- assert_template "account/forgot"
- end
- def submits_forgotten_password(email)
- post forgot_path, :email => email
- assert_response :success
- assert_match(/an email has been sent to reset the password/i, flash[:notice])
- assert_equal 1, emails_sent.size
- end
- def goes_to_reset_password
- get reset_path(:code => "resetcode")
- assert_response :success
- assert_template "account/reset"
- end
- def resets_password_with(password)
- post reset_path, :user => { :password => "new-pass", :password_confirmation => "new-pass" }
- assert_redirected_to dashboard_path
- assert_match(/password was successfully reset/, flash[:notice])
- end
- def goes_to_upgrade_area
- get upgrade_path
- assert_response :success
- assert_template "get_upgrade"
- end
- def upgrades_account_to_full_status
- put upgrade_path, :user => { :upgrading => true, :credit_card_number => "4111111111111111", :expiration_month => "8", :expiration_year => 2.years.from_now.year.to_s, :credit_verification_value => "123", :card_type => "visa" }
- assert_redirected_to dashboard_path
- assert current_user.full?
- assert_equal 2, emails_sent.size # one for user invoice, and one more to admin for upgrade
- end
- end
Add Comment
Please, Sign In to add comment