Skip to content

Instantly share code, notes, and snippets.

Started GET "/api/users/search" for ::1 at 2020-02-20 14:48:18 -0500
Processing by Api::UsersController#search as */*
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 1]]
↳ app/commands/authorize_api_request.rb:17:in `user'
User Load (0.8ms) SELECT "users".* FROM "users" WHERE (NOT EXISTS (SELECT * FROM swipes WHERE sender_id = '8b89fba2-9f4a-4abf-ba36-159edc9b9253' AND receiver_id = users.id)) AND "users"."id" != $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 10]]
↳ app/models/user.rb:45:in `search'
Photo Load (0.6ms) SELECT "photos".* FROM "photos" WHERE "photos"."user_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) [["user_id", "a76b7a81-8ec4-41d4-8ad1-1082a8d42254"], ["user_id", "7e9de44d-b698-4f55-b815-5a1d4cc87770"], ["user_id", "9cdc8e1a-420c-440b-9422-3c1780098ca9"], ["user_id", "ed264c9d-fce5-4c0a-8c07-34b36ee63432"], ["user_id", "9915fb47-74e6-459e-8e09-b08da58f637c"],
Started GET "/api/users/search" for ::1 at 2020-02-20 14:48:18 -0500
Processing by Api::UsersController#search as */*
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 1]]
↳ app/commands/authorize_api_request.rb:17:in `user'
User Load (0.8ms) SELECT "users".* FROM "users" WHERE (NOT EXISTS (SELECT * FROM swipes WHERE sender_id = '8b89fba2-9f4a-4abf-ba36-159edc9b9253' AND receiver_id = users.id)) AND "users"."id" != $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 10]]
↳ app/models/user.rb:45:in `search'
Photo Load (0.6ms) SELECT "photos".* FROM "photos" WHERE "photos"."user_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) [["user_id", "a76b7a81-8ec4-41d4-8ad1-1082a8d42254"], ["user_id", "7e9de44d-b698-4f55-b815-5a1d4cc87770"], ["user_id", "9cdc8e1a-420c-440b-9422-3c1780098ca9"], ["user_id", "ed264c9d-fce5-4c0a-8c07-34b36ee63432"], ["user_id", "9915fb47-74e6-459e-8e09-b08da58f637c"],
class User < ApplicationRecord
validates :sc_external_id, presence: true, uniqueness: true, length: { minimum: 10 }
has_one :profile, dependent: :destroy
has_many :photos, dependent: :destroy
accepts_nested_attributes_for :photos, allow_destroy: true, reject_if: :reject_if_photo_limit_reached
validates_associated :photos
private
class User < ApplicationRecord
validates :sc_external_id, presence: true, uniqueness: true, length: { minimum: 10 }
has_one :profile, dependent: :destroy
has_many :photos, dependent: :destroy
accepts_nested_attributes_for :photos, allow_destroy: true, reject_if: :reject_if_photo_limit_reached
validates_associated :photos
# validate :photo_limit
private
class User < ApplicationRecord
validates :sc_external_id, presence: true, uniqueness: true, length: { minimum: 10 }
has_one :profile, dependent: :destroy
has_many :photos, dependent: :destroy
accepts_nested_attributes_for :photos, allow_destroy: true
validates_associated :photos
validate :photo_limit
private
==== PEDAL ASSEMBLY === [http://www.eurospares.co.uk/parts/lamborghini/murcielago-sv-lp670-4/transmission-pedals/manual-pedal-cluster-50429]
[6][1x] (Part: 410721363) Pedal Spring (Brake/Clutch) / SPRING Ea: ($46.96) Total: ($46.96)
[8][1x] (Part: 410721671) INSERT / ADJUSTING SLEEVE Ea: ($17.48) Total: ($17.48)
[9][1x] (Part: N01100637) HEX.NUT / NUT M6 Ea: ($2.0) Total: ($2.0)
[10][2x] (Part: WHT003109) PIN / PIN Ea: ($2.0) Total: ($4.0)
[11][1x] (Part: 413721325) Brake/Clutch Pedal Pin / JOURNAL Ea: ($324.81) Total: ($324.81)
[12][2x] (Part: WHT002631) WASHER / WASHER 8X12X1 Ea: ($2.0) Total: ($4.0)
[35][1x] (Part: 413721145B) brake pedal / BRAKE PEDAL Ea: ($444.52) Total: ($444.52)
[37][1x] (Part: 413721321B) CLUTCH PEDAL / CLUTCH PEDAL Ea: ($444.52) Total: ($444.52)
[45][1x] (Part: 400721779) COVER / COVER Ea: ($81.89) Total: ($81.89)
require 'rails_helper'
RSpec.describe User, type: :model do
context "factories" do
it "has a valid user factory" do
expect(build(:user)).to be_valid
expect(build(:user)).to be_member
end
it "has a valid vip user factory" do
require 'test_helper'
class Admin::DashboardControllerTest < ActionController::TestCase
test "should not get index without user" do
get :index
assert_redirected_to new_user_session_path
end
test "should not get index with regular user" do
sign_in_user
require 'test_helper'
class Admin::DashboardControllerTest < ActionController::TestCase
test "should not get index without user" do
get :index
assert_redirected_to new_user_session_path
end
test "should not get index with regular user" do
sign_in_user
require 'test_helper'
class Admin::DashboardControllerTest < ActionController::TestCase
test "should not get index without user" do
get :index
assert_redirected_to new_user_session_path
end
test "should not get index with regular user" do
sign_in_user