Module: EgovUtils::TestUtils::ControllerHelpers
- Defined in:
- lib/egov_utils/test_utils/controller_helpers.rb
Instance Attribute Summary collapse
-
#signed_user ⇒ Object
readonly
Returns the value of attribute signed_user.
Instance Method Summary collapse
- #admin_user ⇒ Object
- #anonymous_user ⇒ Object
- #basic_user ⇒ Object
- #default_user(params = {}) ⇒ Object
- #sign_in(user = basic_user) ⇒ Object
Instance Attribute Details
#signed_user ⇒ Object (readonly)
Returns the value of attribute signed_user.
5 6 7 |
# File 'lib/egov_utils/test_utils/controller_helpers.rb', line 5 def signed_user @signed_user end |
Instance Method Details
#admin_user ⇒ Object
12 13 14 |
# File 'lib/egov_utils/test_utils/controller_helpers.rb', line 12 def admin_user default_user(roles: ['admin']) end |
#anonymous_user ⇒ Object
20 21 22 23 24 |
# File 'lib/egov_utils/test_utils/controller_helpers.rb', line 20 def anonymous_user user = default_user allow(user).to receive(:persisted?).and_return(false) user end |
#basic_user ⇒ Object
16 17 18 |
# File 'lib/egov_utils/test_utils/controller_helpers.rb', line 16 def basic_user default_user(roles: ['user']) end |
#default_user(params = {}) ⇒ Object
7 8 9 10 |
# File 'lib/egov_utils/test_utils/controller_helpers.rb', line 7 def default_user(params={}) user = FactoryBot.create(:egov_utils_user, params) user end |
#sign_in(user = basic_user) ⇒ Object
26 27 28 29 |
# File 'lib/egov_utils/test_utils/controller_helpers.rb', line 26 def sign_in(user = basic_user) @signed_user = user allow(controller).to receive(:find_current_user).and_return(user) end |