ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
   # Returns true if a test user is logged in.          AGGIUNTO DA ME !!!!! TUTTO IL SOTTO
   def is_logged_in?
    !session[:gamer_id].nil?
  end

  # Log in as a particular user.
  def log_in_as(gamer)
    session[:gamer_id] = gamer.id
  end

  def complete_log_in
    log_in_as(gamers(:michael))
    get upgrade_url
    get upgrade_path
    get upgrade_path
  end

end

class ActionDispatch::IntegrationTest

  # Log in as a particular user.
  def log_in_as(user, password: 'password', remember_me: '1')
    post login_path, params: { session: { email: user.email,
      password: password,
      remember_me: remember_me } }
    end
  end
