Module: ErpDevSvcs::ControllerSupport
- Defined in:
- lib/erp_dev_svcs/controller_support/controller_support.rb
Instance Method Summary collapse
-
#basic_user_auth ⇒ Object
calls a function sets up basic user auth so devise won’t cause our controller tests to fail.
- #basic_user_auth_with_admin ⇒ Object
Instance Method Details
#basic_user_auth ⇒ Object
calls a function sets up basic user auth so devise won’t cause our controller tests to fail. It’s my understanding that we have to actually persist these to the DB in order to auth to work, so make sure to call this in the “before(:each)” part of your examples so that the records are cleaned up properly
TODO: Make this method only available to controller tests
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/erp_dev_svcs/controller_support/controller_support.rb', line 10 def basic_user_auth @business_party_type = FactoryGirl.create(:individual) @party = FactoryGirl.create(:individual_party, :business_party => @business_party_type) @pref_opt1 = FactoryGirl.create(:preference_option) @pref_type1 = FactoryGirl.create(:preference_type) @pref_opt2 = FactoryGirl.create(:preference_option, :description => "Blue", :internal_identifier => "blue_extjs_theme", :value => "ext-all.css") @pref_type2 = FactoryGirl.create(:preference_type, :description => "Theme", :internal_identifier => "extjs_theme") #@request.env["devise.mapping"] = Devise.mappings[User.find(1)] salt = 'asdasdastr4325234324sdfds' @user = FactoryGirl.create(:user, :party => @party, :salt => salt, :crypted_password => Sorcery::CryptoProviders::BCrypt.encrypt("password", salt), :activation_state => 'active') login_user(@user) @user end |
#basic_user_auth_with_admin ⇒ Object
39 40 41 42 |
# File 'lib/erp_dev_svcs/controller_support/controller_support.rb', line 39 def basic_user_auth_with_admin @user = User.find_by_username('admin') login_user(@user) end |