Sha256: f5cf3e99c2a204dc1cf2e16921fa508943cb75eff3f4b1d31665d3fb2e9b2810

Contents?: true

Size: 596 Bytes

Versions: 39

Compression:

Stored size: 596 Bytes

Contents

module EgovUtils
  module TestUtils
    module ControllerHelpers

      def default_user(params={})
        user = FactoryBot.create(:egov_utils_user, params)
        user
      end

      def admin_user
        default_user(roles: ['admin'])
      end

      def basic_user
        default_user(roles: ['user'])
      end

      def anonymous_user
        u = default_user
        allow(user).to receive(:persisted?).and_return(false)
        u
      end

      def sign_in(user = basic_user)
        allow(controller).to receive(:find_current_user).and_return(user)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
egov_utils-0.3.5 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.3.4 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.3.3 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.3.2 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.3.1 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.3.0 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.13 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.12 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.11 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.10 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.9 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.8 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.7 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.6 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.5 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.4 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.3 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.2 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.1 lib/egov_utils/test_utils/controller_helpers.rb
egov_utils-0.2.0 lib/egov_utils/test_utils/controller_helpers.rb