Here's an example of a rspec test helper that will let you sign in as a given user.
Create spec/support/helpers/authentication.rb
with the following:
module Helpers
module Authentication
def sign_in_as(user)
# frozen_string_literal: true | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do |
# frozen_string_literal: true | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do |
# | |
# Install the MYSQL driver | |
# gem install mysql2 | |
# | |
# Ensure the MySQL gem is defined in your Gemfile | |
# gem 'mysql2' | |
# | |
# And be sure to use new-style password hashing: | |
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
development: |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app
rails c | |
require 'sidekiq/api' | |
puts 'remove sheduled - start' | |
ss = Sidekiq::ScheduledSet.new | |
ss.select {|scheduled| scheduled['queue'] == 'nome_da_fila' }.map(&:delete) | |
puts 'remove sheduled - finished' | |
puts 'remove retry nome_da_fila - start' |
# frozen_string_literal: true | |
class AutomaticBenefit < ApplicationRecord | |
include Activatable | |
attr_accessor :unit_id, :program_id, :teste | |
default_value_for :teste, value: false, allows_nil: false | |
belongs_to :material_resource |
version: '3' | |
services: | |
mysqlsrv: | |
image: mysql:5.7 | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
MYSQL_DATABASE: "root" | |
ports: | |
- "3306:3306" |
https://bearmetal.eu/theden/how-do-i-know-whether-my-rails-app-is-thread-safe-or-not/ https://stackoverflow.com/questions/9558192/thread-safety-class-variables-in-ruby