add controller tests
This commit is contained in:
parent
1c2ca42dda
commit
21aa24c010
16 changed files with 1140 additions and 4 deletions
28
spec/support/spec_test_helper.rb
Normal file
28
spec/support/spec_test_helper.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module SpecTestHelper
|
||||
def login(user)
|
||||
user = User.where(:nick => user.nick).first if user.is_a?(Symbol)
|
||||
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
|
||||
|
||||
def post_with_defaults(action, params: {}, xhr: false, format: nil)
|
||||
params['foodcoop'] = FoodsoftConfig[:default_scope]
|
||||
post action, params: params, xhr: xhr, format: format
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include SpecTestHelper, :type => :controller
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue