Skip to content

Instantly share code, notes, and snippets.

View itsmeurbi's full-sized avatar
🏠
Working from home

Miguel Ángel Urbina itsmeurbi

🏠
Working from home
View GitHub Profile
@itsmeurbi
itsmeurbi / work_climate_sorting_per_submission.sql
Created June 5, 2024 15:37
Work Climate sorting per submissions
-- LATERAL was introduced in PostgreSQL 9.3
-- Considering the last submission
SELECT employees.*,
COALESCE(scores.value, -6) value
FROM employees
LEFT JOIN LATERAL (
SELECT scores.*
FROM scores
WHERE scores.employee_id = employees.id
@itsmeurbi
itsmeurbi / redis-auto-start-apple-silicon.md
Last active March 4, 2023 17:14
redis-auto-start-apple-silicon.md

Install Redis with Homebrew

brew install redis

Create symbolic link in /LaunchAgents to the default redis .plist file

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents/
require 'test_helper'
class CommentsControllerTest < ActionDispatch::IntegrationTest
test '#create stores a comment for a given post' do
my_post = Post.create(title: 'My post', content: 'My new blog post')
post post_comments_path(my_post), params: { comment: { content: 'Nice post!' } }
assert_redirected_to post_path(my_post)
assert_equal 'Comment created!', flash[:notice]
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
test 'it is not valid without a post' do
comment = Comment.new
refute comment.valid?
assert_equal ['must exist'], comment.errors.messages[:post]
end
require 'test_helper'
class PostsControllerTest < ActionDispatch::IntegrationTest
test '#index returns a list of all available posts' do
get posts_path
assert_response :success
end
test '#new returns a posts form' do
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test 'it is not valid without title' do
post = Post.new
refute post.valid?
assert_equal ["can't be blank"], post.errors.messages[:title]
end