class User < ActiveRecord::Base
  devise :two_factor_authenticatable,
         otp_secret_encryption_key: ENV['TWO_FACTOR_ENCRYPTION_KEY'],
         otp_allowed_drift: 60

  devise :rememberable, :trackable, :validatable, :timeoutable

  before_create :initialize_otp_secret

  def initialize_otp_secret
    self.otp_secret = User.generate_otp_secret
  end

end
class User < ActiveRecord::Base
  devise :two_factor_authenticatable,
         otp_secret_encryption_key: Rails.env.test? ? 'SECRET' : ENV['TWO_FACTOR_ENCRYPTION_KEY'],
         otp_allowed_drift: 60

  devise :rememberable, :trackable, :validatable, :timeoutable

  before_create :initialize_otp_secret

  def initialize_otp_secret
    self.otp_secret = User.generate_otp_secret
  end

end
Make tests less dependent on config.
Make tests less dependent on config.

For the test environment it's okay if no TWO_FACTOR_ENCRYPTION_KEY is set up, we can use any old key.
This will make it easier to run tests from a fresh install.
