Skip to content

Instantly share code, notes, and snippets.

View VoltanBro's full-sized avatar
🇺🇦

Vitalii Molchanov VoltanBro

🇺🇦
View GitHub Profile
# frozen_string_literal: true
require 'swagger_helper'
RSpec.describe 'Couriers', type: :request do
path '/api/v1/auth/sign_in/' do
post 'Login courier' do
tags 'Couriers'
produces 'application/json', 'application/xml'
parameter name: :email, in: :body, type: :string, required: true
Started POST "/api/v1/sign_in" for 127.0.0.1 at 2020-06-06 03:00:06 +0300
(0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by Api::V1::SessionsController#create as JSON
Parameters: {"courier"=>{"email"=>"testcourier@test.com", "password"=>"[FILTERED]"}, "session"=>{"courier"=>{"email"=>"testcourier@test.com", "password"=>"[FILTERED]"}}}
Courier Load (0.4ms) SELECT "couriers".* FROM "couriers" WHERE "couriers"."id" = $1 ORDER BY "couriers"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
Completed 500 Internal Server Error in 23ms (ActiveRecord: 4.8ms | Allocations: 9516)
TypeError (no implicit conversion of nil into String):
Started POST "/api/v1/sign_in" for 127.0.0.1 at 2020-06-06 03:00:06 +0300
(0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by Api::V1::SessionsController#create as JSON
Parameters: {"courier"=>{"email"=>"testcourier@test.com", "password"=>"[FILTERED]"}, "session"=>{"courier"=>{"email"=>"testcourier@test.com", "password"=>"[FILTERED]"}}}
Courier Load (0.4ms) SELECT "couriers".* FROM "couriers" WHERE "couriers"."id" = $1 ORDER BY "couriers"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
Completed 500 Internal Server Error in 23ms (ActiveRecord: 4.8ms | Allocations: 9516)
TypeError (no implicit conversion of nil into String):
requestBody:
content:
application/json:
schema:
type: object
properties:
courier:
type: object
email:
type: string
@VoltanBro
VoltanBro / vanilla-js-cheatsheet.md
Created February 6, 2021 07:47 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
AllCops:
TargetRubyVersion: 2.7.2
NewCops: enable
Exclude:
- 'db/**/*'
- 'bin/*'
Layout/LineLength:
Max: 120
@VoltanBro
VoltanBro / rails-jsonb-queries
Created December 21, 2021 20:34 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
# frozen_string_literal: true
class CustomerCreator < BaseInteractor
def call
validate_bot_owner
create_stripe_customer
end
private
@VoltanBro
VoltanBro / todo_fixme_etc_list
Created July 8, 2022 23:35
todo fixme bug and etc comments
[Line 1] ✐ NOTE: This is here because sometimes an intermittent issue appears.
[Line 7] ↻ OPTIMIZE: This could be reworked to not do a O(N2) lookup.
[Line 9] ✓ TODO from John: Add a check here to ensure these are always strings.
[Line 24] ✄ HACK: I am doing something here that is horrible, but it works for now...
[Line 89] ✗ XXX: Let's do this better next time? It's bad.
[Line 136] ☠ FIXME: We sometimes get an undefined index in this array.
[Line 211] ☢ BUG: If the user inputs "Easter" we always output "Egg", even if they wanted a "Bunny".
@VoltanBro
VoltanBro / trait_with_transient.rb
Last active July 12, 2022 19:11
advanced factory transient
trait :my_custom do
transient do
params {{}}
end
after(:build) do |field, evaluator|
field.name = evaluator.params[:name]
end
end