Add home controller test (#972)

Co-authored-by: viehlieb <pf@pragma-shift.net>
Co-authored-by: Tobias Kneuker <tk@pragma-shift.net>
This commit is contained in:
Philipp Rothmann 2023-03-25 18:20:13 +01:00 committed by GitHub
parent debce2a635
commit 503ed6c379
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 187 additions and 2 deletions

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
module SpecTestHelper
def login(user)
user = User.find_by_nick(user.nick)
session[:user_id] = user.id
session[:scope] = FoodsoftConfig[:default_scope] # Save scope in session to not allow switching between foodcoops with one account
session[:locale] = user.locale
end
def current_user
User.find(session[:user_id])
end
def get_with_defaults(action, params: {}, xhr: false, format: nil)
params['foodcoop'] = FoodsoftConfig[:default_scope]
get action, params: params, xhr: xhr, format: format
end
end
RSpec.configure do |config|
config.include SpecTestHelper, type: :controller
end